diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-10-11 22:59:22 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-10-11 22:59:22 +0000 |
commit | 284d56227c7a5f2ba693e290abc3740af4d52a8d (patch) | |
tree | 013317c45d8c3d2540e87177ba62abbcab83c3a1 /lib | |
parent | 74a4ba21f78e3843e7efa512c4a2e4a002230c1d (diff) | |
download | src-284d56227c7a5f2ba693e290abc3740af4d52a8d.tar.gz src-284d56227c7a5f2ba693e290abc3740af4d52a8d.zip |
"Left precision" and "right precision" are not flags, but separate parts
of the format string that appear after the field width.
Notes
Notes:
svn path=/head/; revision=104942
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdlib/strfmon.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c index d30f268356ca..b74baf0f9d5b 100644 --- a/lib/libc/stdlib/strfmon.c +++ b/lib/libc/stdlib/strfmon.c @@ -174,18 +174,6 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format, case '-': /* alignment (left) */ flags |= LEFT_JUSTIFY; continue; - case '#': /* left || right precision */ - case '.': - if (*fmt == '#') - ntmp = &left_prec; - else - ntmp = &right_prec; - - if (!isdigit((unsigned char)*++fmt)) - goto format_error; - GET_NUMBER(*ntmp); - fmt--; - continue; default: break; } @@ -201,7 +189,21 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format, if (dst + width >= s + maxsize) goto e2big_error; } - + + /* Left precision */ + if (*fmt == '#') { + if (!isdigit((unsigned char)*++fmt)) + goto format_error; + GET_NUMBER(left_prec); + } + + /* Right precision */ + if (*fmt == '.') { + if (!isdigit((unsigned char)*++fmt)) + goto format_error; + GET_NUMBER(right_prec); + } + /* Conversion Characters */ switch (*fmt++) { case 'i': /* use internaltion currency format */ |