public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] %Z [PATCH v6]
@ 2023-07-31 14:24 Stanley Lancaster
  2023-08-02 17:16 ` Adhemerval Zanella Netto
  2023-08-14 13:48 ` Carlos O'Donell
  0 siblings, 2 replies; 3+ messages in thread
From: Stanley Lancaster @ 2023-07-31 14:24 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stanley Lancaster

---
 time/strptime_l.c   | 19 ++++++++++++++-----
 time/tst-strptime.c |  2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/time/strptime_l.c b/time/strptime_l.c
index 85c3249fcc..1b84065c19 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -770,11 +770,20 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
 	  break;
 	case 'Z':
 	  /* Read timezone but perform no conversion.  */
-	  while (ISSPACE (*rp))
-	    rp++;
-	  while (!ISSPACE (*rp) && *rp != '\0')
-	    rp++;
-	  break;
+		{
+			while (ISSPACE (*rp))
+	    	rp++;
+			/* Read timezone but perform no conversion.  */
+			/* we recognize the format [-+a-zA-Z0-9]{3,} */
+			const char* start_rp = rp;
+
+			while ((*rp >= 'A' && *rp <= 'Z') || 
+				(*rp >= 'a' && *rp <= 'z') || 
+				(*rp >= '0' && *rp <= '9'))
+				rp++;
+			if (start_rp+3 < rp)
+				return NULL;
+		}
 	case 'z':
 	  /* We recognize four formats:
 	     1. Two digits specify hours.
diff --git a/time/tst-strptime.c b/time/tst-strptime.c
index 3dae9e0594..40145cb109 100644
--- a/time/tst-strptime.c
+++ b/time/tst-strptime.c
@@ -48,6 +48,8 @@ static const struct
     6, 0, 0, 1 },
   { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
     6, 0, 0, 1 },
+  { "en_US.ISO-8859-1", "2000-01-01 08:12:21 AM CST/", "%Y-%m-%d %I:%M:%S %p %Z/", 
+    6, 0, 0, 1},
   { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
   { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
   /* Most of the languages do not need the declension of the month names
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-14 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 14:24 [PATCH] %Z [PATCH v6] Stanley Lancaster
2023-08-02 17:16 ` Adhemerval Zanella Netto
2023-08-14 13:48 ` Carlos O'Donell

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).