diff options
author | Rob Landley <rob@landley.net> | 2015-01-11 10:16:38 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-01-11 10:16:38 -0600 |
commit | d0dead30a53c0353fd1c31aa5183fdcc2b30491b (patch) | |
tree | bf13cf40aa3215ce864e51d3368af3744eddde0c /toys/pending/printf.c | |
parent | caa6b014ba15dea377e5f65fcac57afaa932fa64 (diff) | |
download | toybox-d0dead30a53c0353fd1c31aa5183fdcc2b30491b.tar.gz |
One more bugfix for printf.c, with test suite entry. (Make %-3d etc work.)
Diffstat (limited to 'toys/pending/printf.c')
-rw-r--r-- | toys/pending/printf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/toys/pending/printf.c b/toys/pending/printf.c index 81fcd22a..c9afc9b2 100644 --- a/toys/pending/printf.c +++ b/toys/pending/printf.c @@ -4,6 +4,8 @@ * Copyright 2014 Kyungwan Han <asura321@gmail.com> * * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html + * + * todo: *m$ ala printf("%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec); USE_PRINTF(NEWTOY(printf, "<1", TOYFLAG_USR|TOYFLAG_BIN)) @@ -93,7 +95,7 @@ void printf_main(void) // Parse width.precision between % and type indicator. *to++ = '%'; - while (strchr("-+# '0", *f) && (to-toybuf)<10) *to = *f++; + while (strchr("-+# '0", *f) && (to-toybuf)<10) *to++ = *f++; for (i=0; i<2; i++) { if (eat(&f, '*')) { if (*arg) wp[i] = atolx(*arg++); @@ -118,10 +120,10 @@ void printf_main(void) else if (strchr("diouxX", c)) { long ll; - sprintf(to, "*.*ll%c", c); if (*aa == '\'' || *aa == '"') ll = aa[1]; else ll = strtoll(aa, &end, 0); + sprintf(to, "*.*ll%c", c); printf(toybuf, wp[0], wp[1], ll); } else if (strchr("feEgG", c)) { long double ld = strtold(aa, &end); |