summaryrefslogtreecommitdiff
path: root/lib/printf
diff options
context:
space:
mode:
Diffstat (limited to 'lib/printf')
-rw-r--r--lib/printf/glue.c16
-rw-r--r--lib/printf/printflocal.h5
-rw-r--r--lib/printf/vfprintf.c30
3 files changed, 37 insertions, 14 deletions
diff --git a/lib/printf/glue.c b/lib/printf/glue.c
index 477fc0d384..389f503c33 100644
--- a/lib/printf/glue.c
+++ b/lib/printf/glue.c
@@ -210,10 +210,10 @@ void printfrr_ext_reg(const struct printfrr_ext *ext)
exts[i] = ext;
}
-ssize_t printfrr_extp(struct fbuf *buf, const char **fmtp, int prec,
+ssize_t printfrr_extp(struct fbuf *buf, struct printfrr_eargs *ea,
const void *ptr)
{
- const char *fmt = *fmtp;
+ const char *fmt = ea->fmt;
const struct printfrr_ext *ext;
size_t i;
@@ -227,16 +227,16 @@ ssize_t printfrr_extp(struct fbuf *buf, const char **fmtp, int prec,
continue;
if (strncmp(ext->match, fmt, strlen(ext->match)))
continue;
- *fmtp += strlen(ext->match);
- return ext->print_ptr(buf, fmtp, prec, ptr);
+ ea->fmt += strlen(ext->match);
+ return ext->print_ptr(buf, ea, ptr);
}
return -1;
}
-ssize_t printfrr_exti(struct fbuf *buf, const char **fmtp, int prec,
+ssize_t printfrr_exti(struct fbuf *buf, struct printfrr_eargs *ea,
uintmax_t num)
{
- const char *fmt = *fmtp;
+ const char *fmt = ea->fmt;
const struct printfrr_ext *ext;
size_t i;
@@ -250,8 +250,8 @@ ssize_t printfrr_exti(struct fbuf *buf, const char **fmtp, int prec,
continue;
if (strncmp(ext->match, fmt, strlen(ext->match)))
continue;
- *fmtp += strlen(ext->match);
- return ext->print_int(buf, fmtp, prec, num);
+ ea->fmt += strlen(ext->match);
+ return ext->print_int(buf, ea, num);
}
return -1;
}
diff --git a/lib/printf/printflocal.h b/lib/printf/printflocal.h
index df962fc043..bac80e801c 100644
--- a/lib/printf/printflocal.h
+++ b/lib/printf/printflocal.h
@@ -101,6 +101,7 @@ int _frr_find_warguments(const wchar_t *, va_list, union arg **) DSO_LOCAL;
#endif
/* returns number of bytes needed for full output, or -1 */
-ssize_t printfrr_extp(struct fbuf *, const char **, int, const void *)
+ssize_t printfrr_extp(struct fbuf *, struct printfrr_eargs *ea, const void *)
+ DSO_LOCAL;
+ssize_t printfrr_exti(struct fbuf *, struct printfrr_eargs *ea, uintmax_t)
DSO_LOCAL;
-ssize_t printfrr_exti(struct fbuf *, const char **, int, uintmax_t) DSO_LOCAL;
diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c
index 96675e3620..7fafa89aa7 100644
--- a/lib/printf/vfprintf.c
+++ b/lib/printf/vfprintf.c
@@ -456,14 +456,25 @@ reswitch: switch (ch) {
ulval = SARG();
if (printfrr_ext_char(fmt[0])) {
+ struct printfrr_eargs ea = {
+ .fmt = fmt,
+ .precision = prec,
+ .width = width,
+ .alt_repr = !!(flags & ALT),
+ .leftadj = !!(flags & LADJUST),
+ };
+
if (cb)
extstart = cb->pos;
- size = printfrr_exti(cb, &fmt, prec,
+ size = printfrr_exti(cb, &ea,
(flags & INTMAX_SIZE) ? ujval
: (uintmax_t)ulval);
- if (size >= 0)
+ if (size >= 0) {
+ fmt = ea.fmt;
+ width = ea.width;
goto ext_printed;
+ }
}
if (flags & INTMAX_SIZE) {
if ((intmax_t)ujval < 0) {
@@ -539,12 +550,23 @@ reswitch: switch (ch) {
*/
ptrval = GETARG(void *);
if (printfrr_ext_char(fmt[0])) {
+ struct printfrr_eargs ea = {
+ .fmt = fmt,
+ .precision = prec,
+ .width = width,
+ .alt_repr = !!(flags & ALT),
+ .leftadj = !!(flags & LADJUST),
+ };
+
if (cb)
extstart = cb->pos;
- size = printfrr_extp(cb, &fmt, prec, ptrval);
- if (size >= 0)
+ size = printfrr_extp(cb, &ea, ptrval);
+ if (size >= 0) {
+ fmt = ea.fmt;
+ width = ea.width;
goto ext_printed;
+ }
}
ujval = (uintmax_t)(uintptr_t)ptrval;
base = 16;