bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: removing stdint's dependency on wchar


From: Bruno Haible
Subject: Re: removing stdint's dependency on wchar
Date: Sat, 19 Feb 2011 01:52:10 +0100
User-agent: KMail/1.9.9

Hi Paul,

At the beginning of this thread, you made this statement:

> The problem is
> that md5 includes stdint.h for uint32_t, and the stdint
> module depends on wchar for WCHAR_MIN etc; but md5 does
> not need WCHAR_MIN etc.

It's easy to get this impression. But no, 'stdint' does not depend on 'wchar'
for WCHAR_MIN etc. It depends on 'wchar' out of pure commodity.

Look at the git history:

  - On 2006-06-26, we found out that for getting WCHAR_MIN, WCHAR_MAX one
    needs to include <wchar.h> on some systems. I think these systems are
    AIX 4.3.2, HP-UX 11.11, Interix 3.5, OSF/1, and BSDI.
    <http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00223.html>
    
<http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=b17f732462b975b60c11f8800e413c6dff691e0c>

  - Later, on 2007-01-06, we had a working 'wchar' module, and decided
    to use it everywhere, to remove the use of @HAVE_WCHAR_H@:
    <http://lists.gnu.org/archive/html/bug-gnulib/2007-01/msg00267.html>
    
<http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=96f7b7d91a671011cb95059bad591615c250495d>

So, in order to break the dependency, we only need to revert a small part
of the 2007-01-06 patch.

Here's the proposed patch. It does not modify the promises made by the 'stdint'
module. It also is much smaller and does not require the creation of a separate
module.


2011-02-18  Bruno Haible  <address@hidden>

        stdint: Cut dependency to module 'wchar'.
        * lib/stdint.in.h: Include wchar.h only when HAVE_WCHAR_H is 1. Also
        include the necessary prerequisites.
        * m4/stdint.m4 (gl_STDINT_H): Test whether wchar.h exists.
        * modules/stdint (Depends-on): Remove wchar.
        (Makefile.am): Substitute HAVE_WCHAR_H.
        This reverts part of a 2007-01-06 commit. Reported by Paul Eggert.

--- lib/stdint.in.h.orig        Sat Feb 19 01:46:42 2011
+++ lib/stdint.in.h     Sat Feb 19 01:44:49 2011
@@ -497,7 +497,12 @@
    sequence of nested includes
    <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
    <stdint.h> and assumes its types are already defined.  */
-#if ! (defined WCHAR_MIN && defined WCHAR_MAX)
+#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
+  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+     included before <wchar.h>.  */
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
 # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
 # include <wchar.h>
 # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
--- m4/stdint.m4.orig   Sat Feb 19 01:46:42 2011
+++ m4/stdint.m4        Sat Feb 19 01:42:38 2011
@@ -1,4 +1,4 @@
-# stdint.m4 serial 37
+# stdint.m4 serial 38
 dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,6 +27,15 @@
   fi
   AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
 
+  dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
+  AC_CHECK_HEADERS_ONCE([wchar.h])
+  if test $ac_cv_header_wchar_h = yes; then
+    HAVE_WCHAR_H=1
+  else
+    HAVE_WCHAR_H=0
+  fi
+  AC_SUBST([HAVE_WCHAR_H])
+
   dnl Check for <inttypes.h>.
   dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
   if test $ac_cv_header_inttypes_h = yes; then
--- modules/stdint.orig Sat Feb 19 01:46:42 2011
+++ modules/stdint      Sat Feb 19 01:45:53 2011
@@ -14,7 +14,6 @@
 Depends-on:
 include_next
 multiarch
-wchar
 
 configure.ac:
 gl_STDINT_H
@@ -36,6 +35,7 @@
              -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
              -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
              -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
+             -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
              -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
              -e 
's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
              -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \

-- 
In memoriam Khosrow Golsorkhi <http://en.wikipedia.org/wiki/Khosrow_Golsorkhi>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]