public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] TZ: Replace unreliable isupper calls on wchars
@ 2016-05-25 10:13 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2016-05-25 10:13 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=030d86d04dbd6ae878ff894256c5a465890d5970

commit 030d86d04dbd6ae878ff894256c5a465890d5970
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed May 25 12:13:03 2016 +0200

    TZ: Replace unreliable isupper calls on wchars
    
    In case the TZ variable is empty, Cygwin fetches timezone info from
    Windows.  Extracting the timezone short name uses isupper on wide chars.
    Replace with explicit check for A <= character <= Z to be independent
    of undefined behaviour.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/localtime.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc
index d57a020..2d10508 100644
--- a/winsup/cygwin/localtime.cc
+++ b/winsup/cygwin/localtime.cc
@@ -1543,7 +1543,8 @@ tzsetwall (void)
 	    GetTimeZoneInformation(&tz);
 	    dst = cp = buf;
 	    for (src = tz.StandardName; *src; src++)
-	      if (isupper(*src)) *dst++ = *src;
+	      if (*src >= L'A' && *src <= L'Z')
+		*dst++ = *src;
 	    if ((dst - cp) < 3)
 	      {
 		/* In non-english Windows, converted tz.StandardName
@@ -1561,7 +1562,8 @@ tzsetwall (void)
 		cp = strchr(cp, 0);
 		dst = cp;
 		for (src = tz.DaylightName; *src; src++)
-		  if (isupper(*src)) *dst++ = *src;
+		  if (*src >= L'A' && *src <= L'Z')
+		    *dst++ = *src;
 		if ((dst - cp) < 3)
 		  {
 		    /* In non-english Windows, converted tz.DaylightName


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-25 10:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25 10:13 [newlib-cygwin] TZ: Replace unreliable isupper calls on wchars Corinna Vinschen

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