Blame gl/btowc.c

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