This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v1.1][BZ #4772] Allow strptime read outputs from strftime.
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, libc-alpha at sourceware dot org
- Date: Wed, 4 Dec 2013 18:16:09 +0530
- Subject: Re: [PATCH v1.1][BZ #4772] Allow strptime read outputs from strftime.
- Authentication-results: sourceware.org; auth=none
- References: <20131016084143 dot GA7305 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1310161210280 dot 10873 at digraph dot polyomino dot org dot uk> <20131016153632 dot GA16052 at domone dot podge> <20131119111738 dot GC24544 at spoyarek dot pnq dot redhat dot com> <20131204113149 dot GB32756 at domone dot podge>
On Wed, Dec 04, 2013 at 12:31:49PM +0100, OndÅej BÃlka wrote:
> On Tue, Nov 19, 2013 at 04:47:38PM +0530, Siddhesh Poyarekar wrote:
> > On Wed, Oct 16, 2013 at 05:36:32PM +0200, OndÅej BÃlka wrote:
> > > Here is version with test.
> > >
> > >
> > > [BZ #4772]
> > > * time/strptime_l.c: Allow modifiers in strptime.
> >
> > You've corrected the ChangeLog entry in a follow-up email, so that is OK.
> >
> > > --- a/time/tst-strptime.c
> > > +++ b/time/tst-strptime.c
> > > @@ -41,6 +41,7 @@ static const struct
> > > { "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
> > > { "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
> > > { "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
> > > + { "C", "2001 21 Mon", "%2000Y %W %a", 1, 140, 4, 21 },
> >
> > This test is just for the field width, so please add another test for
> > strftime modifiers. The change itself looks OK to me.
> >
> > Siddhesh
> >
> I did not noticed this mail until mike told me. I added modifier test.
>
> [BZ #4772]
> * time/strptime_l.c: Allow modifiers in strptime.
> * time/tst-strptime.c: Add testcase.
>
Incorrect ChangeLog. It should be:
[BZ #4772]
* time/strptime_l.c (__strptime_internal): Allow modifiers
in strptime.
* time/tst-strptime.c (day_tests): Add testcase.
Otherwise OK.
Siddhesh
> diff --git a/time/strptime_l.c b/time/strptime_l.c
> index c2c2ee8..b9a8e14 100644
> --- a/time/strptime_l.c
> +++ b/time/strptime_l.c
> @@ -320,17 +320,14 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
> }
>
> ++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;
> - }
> + /* We 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. */
> diff --git a/time/tst-strptime.c b/time/tst-strptime.c
> index 193f7db..5c5fa7b 100644
> --- a/time/tst-strptime.c
> +++ b/time/tst-strptime.c
> @@ -41,6 +41,8 @@ static const struct
> { "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
> { "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
> { "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
> + { "C", "2001 21 Mon", "%2000Y %W %a", 1, 140, 4, 21 },
> + { "C", "2001 21 Mon", "%^Y %W %a", 1, 140, 4, 21 },
> { "C", "2001 EST 21 Mon", "%Y %Z %W %a", 1, 140, 4, 21 },
> { "C", "2012 00 Sun", "%Y %W %a", 0, 0, 0, 1 },
> { "ja_JP.EUC-JP", "2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p",