wpp: Stop parsing single and double quoted string constants after a first newline character.

Józef Kucia joseph.kucia at gmail.com
Wed Mar 14 17:02:03 CDT 2012


---
 dlls/d3dcompiler_43/tests/asm.c |    7 +++-
 libs/wpp/ppl.l                  |   91 ++++++++++++++++++++++++---------------
 2 files changed, 62 insertions(+), 36 deletions(-)

diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c
index 1e986df..c216abb 100644
--- a/dlls/d3dcompiler_43/tests/asm.c
+++ b/dlls/d3dcompiler_43/tests/asm.c
@@ -1643,7 +1643,12 @@ static void d3dpreprocess_test(void)
     messages = NULL;
     hr = D3DPreprocess(quotation_marks_test, strlen(quotation_marks_test), NULL,
             NULL, NULL, &shader, &messages);
-    todo_wine ok(hr == S_OK, "quotation marks test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
+    ok(hr == S_OK, "quotation marks test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF);
+    if (SUCCEEDED(hr))
+    {
+        const char *preprocessed_shader = ID3D10Blob_GetBufferPointer(shader);
+        ok(strstr(preprocessed_shader, "mov") != NULL, "Expected 'mov' instruction in preprocessed shader\n");
+    } else skip("Failed to preprocess shader\n");
     if (messages)
     {
         trace("D3DPreprocess messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l
index 8d979dc..e622c2b 100644
--- a/libs/wpp/ppl.l
+++ b/libs/wpp/ppl.l
@@ -261,6 +261,8 @@ static void add_string(const char *str, int len);
 static char *get_string(void);
 static void put_string(void);
 static int string_start(void);
+static int end_single_quoted_string(void);
+static int end_double_quoted_string(void);
 /* Macro functions */
 static void push_macro(pp_entry_t *ppp);
 static macexpstackentry_t *top_macro(void);
@@ -612,41 +614,9 @@ void pp_writestring(const char *format, ...)
 <INITIAL,pp_macexp>\"		pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs);
 <INITIAL,pp_macexp>\'		pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs);
 <pp_dqs>[^"\\\n]+		add_string(ppy_text, ppy_leng);
-<pp_dqs>\"			{
-		add_string(ppy_text, ppy_leng);
-		yy_pop_state();
-		switch(yy_current_state())
-		{
-		case pp_pp:
-		case pp_define:
-		case pp_mbody:
-		case pp_inc:
-		case RCINCL:
-			if (yy_current_state()==RCINCL) yy_pop_state();
-			ppy_lval.cptr = get_string();
-			return tDQSTRING;
-		case pp_line:
-			ppy_lval.cptr = get_string();
-			return tDQSTRING;
-		default:
-			put_string();
-		}
-	}
+<pp_dqs>\"			add_string(ppy_text, ppy_leng); if(end_double_quoted_string()) return tDQSTRING;
 <pp_sqs>[^'\\\n]+		add_string(ppy_text, ppy_leng);
-<pp_sqs>\'			{
-		add_string(ppy_text, ppy_leng);
-		yy_pop_state();
-		switch(yy_current_state())
-		{
-		case pp_if:
-		case pp_define:
-		case pp_mbody:
-			ppy_lval.cptr = get_string();
-			return tSQSTRING;
-		default:
-			put_string();
-		}
-	}
+<pp_sqs>\'			add_string(ppy_text, ppy_leng); if(end_single_quoted_string()) return tSQSTRING;
 <pp_iqs>[^\>\\\n]+		add_string(ppy_text, ppy_leng);
 <pp_iqs>\>			{
 		add_string(ppy_text, ppy_leng);
@@ -679,11 +649,23 @@ void pp_writestring(const char *format, ...)
 		}
 	}
 <pp_iqs,pp_dqs,pp_sqs>\\.	add_string(ppy_text, ppy_leng);
-<pp_iqs,pp_dqs,pp_sqs>\n	{
+<pp_iqs>\n		{
 		newline(1);
 		add_string(ppy_text, ppy_leng);
 		ppy_warning("Newline in string constant encountered (started line %d)", string_start());
 	}
+<pp_dqs>\n		{
+		newline(-1);
+		add_string(ppy_text, ppy_leng);
+		ppy_warning("Newline in double quoted string constant encountered (started line %d)", string_start());
+		if(end_double_quoted_string()) return tDQSTRING;
+	}
+<pp_sqs>\n		{
+		newline(-1);
+		add_string(ppy_text, ppy_leng);
+		ppy_warning("Newline in single quoted string constant encountered (started line %d)", string_start());
+		if(end_single_quoted_string()) return tSQSTRING;
+	}
 
 	/*
 	 * Identifier scanning
@@ -1285,6 +1267,45 @@ static int string_start(void)
 	return str_startline;
 }
 
+/* Returns 1 if single quoted string token should be returned */
+static int end_single_quoted_string(void)
+{
+	yy_pop_state();
+	switch(yy_current_state())
+	{
+	case pp_if:
+	case pp_define:
+	case pp_mbody:
+		ppy_lval.cptr = get_string();
+		return 1;
+	default:
+		put_string();
+	}
+	return 0;
+}
+
+/* Returns 1 if double quoted string token should be returned */
+static int end_double_quoted_string(void)
+{
+	yy_pop_state();
+	switch(yy_current_state())
+	{
+	case pp_pp:
+	case pp_define:
+	case pp_mbody:
+	case pp_inc:
+	case RCINCL:
+		if (yy_current_state()==RCINCL) yy_pop_state();
+		ppy_lval.cptr = get_string();
+		return 1;
+	case pp_line:
+		ppy_lval.cptr = get_string();
+		return 1;
+	default:
+		put_string();
+	}
+	return 0;
+}
 
 /*
  *-------------------------------------------------------------------------
-- 
1.7.8.5




More information about the wine-patches mailing list