[tz] [PROPOSED 5/5] Remove ancient asctime.c cruft

Paul Eggert eggert at cs.ucla.edu
Tue Jul 12 16:14:07 UTC 2022

* asctime.c (ASCTIME_FMT, ASCTIME_FMT_B): Don’t worry about
portability to pre-C89 C libraries.  They are no longer of
practical importance, and we can assume at least C89 by now.
Also, don’t worry about warnings from ancient GCC.  They were just
warnings anyway, and they were warning about pre-C89 portability.
 asctime.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/asctime.c b/asctime.c
index fd3b038..f0159f8 100644
--- a/asctime.c
+++ b/asctime.c
@@ -16,12 +16,6 @@
 #include "private.h"
 #include <stdio.h>
-** Some systems only handle "%.2d"; others only handle "%02d";
-** "%02.2d" makes (most) everybody happy.
-** At least some versions of gcc warn about the %02.2d;
-** we conditionalize below to avoid the warning.
 ** All years associated with 32-bit time_t values are exactly four digits long;
 ** some years associated with 64-bit time_t values are not.
@@ -34,22 +28,14 @@
 ** The ISO C and POSIX standards prohibit padding the year,
 ** but many implementations pad anyway; most likely the standards are buggy.
-#ifdef __GNUC__
-static char const ASCTIME_FMT[] = "%s %s%3d %2.2d:%2.2d:%2.2d %-4s\n";
-static char const ASCTIME_FMT[] = "%s %s%3d %02.2d:%02.2d:%02.2d %-4s\n";
+static char const ASCTIME_FMT[] = "%s %s%3d %.2d:%.2d:%.2d %-4s\n";
 ** For years that are more than four digits we put extra spaces before the year
 ** so that code trying to overwrite the newline won't end up overwriting
 ** a digit within a year and truncating the year (operating on the assumption
 ** that no output is better than wrong output).
-#ifdef __GNUC__
-static char const ASCTIME_FMT_B[] = "%s %s%3d %2.2d:%2.2d:%2.2d     %s\n";
-static char const ASCTIME_FMT_B[] = "%s %s%3d %02.2d:%02.2d:%02.2d     %s\n";
+static char const ASCTIME_FMT_B[] = "%s %s%3d %.2d:%.2d:%.2d     %s\n";
 enum { STD_ASCTIME_BUF_SIZE = 26 };

More information about the tz mailing list