[PATCH v3] vbscript: Treat \r as a newline separator.

Zebediah Figura z.figura12 at gmail.com
Sat Jun 16 19:05:30 CDT 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
Sorry about the delay; seems this one got lost somehow.

 dlls/vbscript/lex.c       |  6 ++++--
 dlls/vbscript/tests/run.c | 12 ++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index 98b4cbb..b0fac48 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -383,13 +383,14 @@ static int parse_hex_literal(parser_ctx_t *ctx, LONG *ret)
 
 static void skip_spaces(parser_ctx_t *ctx)
 {
-    while(*ctx->ptr == ' ' || *ctx->ptr == '\t' || *ctx->ptr == '\r')
+    while(*ctx->ptr == ' ' || *ctx->ptr == '\t')
         ctx->ptr++;
 }
 
 static int comment_line(parser_ctx_t *ctx)
 {
-    ctx->ptr = strchrW(ctx->ptr, '\n');
+    static const WCHAR newlineW[] = {'\n','\r',0};
+    ctx->ptr = strpbrkW(ctx->ptr, newlineW);
     if(ctx->ptr)
         ctx->ptr++;
     else
@@ -421,6 +422,7 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
 
     switch(c) {
     case '\n':
+    case '\r':
         ctx->ptr++;
         return tNL;
     case '\'':
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c
index 6b57540..191f5a7 100644
--- a/dlls/vbscript/tests/run.c
+++ b/dlls/vbscript/tests/run.c
@@ -2394,6 +2394,18 @@ static void run_tests(void)
     ok(FAILED(hres), "script didn't fail\n");
     todo_wine CHECK_CALLED(OnScriptError);
 
+    SET_EXPECT(global_success_d);
+    SET_EXPECT(global_success_i);
+    parse_script_a("' comment\r"
+                   "Sub testsub(arg)\r"
+                   "If arg = 1 Then\r\r"
+                   "Call reportSuccess()\n\n"
+                   "End If\r\n"
+                   "End Sub\n\r"
+                   "Call testsub(1)");
+    CHECK_CALLED(global_success_d);
+    CHECK_CALLED(global_success_i);
+
     run_from_res("lang.vbs");
     run_from_res("api.vbs");
     run_from_res("regexp.vbs");
-- 
2.7.4




More information about the wine-devel mailing list