Blame pcre32_ord2utf32.c

Packit 78a954
/*************************************************
Packit 78a954
*      Perl-Compatible Regular Expressions       *
Packit 78a954
*************************************************/
Packit 78a954
Packit 78a954
/* PCRE is a library of functions to support regular expressions whose syntax
Packit 78a954
and semantics are as close as possible to those of the Perl 5 language.
Packit 78a954
Packit 78a954
                       Written by Philip Hazel
Packit 78a954
           Copyright (c) 1997-2012 University of Cambridge
Packit 78a954
Packit 78a954
-----------------------------------------------------------------------------
Packit 78a954
Redistribution and use in source and binary forms, with or without
Packit 78a954
modification, are permitted provided that the following conditions are met:
Packit 78a954
Packit 78a954
    * Redistributions of source code must retain the above copyright notice,
Packit 78a954
      this list of conditions and the following disclaimer.
Packit 78a954
Packit 78a954
    * Redistributions in binary form must reproduce the above copyright
Packit 78a954
      notice, this list of conditions and the following disclaimer in the
Packit 78a954
      documentation and/or other materials provided with the distribution.
Packit 78a954
Packit 78a954
    * Neither the name of the University of Cambridge nor the names of its
Packit 78a954
      contributors may be used to endorse or promote products derived from
Packit 78a954
      this software without specific prior written permission.
Packit 78a954
Packit 78a954
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 78a954
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 78a954
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 78a954
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Packit 78a954
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Packit 78a954
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Packit 78a954
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 78a954
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Packit 78a954
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Packit 78a954
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Packit 78a954
POSSIBILITY OF SUCH DAMAGE.
Packit 78a954
-----------------------------------------------------------------------------
Packit 78a954
*/
Packit 78a954
Packit 78a954
Packit 78a954
/* This file contains a private PCRE function that converts an ordinal
Packit 78a954
character value into a UTF32 string. */
Packit 78a954
Packit 78a954
#ifdef HAVE_CONFIG_H
Packit 78a954
#include "config.h"
Packit 78a954
#endif
Packit 78a954
Packit 78a954
/* Generate code with 32 bit character support. */
Packit 78a954
#define COMPILE_PCRE32
Packit 78a954
Packit 78a954
#include "pcre_internal.h"
Packit 78a954
Packit 78a954
/*************************************************
Packit 78a954
*       Convert character value to UTF-32         *
Packit 78a954
*************************************************/
Packit 78a954
Packit 78a954
/* This function takes an integer value in the range 0 - 0x10ffff
Packit 78a954
and encodes it as a UTF-32 character in 1 pcre_uchars.
Packit 78a954
Packit 78a954
Arguments:
Packit 78a954
  cvalue     the character value
Packit 78a954
  buffer     pointer to buffer for result - at least 1 pcre_uchars long
Packit 78a954
Packit 78a954
Returns:     number of characters placed in the buffer
Packit 78a954
*/
Packit 78a954
Packit 78a954
unsigned int
Packit 78a954
PRIV(ord2utf)(pcre_uint32 cvalue, pcre_uchar *buffer)
Packit 78a954
{
Packit 78a954
#ifdef SUPPORT_UTF
Packit 78a954
Packit 78a954
*buffer = (pcre_uchar)cvalue;
Packit 78a954
return 1;
Packit 78a954
Packit 78a954
#else /* SUPPORT_UTF */
Packit 78a954
(void)(cvalue);  /* Keep compiler happy; this function won't ever be */
Packit 78a954
(void)(buffer);  /* called when SUPPORT_UTF is not defined. */
Packit 78a954
return 0;
Packit 78a954
#endif /* SUPPORT_UTF */
Packit 78a954
}
Packit 78a954
Packit 78a954
/* End of pcre32_ord2utf32.c */