Mail Archives: djgpp-workers/2001/01/16/04:58:25
On Sun, 14 Jan 2001, Jason Green wrote:
> Attached below are two patches to make strftime() compliant with
> latest ISO C standard.
Thanks! I think the changes can go in, except for the issues I raise
below which I think we should discuss.
> I have not read up about locales so I am assuming that behaviour in
> DJGPP should be according to the "C" locale.
Yes, the C locale is the only one really supported by DJGPP.
> gcc 2.95.2 emits a warning when strftime() is used with %G, this
> happens both in DJGPP and under Linux.
[snip]
> $ gcc -Wall -pedantic percentg.c
> percentg.c: In function `main':
> percentg.c:9: warning: ANSI C does not support `%G'
This warning can be disregarded. The DJGPP library build procedure
doesn't use -pedantic (and given the above misfeature, probably never
will). Here's the full set of warning switches used by the library
build; if you can compile without any warning or errors using those
switches, you are okay.
-Wall
-Wbad-function-cast
-Wcast-qual
-Werror
-Wmissing-declarations
-Wmissing-prototypes
-Wpointer-arith
-Wshadow
-Wstrict-prototypes
-Wtraditional
-Wwrite-strings
> [#7] In the "C" locale, the E and O modifiers are ignored
> and the replacement strings for the following specifiers
> are:
> %c equivalent to ``%A %B %d %T %Y''.
> %p one of ``am'' or ``pm''.
> %x equivalent to ``%A %B %d %Y''.
Ouch! This looks like a certain incompatibility with C89, where most
implementations, including the "Standard C Library" by Plauger,
generated a different output.
What do we do about this, and possibly other, incompatibilities
between C89 and C99? Do we introduce some global variable that
controls which variant is used? Do other implementations, such as
glibc, have some facilities to be compatible to different standards?
> for (; *format; ++format)
> {
> if (*format == '%')
> {
> - int pad = '0', space=' ';
> + int pad = '0', space=' ', modifier = 0;
> if (format[1] == '_')
> pad = space = ' ', format++;
> if (format[1] == '-')
> @@ -74,6 +140,11 @@
> pad = space = '0', format++;
> if (format[1] == '^')
> upcase = 1, format++;
DJ, these format modifiers (-, _, 0, and ^) don't exist in the C
standard, AFAICS, and aren't documented in libc.info. Is this for
compatibility with some other implementation? If so, which one?
- Raw text -