This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix syslog(3) in non-C non-US locales


On Thu, Sep 25, 2003 at 12:40:24PM +0200, Jakub Jelinek wrote:
> Hi!
> 
> According to http://www.ietf.org/rfc/rfc3164.txt
> syslog is supposed to write to the pipe
> <pri>%h %e %T hostname
> in C locale.
> But glibc is writing %h %e %T time in current locale's format, which
> does not comply (and e.g. for CJK locales where some abmon names
> start with space it even confuses syslogd so much to print date twice).

Just noticed it eats unnecessary .plt slot.
Here is a better patch:

2003-09-25  Jakub Jelinek  <jakub@redhat.com>

	* misc/syslog.c: Include locale.h.
	(vsyslog): Add date always in C locale %h %e %T format.

--- libc/misc/syslog.c.jj	2003-07-15 11:04:37.000000000 -0400
+++ libc/misc/syslog.c	2003-09-25 09:07:29.000000000 -0400
@@ -48,6 +48,7 @@ static char sccsid[] = "@(#)syslog.c	8.4
 #include <stdlib.h>
 #include <bits/libc-lock.h>
 #include <signal.h>
+#include <locale.h>
 
 #if __STDC__
 #include <stdarg.h>
@@ -187,10 +188,11 @@ vsyslog(pri, fmt, ap)
 	    prioff = fprintf (f, "<%d>", pri);
 	    (void) time (&now);
 #ifdef USE_IN_LIBIO
-	    f->_IO_write_ptr += strftime (f->_IO_write_ptr,
-					  f->_IO_write_end - f->_IO_write_ptr,
-					  "%h %e %T ",
-					  __localtime_r (&now, &now_tm));
+	    f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr,
+					      f->_IO_write_end - f->_IO_write_ptr,
+					      "%h %e %T ",
+					      __localtime_r (&now, &now_tm),
+					      &_nl_C_locobj);
 #else
 	    f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp,
 				   "%h %e %T ", __localtime_r (&now, &now_tm));

	Jakub


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