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: Paul Eggert
Subject: Re: time_r.h -> time_.h
Date: Thu, 01 Mar 2007 13:29:32 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Therefore I propose to remove this paragraph:
>
> -You should include Gnulib-provided headers before system headers,
> -so that Gnulib-provided headers can adjust how a system header
> -behaves.

That sounds good; thanks.

> 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?

The former.

> 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.

That's OK.  The code will still work.  I am a bit leery of calling
undeclared functions when there's a suitable portable alternative,
which there is here.

It may be in other situations that it's important to call an
undeclared function, but my impression is that that sort of situation
is becoming less and less plausible as time goes on.

> 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.

Thanks.

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

Yes, because strptime isn't in ANSI C, nor is it in base POSIX, so its
declaration is excluded in some pedantic environments.

Also strptime's behavior might change if you're defining extensions.
On Solaris 10, for example, you get a different strptime if extensions
are used, and even if you are compiling pedantically you probably want
this since it's the strptime that is normally used and is
better-tested.

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

Thanks.

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

The difference here is that eschew_* functions should never be used,
and there is no replacement for them in gnulib.  For example, portable
code should never use asctime, not even glibc asctime, since it
mishandles some rare cases.

If we ever find a bug-free asctime in the field, or an unportable but
safe usage of asctime in gnulib-using code, then we can revisit this
decision.  I haven't encountered any yet, though.

I installed this:

2007-03-01  Paul Eggert  <address@hidden>

        Followup to the 2007-02-12 patch, using suggestions from Bruno Haible in
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-02/msg00136.html>.
        * doc/gnulib-tool.texi (Initial import): Mention _FILE_OFFSET_BITS
        as another example.
        * lib/time_.h: Fix misspelling.
        * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP):
        Require gl_HEADER_TIME_H_DEFAULTS.
        * m4/strptime.m4 (gl_FUNC_STRPTIME): Likewise.
        * m4/time_r.m4 (gl_TIME_R): Likewise.
        * m4/timegm.m4 (gl_FUNC_TIMEGM): Likewise.

Index: doc/gnulib-tool.texi
===================================================================
RCS file: /cvsroot/gnulib/gnulib/doc/gnulib-tool.texi,v
retrieving revision 1.10
diff -u -p -r1.10 gnulib-tool.texi
--- doc/gnulib-tool.texi        24 Feb 2007 01:13:52 -0000      1.10
+++ doc/gnulib-tool.texi        1 Mar 2007 21:24:52 -0000
@@ -232,8 +232,9 @@ use of @code{strdup}.
 In the usual case where Autoconf is creating a @file{config.h} file,
 you should include @file{config.h} first, before any other include
 file.  That way, for example, if @file{config.h} defines
address@hidden to be the empty string on a pre-C99 host, the
-definition is consistent for all include files.
address@hidden to be the empty string on a pre-C99 host, or a macro
+like @samp{_FILE_OFFSET_BITS} that affects the layout of data
+structures, 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
Index: lib/time_.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/time_.h,v
retrieving revision 1.1
diff -u -p -r1.1 time_.h
--- lib/time_.h 12 Feb 2007 18:49:19 -0000      1.1
+++ lib/time_.h 1 Mar 2007 21:24:52 -0000
@@ -86,7 +86,7 @@ char *strptime (char const *restrict __b
 time_t timegm (struct tm *__tm);
 #endif

-/* Encourage applications to avoid unsafe functions that can overrrun
+/* Encourage applications to avoid unsafe functions that can overrun
    buffers when given outlandish struct tm values.  Portable
    applications should use strftime (or even sprintf) instead.  */
 # if GNULIB_PORTCHECK
Index: m4/nanosleep.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/nanosleep.m4,v
retrieving revision 1.29
diff -u -p -r1.29 nanosleep.m4
--- m4/nanosleep.m4     24 Feb 2007 10:01:49 -0000      1.29
+++ m4/nanosleep.m4     1 Mar 2007 21:24:52 -0000
@@ -1,4 +1,4 @@
-#serial 21
+#serial 22

 dnl From Jim Meyering.
 dnl Check for the nanosleep function.
@@ -17,6 +17,7 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
  dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
  AC_REQUIRE([gl_CLOCK_TIME])
  AC_CHECK_HEADERS_ONCE(sys/time.h)

Index: m4/strptime.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strptime.m4,v
retrieving revision 1.3
diff -u -p -r1.3 strptime.m4
--- m4/strptime.m4      12 Feb 2007 18:49:19 -0000      1.3
+++ m4/strptime.m4      1 Mar 2007 21:24:52 -0000
@@ -1,4 +1,4 @@
-# strptime.m4 serial 3
+# strptime.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,7 @@ dnl with or without modifications, as lo

 AC_DEFUN([gl_FUNC_STRPTIME],
 [
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REPLACE_FUNCS(strptime)
   AC_REQUIRE([gl_TM_GMTOFF])
Index: m4/time_r.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/time_r.m4,v
retrieving revision 1.7
diff -u -p -r1.7 time_r.m4
--- m4/time_r.m4        12 Feb 2007 18:49:19 -0000      1.7
+++ m4/time_r.m4        1 Mar 2007 21:24:52 -0000
@@ -9,7 +9,10 @@ dnl Written by Paul Eggert.

 AC_DEFUN([gl_TIME_R],
 [
+ dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_C_RESTRICT])

   AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
Index: m4/timegm.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/timegm.m4,v
retrieving revision 1.4
diff -u -p -r1.4 timegm.m4
--- m4/timegm.m4        12 Feb 2007 18:49:19 -0000      1.4
+++ m4/timegm.m4        1 Mar 2007 21:24:52 -0000
@@ -1,4 +1,4 @@
-# timegm.m4 serial 4
+# timegm.m4 serial 5
 dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,7 @@ dnl with or without modifications, as lo

 AC_DEFUN([gl_FUNC_TIMEGM],
 [
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MKTIME])
   if test $ac_cv_func_working_mktime = no; then
     # Assume that timegm is buggy if mktime is.




reply via email to

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