summaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.c
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1995-05-07 07:00:18 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1995-05-07 07:00:18 +0000
commitd867cefdcb3c34803b4746663685336865e8ac97 (patch)
tree11454b982f22fe5b348c15f858154abc5cb4587f /usr.bin/printf/printf.c
parent6d3fd1b72c4f316b3688d467d2530a81db5f2cce (diff)
Notes
Diffstat (limited to 'usr.bin/printf/printf.c')
-rw-r--r--usr.bin/printf/printf.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 69f0c8ecd4bf..3136703467dd 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -132,7 +132,7 @@ main(argc, argv)
* up the format string.
*/
skip1 = "#-+ 0";
- skip2 = "*0123456789";
+ skip2 = "0123456789";
escape(fmt = format = *argv); /* backslash interpretation */
gargv = ++argv;
@@ -170,21 +170,28 @@ next: for (start = fmt;; ++fmt) {
if (*fmt == '*') {
if (getint(&fieldwidth))
return (1);
- } else
+ ++fmt;
+ } else {
fieldwidth = 0;
- /* skip to possible '.', get following precision */
- for (; strchr(skip2, *fmt); ++fmt);
- if (*fmt == '.')
+ /* skip to possible '.', get following precision */
+ for (; strchr(skip2, *fmt); ++fmt);
+ }
+ if (*fmt == '.') {
+ /* precision present? */
++fmt;
- if (*fmt == '*') {
- if (getint(&precision))
- return (1);
+ if (*fmt == '*') {
+ if (getint(&precision))
+ return (1);
+ ++fmt;
+ } else {
+ precision = 0;
+
+ /* skip to conversion char */
+ for (; strchr(skip2, *fmt); ++fmt);
+ }
} else
precision = 0;
-
- /* skip to conversion char */
- for (; strchr(skip2, *fmt); ++fmt);
if (!*fmt) {
warnx("missing format character", NULL, NULL);
return (1);
@@ -227,7 +234,7 @@ next: for (start = fmt;; ++fmt) {
break;
}
default:
- warnx("illegal format character", NULL, NULL);
+ warnx("illegal format character %c", convch, NULL);
return (1);
}
*fmt = nextch;