mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fixed code to support field width and precision
This commit is contained in:
parent
d9c9760aac
commit
b989978dd3
1 changed files with 15 additions and 13 deletions
|
@ -97,7 +97,7 @@ C_STRTOD (wchar_t const *nptr, wchar_t **endptr)
|
|||
|
||||
if (!saved_locale.empty())
|
||||
{
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
wsetlocale (LC_NUMERIC, L"C");
|
||||
}
|
||||
|
||||
r = STRTOD (nptr, endptr);
|
||||
|
@ -322,21 +322,24 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
length_modifier = L"L";
|
||||
length_modifier_len = 1;
|
||||
break;
|
||||
|
||||
case L's':
|
||||
length_modifier = L"l";
|
||||
length_modifier_len = 1;
|
||||
break;
|
||||
default:
|
||||
length_modifier = start; /* Any valid pointer will do. */
|
||||
length_modifier_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
p = static_cast<wchar_t*>(malloc (length + length_modifier_len + 2));
|
||||
q = static_cast<wchar_t*>(mempcpy (p, start, length));
|
||||
q = static_cast<wchar_t*>(mempcpy (q, length_modifier, length_modifier_len));
|
||||
p = new wchar_t[length + length_modifier_len + 2];
|
||||
q = static_cast<wchar_t*>(mempcpy (p, start, sizeof(wchar_t) * length));
|
||||
q = static_cast<wchar_t*>(mempcpy (q, length_modifier, sizeof(wchar_t) * length_modifier_len));
|
||||
*q++ = conversion;
|
||||
*q = L'\0';
|
||||
}
|
||||
|
||||
append_format(fmt, L"%%l%lc", conversion);
|
||||
|
||||
fmt = p;
|
||||
switch (conversion)
|
||||
{
|
||||
case L'd':
|
||||
|
@ -393,7 +396,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
case L'g':
|
||||
case L'G':
|
||||
{
|
||||
debug(0, "Field width %d, Precision %d", field_width, precision);
|
||||
|
||||
long double arg = vstrtold (argument);
|
||||
if (!have_field_width)
|
||||
|
@ -421,8 +423,6 @@ debug(0, "Field width %d, Precision %d", field_width, precision);
|
|||
break;
|
||||
|
||||
case L's':
|
||||
|
||||
debug(0, "Field width %d, Precision %d", field_width, precision);
|
||||
if (!have_field_width)
|
||||
{
|
||||
if (!have_precision){
|
||||
|
@ -529,16 +529,18 @@ debug(0, "Field width %d, Precision %d", field_width, precision);
|
|||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
field_width = 0;
|
||||
else{
|
||||
field_width = 0;
|
||||
}
|
||||
have_field_width = true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
while (iswdigit(*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == L'.')
|
||||
{
|
||||
++f;
|
||||
|
|
Loading…
Reference in a new issue