On Wed, Dec 18, 2013 at 11:36 PM, Maurice Quennet <m...@web.de> wrote: > Hello dev@, >
Hello mjq@, > diff --git a/Makefile b/Makefile > index 2a72a1c..e93f570 100644 [...] > +void > +printfmt(void) > +{ > + int e; > + long l; > + double d; > + char c, f, *tmp; > + > + if (*end == '%') { > + putchar('%'); > + fmt = ++end; > + return; > + } > + > + if (*arg == NULL) > + eprintf("missing argument\n"); > + > + if (*end == 'b') { > + fmt = *arg; > + tmp = end; > + > + while (*fmt) { > + if (*fmt == '\\') { > + ++fmt; > + printesc(); > + continue; > + } > + putchar(*fmt); > + ++fmt; > + } > + > + fmt = end = tmp + 1; > + return; > + } > + > + for (; *end; ++end) { > + if (!isdigit(*end) && *end != '#' && *end != '.' && > + *end != '+' && *end != '-' && *end != ' ') > + break; > + } > + > + if (*end == '\0') > + eprintf("%s: invalid directive\n", fmt); > + > + f = *end; > + c = *++end; > + *end = '\0'; > + > + switch (f) { > + case 'c': > + printf(fmt, **arg++); > + break; > + case 's': > + printf(fmt, *arg++); > + break; > + case 'd': case 'i': case 'o': > + case 'u': case 'X': case 'x': > + e = errno; > + errno = 0; > + l = strtol(*arg, NULL, 0); > + if (errno) > + eprintf("%s: invalid value\n", *arg); > + printf(fmt, l); > + ++arg; > + errno = e; > + break; > + case 'a': case 'A': case 'e': case 'E': > + case 'f': case 'F': case 'g': case 'G': > + e = errno; > + errno = 0; > + d = strtod(*arg, NULL); > + if (errno) > + eprintf("%s: invalid value\n", *arg); > + printf(fmt, d); > + ++arg; > + errno = e; > + break; > + default: > + eprintf("%s: invalid directive\n", fmt); > + } > + > + *end = c; > + fmt = end; > +} > + I'm confused about what you're trying to accomplish here. How about you just copy the format part from the for loop up there and throw it into the standard library's printf? cheers! mar77i