[PATCH] update tzset tests

Keith Packard keithp@keithp.com
Wed May 18 20:56:57 GMT 2022


Dimitar Dimitrov <dimitar@dinux.eu> writes:

> On Tue, May 17, 2022 at 10:45:11AM +0200, jdoubleu wrote:
>> Sorry, here's the patch.
>
> Hi jdoubleu,
>
> I managed to test your change with https://sourceware.org/pipermail/newlib/2022/019710.html
>
> Only the following test case fails in tzset.c:
>      {"<+0123456789ABCDEF>3:33:33",               IN_SECONDS(3, 33, 33),   NO_TIME},                 // truncates the name (17 + 1)
> Failure message is:
>   Assertion failed! Expected 1647906533 to equal 1647893720. winter
> time, timezone = "<+0123456789ABCDEF>3:33:33"

Yeah, the code needs a fix to truncate the TZ name but then skip to the
'>' and keep going.

Something like this (line numbers likely wrong; this patch is from picolibc):

@@ -153,13 +55,8 @@
 
       /* quit if no items, too few or too many chars, or no close quote '>' */
       if (sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_std, &n) <= 0
-          || n < TZNAME_MIN || TZNAME_MAX < n)
+		|| n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n])
         return;
-      while (tzenv[n] != '>') {
-          if (!tzenv[n])
-              return;
-          n++;
-      }
 
       ++tzenv;	/* bump for close quote '>' */
     }
@@ -199,18 +96,13 @@
 
       /* quit if no items, too few or too many chars, or no close quote '>' */
       if (sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_dst, &n) <= 0
-          || n < TZNAME_MIN || TZNAME_MAX < n)
+		|| n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n])
 	{ /* No dst */
 	  _tzname[1] = _tzname[0];
 	  _timezone = tz->__tzrule[0].offset;
 	  _daylight = 0;
-          return;
+	  return;
 	}
-      while (tzenv[n] != '>') {
-          if (!tzenv[n])
-              return;
-          n++;
-      }
 
       ++tzenv;	/* bump for close quote '>' */
     }

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20220518/7c2abe30/attachment-0001.sig>


More information about the Newlib mailing list