[PATCH] combine strftime flags

Ondrej Oprala ooprala@redhat.com
Mon Mar 11 16:25:00 GMT 2013


this patch should fix weird strftime's behaviour
when using #^ for several format options.

Thanks,
Ondrej
-------------- next part --------------
>From 758b8a01129cc98bdfce28f84543f72479da1b15 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@redhat.com>
Date: Mon, 11 Mar 2013 17:08:09 +0100
Subject: [PATCH] strftime: correctly combine case flags

---
 time/strftime_l.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/time/strftime_l.c b/time/strftime_l.c
index cf7d1a7..c6bbc04 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);
-- 
1.7.11.7



More information about the Libc-alpha mailing list