diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-05-02 11:32:21 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-05-02 11:32:21 -0700 |
commit | 9fd0afa69c6c088fb80c2e2611cc45301fdc99ef (patch) | |
tree | c1e94e9a05edc6ee2187dee2732d23a877ac7dac | |
parent | f25f2fa17a59182b34e5f68f725ef14b7c7f38a6 (diff) |
use a case-insensitive regex in strptime; fixes #2324
-rw-r--r-- | src/library.js | 2 | ||||
-rw-r--r-- | tests/core/test_strptime_tm.in | 31 | ||||
-rw-r--r-- | tests/core/test_strptime_tm.out | 19 |
3 files changed, 50 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js index c8c5a0ff..751cc6d0 100644 --- a/src/library.js +++ b/src/library.js @@ -5782,7 +5782,7 @@ LibraryManager.library = { pattern = pattern.replace(new RegExp('\\%'+pattern[i+1], 'g'), ''); } - var matches = new RegExp('^'+pattern).exec(Pointer_stringify(buf)) + var matches = new RegExp('^'+pattern, "i").exec(Pointer_stringify(buf)) // Module['print'](Pointer_stringify(buf)+ ' is matched by '+((new RegExp('^'+pattern)).source)+' into: '+JSON.stringify(matches)); function initDate() { diff --git a/tests/core/test_strptime_tm.in b/tests/core/test_strptime_tm.in index 93cdb1d5..2cccfa55 100644 --- a/tests/core/test_strptime_tm.in +++ b/tests/core/test_strptime_tm.in @@ -2,6 +2,15 @@ #include <stdio.h> #include <string.h> +void ReadMonth(const char *month) +{ + tm value = {0}; + if(strptime(month, "%b", &value)) + { + printf("%s: %d\n", month, value.tm_mon); + } +} + int main() { struct tm tm; char *ptr = strptime("17410105012000", "%H%M%S%d%m%Y", &tm); @@ -24,4 +33,26 @@ int main() { : "ERR")))))), tm.tm_mon + 1, tm.tm_mday, tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec); + + printf("\n"); + + ReadMonth("jan"); + ReadMonth("january"); + ReadMonth("feb"); + ReadMonth("february"); + ReadMonth("march"); + ReadMonth("mar"); + ReadMonth("april"); + ReadMonth("may"); + ReadMonth("may"); + ReadMonth("june"); + ReadMonth("jul"); + ReadMonth("august"); + ReadMonth("september"); + ReadMonth("oct"); + ReadMonth("nov"); + ReadMonth("november"); + ReadMonth("december"); + + return 0; } diff --git a/tests/core/test_strptime_tm.out b/tests/core/test_strptime_tm.out index 32c321f7..c241cbdd 100644 --- a/tests/core/test_strptime_tm.out +++ b/tests/core/test_strptime_tm.out @@ -1 +1,18 @@ -OK: Wed, 1/5/2000 17:41:1
\ No newline at end of file +OK: Wed, 1/5/2000 17:41:1 +jan: 0 +january: 0 +feb: 1 +february: 1 +march: 2 +mar: 2 +april: 3 +may: 4 +may: 4 +june: 5 +jul: 6 +august: 7 +september: 8 +oct: 9 +nov: 10 +november: 10 +december: 11 |