Module Name: src Committed By: martin Date: Mon Jul 24 17:16:00 UTC 2023
Modified Files: src/lib/libc/time [netbsd-10]: NEWS localtime.c private.h zdump.c zic.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #242): lib/libc/time/localtime.c: revision 1.137 lib/libc/time/zdump.c: revision 1.61 lib/libc/time/NEWS: revision 1.41 lib/libc/time/zic.c: revision 1.88 lib/libc/time/zic.c: revision 1.89 lib/libc/time/private.h: revision 1.65 Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance. Requested by Jan-Benedict Glaw. put attributes first for c23 compliance. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.40.2.1 src/lib/libc/time/NEWS cvs rdiff -u -r1.136 -r1.136.2.1 src/lib/libc/time/localtime.c cvs rdiff -u -r1.64 -r1.64.2.1 src/lib/libc/time/private.h cvs rdiff -u -r1.60 -r1.60.2.1 src/lib/libc/time/zdump.c cvs rdiff -u -r1.87 -r1.87.2.1 src/lib/libc/time/zic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/time/NEWS diff -u src/lib/libc/time/NEWS:1.40 src/lib/libc/time/NEWS:1.40.2.1 --- src/lib/libc/time/NEWS:1.40 Sun Dec 11 17:57:23 2022 +++ src/lib/libc/time/NEWS Mon Jul 24 17:15:59 2023 @@ -85,6 +85,11 @@ Release 2022g - 2022-11-29 08:58:31 -080 lines are in the file 'backward'. (Inspired by a suggestion from Stephen Colebourne.) + On C23-compatible platforms tzcode no longer uses syntax like + 'static [[noreturn]] void usage(void);'. Instead, it uses + '[[noreturn]] static void usage(void);' as strict C23 requires. + (Problem reported by Houge Langley.) + Release 2022f - 2022-10-28 18:04:57 -0700 Index: src/lib/libc/time/localtime.c diff -u src/lib/libc/time/localtime.c:1.136 src/lib/libc/time/localtime.c:1.136.2.1 --- src/lib/libc/time/localtime.c:1.136 Sun Dec 11 17:57:23 2022 +++ src/lib/libc/time/localtime.c Mon Jul 24 17:15:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.136 2022/12/11 17:57:23 christos Exp $ */ +/* $NetBSD: localtime.c,v 1.136.2.1 2023/07/24 17:15:59 martin Exp $ */ /* Convert timestamp from time_t to struct tm. */ @@ -12,7 +12,7 @@ #if 0 static char elsieid[] = "@(#)localtime.c 8.17"; #else -__RCSID("$NetBSD: localtime.c,v 1.136 2022/12/11 17:57:23 christos Exp $"); +__RCSID("$NetBSD: localtime.c,v 1.136.2.1 2023/07/24 17:15:59 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -894,7 +894,7 @@ is_digit(char c) ** Return a pointer to that character. */ -static ATTRIBUTE_REPRODUCIBLE const char * +ATTRIBUTE_REPRODUCIBLE static const char * getzname(register const char *strp) { register char c; @@ -915,7 +915,7 @@ getzname(register const char *strp) ** We don't do any checking here; checking is done later in common-case code. */ -static ATTRIBUTE_REPRODUCIBLE const char * +ATTRIBUTE_REPRODUCIBLE static const char * getqzname(register const char *strp, const int delim) { register int c; Index: src/lib/libc/time/private.h diff -u src/lib/libc/time/private.h:1.64 src/lib/libc/time/private.h:1.64.2.1 --- src/lib/libc/time/private.h:1.64 Sun Dec 11 17:57:23 2022 +++ src/lib/libc/time/private.h Mon Jul 24 17:16:00 2023 @@ -1,6 +1,6 @@ /* Private header for tzdb code. */ -/* $NetBSD: private.h,v 1.64 2022/12/11 17:57:23 christos Exp $ */ +/* $NetBSD: private.h,v 1.64.2.1 2023/07/24 17:16:00 martin Exp $ */ #ifndef PRIVATE_H #define PRIVATE_H @@ -646,7 +646,7 @@ char *asctime(struct tm const *); char *asctime_r(struct tm const *restrict, char *restrict); char *ctime(time_t const *); char *ctime_r(time_t const *, char *); -double difftime(time_t, time_t) ATTRIBUTE_UNSEQUENCED; +ATTRIBUTE_UNSEQUENCED double difftime(time_t, time_t); size_t strftime(char *restrict, size_t, char const *restrict, struct tm const *restrict); # if HAVE_STRFTIME_L @@ -762,10 +762,10 @@ timezone_t tzalloc(char const *); void tzfree(timezone_t); # ifdef STD_INSPIRED # if TZ_TIME_T || !defined posix2time_z -time_t posix2time_z(timezone_t __restrict, time_t) ATTRIBUTE_REPRODUCIBLE; +ATTRIBUTE_REPRODUCIBLE time_t posix2time_z(timezone_t __restrict, time_t); # endif # if TZ_TIME_T || !defined time2posix_z -time_t time2posix_z(timezone_t __restrict, time_t) ATTRIBUTE_REPRODUCIBLE; +ATTRIBUTE_REPRODUCIBLE time_t time2posix_z(timezone_t __restrict, time_t); # endif # endif #endif Index: src/lib/libc/time/zdump.c diff -u src/lib/libc/time/zdump.c:1.60 src/lib/libc/time/zdump.c:1.60.2.1 --- src/lib/libc/time/zdump.c:1.60 Tue Dec 13 19:08:42 2022 +++ src/lib/libc/time/zdump.c Mon Jul 24 17:15:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: zdump.c,v 1.60 2022/12/13 19:08:42 christos Exp $ */ +/* $NetBSD: zdump.c,v 1.60.2.1 2023/07/24 17:15:59 martin Exp $ */ /* Dump time zone data in a textual format. */ /* @@ -8,7 +8,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: zdump.c,v 1.60 2022/12/13 19:08:42 christos Exp $"); +__RCSID("$NetBSD: zdump.c,v 1.60.2.1 2023/07/24 17:15:59 martin Exp $"); #endif /* !defined lint */ #ifndef NETBSD_INSPIRED @@ -94,7 +94,7 @@ static bool warned; static bool errout; static char const *abbr(struct tm const *); -static intmax_t delta(struct tm *, struct tm *) ATTRIBUTE_REPRODUCIBLE; +ATTRIBUTE_REPRODUCIBLE static intmax_t delta(struct tm *, struct tm *); static void dumptime(struct tm const *); static time_t hunt(timezone_t, time_t, time_t, bool); static void show(timezone_t, char *, time_t, bool); @@ -102,7 +102,7 @@ static void showextrema(timezone_t, char static void showtrans(char const *, struct tm const *, time_t, char const *, char const *); static const char *tformat(void); -static time_t yeartot(intmax_t) ATTRIBUTE_REPRODUCIBLE; +ATTRIBUTE_REPRODUCIBLE static time_t yeartot(intmax_t); /* Is C an ASCII digit? */ static bool @@ -130,7 +130,7 @@ is_alpha(char a) } } -static ATTRIBUTE_NORETURN void +ATTRIBUTE_NORETURN static void size_overflow(void) { fprintf(stderr, _("%s: size overflow\n"), progname); @@ -139,7 +139,7 @@ size_overflow(void) /* Return A + B, exiting if the result would overflow either ptrdiff_t or size_t. */ -static ATTRIBUTE_REPRODUCIBLE ptrdiff_t +ATTRIBUTE_REPRODUCIBLE static ptrdiff_t sumsize(size_t a, size_t b) { #ifdef ckd_add @@ -156,7 +156,7 @@ sumsize(size_t a, size_t b) /* Return a pointer to a newly allocated buffer of size SIZE, exiting on failure. SIZE should be nonzero. */ -static void * ATTRIBUTE_MALLOC +ATTRIBUTE_MALLOC static void * xmalloc(size_t size) { void *p = malloc(size); @@ -922,7 +922,7 @@ showextrema(timezone_t tz, char *zone, t # include <stdarg.h> /* A substitute for snprintf that is good enough for zdump. */ -static int ATTRIBUTE_FORMAT((printf, 3, 4)) +ATTRIBUTE_FORMAT((printf, 3, 4)) static int my_snprintf(char *s, size_t size, char const *format, ...) { int n; Index: src/lib/libc/time/zic.c diff -u src/lib/libc/time/zic.c:1.87 src/lib/libc/time/zic.c:1.87.2.1 --- src/lib/libc/time/zic.c:1.87 Tue Dec 13 19:08:42 2022 +++ src/lib/libc/time/zic.c Mon Jul 24 17:16:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: zic.c,v 1.87 2022/12/13 19:08:42 christos Exp $ */ +/* $NetBSD: zic.c,v 1.87.2.1 2023/07/24 17:16:00 martin Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -11,7 +11,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: zic.c,v 1.87 2022/12/13 19:08:42 christos Exp $"); +__RCSID("$NetBSD: zic.c,v 1.87.2.1 2023/07/24 17:16:00 martin Exp $"); #endif /* !defined lint */ /* Use the system 'time' function, instead of any private replacement. @@ -472,20 +472,20 @@ static char roll[TZ_MAX_LEAPS]; ** Memory allocation. */ -static ATTRIBUTE_NORETURN void +ATTRIBUTE_NORETURN static void memory_exhausted(const char *msg) { fprintf(stderr, _("%s: Memory exhausted: %s\n"), progname, msg); exit(EXIT_FAILURE); } -static ATTRIBUTE_NORETURN void +ATTRIBUTE_NORETURN static void size_overflow(void) { memory_exhausted(_("size overflow")); } -static ATTRIBUTE_REPRODUCIBLE ptrdiff_t +ATTRIBUTE_REPRODUCIBLE static ptrdiff_t size_sum(size_t a, size_t b) { #ifdef ckd_add @@ -500,7 +500,7 @@ size_sum(size_t a, size_t b) size_overflow(); } -static ATTRIBUTE_REPRODUCIBLE ptrdiff_t +ATTRIBUTE_REPRODUCIBLE static ptrdiff_t size_product(ptrdiff_t nitems, ptrdiff_t itemsize) { #ifdef ckd_mul @@ -515,7 +515,7 @@ size_product(ptrdiff_t nitems, ptrdiff_t size_overflow(); } -static ATTRIBUTE_REPRODUCIBLE ptrdiff_t +ATTRIBUTE_REPRODUCIBLE static ptrdiff_t align_to(ptrdiff_t size, ptrdiff_t alignment) { ptrdiff_t lo_bits = alignment - 1, sum = size_sum(size, lo_bits); @@ -539,7 +539,7 @@ memcheck(void *ptr) return ptr; } -static void * ATTRIBUTE_MALLOC +ATTRIBUTE_MALLOC static void * emalloc(size_t size) { return memcheck(malloc(size)); @@ -551,7 +551,7 @@ erealloc(void *ptr, size_t size) return memcheck(realloc(ptr, size)); } -static char * ATTRIBUTE_MALLOC +ATTRIBUTE_MALLOC static char * estrdup(char const *str) { return memcheck(strdup(str)); @@ -622,7 +622,7 @@ eat(int fnum, lineno num) eats(fnum, num, 0, -1); } -static void ATTRIBUTE_FORMAT((printf, 1, 0)) +ATTRIBUTE_FORMAT((printf, 1, 0)) static void verror(const char *const string, va_list args) { /* @@ -640,7 +640,7 @@ verror(const char *const string, va_list fprintf(stderr, "\n"); } -static void ATTRIBUTE_FORMAT((printf, 1, 2)) +ATTRIBUTE_FORMAT((printf, 1, 2)) static void error(const char *const string, ...) { va_list args; @@ -650,7 +650,7 @@ error(const char *const string, ...) errors = true; } -static void ATTRIBUTE_FORMAT((printf, 1, 2)) +ATTRIBUTE_FORMAT((printf, 1, 2)) static void warning(const char *const string, ...) { va_list args; @@ -680,7 +680,7 @@ close_file(FILE *stream, char const *dir } } -static ATTRIBUTE_NORETURN void +ATTRIBUTE_NORETURN static void usage(FILE *stream, int status) { fprintf(stream, @@ -3626,7 +3626,7 @@ lowerit(char a) } /* case-insensitive equality */ -static ATTRIBUTE_REPRODUCIBLE bool +ATTRIBUTE_REPRODUCIBLE static bool ciequal(const char *ap, const char *bp) { while (lowerit(*ap) == lowerit(*bp++)) @@ -3635,7 +3635,7 @@ ciequal(const char *ap, const char *bp) return false; } -static ATTRIBUTE_REPRODUCIBLE bool +ATTRIBUTE_REPRODUCIBLE static bool itsabbr(const char *abbr, const char *word) { if (lowerit(*abbr) != lowerit(*word)) @@ -3651,7 +3651,7 @@ itsabbr(const char *abbr, const char *wo /* Return true if ABBR is an initial prefix of WORD, ignoring ASCII case. */ -static ATTRIBUTE_REPRODUCIBLE bool +ATTRIBUTE_REPRODUCIBLE static bool ciprefix(char const *abbr, char const *word) { do @@ -3754,14 +3754,14 @@ getfields(char *cp, char **array, int ar return nsubs; } -static ATTRIBUTE_NORETURN void +ATTRIBUTE_NORETURN static void time_overflow(void) { error(_("time overflow")); exit(EXIT_FAILURE); } -static ATTRIBUTE_REPRODUCIBLE zic_t +ATTRIBUTE_REPRODUCIBLE static zic_t oadd(zic_t t1, zic_t t2) { #ifdef ckd_add @@ -3775,7 +3775,7 @@ oadd(zic_t t1, zic_t t2) time_overflow(); } -static ATTRIBUTE_REPRODUCIBLE zic_t +ATTRIBUTE_REPRODUCIBLE static zic_t tadd(zic_t t1, zic_t t2) { #ifdef ckd_add