mirror of
https://github.com/coreutils/coreutils.git
synced 2025-01-22 08:03:40 +08:00
(vstrtold): Renamed from vstrtod.
Now returns long double. All uses changed. (print_direc): Use "L" length modifier when printing floating point numbers, since we're now printing long double.
This commit is contained in:
parent
bae8432a9b
commit
830de27082
15
src/printf.c
15
src/printf.c
@ -185,7 +185,7 @@ FUNC_NAME (char const *s) \
|
||||
|
||||
STRTOX (intmax_t, vstrtoimax, (strtoimax (s, &end, 0)))
|
||||
STRTOX (uintmax_t, vstrtoumax, (strtoumax (s, &end, 0)))
|
||||
STRTOX (double, vstrtod, (c_strtod (s, &end)))
|
||||
STRTOX (long double, vstrtold, (c_strtold (s, &end)))
|
||||
|
||||
/* Output a single-character \ escape. */
|
||||
|
||||
@ -334,22 +334,31 @@ print_direc (const char *start, size_t length, char conversion,
|
||||
integer length modifier. */
|
||||
{
|
||||
char *q;
|
||||
char const *length_modifier;
|
||||
size_t length_modifier_len;
|
||||
|
||||
switch (conversion)
|
||||
{
|
||||
case 'd': case 'i': case 'o': case 'u': case 'x': case 'X':
|
||||
length_modifier = PRIdMAX;
|
||||
length_modifier_len = sizeof PRIdMAX - 2;
|
||||
break;
|
||||
|
||||
case 'a': case 'e': case 'f': case 'g':
|
||||
case 'A': case 'E': case 'F': case 'G':
|
||||
length_modifier = "L";
|
||||
length_modifier_len = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
length_modifier = start; /* Any valid pointer will do. */
|
||||
length_modifier_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
p = xmalloc (length + length_modifier_len + 2);
|
||||
q = mempcpy (p, start, length);
|
||||
q = mempcpy (q, PRIdMAX, length_modifier_len);
|
||||
q = mempcpy (q, length_modifier, length_modifier_len);
|
||||
*q++ = conversion;
|
||||
*q = '\0';
|
||||
}
|
||||
@ -409,7 +418,7 @@ print_direc (const char *start, size_t length, char conversion,
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
double arg = vstrtod (argument);
|
||||
long double arg = vstrtold (argument);
|
||||
if (!have_field_width)
|
||||
{
|
||||
if (!have_precision)
|
||||
|
Loading…
Reference in New Issue
Block a user