This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] strftime incorrectly combines flags
- From: Ondrej Oprala <ooprala at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 24 May 2013 16:25:09 +0200
- Subject: [PATCH] strftime incorrectly combines flags
Hi,
included is a patch for http://sourceware.org/bugzilla/show_bug.cgi?id=15527
Thanks,
Ondrej
>From 5f13e3e0dc8bb00ad24a3ae99c9fa9ff94b5ee90 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@redhat.com>
Date: Mon, 11 Mar 2013 17:08:09 +0100
Subject: [PATCH] Correctly upcase/downcase strftime flags
---
time/strftime_l.c | 24 ++++++++++++------------
time/test_time.c | 9 +++++++++
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/time/strftime_l.c b/time/strftime_l.c
index cf7d1a7..896ca32 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -753,10 +753,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
case L_('a'):
if (modifier != 0)
goto bad_format;
- if (change_case)
+ if (change_case && (to_uppcase ^ to_lowcase))
{
- to_uppcase = 1;
- to_lowcase = 0;
+ to_uppcase = !to_uppcase;
+ to_lowcase = !to_lowcase;
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
cpy (aw_len, a_wkday);
@@ -768,10 +768,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
case 'A':
if (modifier != 0)
goto bad_format;
- if (change_case)
+ if (change_case && (to_uppcase ^ to_lowcase))
{
- to_uppcase = 1;
- to_lowcase = 0;
+ to_uppcase = !to_uppcase;
+ to_lowcase = !to_lowcase;
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
cpy (STRLEN (f_wkday), f_wkday);
@@ -782,10 +782,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
case L_('b'):
case L_('h'):
- if (change_case)
+ if (change_case && (to_uppcase ^ to_lowcase))
{
- to_uppcase = 1;
- to_lowcase = 0;
+ to_uppcase = !to_uppcase;
+ to_lowcase = !to_lowcase;
}
if (modifier != 0)
goto bad_format;
@@ -799,10 +799,10 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
case L_('B'):
if (modifier != 0)
goto bad_format;
- if (change_case)
+ if (change_case && (to_uppcase ^ to_lowcase))
{
- to_uppcase = 1;
- to_lowcase = 0;
+ to_uppcase = !to_uppcase;
+ to_lowcase = !to_lowcase;
}
#if defined _NL_CURRENT || !HAVE_STRFTIME
cpy (STRLEN (f_month), f_month);
diff --git a/time/test_time.c b/time/test_time.c
index 5c38652..320a73c 100644
--- a/time/test_time.c
+++ b/time/test_time.c
@@ -109,6 +109,15 @@ main (int argc, char **argv)
curtime = mktime (loctime);
strftime (buffer, SIZE, "%D %T was %w the %jth.\n", loctime);
fputs (buffer, stdout);
+
+ strftime (buffer, SIZE, "Lower/upper-cased %a: %^#a %^a\n", loctime);
+ fputs (buffer, stdout);
+ strftime (buffer, SIZE, "Lower/upper-cased %A: %^#A %^A\n", loctime);
+ fputs (buffer, stdout);
+ strftime (buffer, SIZE, "Lower/upper-cased %b: %^#b %^b\n", loctime);
+ fputs (buffer, stdout);
+ strftime (buffer, SIZE, "Lower/upper-cased %B: %^#B %^B\n", loctime);
+ fputs (buffer, stdout);
}
return (lose ? EXIT_FAILURE : EXIT_SUCCESS);
--
1.7.11.7