aboutsummaryrefslogtreecommitdiffstats
path: root/strftime.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-29 08:28:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-29 08:28:09 +0000
commit241902e7091a0ad514683488020011e827ad7750 (patch)
treeac760222c6b0c9c25a83bf2ae0537d7a0843d698 /strftime.c
parent60683816be0674fc3e0a07855f5c2de68c4db771 (diff)
downloadruby-241902e7091a0ad514683488020011e827ad7750.tar.gz
strftime.c: fix locale modifier
partially borrowed from ext/date. * strftime.c (rb_strftime_with_timespec): check conversion with locale modifier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/strftime.c b/strftime.c
index 767a852727..8d301e1115 100644
--- a/strftime.c
+++ b/strftime.c
@@ -187,7 +187,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
long y;
int precision, flags, colons;
char padding;
- enum {LEFT, CHCASE, LOWER, UPPER, LOCALE_O, LOCALE_E};
+ enum {LEFT, CHCASE, LOWER, UPPER};
#define BIT_OF(n) (1U<<(n))
#ifdef MAILHEADER_EXT
int sign;
@@ -222,7 +222,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
for (; *format && s < endp - 1; format++) {
#define FLAG_FOUND() do { \
- if (precision > 0 || flags & (BIT_OF(LOCALE_E)|BIT_OF(LOCALE_O))) \
+ if (precision > 0) \
goto unknown; \
} while (0)
#define NEEDS(n) do if (s >= endp || (n) >= endp - s - 1) goto err; while (0)
@@ -608,11 +608,13 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, rb_encodi
case 'E':
/* POSIX locale extensions, ignored for now */
- flags |= BIT_OF(LOCALE_E);
+ if (!format[1] || !strchr("cCxXyY", format[1]))
+ goto unknown;
goto again;
case 'O':
/* POSIX locale extensions, ignored for now */
- flags |= BIT_OF(LOCALE_O);
+ if (!format[1] || !strchr("deHkIlmMSuUVwWy", format[1]))
+ goto unknown;
goto again;
case 'V': /* week of year according ISO 8601 */