diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-08-27 13:28:46 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-08-27 13:28:46 -0400 |
commit | 8a9b6497167626e768cab063e9d6c381523b3244 (patch) | |
tree | af5c07141461bd9bd2d580bb7a84b4234e1c916f /printf.c | |
parent | d548b86e120db7e1327eea957a698d4bb874a1fb (diff) | |
download | bfs-8a9b6497167626e768cab063e9d6c381523b3244.tar.xz |
printf: Save some lines in time specifier parsing
Diffstat (limited to 'printf.c')
-rw-r--r-- | printf.c | 40 |
1 files changed, 4 insertions, 36 deletions
@@ -706,45 +706,13 @@ struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline) directive->fn = bfs_printf_strftime; command->needs_stat = true; c = *++i; - switch (c) { - case '@': - case 'H': - case 'I': - case 'k': - case 'l': - case 'M': - case 'p': - case 'r': - case 'S': - case 'T': - case '+': - case 'X': - case 'Z': - case 'a': - case 'A': - case 'b': - case 'B': - case 'c': - case 'd': - case 'D': - case 'h': - case 'j': - case 'm': - case 'U': - case 'w': - case 'W': - case 'x': - case 'y': - case 'Y': - directive->c = c; - break; - - case '\0': + if (!c) { cfprintf(cerr, "%{er}error: '%s': Incomplete time specifier '%s%c'.%{rs}\n", format, directive->str, i[-1]); goto directive_error; - - default: + } else if (strchr("@HIklMprST+XZaAbBcdDhjmUwWxyY", c)) { + directive->c = c; + } else { cfprintf(cerr, "%{er}error: '%s': Unrecognized time specifier '%%%c%c'.%{rs}\n", format, i[-1], c); goto directive_error; |