This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fix for glibc strftime.c bug that causes display-time to hang emacs


   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);
  	  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]