jscript: Fixed backslash handling in regular expressions.

This commit is contained in:
Jacek Caban 2008-10-02 16:23:15 +02:00 committed by Alexandre Julliard
parent 383de2d79a
commit 31b3071552
2 changed files with 11 additions and 3 deletions

View File

@ -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");

View File

@ -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");