Index | Thread | Search

From:
enh <enh@google.com>
Subject:
Re: strptime: %P
To:
"Todd C. Miller" <Todd.Miller@sudo.ws>
Cc:
OpenBSD Tech <tech@openbsd.org>
Date:
Wed, 27 Aug 2025 15:56:40 -0400

Download raw body.

Thread
On Tue, Aug 26, 2025 at 9:41 PM Todd C. Miller <Todd.Miller@sudo.ws> wrote:
>
> On Tue, 26 Aug 2025 16:32:59 -0400, enh wrote:
>
> > %P is a strftime() extension that's "%p but in lowercase". because of
> > this, there's code that expects to be able to use %p and %P
> > interchangeably in strptime() format strings. Android has thus carried
> > this patch for years. (despite me forgetting to send it upstream;
> > sorry!)
>
> I'm unsure about this one since we don't support %P in our strftime().
> Perhaps it would help ports?

yeah, i have a bunch of patches in bionic's strftime.c but -- unlike
strptime.c which was obviously the openbsd one -- i don't even know
where the strftime.c came from. the closest to a clue in the initial
commit is:

static const char      sccsid[] = "@(#)strftime.c      5.4 (Berkeley) 3/14/89";

anyway, fwiw, it looks like %P comes from glibc -- which is presumably
why we ended up with it! -- but musl didn't include it, and none of
freebsd/netbsd/openbsd do (and so macos/ios don't either, because they
use the freebsd code).

the other obvious addition that bionic has seems to only be in glibc
and freebsd --- the -/_/0 modifiers. (oh, looks like netbsd took those
from freebsd in 2019 with 7a6dbc347cf9e8f508abf1c30a9dca99c7f33887.)

looking at the history of the likely candidates of bionic's strftime.c
(tzcode itself, or freebsd/netbsd/openbsd) i still have no idea where
it came from --- the "getformat()" function that implements the -/_/0
modifiers doesn't exist in any of the others (the freebsd
implementation of the same functionality being completely different).

>  - todd