Blame lib/unistring/unistr/u32-mbtouc-unsafe.c

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