public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Handle %x, %X, %r, %c in strptime for certain locales
@ 2007-07-20 19:18 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2007-07-20 19:18 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

This patch relies on the previous strptime patch I posted today.
While strptime (xxx, nl_langinfo (D_FMT), &tm) etc. may be invalid,
as the returned format string contains modifiers/width strftime
handles, but strptime does not, strptime (xxx, "%x", &tm) must
work, unless we declare all the locales using GNU extensions
in strftime format strings invalid.
This patch will ignore the modifiers and width only in the recursive calls,
so it means no user visible extensions to strptime.

2007-07-20  Jakub Jelinek  <jakub@redhat.com>

	[BZ #4772]
	* time/strptime_l.c (__strptime_internal): Silently ignore
	strftime modifiers and field width in recursive calls.
	
--- libc/time/strptime_l.c.jj	2007-07-20 16:55:44.000000000 +0200
+++ libc/time/strptime_l.c	2007-07-20 20:26:18.000000000 +0200
@@ -329,6 +329,18 @@ __strptime_internal (rp, fmt, tmp, state
 	}
 
       ++fmt;
+      if (statep != NULL)
+	{
+	  /* In recursive calls silently discard strftime modifiers.  */
+	  while (*fmt == '-' || *fmt == '_' || *fmt == '0'
+		 || *fmt == '^' || *fmt == '#')
+	    ++fmt;
+
+	  /* And field width.  */
+	  while (*fmt >= '0' && *fmt <= '9')
+	    ++fmt;
+	}
+
 #ifndef _NL_CURRENT
       /* We need this for handling the `E' modifier.  */
     start_over:

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-20 19:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-20 19:18 [PATCH] Handle %x, %X, %r, %c in strptime for certain locales Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).