Skip to content
Snippets Groups Projects
Commit d43fa74f authored by Isaac Hartung's avatar Isaac Hartung Committed by Morris Jette
Browse files

Fix end case in printing double value

parent 6d8436dc
No related branches found
No related tags found
No related merge requests found
...@@ -279,16 +279,25 @@ extern void print_fields_double(print_field_t *field, double value, int last) ...@@ -279,16 +279,25 @@ extern void print_fields_double(print_field_t *field, double value, int last)
else if (print_fields_parsable_print && fields_delimiter) else if (print_fields_parsable_print && fields_delimiter)
printf("%f%s", value, fields_delimiter); printf("%f%s", value, fields_delimiter);
else { else {
int length, width = abs_len; int length, width = abs_len;
char *tmp = xmalloc(width + 10); char *tmp = xmalloc(width + 10);
sprintf(tmp, "%*.*g", width, width, value); sprintf(tmp, "%*f", abs_len, value);
length = strlen(tmp); length = strlen(tmp);
if (length > width) if (length > width) {
width -= length - width; sprintf(tmp, "%*.*e", width, width, value);
if (field->len == abs_len) length = strlen(tmp);
printf("%*.*g ", width, width, value); if (length > width)
else width -= length - width;
printf("%-*.*g ", width, width, value); if (field->len == abs_len)
printf("%*.*e ", width, width, value);
else
printf("%-*.*e ", width, width, value);
} else {
if (field->len == abs_len)
printf("%*f ", width, value);
else
printf("%-*f ", width, value);
}
xfree(tmp); xfree(tmp);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment