X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fwchar.in.h;h=c0323fec94066ef0fb996573b6bb637e158d1166;hb=ab43907148e80f3895280928c05d4be93875580f;hp=bf9041500661048dd11d410adaf636eba30ece80;hpb=6906a95bfc7fc83e4ffa7ef2f68e377157d926f7;p=gnulib.git diff --git a/lib/wchar.in.h b/lib/wchar.in.h index bf9041500..c0323fec9 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that have issues. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +30,18 @@ @PRAGMA_SYSTEM_HEADER@ #endif -#ifdef __need_mbstate_t -/* Special invocation convention inside uClibc header files. */ +#if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H +/* Special invocation convention: + - Inside uClibc header files. + - On HP-UX 11.00 we have a sequence of nested includes + -> -> , and the latter includes , + once indirectly -> -> -> + and once directly. In both situations 'wint_t' is not yet defined, + therefore we cannot provide the function overrides; instead include only + the system's . + - On IRIX 6.5, similarly, we have an include -> , and + the latter includes . But here, we have no way to detect whether + is completely included or is still being included. */ #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ @@ -40,13 +50,18 @@ #ifndef _GL_WCHAR_H +#define _GL_ALREADY_INCLUDING_WCHAR_H + /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include + included before . + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +# include +# include +#endif /* Include the original if it exists. Some builds of uClibc lack it. */ @@ -55,11 +70,15 @@ # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ #endif +#undef _GL_ALREADY_INCLUDING_WCHAR_H + #ifndef _GL_WCHAR_H #define _GL_WCHAR_H /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -68,6 +87,9 @@ extern "C" { /* Define wint_t. (Also done in wctype.in.h.) */ #if !@HAVE_WINT_T@ && !defined wint_t # define wint_t int +# ifndef WEOF +# define WEOF -1 +# endif #endif @@ -84,7 +106,11 @@ typedef int rpl_mbstate_t; /* Convert a single-byte character to a wide character. */ #if @GNULIB_BTOWC@ -# if !@HAVE_BTOWC@ +# if @REPLACE_BTOWC@ +# undef btowc +# define btowc rpl_btowc +# endif +# if !@HAVE_BTOWC@ || @REPLACE_BTOWC@ extern wint_t btowc (int c); # endif #elif defined GNULIB_POSIXCHECK @@ -153,7 +179,11 @@ extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); /* Recognize a multibyte character. */ #if @GNULIB_MBRLEN@ -# if !@HAVE_MBRLEN@ +# if @REPLACE_MBRLEN@ +# undef mbrlen +# define mbrlen rpl_mbrlen +# endif +# if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); # endif #elif defined GNULIB_POSIXCHECK @@ -172,7 +202,8 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); # define mbsrtowcs rpl_mbsrtowcs # endif # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ -extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); +extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef mbsrtowcs @@ -190,7 +221,8 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t # define mbsnrtowcs rpl_mbsnrtowcs # endif # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@ -extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps); +extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef mbsnrtowcs @@ -201,6 +233,62 @@ extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_ #endif +/* Convert a wide character to a multibyte character. */ +#if @GNULIB_WCRTOMB@ +# if @REPLACE_WCRTOMB@ +# undef wcrtomb +# define wcrtomb rpl_wcrtomb +# endif +# if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@ +extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcrtomb +# define wcrtomb(s,w,p) \ + (GL_LINK_WARNING ("wcrtomb is unportable - " \ + "use gnulib module wcrtomb for portability"), \ + wcrtomb (s, w, p)) +#endif + + +/* Convert a wide string to a string. */ +#if @GNULIB_WCSRTOMBS@ +# if @REPLACE_WCSRTOMBS@ +# undef wcsrtombs +# define wcsrtombs rpl_wcsrtombs +# endif +# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@ +extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsrtombs +# define wcsrtombs(d,s,l,p) \ + (GL_LINK_WARNING ("wcsrtombs is unportable - " \ + "use gnulib module wcsrtombs for portability"), \ + wcsrtombs (d, s, l, p)) +#endif + + +/* Convert a wide string to a string. */ +#if @GNULIB_WCSNRTOMBS@ +# if @REPLACE_WCSNRTOMBS@ +# undef wcsnrtombs +# define wcsnrtombs rpl_wcsnrtombs +# endif +# if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@ +extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsnrtombs +# define wcsnrtombs(d,s,n,l,p) \ + (GL_LINK_WARNING ("wcsnrtombs is unportable - " \ + "use gnulib module wcsnrtombs for portability"), \ + wcsnrtombs (d, s, n, l, p)) +#endif + + /* Return the number of screen columns needed for WC. */ #if @GNULIB_WCWIDTH@ # if @REPLACE_WCWIDTH@