]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
authorSami Kerola <kerolasa@iki.fi>
Sat, 27 Dec 2014 09:32:45 +0000 (09:32 +0000)
committerSami Kerola <kerolasa@iki.fi>
Mon, 8 Jun 2015 20:53:36 +0000 (21:53 +0100)
Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the
warning, so that the above workaround is no longer required.

Reference: http://man7.org/linux/man-pages/man3/strftime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
term-utils/Makemodule.am
term-utils/script.c

index de62098aa688b720eb2f73e4d940237bc5c46fd8..1b735b9bc02e23d95e380eb27d68356ee145079c 100644 (file)
@@ -2,6 +2,7 @@ if BUILD_SCRIPT
 usrbin_exec_PROGRAMS += script
 dist_man_MANS += term-utils/script.1
 script_SOURCES = term-utils/script.c
+script_CFLAGS = $(AM_CFLAGS) -Wno-format-y2k
 script_LDADD = $(LDADD)
 if HAVE_UTIL
 script_LDADD += -lutil
index 86864b00aba840846348bbc43e46ebd7780d709e..d045111c7c1da547f4b853a9ec2ebd9731d72bda 100644 (file)
@@ -166,15 +166,6 @@ static void die_if_link(const struct script_control *ctl)
                       "Program not started."), ctl->fname);
 }
 
-/*
- * Stop extremely silly gcc complaint on %c:
- *  warning: `%c' yields only last 2 digits of year in some locales
- */
-static void my_strftime(char *buf, size_t len, const char *fmt, const struct tm *tm)
-{
-       strftime(buf, len, fmt, tm);
-}
-
 static void __attribute__((__noreturn__)) done(struct script_control *ctl)
 {
        if (ctl->isterm)
@@ -308,7 +299,7 @@ static void do_io(struct script_control *ctl)
        pfd[2].fd = ctl->sigfd;
        pfd[2].events = POLLIN | POLLERR | POLLHUP;
 
-       my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
+       strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
        fprintf(ctl->typescriptfp, _("Script started on %s"), buf);
 
        while (!ctl->die) {
@@ -342,8 +333,8 @@ static void do_io(struct script_control *ctl)
        if (!ctl->die)
                finish(ctl, 1); /* wait for children */
        if (!ctl->qflg && ctl->typescriptfp) {
-               time_t tvec = script_time((time_t *)NULL);
-               my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
+               tvec = script_time((time_t *)NULL);
+               strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
                fprintf(ctl->typescriptfp, _("\nScript done on %s"), buf);
        }
        done(ctl);