Sender: ml AT delorie DOT com Message-ID: <3471B576.50005682@cdata.tvnet.hu> Date: Tue, 18 Nov 1997 16:34:14 +0100 From: Molnar Laszlo MIME-Version: 1.0 To: DJGPP workers Subject: bug in strftime.c Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Hi Workers! It seems there is a little bug in strftime(): when the user specifies a format with space padding and the number which should be printed is 0, then he gets: " " instead of " 0". The patch below works for me. And an interesting thing: when this file with a little test program is compiled with -O3 the executable was 2500 bytes longer than when I compiled them with -O2. Maybe it would worth to optimize for space for some non time critical function like this? Laszlo ps: as I saw some new functionality was added to this function since alpha 971009, so the docs appears to be out of date. *** strftime.c~ Sun Nov 2 16:02:08 1997 --- strftime.c Mon Nov 17 22:50:12 1997 *************** *** 43,50 **** { static char buf[10]; ! char *p; ! for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) *p-- = n % 10 + '0'; if (pad) while (p > buf && digits-- > 0) --- 43,54 ---- { static char buf[10]; ! char *p = buf + sizeof(buf) - 2; ! do { *p-- = n % 10 + '0'; + n /= 10; + digits--; + } while (n > 0 && p > buf); + if (pad) while (p > buf && digits-- > 0)