Jacek Caban : jscript: Fixed backslash handling in regular expressions.
Alexandre Julliard
julliard at winehq.org
Mon Oct 6 09:35:00 CDT 2008
Module: wine
Branch: master
Commit: 31b3071552b92fcd03988ee97764eb6249b80f57
URL: http://source.winehq.org/git/wine.git/?a=commit;h=31b3071552b92fcd03988ee97764eb6249b80f57
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Oct 2 16:23:15 2008 +0200
jscript: Fixed backslash handling in regular expressions.
---
dlls/jscript/lex.c | 6 ++++--
dlls/jscript/tests/regexp.js | 8 +++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c
index 4ad9fe5..93397a3 100644
--- a/dlls/jscript/lex.c
+++ b/dlls/jscript/lex.c
@@ -709,8 +709,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx)
TRACE("\n");
re = ctx->ptr;
- while(ctx->ptr < ctx->end && (*ctx->ptr != '/' || *(ctx->ptr-1) == '\\'))
- ctx->ptr++;
+ while(ctx->ptr < ctx->end && *ctx->ptr != '/') {
+ if(*ctx->ptr++ == '\\' && ctx->ptr < ctx->end)
+ ctx->ptr++;
+ }
if(ctx->ptr == ctx->end) {
WARN("unexpected end of file\n");
diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js
index a5be6ac..e797723 100644
--- a/dlls/jscript/tests/regexp.js
+++ b/dlls/jscript/tests/regexp.js
@@ -47,10 +47,16 @@ ok(m["1"] === "ab", "m[1] is not \"ab\"");
m = "aaabcabc".match(/a+b/g);
ok(typeof(m) === "object", "typeof m is not object");
-ok(m.length === 2, "m.length is not 1");
+ok(m.length === 2, "m.length is not 2");
ok(m["0"] === "aaab", "m[0] is not \"ab\"");
ok(m["1"] === "ab", "m[1] is not \"ab\"");
+m = "aaa\\\\cabc".match(/\\/g);
+ok(typeof(m) === "object", "typeof m is not object");
+ok(m.length === 2, "m.length is not 2");
+ok(m["0"] === "\\", "m[0] is not \"\\\"");
+ok(m["1"] === "\\", "m[1] is not \"\\\"");
+
m = "abcabc".match(new RegExp("ab"));
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
More information about the wine-cvs
mailing list