bug-gnulib
[Top][All Lists]
Advanced

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

Re: time_r.h -> time_.h


From: Bruno Haible
Subject: Re: time_r.h -> time_.h
Date: Tue, 13 Feb 2007 02:45:38 +0100
User-agent: KMail/1.5.4

Hello Paul,

Here are some nitpicking remarks.

-----------------------------------------------------------------------------

About gnulib-tool.texi: I don't agree with this paragraph

  You should include Gnulib-provided headers before system headers,
  so that Gnulib-provided headers can adjust how a system header
  behaves.

Except for <config.h>, the user doesn't want ordering constraints. We have
been successful in avoiding them, for example in <stdint.h> or <inttypes.h>,
by including all system headers in advance that might conflict with the
definitions of our replacement header file. Therefore I propose to remove
this paragraph:

--- doc/gnulib-tool.texi        12 Feb 2007 18:49:19 -0000      1.9
+++ doc/gnulib-tool.texi        13 Feb 2007 00:30:27 -0000
@@ -233,11 +233,10 @@
 you should include @file{config.h} first, before any other include
 file.  That way, for example, if @file{config.h} defines
 @samp{restrict} to be the empty string on a pre-C99 host, the
-definition is consistent for all include files.
-
-You should include Gnulib-provided headers before system headers,
-so that Gnulib-provided headers can adjust how a system header
-behaves.
+definition is consistent for all include files.  This is also
+necessary because @file{config.h} may define macros like @samp{_GNU_SOURCE}
+or @samp{_FILE_OFFSET_BITS} which have an effect only if defined before the
+first system header file is included.
 
 A final word of warning: Gnulib currently assumes it will be
 responsible for @emph{all} functions that end up in the Autoconf

-----------------------------------------------------------------------------

The timegm.m4 did check whether timegm was declared. Was it because some
platforms defined the function but did not declare it? Or the opposite?
I'm asking because in the first case, the new timegm.m4 and <time.h> provides
a replacement to the function although it already exists in libc.

-----------------------------------------------------------------------------

gl_TIME_R should AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) to exclude the
possibility that REPLACE_LOCALTIME_R gets set to 0 after it has already
been set to 1 inside gl_TIME_R.

Likewise for gl_FUNC_NANOSLEEP, gl_FUNC_STRPTIME, gl_FUNC_TIMEGM.

-----------------------------------------------------------------------------

strptime now requires the 'extensions' module, although it didn't before.
Is this intentional?

-----------------------------------------------------------------------------

time_.h: "overrrun" -> "overrun"

-----------------------------------------------------------------------------

>       This implementation tries out a simpler approach
>       for replacing decls in standard include files (as compared to
>       the string module), somewhat as an experiment.

Hmm. If used GNULIB_PORTCHECK, the user will get link errors about
eschew_asctime but about rpl_nanosleep? Not consistent.

-----------------------------------------------------------------------------

Btw, a gnulib user may want to ignore the gnulib portability checks (for
example, if the target platforms all have nanosleep()), i.e. he may willfully
use --avoid=nanosleep. It's hard to progress after a link error; he will
need to use "make -k", and if libraries are involved, "make -k" will not
even attempt to link every program. So I think it's better to turn all
gnulib-induced link errors into link-time warnings. I'm applying this.

2007-02-12  Bruno Haible  <address@hidden>

        * lib/string_.h (memmem, mempcpy, memrchr, stpcpy, stpncpy, strchrnul,
        strdup, strndup, strnlen, strpbrk, strsep, strtok_r): If
        GNULIB_POSIXCHECK and the gnulib module not enabled, provoke a link-
        time warning rather than a link error.

*** lib/string_.h       12 Feb 2007 19:06:30 -0000      1.21
--- lib/string_.h       13 Feb 2007 00:53:50 -0000
***************
*** 64,70 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef memmem
! # define memmem memmem_is_unportable__use_gnulib_module_memmem_for_portability
  #endif
  
  /* Copy N bytes of SRC to DEST, return pointer to bytes after the
--- 64,72 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef memmem
! # define memmem(a,al,b,bl) \
!     (GL_LINK_WARNING ("memmem is unportable - use gnulib module memmem for 
portability"), \
!      memmem (a, al, b, bl))
  #endif
  
  /* Copy N bytes of SRC to DEST, return pointer to bytes after the
***************
*** 76,82 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef mempcpy
! # define mempcpy 
mempcpy_is_unportable__use_gnulib_module_mempcpy_for_portability
  #endif
  
  /* Search backwards through a block for a byte (specified as an int).  */
--- 78,86 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef mempcpy
! # define mempcpy(a,b,n) \
!     (GL_LINK_WARNING ("mempcpy is unportable - use gnulib module mempcpy for 
portability"), \
!      mempcpy (a, b, n))
  #endif
  
  /* Search backwards through a block for a byte (specified as an int).  */
***************
*** 86,92 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef memrchr
! # define memrchr 
memrchr_is_unportable__use_gnulib_module_memrchr_for_portability
  #endif
  
  /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
--- 90,98 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef memrchr
! # define memrchr(a,b,c) \
!     (GL_LINK_WARNING ("memrchr is unportable - use gnulib module memrchr for 
portability"), \
!      memrchr (a, b, c))
  #endif
  
  /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
***************
*** 96,102 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef stpcpy
! # define stpcpy stpcpy_is_unportable__use_gnulib_module_stpcpy_for_portability
  #endif
  
  /* Copy no more than N bytes of SRC to DST, returning a pointer past the
--- 102,110 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef stpcpy
! # define stpcpy(a,b) \
!     (GL_LINK_WARNING ("stpcpy is unportable - use gnulib module stpcpy for 
portability"), \
!      stpcpy (a, b))
  #endif
  
  /* Copy no more than N bytes of SRC to DST, returning a pointer past the
***************
*** 109,115 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef stpncpy
! # define stpncpy 
stpncpy_is_unportable__use_gnulib_module_stpncpy_for_portability
  #endif
  
  /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
--- 117,125 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef stpncpy
! # define stpncpy(a,b,n) \
!     (GL_LINK_WARNING ("stpncpy is unportable - use gnulib module stpncpy for 
portability"), \
!      stpncpy (a, b, n))
  #endif
  
  /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
***************
*** 162,168 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strchrnul
! # define strchrnul 
strchrnul_is_unportable__use_gnulib_module_strchrnul_for_portability
  #endif
  
  /* Duplicate S, returning an identical malloc'd string.  */
--- 172,180 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strchrnul
! # define strchrnul(a,b) \
!     (GL_LINK_WARNING ("strchrnul is unportable - use gnulib module strchrnul 
for portability"), \
!      strchrnul (a, b))
  #endif
  
  /* Duplicate S, returning an identical malloc'd string.  */
***************
*** 172,178 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strdup
! # define strdup strdup_is_unportable__use_gnulib_module_strdup_for_portability
  #endif
  
  /* Return a newly allocated copy of at most N bytes of STRING.  */
--- 184,192 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strdup
! # define strdup(a) \
!     (GL_LINK_WARNING ("strdup is unportable - use gnulib module strdup for 
portability"), \
!      strdup (a))
  #endif
  
  /* Return a newly allocated copy of at most N bytes of STRING.  */
***************
*** 186,192 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strndup
! # define strndup 
strndup_is_unportable__use_gnulib_module_strndup_for_portability
  #endif
  
  /* Find the length (number of bytes) of STRING, but scan at most
--- 200,208 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strndup
! # define strndup(a,n) \
!     (GL_LINK_WARNING ("strndup is unportable - use gnulib module strndup for 
portability"), \
!      strndup (a, n))
  #endif
  
  /* Find the length (number of bytes) of STRING, but scan at most
***************
*** 198,204 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strnlen
! # define strnlen 
strnlen_is_unportable__use_gnulib_module_strnlen_for_portability
  #endif
  
  #if defined GNULIB_POSIXCHECK
--- 214,222 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strnlen
! # define strnlen(a,n) \
!     (GL_LINK_WARNING ("strnlen is unportable - use gnulib module strnlen for 
portability"), \
!      strnlen (a, n))
  #endif
  
  #if defined GNULIB_POSIXCHECK
***************
*** 229,235 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strpbrk
! # define strpbrk 
strpbrk_is_unportable__use_gnulib_module_strpbrk_for_portability
  #endif
  
  #if defined GNULIB_POSIXCHECK
--- 247,255 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strpbrk
! # define strpbrk(s,a) \
!     (GL_LINK_WARNING ("strpbrk is unportable - use gnulib module strpbrk for 
portability"), \
!      strpbrk (s, a))
  #endif
  
  #if defined GNULIB_POSIXCHECK
***************
*** 278,284 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strsep
! # define strsep strsep_is_unportable__use_gnulib_module_strsep_for_portability
  #endif
  
  #if defined GNULIB_POSIXCHECK
--- 298,306 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strsep
! # define strsep(s,d) \
!     (GL_LINK_WARNING ("strsep is unportable - use gnulib module strsep for 
portability"), \
!      strsep (s, d))
  #endif
  
  #if defined GNULIB_POSIXCHECK
***************
*** 342,348 ****
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strtok_r
! # define strtok_r 
strtok_r_is_unportable__use_gnulib_module_strtok_r_for_portability
  #endif
  
  
--- 364,372 ----
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef strtok_r
! # define strtok_r(s,d,p) \
!     (GL_LINK_WARNING ("strtok_r is unportable - use gnulib module strtok_r 
for portability"), \
!      strtok_r (s, d, p))
  #endif
  
  





reply via email to

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