Fw: [PATCH 1/2] strftime.c(__strftime): add %i, %q, %v, tests; tweak %Z docs

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Mon Sep 19 23:21:35 GMT 2022


On 2022-09-19 09:51, C Howland wrote:
>     newlib/libc/time/strftime.c(__strftime):
>     %i year in century [00..99] Synonym for "%y". Non-POSIX extension.
>     [tm_year]
>     %q GNU quarter of the year (from `<<1>>' to `<<4>>') [tm_mon]
>     %v OSX/Ruby VMS/Oracle date "%d-%b-%Y". Non-POSIX extension.
>     [tm_mday, tm_mon, tm_year]
>     add %i %q %v tests
>     %Z clarify current time zone *abbreviation* not "name" [tm_isdst]

> While the additions themselves nominally look good, all being extensions 
> they ought to be gated by the appropriate ifdefs, and the manual would 
> best mention what gates are needed to get them.  %q would be 
> __GNU_VISIBLE as the gate and _GNU_SOURCE for the user/manual, and I'd 
> guess probably __MISC_VISIBLE gate for the others (user action as noted 
> in sys/features.h).

Those features are more appropriate for application build time feature 
support selection, not for library implementations.

I checked and implementations (including BSD, and Cygwin strptime.cc) 
don't gate features, except by what the build config supports and desires:

	__CYGWIN__, __HAVE_LOCALE_INFO_EXTENDED__, __TM_GMTOFF,
	__TM_ZONE, _WANT_C99_TIME_FORMATS, MAKE_WCSFTIME, YEAR_BASE

and strptime.c *#defines _GNU_SOURCE* before all #include-s.

The overhead of the additions is minimal compared to existing 
conversions, the likely impact of issues with new conversions used in 
existing sources is low, and any use is defined as UB.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]


More information about the Newlib mailing list