newlib's asctime() does not comply with "The Single UNIX Specification, Version 2"
Egor Duda
deo@logos-m.ru
Wed May 10 08:59:00 GMT 2000
Hi!
Single UNIX Specification V2 says that asctime() must use the
following method to format its output.
sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
wday_name[timeptr->tm_wday],
mon_name[timeptr->tm_mon],
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
1900 + timeptr->tm_year);
whereas current asctime from anoncvs.cygnus.com uses
"%.3s %.3s %.2d %.2d:%.2d:%.2d %d\n" string.
Easy to see, that when tm_mday < 10, newlib will pad it with
leading zero. according to standard it must pad it with space.
One of the problems arising from this noncompliance is described
below.
yesterday, i've checked out (quite large) parts of anoncvs repository
to my machine at work, which is running cygwin. As long as CVS uses
asctime and friends to fill timestamp field if CVS/Entries file, some
of those entries looked like
/Makefile.in/1.2/Sun Apr 09 06:15:43 2000/-ko/
(note the leading zero in timestap). As long as i use cvs at work
there're no problems -- cvs uses the same newlib's asctime to check if
timestamp had been changed. But then i tar.gz'ed my working copy, burn
it on cd and take it to my home machine, which is running linux with
glibc-2.1.1. I've uncompressed working copy and run "cvs update".
Since my home machine has rather slow connection to internet, i've
immediately noticed too much traffic to update yesterday's working
copy. When i turn on cvs's trace mode (cvs -t) i've seen that cvs's
checking out all the files again! Removing leading zeroes in
CVS/Entries solves the problem.
patch's attached below.
Egor. mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19
acstime.patch
acstine.Changelog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: acstime.patch
Type: text/x-diff
Size: 494 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20000510/43139a1f/attachment.bin>
-------------- next part --------------
Wed May 10 18:11:24 2000 Egor Duda <deo@logos-m.ru>
* libc/time/asctime_r.c (asctime_r): Change output format. Day of
month is now padded with space, not zero.
More information about the Newlib
mailing list