mirror of
https://github.com/fluencelabs/musl
synced 2025-04-24 23:02:14 +00:00
implement wcsftime padding specifier extensions
Commit 8a6bd7307da3fc4d08dd6a9277b611ccb4971354 added support for padding specifier extensions to strftime, but did not modify wcsftime. In the process, it added a parameter to __strftime_fmt_1 in strftime.c, but failed to update the prototype in wcsftime.c. This was found by compiling musl with LTO: src/time/wcsftime.c:7:13: warning: type of '__strftime_fmt_1' does \ not match original declaration [-Wlto-type-mismatch] Fix the prototype of __strftime_fmt_1 in wcsftime.c, and generate the 'pad' argument the same way as it is done in strftime.
This commit is contained in:
parent
119bc55ba6
commit
ea81529fb9
@ -4,7 +4,7 @@
|
|||||||
#include "locale_impl.h"
|
#include "locale_impl.h"
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
|
|
||||||
const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *tm, locale_t loc);
|
const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *tm, locale_t loc, int pad);
|
||||||
|
|
||||||
size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, const struct tm *restrict tm, locale_t loc)
|
size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, const struct tm *restrict tm, locale_t loc)
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, co
|
|||||||
wchar_t *p;
|
wchar_t *p;
|
||||||
const char *t_mb;
|
const char *t_mb;
|
||||||
const wchar_t *t;
|
const wchar_t *t;
|
||||||
int plus;
|
int pad, plus;
|
||||||
unsigned long width;
|
unsigned long width;
|
||||||
for (l=0; l<n; f++) {
|
for (l=0; l<n; f++) {
|
||||||
if (!*f) {
|
if (!*f) {
|
||||||
@ -26,6 +26,8 @@ size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, co
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
f++;
|
f++;
|
||||||
|
pad = 0;
|
||||||
|
if (*f == '-' || *f == '_' || *f == '0') pad = *f++;
|
||||||
if ((plus = (*f == '+'))) f++;
|
if ((plus = (*f == '+'))) f++;
|
||||||
width = wcstoul(f, &p, 10);
|
width = wcstoul(f, &p, 10);
|
||||||
if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
|
if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
|
||||||
@ -35,7 +37,7 @@ size_t __wcsftime_l(wchar_t *restrict s, size_t n, const wchar_t *restrict f, co
|
|||||||
}
|
}
|
||||||
f = p;
|
f = p;
|
||||||
if (*f == 'E' || *f == 'O') f++;
|
if (*f == 'E' || *f == 'O') f++;
|
||||||
t_mb = __strftime_fmt_1(&buf, &k, *f, tm, loc);
|
t_mb = __strftime_fmt_1(&buf, &k, *f, tm, loc, pad);
|
||||||
if (!t_mb) break;
|
if (!t_mb) break;
|
||||||
k = mbstowcs(wbuf, t_mb, sizeof wbuf / sizeof *wbuf);
|
k = mbstowcs(wbuf, t_mb, sizeof wbuf / sizeof *wbuf);
|
||||||
if (k == (size_t)-1) return 0;
|
if (k == (size_t)-1) return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user