Mail Archives: cygwin/2001/02/01/12:12:10
On Thu, 1 Feb 2001 08:59:17 -0500, Christopher Faylor <cgf AT redhat DOT com> wrote:
>
> On Thu, Feb 01, 2001 at 02:01:03AM -0800, Lothan wrote:
> >> From: cygwin-owner AT sources DOT redhat DOT com
> >> [mailto:cygwin-owner AT sources DOT redhat DOT com]On Behalf Of Jerome BENOIT
> >> Sent: Wednesday, January 31, 2001 6:48 PM
> >> To: Cygnus
> >> Subject: date +"%Z"
> >>
> >>
> >> Hello !
> >>
> >> It seems that the command line
> >>
> >> date +"%Z"
> >>
> >> hangs under Win98.
> >>
> >> I hope it helps,
> >> Jerome BENOIT
> >
> >The problem is in this section of code in the show_date() routine in date.c:
> >
> > do
> > {
> > out_length += 200;
> > out = (char *) xrealloc(out, out_length);
> > }
> > while(strftime(out, out_length, format, tm) == 0);
On the the date.c loaded from the GNU source (sh-utils-2.0.tar.gz of
1999-08-15 from ftp.gnu.org) the date.c itself is from 1999-08-01.
The check is like this:
while (strftime (out, out_length, format, tm) == 0 && out[0] != '\0');
> >It allocates memory 200 bytes at a time until strftime() returns a success
> >status. The basic premise seems to be to allocate a large enough buffer for
> >strftime() to write the specified date format into. Unfortunately it's
> >bumping heads with this basic code in strftime():
> >
> > size_t count = 0;
> >
> > switch(*format)
> > {
> > case "Z":
> > break;
> > }
> >
> > s[count] = '\0';
> > return count;
> >
On the strftime.c (from 1999-04-08, same GNU source as date.c),
the code is like this:
case 'Z':
if (change_case)
{
to_uppcase = 0;
to_lowcase = 1;
}
#if HAVE_TZNAME
/* The tzset() call might have changed the value. */
if (!(zone && *zone) && tp->tm_isdst >= 0)
zone = tzname[tp->tm_isdst];
#endif
if (! zone)
zone = ""; /* POSIX.2 requires the empty string here. */
cpy (strlen (zone), zone);
break;
> >In this case strftime() doesn't support the %Z format, so it always returns
> >zero. This leads to the code in date continuously allocating memory until
> >it's completely exhausted.
This is the code in shellutils-src.tar.gz, but it is NOT the current
GNU code.
> If anyone is interested, could you let the maintainer of the date code know
> about this? There is probably a GNU maintainer but I don't know who it is.
Chris, You have spoken without checking the (GNU) sources first (see my
code snippet above). This is NOT a GNU problem (even if the 1 line in
the date check was like the GNU version, there would be no bug). The
problem is the porting to Cygwin.
I've checked the date.c and strftime.c on shellutils-src.tar.gz (of
2000-01-18 from ftp.sunet.se) these sources are from 1997-11-06. So it
is probably based on based on sh-utils-1.16.tar.gz from 1997-01-27. May
be a new port of sh-utils is in order (and if you tell me to take it on
myself, I'm willing but it will take some time).
Ehud.
--
@@@@@@ @@@ @@@@@@ @ @ Ehud Karni Simon & Wiesel Insurance agency
@ @ @ @@ @ Tel: +972-3-6212-757 Fax: +972-3-6292-544
@ @ @ @ @ @@ (USA) Fax and voice mail: 1-815-5509341
@ @ @ @ @ @ Better Safe Than Sorry
http://www.simonwiesel.co.il mailto:ehud AT unix DOT simonwiesel DOT co DOT il
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -