Re: [PATCH] update tzset tests

jdoubleu <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On 5/18/2022 8:48 PM, Dimitar Dimitrov wrote:
> Only the following test case fails in tzset.c:
>      {"<+0123456789ABCDEF>3:33:33",               IN_SECONDS(3, 33, 33),   NO_TIME},

Oh, yes. You're right. This test *should* fail. I forgot to remove it 
from the "succeeding" tests.

> BTW, it took me a while to realize that your patch and the source code in
> newlib's GIT have different line endings 

That's unfortunate, I'm sorry. I'll watch out for it in the future.

On 5/18/2022 10:56 PM, Keith Packard wrote:
> Yeah, the code needs a fix to truncate the TZ name but then skip to the
> '>' and keep going.

I don't think it should. As we discussed earlier[1], it should fail in 
such cases.

I'm going fix my patch. Thanks for running the tests!


[1]: https://sourceware.org/pipermail/newlib/2022/019567.html


Cheers
---
🙎🏻‍♂️ jdoubleu
On 5/18/2022 10:56 PM, Keith Packard wrote:
> Dimitar Dimitrov <[email protected]> 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 '>' */
>       }
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.