diff options
Diffstat (limited to 'lib/nstrftime.c')
-rw-r--r-- | lib/nstrftime.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 19d7337e816..c1dd5542478 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -3,7 +3,7 @@ This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 3 of the + published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, @@ -22,7 +22,7 @@ # define HAVE_TZNAME 1 # include "../locale/localeinfo.h" #else -# include <config.h> +# include <libc-config.h> # if FPRINTFTIME # include "fprintftime.h" # else @@ -367,10 +367,7 @@ tm_diff (const struct tm *a, const struct tm *b) #define ISO_WEEK1_WDAY 4 /* Thursday */ #define YDAY_MINIMUM (-366) static int iso_week_days (int, int); -#if defined __GNUC__ || defined __clang__ -__inline__ -#endif -static int +static __inline int iso_week_days (int yday, int wday) { /* Add enough to the first operand of % to make it nonnegative. */ @@ -428,9 +425,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, 0, -1, &tzset_called extra_args LOCALE_ARG); } -#if defined _LIBC && ! FPRINTFTIME libc_hidden_def (my_strftime) -#endif /* Just like my_strftime, above, but with more parameters. UPCASE indicates that the result should be converted to upper case. @@ -656,6 +651,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #endif /* ! DO_MULTIBYTE */ + char const *percent = f; + /* Check for flags that can modify a format. */ while (1) { @@ -757,8 +754,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) while (0) case L_('%'): - if (modifier != 0) - goto bad_format; + if (f - 1 != percent) + goto bad_percent; add1 (*f); break; @@ -1161,7 +1158,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) case L_('q'): /* GNU extension. */ DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1); - break; case L_('R'): subfmt = L_("%H:%M"); @@ -1472,6 +1468,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) } case L_('\0'): /* GNU extension: % at end of format. */ + bad_percent: --f; FALLTHROUGH; default: @@ -1479,12 +1476,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) since this is most likely the right thing to do if a multibyte string has been misparsed. */ bad_format: - { - int flen; - for (flen = 1; f[1 - flen] != L_('%'); flen++) - continue; - cpy (flen, &f[1 - flen]); - } + cpy (f - percent + 1, percent); break; } } |