[PROPOSED] Commentary fixes
* Makefile: Mention constraints on TZDIR_BASENAME. * asctime.c: Remove obsolete comment, as zdump now uses snprintf. --- Makefile | 1 + asctime.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 05b40bb..07f4f77 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ TOPDIR= /usr/local # "Compiled" time zone information is placed in the "TZDIR" directory # (and subdirectories). # Use an absolute path name for TZDIR unless you're just testing the software. +# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty. TZDIR_BASENAME= zoneinfo TZDIR= $(TOPDIR)/etc/$(TZDIR_BASENAME) diff --git a/asctime.c b/asctime.c index 1613f78..de681ce 100644 --- a/asctime.c +++ b/asctime.c @@ -99,9 +99,6 @@ asctime_r(register const struct tm *timeptr, char *buf) ** (e.g., timeptr->tm_mday) when processing "%Y". */ strftime(year, sizeof year, "%Y", timeptr); - /* - ** We avoid using snprintf since it's not available on all systems. - */ sprintf(result, ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), wn, mn, -- 2.9.4
Date: Mon, 12 Jun 2017 11:23:53 -0700 From: Paul Eggert <eggert@cs.ucla.edu> Message-ID: <20170612182353.4103-1-eggert@cs.ucla.edu> | * asctime.c: Remove obsolete comment, as zdump now uses snprintf. zdump might, but the code in question (in asctime) obviously doesn't | - /* | - ** We avoid using snprintf since it's not available on all systems. | - */ | sprintf(result, | ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), | wn, mn, kre
On 06/12/2017 03:22 PM, Robert Elz wrote:
zdump might, but the code in question (in asctime) obviously doesn't
True. To some extent I removed that comment for reasons that I didn't bother to write down in the commit log. First, snprintf has been required since C89 and is now universal, and there's little point to documenting ancient backward-compatibility problems that no longer matter. Second, sprintf can be preferable to snprintf when either will do, as sprintf has a simpler API - i.e., nowadays the code avoids snprintf for reasons other than the just-removed comment.
participants (2)
-
Paul Eggert -
Robert Elz