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

enh enh at google.com
Tue Jan 24 16:03:47 PST 2017


On Tue, Jan 24, 2017 at 3:47 PM, Rob Landley <rob at landley.net> wrote:
>
>
> 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?

i have an open feature request for %s in bionic
(http://code.google.com/p/android/issues/detail?id=229155) and iirc
freebsd and netbsd both have it, but different (gmtime versus
localtime). openbsd didn't have it. ios matches freebsd. which meant
ios and glibc disagree, which is why that's on my big list of things
i'm not sure what to do about. glibc was probably there first, but ios
is probably more relevant.

i'd rather work on making the icu4c APIs available to apps anyway :-)

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



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.



More information about the Toybox mailing list