[Toybox] Stat %Z - What are valid values?

Rob Landley rob at landley.net
Tue Jan 24 15:47:46 PST 2017



On 01/21/2017 06:25 PM, Rich Felker wrote:
> On Sat, Jan 21, 2017 at 03:18:28PM -0600, Rob Landley wrote:
>>> Or if it's signed, that's -1346458162 which would be... sometime in the
>>> 1930's? hmmm... "./date -D %s -d -1346458162" is failing under glibc,
>>> and failing _differently_ under musl. (Wheee.)
>>>
>>> /me goes down tangent rathole debugging why.
>> ....
>>>
>>> (Answer: musl doesn't implement %s at all, and glibc doesn't allow the
>>> %s value it converts to be negative.)
>>
>> Query: does bionic strptime() handle %s, and if so does it handle
>> negative input values? (If not I suppose I can try to special case this
>> in toybox, but ew.)
>>
>> Also, Rich: any interest in adding this to musl?
> 
> strptime with %s? I suspect there are some nasty underspecified issues
> with how it interacts with timezones.

I thought unix time was always UTS and the timezone just affected how it
was displayed?

> All the standard specifiers work
> with broken-down (struct tm) time so timezone is irrelevant to how
> they operate.

I'm tempted to add support for it myself, but the problem is the format
could be "time=[%s]" and I'd have to parse context data. (I can just
strstr() but I'd have to make sure it wasn't %%s...)

> So the answer isn't no, but "it's complicated", and needs more
> research on how other implementations work,

I think it's just glibc so far?

> if they're consistent,
> pros and cons of different possible behaviors, etc.

It's not that big a deal for me to do it myself, I just thought I'd
raise the issue. If bionic and musl both add %s that supports negative
numbers, I'm happy to leave glibc as broken until they catch up. If they
don't, it makes sense to do it myself...

> Rich

Rob


More information about the Toybox mailing list