X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fwchar.in.h;h=3c6cd7b891e38b75c21c6584951748164b8aa105;hb=159eae9ff30acac95b6d397f053df8cd6fca62a3;hp=e4647331e382d84b0d2b67b5abc6e7c9d3e10428;hpb=b1876e6e277008edfa4d9e66b19ba2bb939c6b00;p=gnulib.git diff --git a/lib/wchar.in.h b/lib/wchar.in.h index e4647331e..3c6cd7b89 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-2009 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,6 +50,8 @@ #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 @@ -55,6 +67,8 @@ # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ #endif +#undef _GL_ALREADY_INCLUDING_WCHAR_H + #ifndef _GL_WCHAR_H #define _GL_WCHAR_H @@ -68,22 +82,30 @@ 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 /* Override mbstate_t if it is too small. On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for implementing mbrtowc for encodings like UTF-8. */ -#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) +#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ typedef int rpl_mbstate_t; # undef mbstate_t # define mbstate_t rpl_mbstate_t +# define GNULIB_defined_mbstate_t 1 #endif /* 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 @@ -116,7 +138,11 @@ extern int wctob (wint_t wc); /* Test whether *PS is in the initial state. */ #if @GNULIB_MBSINIT@ -# if !@HAVE_MBSINIT@ +# if @REPLACE_MBSINIT@ +# undef mbsinit +# define mbsinit rpl_mbsinit +# endif +# if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@ extern int mbsinit (const mbstate_t *ps); # endif #elif defined GNULIB_POSIXCHECK @@ -130,7 +156,11 @@ extern int mbsinit (const mbstate_t *ps); /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBRTOWC@ -# if !@HAVE_MBRTOWC@ +# if @REPLACE_MBRTOWC@ +# undef mbrtowc +# define mbrtowc rpl_mbrtowc +# endif +# if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@ extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); # endif #elif defined GNULIB_POSIXCHECK @@ -144,7 +174,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 @@ -158,7 +192,11 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); /* Convert a string to a wide string. */ #if @GNULIB_MBSRTOWCS@ -# if !@HAVE_MBSRTOWCS@ +# if @REPLACE_MBSRTOWCS@ +# undef mbsrtowcs +# 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); # endif #elif defined GNULIB_POSIXCHECK @@ -170,6 +208,74 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t #endif +/* Convert a string to a wide string. */ +#if @GNULIB_MBSNRTOWCS@ +# if @REPLACE_MBSNRTOWCS@ +# undef mbsnrtowcs +# 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); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsnrtowcs +# define mbsnrtowcs(d,s,n,l,p) \ + (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \ + "use gnulib module mbsnrtowcs for portability"), \ + mbsnrtowcs (d, s, n, l, p)) +#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); +# 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 !@HAVE_WCSNRTOMBS@ +extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps); +# 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@