public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Martisko <jamartis@redhat.com>
To: libc-alpha@sourceware.org, Mike Frysinger <vapier@gentoo.org>
Subject: Re: [PATCH][BZ #15527] strftime_l.c: Support lowercase output
Date: Wed, 07 Dec 2016 10:18:00 -0000	[thread overview]
Message-ID: <5847E1D6.5040509@redhat.com> (raw)
In-Reply-To: <20161206232035.GH10558@vapier.lan>

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

Oh, my bad. That seems reasonable, sending new patch.
JM

On 7.12.2016 00:20, Mike Frysinger wrote:
> On 29 Jun 2016 09:55, Jakub Martisko wrote:
>> thanks for your comment. The reason why I sent the patch is that there 
>> is a bug/feature request for similar functionality in coreutils' "date" 
>> program and the maintainers of coreutils/gnulib do not want to diverge 
>> from the glibc interface. Even though the replacing you mentioned does 
>> indeed work, built-in version would be imo better (for example when 
>> using other shell than bash), especially when all of the needed 
>> functionality was already implemented.
> 
> i think his point is that bash has already defined a syntax, but you
> are doing it differently and there's (afaict) no need for it.  he isn't
> saying you should use bash if you want lower/upper case.
> 
> so instead of adding new syntax like "%#^x", add "%,x"
> -mike
> 

[-- Attachment #2: 0001-time-stfrtime_l.c-add-lowercase-support.patch --]
[-- Type: text/x-patch, Size: 2514 bytes --]

From 1289b48ee174bda5dc6266df1ed216f172fc5dd4 Mon Sep 17 00:00:00 2001
From: Jakub Martisko <jamartis@redhat.com>
Date: Wed, 7 Dec 2016 10:52:08 +0100
Subject: [PATCH] time/stfrtime_l.c: add lowercase support

* [BZ #15527]
* time/strftime_l.c (__strftime_internal): Implement conversion to
all lowercase.
* manual/time.texi: Document # and , flags.
* time/tst-strftime.c (do_test): Test case conversion.
---
 manual/time.texi    |  8 ++++++++
 time/strftime_l.c   |  4 +++-
 time/tst-strftime.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/manual/time.texi b/manual/time.texi
index f94cbe4..39ed062 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1352,6 +1352,14 @@ with spaces.
 @item ^
 The output uses uppercase characters, but only if this is possible
 (@pxref{Case Conversion}).
+
+@item #
+The output uses opposite case, but only if this is possible
+(@pxref{Case Conversion}).
+
+@item ,
+The output uses lowercase characters, but only if this is possible
+(@pxref{Case Conversion}).
 @end table
 
 The default action is to pad the number with zeros to keep it a constant
diff --git a/time/strftime_l.c b/time/strftime_l.c
index 1205035..6ed5f63 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -671,7 +671,9 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
 	    case L_('#'):
 	      change_case = 1;
 	      continue;
-
+      case L_(','):
+  	      to_lowcase = 1;
+  	      continue;
 	    default:
 	      break;
 	    }
diff --git a/time/tst-strftime.c b/time/tst-strftime.c
index af3ff72..258d40a 100644
--- a/time/tst-strftime.c
+++ b/time/tst-strftime.c
@@ -154,6 +154,36 @@ do_test (void)
 	}
     }
 
+	const struct
+	  {
+	    const char *fmt;
+	    const char *exp;
+	    size_t n;
+	  } ctests[] =
+	    {
+	      { "%^A", "SUNDAY", 6 },
+	      { "%,A", "sunday", 6 },
+	      { "%A", "Sunday", 6 },
+	    };
+#define nctests (sizeof (ctests) / sizeof (ctests[0]))
+	  for (cnt = 0; cnt < nctests; ++cnt)
+    {
+      char buf[100];
+      size_t r = strftime (buf, sizeof (buf), ctests[cnt].fmt, &ttm);
+      if (r != ctests[cnt].n)
+	{
+	  printf ("strftime(\"%s\") returned %zu not %zu\n",
+		  ctests[cnt].fmt, r, ctests[cnt].n);
+	  result = 1;
+	}
+      if (strcmp (buf, ctests[cnt].exp) != 0)
+	{
+	  printf ("strftime(\"%s\") produced \"%s\" not \"%s\"\n",
+		  ctests[cnt].fmt, buf, ctests[cnt].exp);
+	  result = 1;
+	}
+    }
+
   return result + do_bz18985 ();
 }
 
-- 
2.5.5


  reply	other threads:[~2016-12-07 10:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  8:54 Jakub Martisko
2016-06-15  9:09 ` Andreas Schwab
2016-06-29  7:55   ` Jakub Martisko
2016-12-06 23:20     ` Mike Frysinger
2016-12-07 10:18       ` Jakub Martisko [this message]
2016-12-07 15:39         ` Mike Frysinger
2016-12-09  1:14           ` Rafal Luzynski
2016-12-09  4:08             ` Mike Frysinger
2016-12-09 11:00               ` Rafal Luzynski
2016-12-09 16:20                 ` Mike Frysinger
2016-12-09 22:37                   ` Rafal Luzynski
2017-04-07 23:29                     ` Rafal Luzynski
2016-11-29 12:21 ` Jakub Martisko
2016-11-29 12:42   ` Jakub Martisko
2016-12-01 23:29     ` Rafal Luzynski
2016-12-05 14:55       ` Jakub Martisko
2016-12-06 22:47         ` Rafal Luzynski
2016-12-06 23:21 ` Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2016-05-12 15:26 [PATCH][BZ 15527] " Jakub Martisko

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=5847E1D6.5040509@redhat.com \
    --to=jamartis@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=vapier@gentoo.org \
    /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).