summaryrefslogtreecommitdiff
path: root/lib/nstrftime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nstrftime.c')
-rw-r--r--lib/nstrftime.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 202381d4107..190ff4d8f20 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -651,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)
{
@@ -752,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;
@@ -1467,6 +1469,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:
@@ -1474,12 +1477,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;
}
}