delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/01/16/04:58:25

Date: Tue, 16 Jan 2001 11:55:59 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
cc: djgpp-workers AT delorie DOT com, Esa A E Peuha <peuha AT cc DOT helsinki DOT fi>
Subject: Re: strftime patch
In-Reply-To: <phs26tgvhm0ir3j1fus6tl8lf6nkh7637a@4ax.com>
Message-ID: <Pine.SUN.3.91.1010116115529.1793J-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019