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())
|
if (!saved_locale.empty())
|
||||||
{
|
{
|
||||||
setlocale (LC_NUMERIC, "C");
|
wsetlocale (LC_NUMERIC, L"C");
|
||||||
}
|
}
|
||||||
|
|
||||||
r = STRTOD (nptr, endptr);
|
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 = L"L";
|
||||||
length_modifier_len = 1;
|
length_modifier_len = 1;
|
||||||
break;
|
break;
|
||||||
|
case L's':
|
||||||
|
length_modifier = L"l";
|
||||||
|
length_modifier_len = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
length_modifier = start; /* Any valid pointer will do. */
|
length_modifier = start; /* Any valid pointer will do. */
|
||||||
length_modifier_len = 0;
|
length_modifier_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = static_cast<wchar_t*>(malloc (length + length_modifier_len + 2));
|
p = new wchar_t[length + length_modifier_len + 2];
|
||||||
q = static_cast<wchar_t*>(mempcpy (p, start, length));
|
q = static_cast<wchar_t*>(mempcpy (p, start, sizeof(wchar_t) * length));
|
||||||
q = static_cast<wchar_t*>(mempcpy (q, length_modifier, length_modifier_len));
|
q = static_cast<wchar_t*>(mempcpy (q, length_modifier, sizeof(wchar_t) * length_modifier_len));
|
||||||
*q++ = conversion;
|
*q++ = conversion;
|
||||||
*q = L'\0';
|
*q = L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
append_format(fmt, L"%%l%lc", conversion);
|
fmt = p;
|
||||||
switch (conversion)
|
switch (conversion)
|
||||||
{
|
{
|
||||||
case L'd':
|
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':
|
||||||
case L'G':
|
case L'G':
|
||||||
{
|
{
|
||||||
debug(0, "Field width %d, Precision %d", field_width, precision);
|
|
||||||
|
|
||||||
long double arg = vstrtold (argument);
|
long double arg = vstrtold (argument);
|
||||||
if (!have_field_width)
|
if (!have_field_width)
|
||||||
|
@ -421,8 +423,6 @@ debug(0, "Field width %d, Precision %d", field_width, precision);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L's':
|
case L's':
|
||||||
|
|
||||||
debug(0, "Field width %d, Precision %d", field_width, precision);
|
|
||||||
if (!have_field_width)
|
if (!have_field_width)
|
||||||
{
|
{
|
||||||
if (!have_precision){
|
if (!have_precision){
|
||||||
|
@ -529,16 +529,18 @@ debug(0, "Field width %d, Precision %d", field_width, precision);
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
field_width = 0;
|
field_width = 0;
|
||||||
|
}
|
||||||
have_field_width = true;
|
have_field_width = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
while (iswdigit(*f))
|
while (iswdigit(*f))
|
||||||
{
|
{
|
||||||
++f;
|
++f;
|
||||||
++direc_length;
|
++direc_length;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (*f == L'.')
|
if (*f == L'.')
|
||||||
{
|
{
|
||||||
++f;
|
++f;
|
||||||
|
|
Loading…
Reference in a new issue