gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, gawk-4.2-stable, updated. gawk-4.1.0-308


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.2-stable, updated. gawk-4.1.0-3086-gd5d60a5
Date: Wed, 12 Dec 2018 14:09:30 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-4.2-stable has been updated
       via  d5d60a503f6de8866be843b40fe6de7c20a0f3a0 (commit)
      from  c856f5c96f88cc8a5aacf6ee90e92ed80bd8c3ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=d5d60a503f6de8866be843b40fe6de7c20a0f3a0

commit d5d60a503f6de8866be843b40fe6de7c20a0f3a0
Author: Andrew J. Schorr <address@hidden>
Date:   Wed Dec 12 14:08:15 2018 -0500

    Speed up UTC mktime by using library timegm if available instead of our 
slow implementation.

diff --git a/ChangeLog b/ChangeLog
index b20df74..eaf475d 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-12         Andrew J. Schorr      <address@hidden>
+
+       * configure.ac (AC_CHECK_FUNCS): Check for timegm.
+       * builtin.c (mktime_tz): Remove function; we will use timegm instead.
+       (do_mktime): Replace 'mktime_tz(& then, "UTC+0")' with 'timegm(& then)'.
+       * protos.h (timegm): Add timegm proto on systems lacking it.
+       * replace.c (timegm): Include missing_d/timegm.c if needed.
+
 2018-12-06         Arnold D. Robbins     <address@hidden>
 
        * configure.ac: Add -ggdb3 to CFLAGS if developing and remove
diff --git a/builtin.c b/builtin.c
index d7b2337..f2d3105 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2096,34 +2096,6 @@ do_systime(int nargs ATTRIBUTE_UNUSED)
        return make_number((AWKNUM) lclock);
 }
 
-/* mktime_tz --- based on Linux timegm man page */
-
-static time_t
-mktime_tz(struct tm *tm, const char *tzreq)
-{
-       time_t ret;
-       char *tz = getenv("TZ");
-
-       if (tz)
-               tz = estrdup(tz, strlen(tz));
-       if (setenv("TZ", tzreq, 1) < 0) {
-               warning(_("setenv(TZ, %s) failed (%s)"), tzreq, 
strerror(errno));
-               return -1;
-       }
-       tzset();
-       ret = mktime(tm);
-       if (tz) {
-               if (setenv("TZ", tz, 1) < 0)
-                       fatal(_("setenv(TZ, %s) restoration failed (%s)"), tz, 
strerror(errno));
-               free(tz);
-       } else {
-               if (unsetenv("TZ") < 0)
-                       fatal(_("unsetenv(TZ) failed (%s)"), strerror(errno));
-       }
-       tzset();
-       return ret;
-}
-
 /* do_mktime --- turn a time string into a timestamp */
 
 NODE *
@@ -2184,7 +2156,7 @@ do_mktime(int nargs)
        then.tm_year = year - 1900;
        then.tm_isdst = dst;
 
-       then_stamp = (do_gmt ? mktime_tz(& then, "UTC+0") : mktime(& then));
+       then_stamp = (do_gmt ? timegm(& then) : mktime(& then));
        return make_number((AWKNUM) then_stamp);
 }
 
diff --git a/configh.in b/configh.in
index 8c4d94d..85adc14 100644
--- a/configh.in
+++ b/configh.in
@@ -279,6 +279,9 @@
 /* Define to 1 if you have the <termios.h> header file. */
 #undef HAVE_TERMIOS_H
 
+/* Define to 1 if you have the `timegm' function. */
+#undef HAVE_TIMEGM
+
 /* Define to 1 if you have the `tmpfile' function. */
 #undef HAVE_TMPFILE
 
diff --git a/configure b/configure
index b3ba275..f488b48 100755
--- a/configure
+++ b/configure
@@ -9982,7 +9982,7 @@ for ac_func in __etoa_l atexit btowc fmod gai_strerror \
        memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \
        snprintf strchr \
        strerror strftime strcasecmp strncasecmp strcoll strtod strtoul \
-       system tmpfile towlower towupper tzset usleep waitpid wcrtomb \
+       system timegm tmpfile towlower towupper tzset usleep waitpid wcrtomb \
        wcscoll wctype
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
diff --git a/configure.ac b/configure.ac
index c6c7e50..bbc87b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -312,7 +312,7 @@ AC_CHECK_FUNCS(__etoa_l atexit btowc fmod gai_strerror \
        memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \
        snprintf strchr \
        strerror strftime strcasecmp strncasecmp strcoll strtod strtoul \
-       system tmpfile towlower towupper tzset usleep waitpid wcrtomb \
+       system timegm tmpfile towlower towupper tzset usleep waitpid wcrtomb \
        wcscoll wctype)
 dnl this check is for both mbrtowc and the mbstate_t type, which is good
 AC_FUNC_MBRTOWC
diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog
index bc54838..2d69087 100644
--- a/missing_d/ChangeLog
+++ b/missing_d/ChangeLog
@@ -1,3 +1,7 @@
+2018-12-12         Andrew J. Schorr     <address@hidden>
+
+       * timegm.c: New file implementing timegm.
+
 2018-10-03         Arnold D. Robbins     <address@hidden>
 
        * intprops.h, verify.h: Removed. The copy in ../support is
diff --git a/missing_d/timegm.c b/missing_d/timegm.c
new file mode 100644
index 0000000..f7b780d
--- /dev/null
+++ b/missing_d/timegm.c
@@ -0,0 +1,29 @@
+#include <time.h>
+#include <stdlib.h>
+
+static time_t
+timegm(struct tm *tm)
+{
+       time_t ret;
+       char *tz = getenv("TZ");
+       const char *tzreq = "UTC+0";    /* more portable than ""? */
+
+       if (tz)
+               tz = estrdup(tz, strlen(tz));
+       if (setenv("TZ", tzreq, 1) < 0) {
+               warning(_("setenv(TZ, %s) failed (%s)"), tzreq, 
strerror(errno));
+               return -1;
+       }
+       tzset();
+       ret = mktime(tm);
+       if (tz) {
+               if (setenv("TZ", tz, 1) < 0)
+                       fatal(_("setenv(TZ, %s) restoration failed (%s)"), tz, 
strerror(errno));
+               free(tz);
+       } else {
+               if (unsetenv("TZ") < 0)
+                       fatal(_("unsetenv(TZ) failed (%s)"), strerror(errno));
+       }
+       tzset();
+       return ret;
+}
diff --git a/protos.h b/protos.h
index 5693a43..4dd4a22 100644
--- a/protos.h
+++ b/protos.h
@@ -129,6 +129,10 @@ extern void tzset();
 extern time_t mktime(struct tm *tp);
 #endif
 
+#ifndef HAVE_TIMEGM
+extern time_t timegm(struct tm *);
+#endif
+
 #ifndef HAVE_SNPRINTF
 extern int snprintf(char *restrict buf, size_t len, const char *restrict fmt, 
...);
 #endif
diff --git a/replace.c b/replace.c
index db7f089..ae069f5 100644
--- a/replace.c
+++ b/replace.c
@@ -91,6 +91,10 @@
 #include "missing_d/mktime.c"
 #endif /* HAVE_MKTIME */
 
+#ifndef HAVE_TIMEGM
+#include "missing_d/timegm.c"
+#endif /* HAVE_TIMEGM */
+
 #ifndef HAVE_SNPRINTF
 #include "missing_d/snprintf.c"
 #endif

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

Summary of changes:
 ChangeLog           |  8 ++++++++
 builtin.c           | 30 +-----------------------------
 configh.in          |  3 +++
 configure           |  2 +-
 configure.ac        |  2 +-
 missing_d/ChangeLog |  4 ++++
 missing_d/timegm.c  | 29 +++++++++++++++++++++++++++++
 protos.h            |  4 ++++
 replace.c           |  4 ++++
 9 files changed, 55 insertions(+), 31 deletions(-)
 create mode 100644 missing_d/timegm.c


hooks/post-receive
-- 
gawk



reply via email to

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