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]

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


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).

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 08:25:50.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]