Blame gllib/unistr/u32-uctomb.c

rpm-build 858c0f
/* Store a character in UTF-32 string.
rpm-build 858c0f
   Copyright (C) 2002, 2005-2006, 2009-2017 Free Software Foundation, Inc.
rpm-build 858c0f
   Written by Bruno Haible <bruno@clisp.org>, 2002.
rpm-build 858c0f
rpm-build 858c0f
   This program is free software: you can redistribute it and/or modify it
rpm-build 858c0f
   under the terms of the GNU General Public License as published
rpm-build 858c0f
   by the Free Software Foundation; either version 3 of the License, or
rpm-build 858c0f
   (at your option) any later version.
rpm-build 858c0f
rpm-build 858c0f
   This program is distributed in the hope that it will be useful,
rpm-build 858c0f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 858c0f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 858c0f
   General Public License for more details.
rpm-build 858c0f
rpm-build 858c0f
   You should have received a copy of the GNU General Public License
rpm-build 858c0f
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
rpm-build 858c0f
rpm-build 858c0f
#include <config.h>
rpm-build 858c0f
rpm-build 858c0f
#if defined IN_LIBUNISTRING
rpm-build 858c0f
/* Tell unistr.h to declare u32_uctomb as 'extern', not 'static inline'.  */
rpm-build 858c0f
# include "unistring-notinline.h"
rpm-build 858c0f
#endif
rpm-build 858c0f
rpm-build 858c0f
/* Specification.  */
rpm-build 858c0f
#include "unistr.h"
rpm-build 858c0f
rpm-build 858c0f
#if !HAVE_INLINE
rpm-build 858c0f
rpm-build 858c0f
int
rpm-build 858c0f
u32_uctomb (uint32_t *s, ucs4_t uc, int n)
rpm-build 858c0f
{
rpm-build 858c0f
  if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
rpm-build 858c0f
    {
rpm-build 858c0f
      if (n > 0)
rpm-build 858c0f
        {
rpm-build 858c0f
          *s = uc;
rpm-build 858c0f
          return 1;
rpm-build 858c0f
        }
rpm-build 858c0f
      else
rpm-build 858c0f
        return -2;
rpm-build 858c0f
    }
rpm-build 858c0f
  else
rpm-build 858c0f
    return -1;
rpm-build 858c0f
}
rpm-build 858c0f
rpm-build 858c0f
#endif