Soft'N'Design Software
/
projects
/
calc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
efdfb54
)
correct issue when using %f with 0
author
Laurent Mazet
<mazet@softndesign.org>
Tue, 27 Dec 2022 21:37:07 +0000
(22:37 +0100)
committer
Laurent Mazet
<mazet@softndesign.org>
Tue, 27 Dec 2022 21:37:07 +0000
(22:37 +0100)
fdprintf.c
patch
|
blob
|
blame
|
history
diff --git
a/fdprintf.c
b/fdprintf.c
index 1bc1b1907a0de6f82d320a015d562131c39cb7ad..6c06e038de3c897ae20b77c5a7d01221ed26ce5d 100644
(file)
--- a/
fdprintf.c
+++ b/
fdprintf.c
@@
-64,7
+64,7
@@
int fdprintf (int fd, const char *fmt, ...)
*str++ = c;
} else {
int t = 0;
- char w = '0';
+
char w = '0';
int i, sz = 0;
void *p = NULL;
@@
-97,6
+97,10
@@
int fdprintf (int fd, const char *fmt, ...)
break;
case 'f': /* float */
f = va_arg (ap, double);
+ if (f == 0) {
+ *str++ = '0';
+ break;
+ }
if (f < 0) {
*str++ = '-';
f = -f;
@@
-110,7
+114,7
@@
int fdprintf (int fd, const char *fmt, ...)
f *= 10;
t--;
}
- f += 1e-7;
+
f += 1e-7;
if (f >= 10) {
f /= 10;
t++;