Blame lib/btowc.c

Packit Service c30d13
/* Convert unibyte character to wide character.
Packit Service c30d13
   Copyright (C) 2008, 2010-2018 Free Software Foundation, Inc.
Packit Service c30d13
   Written by Bruno Haible <bruno@clisp.org>, 2008.
Packit Service c30d13
Packit Service c30d13
   This program is free software: you can redistribute it and/or modify
Packit Service c30d13
   it under the terms of the GNU General Public License as published by
Packit Service c30d13
   the Free Software Foundation; either version 3 of the License, or
Packit Service c30d13
   (at your option) any later version.
Packit Service c30d13
Packit Service c30d13
   This program is distributed in the hope that it will be useful,
Packit Service c30d13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service c30d13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service c30d13
   GNU General Public License for more details.
Packit Service c30d13
Packit Service c30d13
   You should have received a copy of the GNU General Public License
Packit Service c30d13
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service c30d13
Packit Service c30d13
#include <config.h>
Packit Service c30d13
Packit Service c30d13
/* Specification.  */
Packit Service c30d13
#include <wchar.h>
Packit Service c30d13
Packit Service c30d13
#include <stdio.h>
Packit Service c30d13
#include <stdlib.h>
Packit Service c30d13
Packit Service c30d13
wint_t
Packit Service c30d13
btowc (int c)
Packit Service c30d13
{
Packit Service c30d13
  if (c != EOF)
Packit Service c30d13
    {
Packit Service c30d13
      char buf[1];
Packit Service c30d13
      wchar_t wc;
Packit Service c30d13
Packit Service c30d13
      buf[0] = c;
Packit Service c30d13
      if (mbtowc (&wc, buf, 1) >= 0)
Packit Service c30d13
        return wc;
Packit Service c30d13
    }
Packit Service c30d13
  return WEOF;
Packit Service c30d13
}