public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Handle %x, %X, %r, %c in strptime for certain locales
Date: Fri, 20 Jul 2007 19:18:00 -0000	[thread overview]
Message-ID: <20070720192152.GD4603@sunsite.mff.cuni.cz> (raw)

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

                 reply	other threads:[~2007-07-20 19:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070720192152.GD4603@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).