projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typo.
[pspp]
/
src
/
data-out.c
diff --git
a/src/data-out.c
b/src/data-out.c
index 5fce84f6c433b1075db40d5af774ec98eaedfca0..ae322bce59953ddc9ebbf69a6a1be4f813e8e8ce 100644
(file)
--- a/
src/data-out.c
+++ b/
src/data-out.c
@@
-1042,7
+1042,7
@@
try_F (char *dst, const struct fmt_spec *fp, double number)
/* There are no decimal places, so there's no way
that the value can be shortened. Either it fits
or it doesn't. */
/* There are no decimal places, so there's no way
that the value can be shortened. Either it fits
or it doesn't. */
- char buf[4
0
];
+ char buf[4
1
];
sprintf (buf, "%*.0f", fp->w, number);
if (strlen (buf) <= fp->w)
{
sprintf (buf, "%*.0f", fp->w, number);
if (strlen (buf) <= fp->w)
{
@@
-1116,6
+1116,7
@@
format_and_round (char *dst, double number, const struct fmt_spec *fp,
sprintf (buf, "%.*f", decimals, number);
sprintf (buf, "%.*f", decimals, number);
+ /* Omit integer part if it's 0. */
if (!memcmp (buf, "0.", 2))
memmove (buf, buf + 1, strlen (buf));
else if (!memcmp (buf, "-0.", 3))
if (!memcmp (buf, "0.", 2))
memmove (buf, buf + 1, strlen (buf));
else if (!memcmp (buf, "-0.", 3))
@@
-1215,6
+1216,10
@@
format_and_round (char *dst, double number, const struct fmt_spec *fp,
}
}
}
}
+ /* Omit `-' if value output is zero. */
+ if (buf[0] == '-' && buf[strspn (buf, "-.0")] == '\0')
+ memmove (buf, buf + 1, strlen (buf));
+
buf_copy_str_lpad (dst, fp->w, buf);
return 1;
}
buf_copy_str_lpad (dst, fp->w, buf);
return 1;
}