delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/02/01/12:12:10

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Thu, 1 Feb 2001 19:10:51 +0200
Message-Id: <200102011710.TAA12558@linux.>
From: "Ehud Karni" <ehud AT unix DOT simonwiesel DOT co DOT il>
To: cygwin AT cygwin DOT com
Subject: Re: date +%Z
In-reply-to: <20010201085917.F4545@redhat.com> (message from Christopher
Faylor on Thu, 1 Feb 2001 08:59:17 -0500)
Organization: Simon & Wiesel Insurance agency
Reply-to: ehud AT unix DOT simonwiesel DOT co DOT il
References: <3A78CE75 DOT 6B336DAA AT Wanadoo DOT fr> <EJEMICJMAGCJAPFPGPLGOEDHCHAA DOT lothan AT newsguy DOT com> <20010201085917 DOT F4545 AT redhat DOT com>
X-Mailer: Emacs 20.7.1 rmail (send-msg 1.104)
MIME-Version: 1.0

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 -


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