X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ftime%2Fwcsftime.c;h=638e64f6b445772931bb63171082ebaaaccc861a;hb=ebd8ef50d5012733d86ed4a6834ca6d776b069ae;hp=7db76922adf3ac97f62c915ecd6366352a476e60;hpb=95b930ad2646bb733ca9330ab3b990570e7ff9c6;p=musl diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c index 7db76922..638e64f6 100644 --- a/src/time/wcsftime.c +++ b/src/time/wcsftime.c @@ -1,32 +1,71 @@ #include #include -#include +#include +#include "locale_impl.h" +#include "libc.h" -size_t wcsftime(wchar_t *wcs, size_t n, const wchar_t *f, const struct tm *tm) +const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *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) { - size_t k, n0=n; - char out[100], in[4]; - while (*f) { - if (!n) return 0; + size_t l, k; + char buf[100]; + wchar_t wbuf[100]; + wchar_t *p; + const char *t_mb; + const wchar_t *t; + int plus; + unsigned long width; + for (l=0; ltm_year >= 10000-1900) + s[l++] = '+'; + else if (tm->tm_year < -1900) + s[l++] = '-'; + else + width++; + for (; width > k && l < n; width--) + s[l++] = '0'; + } + if (k >= n-l) k = n-l; + wmemcpy(s+l, t, k); + l += k; } - if (!n) return 0; - *wcs++ = 0; - return n0-n; + if (n) { + if (l==n) l=n-1; + s[l] = 0; + } + return 0; } +size_t wcsftime(wchar_t *restrict wcs, size_t n, const wchar_t *restrict f, const struct tm *restrict tm) +{ + return __wcsftime_l(wcs, n, f, tm, CURRENT_LOCALE); +} +weak_alias(__wcsftime_l, wcsftime_l);