Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Date: Thu, 1 Feb 2001 08:59:17 -0500
From: Christopher Faylor <cgf@redhat.com>
To: Cygnus <cygwin@cygwin.com>
Subject: Re: date +"%Z"
Message-ID: <20010201085917.F4545@redhat.com>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: Cygnus <cygwin@cygwin.com>
References: <3A78CE75.6B336DAA@Wanadoo.fr> <EJEMICJMAGCJAPFPGPLGOEDHCHAA.lothan@newsguy.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.3.11i
In-Reply-To: <EJEMICJMAGCJAPFPGPLGOEDHCHAA.lothan@newsguy.com>; from lothan@newsguy.com on Thu, Feb 01, 2001 at 02:01:03AM -0800

On Thu, Feb 01, 2001 at 02:01:03AM -0800, Lothan wrote:
>> From: cygwin-owner@sources.redhat.com
>> [mailto:cygwin-owner@sources.redhat.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);
>
>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;
>
>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.

Thank you very much for the detailed analysis.

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.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

