Update Musl Libc code

We now have implement all of Musl's localization code, the same way that
Musl implements localization. You may need setlocale(LC_ALL, "C.UTF-8"),
just in case anything stops working as expected.
This commit is contained in:
Justine Tunney 2024-07-30 09:14:57 -07:00
parent d0360bf4bd
commit bb815eafaf
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
116 changed files with 6525 additions and 5523 deletions

View file

@ -27,7 +27,7 @@
*/
#include "libc/errno.h"
#include "libc/stdio/stdio.h"
#include "libc/str/locale.h"
#include "libc/str/locale.internal.h"
#include "libc/str/str.h"
#include "libc/ctype.h"
#include "libc/thread/tls.h"
@ -37,7 +37,7 @@ static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_l
{
size_t l;
double x;
int left;
int fill, nogrp, negpar, nosym, left, intl;
int lp, rp, w, fw;
char *s0=s;
for (; n && *fmt; ) {
@ -50,17 +50,29 @@ static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_l
fmt++;
if (*fmt == '%') goto literal;
fill = ' ';
nogrp = 0;
negpar = 0;
nosym = 0;
left = 0;
for (; ; fmt++) {
switch (*fmt) {
case '=':
fill = *++fmt;
(void)fill;
continue;
case '^':
nogrp = 1;
(void)nogrp;
continue;
case '(':
negpar = 1;
(void)negpar;
case '+':
continue;
case '!':
nosym = 1;
(void)nosym;
continue;
case '-':
left = 1;
@ -78,6 +90,9 @@ static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_l
if (*fmt=='.') for (rp=0, fmt++; isdigit(*fmt); fmt++)
rp = 10*rp + (*fmt-'0');
intl = *fmt++ == 'i';
(void)intl;
w = lp + 1 + rp;
if (!left && fw>w) w = fw;
@ -112,7 +127,7 @@ ssize_t strfmon(char *restrict s, size_t n, const char *restrict fmt, ...)
ssize_t ret;
va_start(ap, fmt);
ret = vstrfmon_l(s, n, (locale_t)__get_tls()->tib_locale, fmt, ap);
ret = vstrfmon_l(s, n, CURRENT_LOCALE, fmt, ap);
va_end(ap);
return ret;