about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-07-28 19:02:07 +0000
committerUlrich Drepper <drepper@redhat.com>2007-07-28 19:02:07 +0000
commit7b503bcc1373670a4456ba8f4a5ccfce712347d1 (patch)
treede7baba18c2438fc91a770581f7c44edaab5ed7a
parenta95a608f1b07a5c6e562294c570e89645d9b6176 (diff)
downloadglibc-7b503bcc1373670a4456ba8f4a5ccfce712347d1.tar.gz
glibc-7b503bcc1373670a4456ba8f4a5ccfce712347d1.tar.xz
glibc-7b503bcc1373670a4456ba8f4a5ccfce712347d1.zip
* iconv/gconv_int.h (__GCONV_NULCONV): New internal only error code.
	* iconv/gconv_cache.c (__gconv_lookup_cache): Return __GCONV_NULCONV
	if from and to charsets are the same.
	* iconv/gconv_db.c (__gconv_find_transform): Likewise.
	* intl/dcigettext.c (_nl_find_msg): Return NULL even if __gconv_open
	returns __GCONV_NOCONV, but not for __GCONV_NULCONV.

2007-07-17  Jakub Jelinek  <jakub@redhat.com>

	* wcsmbs/wchar.h: Only define wint_t if __need_wint_t.
	Don't define wint_t when __need_mbstate_t unless it
	is necessary.
	(__mbstate_t): Use __WINT_TYPE__ rather than wint_t
	in the typedef if possible.
	* wctype/wctype.h (wint_t): Define by including
	wchar.h with __need_wint_t instead of including stddef.h
	with __need_wint_t and as fallback definining it ourselves.
	* iconv/gconv.h (__need_wint_t): Define before including
	wchar.h.
	* sysdeps/gnu/_G_config.h: Don't include gconv.h if not _LIBC
	or _GLIBCPP_USE_WCHAR_T.
	(__need_wchar_t): Don't define
	if not _LIBC or _GLIBCPP_USE_WCHAR_T.
	(__need_wint_t): Don't define before including stddef.h,
	define before including wchar.h only if _LIBC or
	_GLIBCPP_USE_WCHAR_T.
	(_G_iconv_t): Don't define if not _LIBC or _GLIBCPP_USE_WCHAR_T.
	* sysdeps/mach/hurd/_G_config.h: Likewise.
	* sysdeps/generic/_G_config.h: Likewise.
	* libio/libio.h (__wunderflow, __wuflow, __woverflow): Only
	prototype if _LIBC or _GLIBCPP_USE_WCHAR_T.
	(_IO_getwc_unlocked, _IO_putwc_unlocked): Only define
	if _LIBC or _GLIBCPP_USE_WCHAR_T.
-rw-r--r--ChangeLog36
-rw-r--r--iconv/gconv.h3
-rw-r--r--iconv/gconv_cache.c4
-rw-r--r--iconv/gconv_db.c5
-rw-r--r--iconv/gconv_int.h8
-rw-r--r--intl/dcigettext.c4
-rw-r--r--libio/libio.h10
-rw-r--r--sysdeps/generic/_G_config.h20
-rw-r--r--sysdeps/gnu/_G_config.h20
-rw-r--r--sysdeps/mach/hurd/_G_config.h20
-rw-r--r--wcsmbs/wchar.h30
-rw-r--r--wctype/wctype.h19
12 files changed, 107 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index ac1062b88f..252207f1b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2007-07-19  Jakub Jelinek  <jakub@redhat.com>
+
+	* iconv/gconv_int.h (__GCONV_NULCONV): New internal only error code.
+	* iconv/gconv_cache.c (__gconv_lookup_cache): Return __GCONV_NULCONV
+	if from and to charsets are the same.
+	* iconv/gconv_db.c (__gconv_find_transform): Likewise.
+	* intl/dcigettext.c (_nl_find_msg): Return NULL even if __gconv_open
+	returns __GCONV_NOCONV, but not for __GCONV_NULCONV.
+
+2007-07-17  Jakub Jelinek  <jakub@redhat.com>
+
+	* wcsmbs/wchar.h: Only define wint_t if __need_wint_t.
+	Don't define wint_t when __need_mbstate_t unless it
+	is necessary.
+	(__mbstate_t): Use __WINT_TYPE__ rather than wint_t
+	in the typedef if possible.
+	* wctype/wctype.h (wint_t): Define by including
+	wchar.h with __need_wint_t instead of including stddef.h
+	with __need_wint_t and as fallback definining it ourselves.
+	* iconv/gconv.h (__need_wint_t): Define before including
+	wchar.h.
+	* sysdeps/gnu/_G_config.h: Don't include gconv.h if not _LIBC
+	or _GLIBCPP_USE_WCHAR_T.
+	(__need_wchar_t): Don't define
+	if not _LIBC or _GLIBCPP_USE_WCHAR_T.
+	(__need_wint_t): Don't define before including stddef.h,
+	define before including wchar.h only if _LIBC or
+	_GLIBCPP_USE_WCHAR_T.
+	(_G_iconv_t): Don't define if not _LIBC or _GLIBCPP_USE_WCHAR_T.
+	* sysdeps/mach/hurd/_G_config.h: Likewise.
+	* sysdeps/generic/_G_config.h: Likewise.
+	* libio/libio.h (__wunderflow, __wuflow, __woverflow): Only
+	prototype if _LIBC or _GLIBCPP_USE_WCHAR_T.
+	(_IO_getwc_unlocked, _IO_putwc_unlocked): Only define
+	if _LIBC or _GLIBCPP_USE_WCHAR_T.
+
 2007-07-28  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/posix/posix_fallocate64.c: Undefine
diff --git a/iconv/gconv.h b/iconv/gconv.h
index d8be8fa8cf..2946335e5e 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997-1999, 2000-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997-1999, 2000-2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -25,6 +25,7 @@
 
 #include <features.h>
 #define __need_mbstate_t
+#define __need_wint_t
 #include <wchar.h>
 #define __need_size_t
 #define __need_wchar_t
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 716c384de2..4fcb0bc2b4 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -1,5 +1,5 @@
 /* Cache handling for iconv modules.
-   Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
 
@@ -285,7 +285,7 @@ __gconv_lookup_cache (const char *toset, const char *fromset,
 
   /* Avoid copy-only transformations if the user requests.   */
   if (__builtin_expect (flags & GCONV_AVOID_NOCONV, 0) && fromidx == toidx)
-    return __GCONV_NOCONV;
+    return __GCONV_NULCONV;
 
   /* If there are special conversions available examine them first.  */
   if (fromidx != 0 && toidx != 0
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index 6540cc393c..cf452e786a 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -1,5 +1,6 @@
 /* Provide access to the collection of available transformation modules.
-   Copyright (C) 1997-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997-2003, 2004, 2005, 2006, 2007
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -756,7 +757,7 @@ __gconv_find_transform (const char *toset, const char *fromset,
     {
       /* Both character sets are the same.  */
       __libc_lock_unlock (__gconv_lock);
-      return __GCONV_NOCONV;
+      return __GCONV_NULCONV;
     }
 
   result = find_derivation (toset, toset_expand, fromset, fromset_expand,
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index 8d9cdaefc2..fd112204bc 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997-2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -114,6 +114,12 @@ enum
   GCONV_AVOID_NOCONV = 1 << 0
 };
 
+/* When GCONV_AVOID_NOCONV is set and no conversion is needed,
+   __GCONV_NULCONV should be returned.  */
+enum
+{
+  __GCONV_NULCONV = -1
+};
 
 /* Global variables.  */
 
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index cb2b1813a7..23e019ab32 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1,5 +1,5 @@
 /* Implementation of the internal dcigettext function.
-   Copyright (C) 1995-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1995-2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -948,7 +948,7 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp)
 			/* If the output encoding is the same there is
 			   nothing to do.  Otherwise do not use the
 			   translation at all.  */
-			if (__builtin_expect (r != __GCONV_NOCONV, 1))
+			if (__builtin_expect (r != __GCONV_NULCONV, 1))
 			  return NULL;
 
 			convd->conv = (__gconv_t) -1;
diff --git a/libio/libio.h b/libio/libio.h
index 9df08614ee..a807883856 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1995,1997-2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1995,1997-2006,2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -413,9 +413,11 @@ extern "C" {
 extern int __underflow (_IO_FILE *);
 extern int __uflow (_IO_FILE *);
 extern int __overflow (_IO_FILE *, int);
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 extern _IO_wint_t __wunderflow (_IO_FILE *);
 extern _IO_wint_t __wuflow (_IO_FILE *);
 extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
+#endif
 
 #if  __GNUC__ >= 3
 # define _IO_BE(expr, res) __builtin_expect ((expr), res)
@@ -435,15 +437,17 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
     ? __overflow (_fp, (unsigned char) (_ch)) \
     : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
-#define _IO_getwc_unlocked(_fp) \
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define _IO_getwc_unlocked(_fp) \
   (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end,\
 	   0) \
    ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
-#define _IO_putwc_unlocked(_wch, _fp) \
+# define _IO_putwc_unlocked(_wch, _fp) \
   (_IO_BE ((_fp)->_wide_data->_IO_write_ptr \
 	   >= (_fp)->_wide_data->_IO_write_end, 0) \
    ? __woverflow (_fp, _wch) \
    : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
+#endif
 
 #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
 #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
diff --git a/sysdeps/generic/_G_config.h b/sysdeps/generic/_G_config.h
index a152b070c6..4aafe65f6b 100644
--- a/sysdeps/generic/_G_config.h
+++ b/sysdeps/generic/_G_config.h
@@ -8,19 +8,15 @@
 
 #include <bits/types.h>
 #define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
 #define __need_NULL
 #include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
-   hold any value corresponding to members of the extended character
-   set, as well as at least one value that does not correspond to any
-   member of the extended character set.  */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
 #define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
 #include <wchar.h>
 #define _G_size_t	size_t
 typedef struct
@@ -41,7 +37,8 @@ typedef struct
 #define _G_wchar_t	wchar_t
 #define _G_wint_t	wint_t
 #define _G_stat64	stat
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
 typedef union
 {
   struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
     struct __gconv_step_data __data;
   } __combined;
 } _G_iconv_t;
+#endif
 
 typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
 typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/sysdeps/gnu/_G_config.h b/sysdeps/gnu/_G_config.h
index 83c78f0b93..211d0224b1 100644
--- a/sysdeps/gnu/_G_config.h
+++ b/sysdeps/gnu/_G_config.h
@@ -8,19 +8,15 @@
 
 #include <bits/types.h>
 #define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
 #define __need_NULL
 #include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
-   hold any value corresponding to members of the extended character
-   set, as well as at least one value that does not correspond to any
-   member of the extended character set.  */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
 #define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
 #include <wchar.h>
 #define _G_size_t	size_t
 typedef struct
@@ -41,7 +37,8 @@ typedef struct
 #define _G_wchar_t	wchar_t
 #define _G_wint_t	wint_t
 #define _G_stat64	stat64
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
 typedef union
 {
   struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
     struct __gconv_step_data __data;
   } __combined;
 } _G_iconv_t;
+#endif
 
 typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
 typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/sysdeps/mach/hurd/_G_config.h b/sysdeps/mach/hurd/_G_config.h
index b643059234..db959246ee 100644
--- a/sysdeps/mach/hurd/_G_config.h
+++ b/sysdeps/mach/hurd/_G_config.h
@@ -8,19 +8,15 @@
 
 #include <bits/types.h>
 #define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
 #define __need_NULL
 #include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
-   hold any value corresponding to members of the extended character
-   set, as well as at least one value that does not correspond to any
-   member of the extended character set.  */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
 #define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
 #include <wchar.h>
 #define _G_size_t	size_t
 typedef struct
@@ -41,7 +37,8 @@ typedef struct
 #define _G_wchar_t	wchar_t
 #define _G_wint_t	wint_t
 #define _G_stat64	stat64
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
 typedef union
 {
   struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
     struct __gconv_step_data __data;
   } __combined;
 } _G_iconv_t;
+#endif
 
 typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
 typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index e9a3fba8c1..569fd2b2f6 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -23,7 +23,7 @@
 
 #ifndef _WCHAR_H
 
-#ifndef __need_mbstate_t
+#if !defined __need_mbstate_t && !defined __need_wint_t
 # define _WCHAR_H 1
 # include <features.h>
 #endif
@@ -39,38 +39,40 @@
 # define __need___va_list
 # include <stdarg.h>
 
+# include <bits/wchar.h>
+
 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */
 # define __need_size_t
 # define __need_wchar_t
 # define __need_NULL
 #endif
-#define __need_wint_t
-#include <stddef.h>
-
-#include <bits/wchar.h>
+#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__
+# undef __need_wint_t
+# define __need_wint_t
+# include <stddef.h>
 
 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
    there.  So define it ourselves if it remains undefined.  */
-#ifndef _WINT_T
+# ifndef _WINT_T
 /* Integral type unchanged by default argument promotions that can
    hold any value corresponding to members of the extended character
    set, as well as at least one value that does not correspond to any
    member of the extended character set.  */
-# define _WINT_T
+#  define _WINT_T
 typedef unsigned int wint_t;
-#else
+# else
 /* Work around problems with the <stddef.h> file which doesn't put
    wint_t in the std namespace.  */
-# if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
-     && defined __WINT_TYPE__
+#  if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
+      && defined __WINT_TYPE__
 __BEGIN_NAMESPACE_STD
 typedef __WINT_TYPE__ wint_t;
 __END_NAMESPACE_STD
+#  endif
 # endif
 #endif
 
-
-#ifndef __mbstate_t_defined
+#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined __mbstate_t_defined
 # define __mbstate_t_defined	1
 /* Conversion state information.  */
 typedef struct
@@ -78,7 +80,11 @@ typedef struct
   int __count;
   union
   {
+# ifdef __WINT_TYPE__
+    __WINT_TYPE__ __wch;
+# else
     wint_t __wch;
+# endif
     char __wchb[4];
   } __value;		/* Value so far.  */
 } __mbstate_t;
diff --git a/wctype/wctype.h b/wctype/wctype.h
index 5bfe43895c..603255931f 100644
--- a/wctype/wctype.h
+++ b/wctype/wctype.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2002, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2002, 2005, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,22 +29,9 @@
 #ifndef __need_iswxxx
 # define _WCTYPE_H	1
 
-/* We try to get wint_t from <stddef.h>, but not all GCC versions define it
-   there.  So define it ourselves if it remains undefined.  */
+/* Get wint_t from <wchar.h>.  */
 # define __need_wint_t
-# include <stddef.h>
-# ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
-   hold any value corresponding to members of the extended character
-   set, as well as at least one value that does not correspond to any
-   member of the extended character set.  */
-#  define _WINT_T
-typedef unsigned int wint_t;
-# else
-#  ifdef __USE_ISOC99
-__USING_NAMESPACE_C99(wint_t)
-#  endif
-# endif
+# include <wchar.h>
 
 /* Constant expression of type `wint_t' whose value does not correspond
    to any member of the extended character set.  */