projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update release info for 0.9.0
[musl]
/
src
/
stdio
/
vfprintf.c
diff --git
a/src/stdio/vfprintf.c
b/src/stdio/vfprintf.c
index
f13fbe1
..
91c6b93
100644
(file)
--- a/
src/stdio/vfprintf.c
+++ b/
src/stdio/vfprintf.c
@@
-73,6
+73,8
@@
static const unsigned char states[]['z'-'A'+1] = {
}, { /* 1: l-prefixed */
S('d') = LONG, S('i') = LONG,
S('o') = ULONG, S('u') = ULONG, S('x') = ULONG, S('X') = ULONG,
}, { /* 1: l-prefixed */
S('d') = LONG, S('i') = LONG,
S('o') = ULONG, S('u') = ULONG, S('x') = ULONG, S('X') = ULONG,
+ S('e') = DBL, S('f') = DBL, S('g') = DBL, S('a') = DBL,
+ S('E') = DBL, S('F') = DBL, S('G') = DBL, S('A') = DBL,
S('c') = INT, S('s') = PTR, S('n') = PTR,
S('l') = LLPRE,
}, { /* 2: ll-prefixed */
S('c') = INT, S('s') = PTR, S('n') = PTR,
S('l') = LLPRE,
}, { /* 2: ll-prefixed */
@@
-552,7
+554,7
@@
static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
fl |= ALT_FORM;
case 'x': case 'X':
a = fmt_x(arg.i, z, t&32);
fl |= ALT_FORM;
case 'x': case 'X':
a = fmt_x(arg.i, z, t&32);
- if (
fl & ALT_FORM
) prefix+=(t>>4), pl=2;
+ if (
arg.i && (fl & ALT_FORM)
) prefix+=(t>>4), pl=2;
if (0) {
case 'o':
a = fmt_o(arg.i, z);
if (0) {
case 'o':
a = fmt_o(arg.i, z);
@@
-570,8
+572,11
@@
static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
case 'u':
a = fmt_u(arg.i, z);
}
case 'u':
a = fmt_u(arg.i, z);
}
- if (!arg.i && !p) continue;
if (p>=0) fl &= ~ZERO_PAD;
if (p>=0) fl &= ~ZERO_PAD;
+ if (!arg.i && !p) {
+ a=z;
+ break;
+ }
p = MAX(p, z-a + !arg.i);
break;
case 'c':
p = MAX(p, z-a + !arg.i);
break;
case 'c':
@@
-581,7
+586,7
@@
static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
case 'm':
if (1) a = strerror(errno); else
case 's':
case 'm':
if (1) a = strerror(errno); else
case 's':
- a = arg.p;
+ a = arg.p
? arg.p : "(null)"
;
z = memchr(a, 0, p);
if (!z) z=a+p;
else p=z-a;
z = memchr(a, 0, p);
if (!z) z=a+p;
else p=z-a;
@@
-647,8
+652,9
@@
int vfprintf(FILE *f, const char *fmt, va_list ap)
FLOCK(f);
if (!f->buf_size) {
saved_buf = f->buf;
FLOCK(f);
if (!f->buf_size) {
saved_buf = f->buf;
- f->buf = internal_buf;
+ f->
wpos = f->wbase = f->
buf = internal_buf;
f->buf_size = sizeof internal_buf;
f->buf_size = sizeof internal_buf;
+ f->wend = internal_buf + sizeof internal_buf;
}
ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
if (saved_buf) {
}
ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
if (saved_buf) {