diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2022-03-05 11:23:01 -0800 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-03-05 11:23:38 -0800 |
| commit | 4306bb6246d4bdf02c2f8bcfa4e78ef6539ed0bf (patch) | |
| tree | 16b6e642a95d66e7f7291677b6d729b1d60b6967 /src | |
| parent | 8f31074cb4c9b023ef0aa47a0ce34c92745169b6 (diff) | |
| download | coreutils-4306bb6246d4bdf02c2f8bcfa4e78ef6539ed0bf.tar.gz coreutils-4306bb6246d4bdf02c2f8bcfa4e78ef6539ed0bf.zip | |
date: fix newly-introduced %%-N bug
* src/date.c (adjust_resolution): Don’t mishandle %%-N.
* tests/misc/date.pl (pct-pct): New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/date.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/date.c b/src/date.c index 163141adc..9a282e2f5 100644 --- a/src/date.c +++ b/src/date.c @@ -310,12 +310,17 @@ adjust_resolution (char const *format) char *copy = NULL; for (char const *f = format; *f; f++) - if (f[0] == '%' && f[1] == '-' && f[2] == 'N') + if (f[0] == '%') { - if (!copy) - copy = xstrdup (format); - copy[f + 1 - format] = '0' + res_width (gettime_res ()); - f += 2; + if (f[1] == '-' && f[2] == 'N') + { + if (!copy) + copy = xstrdup (format); + copy[f + 1 - format] = '0' + res_width (gettime_res ()); + f += 2; + } + else + f += f[1] == '%'; } return copy; |
