Preprocessing asm shaders

Józef Kucia joseph.kucia at gmail.com
Tue Mar 13 18:30:04 CDT 2012


On Tue, Mar 13, 2012 at 1:22 PM, Matteo Bruni wrote:
> That is bug http://bugs.winehq.org/show_bug.cgi?id=24614. My shot at
> it was http://www.winehq.org/pipermail/wine-patches/2011-February/098609.html.
> You can see that my approach was essentially what you are suggesting.
> Still, that's not a very nice thing to do probably (and indeed my
> patch wasn't accepted at the time ;). Rereading it now, I notice that
> the patch also contains some wpp cleanup which should have been in
> separate patches, but I don't think that it was the reason of the
> reject...
> Dan tried a slightly different solution a while later, but still no dice.
>

I'll do a better search before posting to the mailing list next time.
Actually I found this bug in irrEdit CooperCube.

> I'll think about it again as soon as I'll get some time. If you get
> any idea, I'd like to hear it (or, writing a good fix would be even
> better ...)

In the attachment is my fix. It won't harm widl nor wrc. However, I
found out that Wine's wrc isn't compatible with Microsoft Windows
Resource Compiler. In the second attachment there is an example of a
file, which RC.exe compiles without even issuing warning, and wrc
fails to compile it with "Unterminated string" error message. Anyway
wpp will preprocess this file correctly, which can be checked by
running wrc with -E option. If it's an issue, it should be fixed in
wrc parser.
-------------- next part --------------
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;
+}
 
 /*
  *-------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.rc
Type: application/octet-stream
Size: 45 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20120314/ed31be71/attachment.obj>


More information about the wine-devel mailing list