This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
fix for glibc strftime.c bug that causes display-time to hang emacs
- To: rms@gnu.org
- Subject: fix for glibc strftime.c bug that causes display-time to hang emacs
- From: Paul Eggert <eggert@twinsun.com>
- Date: Thu, 24 Sep 1998 13:44:35 -0700 (PDT)
- CC: drepper@gnu.org, libc-alpha@cygnus.com, Jan.Djarv@mbox200.swipnet.se
- References: <199809241751.LAA02366@wijiji.santafe.edu>
Date: Thu, 24 Sep 1998 11:51:44 -0600
From: Richard Stallman <rms@santafe.edu>
It looks like this bug calls for a fix in Emacs
and a fix in strftime.
I think that only strftime needs a fix, as described below.
Jan.Djarv, can you please try this fix? I don't have easy access to
your type of machine.
From: "Jan D." <Jan.Djarv@mbox200.swipnet.se>
Date: Mon, 21 Sep 1998 21:21:21 +0200 (MEST)
When display-time tries to format the time it uses "%-I:%M%p" which
in the default POSIX locale comes out as "8:24PM", but in my locale
it should be "8:24". The loop in Fformat_time_string calls
emacs_strftime which is defined as my_strftime (strftime.c:412).
Eventually it will try to decode %p. It ends up at the underlying_strftime:
label. This calls strftime for %p, and since my locale doesn't have an
am_pm defined, strftime returns 0. my_strftime takes that as an error
and returns 0.
Thanks for your diagnosis; that is the bug. my_strftime shouldn't
take it as an error; it should go on to the next part of the format.
Here is a patch. It needs to be applied to glibc, and then the
resulting strftime.c can be propagated to Emacs.
1998-09-24 Paul Eggert <eggert@twinsun.com>
* strftime.c (underlying_strftime):
Set the buffer to a nonzero value before calling
strftime, and check to see whether strftime has set the buffer to zero.
This lets us distinguish between an empty buffer and an error.
===================================================================
RCS file: RCS/strftime.c,v
retrieving revision 2.0.96.2
retrieving revision 2.0.96.3
diff -c -r2.0.96.2 -r2.0.96.3
*** strftime.c 1998/09/24 19:55:01 2.0.96.2
--- strftime.c 1998/09/24 20:39:19 2.0.96.3
***************
*** 741,748 ****
*u++ = modifier;
*u++ = format_char;
*u = '\0';
len = strftime (ubuf, sizeof ubuf, ufmt, tp);
! if (len == 0)
return 0;
cpy (len, ubuf);
}
--- 741,749 ----
*u++ = modifier;
*u++ = format_char;
*u = '\0';
+ ubuf[0] = '\1';
len = strftime (ubuf, sizeof ubuf, ufmt, tp);
! if (len == 0 && ubuf[0] != '\0')
return 0;
cpy (len, ubuf);
}