Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAA40n-UpO8k3S9OcqrxpKD-qgXjAGtz4Gqa=q8CHCsMaWc6RPw@mail.gmail.com>
Date: Wed, 28 Feb 2024 13:54:10 +0100
From: Jan Mercl <0xjnml@...il.com>
To: musl@...ts.openwall.com
Subject: strftime missing some format verbs

Hi list,

while testing SQLite 3.45.1 with a transpilled-to-Go version of musl
libc, date4.test (from the SQLite Tcl test suite) reports errors. The
reason is the lack of support for the %l, %k and %P format verbs. The
tests pass with this patch:

    --- ./musl-80e3b09823a1d718664bc13704f3f7c19038a19e/src/time/strftime.c
       2024-02-26 21:23:01.000000000 +0100
    +++ ./internal/overlay/musl/src/time/strftime.c        2024-02-28
13:28:36.239990577 +0100
    @@ -96,6 +96,8 @@
             case 'H':
                     val = tm->tm_hour;
                     goto number;
    +        case 'l':
    +                def_pad = '_';
             case 'I':
                     val = tm->tm_hour;
                     if (!val) val = 12;
    @@ -105,6 +107,10 @@
                     val = tm->tm_yday+1;
                     width = 3;
                     goto number;
    +        case 'k':
    +                val = tm->tm_hour;
    +                def_pad = '_';
    +                goto number;
             case 'm':
                     val = tm->tm_mon+1;
                     goto number;
    @@ -117,6 +123,14 @@
             case 'p':
                     item = tm->tm_hour >= 12 ? PM_STR : AM_STR;
                     goto nl_strcat;
    +        case 'P':
    +                item = tm->tm_hour >= 12 ? PM_STR : AM_STR;
    +                fmt = __nl_langinfo_l(item, loc);
    +                char *d = *s;
    +                for (*l = 0; *fmt; (*l)++) {
    +                        *d++ = tolower(*fmt++);
    +                }
    +                return *s;
             case 'r':
                     item = T_FMT_AMPM;
                     goto nl_strftime;

Those verbs seem to be not part of POSIX, so maybe musl does not
support them intentionally.

Regards,

-j

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.