diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-08-08 02:12:21 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-08-15 20:42:16 +0800 |
commit | 7cc9344fb32fdf6b1116235fe6fe8afbc91cdb19 (patch) | |
tree | 6e2a2f54886fbbaa49a0c047125831614383c6f8 | |
parent | a85c54c46c41c079d747eaa8465acb30c5100e5c (diff) | |
download | mupdf-7cc9344fb32fdf6b1116235fe6fe8afbc91cdb19.tar.xz |
Support printing flags in any order.
-rw-r--r-- | source/fitz/printf.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/source/fitz/printf.c b/source/fitz/printf.c index 55a7dfe1..3b0072f7 100644 --- a/source/fitz/printf.c +++ b/source/fitz/printf.c @@ -196,29 +196,29 @@ fz_format_string(fz_context *ctx, void *user, void (*emit)(fz_context *ctx, void { if (c == '%') { - c = *fmt++; - if (c == 0) - break; - - /* sign */ s = 0; - if (c == '+') { - s = 1; - c = *fmt++; - if (c == 0) - break; - } - - /* TODO: '-' to left justify */ - - /* leading zero */ - z = ' '; - if (c == '0') { - z = '0'; - c = *fmt++; - if (c == 0) + z = 0; + + /* flags */ + while ((c = *fmt++) != 0) + { + /* sign */ + if (c == '+') + s = 1; + /* space padding */ + else if (c == ' ') + z = ' '; + /* leading zero */ + else if (c == '0') + z = z != ' ' ? '0' : z; + /* TODO: '-' to left justify */ + else break; } + if (!z) + z = ' '; + if (c == 0) + break; /* width */ w = 0; |