This is the mail archive of the libc-hacker@sourceware.org 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] Handle %x, %X, %r, %c in strptime for certain locales


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


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