diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-15 18:47:56 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-15 18:47:56 +0000 |
commit | a08b44ea30bc57997d89ccd3d0de1850f1e25aca (patch) | |
tree | 06593b1e22ace33081e27946d075abd6084e8d83 /lib | |
parent | 51855122864b0b75c627a56e79d3e2470bf8d1fd (diff) | |
download | coreutils-a08b44ea30bc57997d89ccd3d0de1850f1e25aca.tar.xz |
(my_strftime): Rewrite the previous change slightly,
to make it a bit faster and (I hope) clearer.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strftime.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/strftime.c b/lib/strftime.c index 0f338206e..94eb4ab0f 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -492,7 +492,7 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, int width = -1; bool to_lowcase = false; bool to_uppcase = false; - size_t colons = 0; + size_t colons; bool change_case = false; int format_char; @@ -643,19 +643,6 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, break; } - /* Parse the colons of %:::z *after* the optional field width, - not before, so we accept %9:z, not %:9z. */ - { - const CHAR_T *q; - for (q = f; *q == L_(':') && q - f < 3; q++) - ; /* empty */ - if (*q == L_('z')) - { - colons = q - f; - f = q; - } - } - /* Now do the specified format. */ format_char = *f; switch (format_char) @@ -1320,7 +1307,20 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, #endif break; + case L_(':'): + /* :, ::, and ::: are valid only just before 'z'. + :::: etc. are rejected later. */ + for (colons = 1; f[colons] == L_(':'); colons++) + continue; + if (f[colons] != L_('z')) + goto bad_format; + f += colons; + goto do_z_conversion; + case L_('z'): + colons = 0; + + do_z_conversion: if (tp->tm_isdst < 0) break; |