wpp: add option to not ignore included C code, needed by widl

Dan Hipschman dsh at linux.ucla.edu
Wed Jun 27 20:58:09 CDT 2007


James Hawkins sent me a widl problem.  Here's an example of the problem:

    /* test.idl */
    #include "foo.h"
    [uuid(00000000-0000-0000-0000-000000000000)]
    interface IFoo
    {
      void foo(FOO f);
    }

    /* foo.h */
    typedef int FOO;

$ widl test.idl
test.idl:4: Error: syntax error

Actually, the problem is in wpp.  It ignores code in files ending in .c and .h
because it seems this is necessary for the resource files.  Anyway, this is not
the correct behavior for IDL.  This patch adds the option to switch on/off this
ignore behavior, and leaves it off in widl.  It fixes the above problem, and I
ran a diff on the generated headers used by wine, none of which are affected by
this change.

---
 include/wine/wpp.h     |    1 +
 libs/wpp/ppl.l         |    4 ++--
 libs/wpp/wpp.c         |    6 ++++++
 libs/wpp/wpp_private.h |    1 +
 tools/wrc/wrc.c        |    1 +
 5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/wine/wpp.h b/include/wine/wpp.h
index 10b71e0..557740e 100644
--- a/include/wine/wpp.h
+++ b/include/wine/wpp.h
@@ -30,6 +30,7 @@ extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug );
 extern void wpp_set_pedantic( int on );
 extern void wpp_add_include_path( const char *path );
 extern char *wpp_find_include( const char *name, const char *parent_name );
+extern void wpp_ignore_c_code( int yesno );
 extern int wpp_parse( const char *input, FILE *output );
 extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );
 
diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l
index 58fda7b..5757b99 100644
--- a/libs/wpp/ppl.l
+++ b/libs/wpp/ppl.l
@@ -559,7 +559,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
 			return tDQSTRING;
 		case pp_line:
 			ppy_lval.cptr = get_string();
-			if (is_c_h_include(ppy_lval.cptr, 1)) pass_data=0;
+			if (pp_status.ignore_c_code && is_c_h_include(ppy_lval.cptr, 1)) pass_data=0;
 			else pass_data=1;
 			return tDQSTRING;
 		default:
@@ -1466,7 +1466,7 @@ void pp_do_include(char *fname, int type)
 	pp_incl_state.seen_junk = 0;
 	pp_incl_state.state = 0;
 	pp_incl_state.ppp = NULL;
-	if (is_c_h_include(newpath, 0)) pass_data=0;
+	if (pp_status.ignore_c_code && is_c_h_include(newpath, 0)) pass_data=0;
 	else pass_data=1;
 
 	if(pp_status.debug)
diff --git a/libs/wpp/wpp.c b/libs/wpp/wpp.c
index 7b87c36..287c04b 100644
--- a/libs/wpp/wpp.c
+++ b/libs/wpp/wpp.c
@@ -138,6 +138,12 @@ void wpp_set_pedantic( int on )
 }
 
 
+void wpp_ignore_c_code( int yesno )
+{
+    pp_status.ignore_c_code = yesno;
+}
+
+
 /* the main preprocessor parsing loop */
 int wpp_parse( const char *input, FILE *output )
 {
diff --git a/libs/wpp/wpp_private.h b/libs/wpp/wpp_private.h
index ff0fae7..5556d3b 100644
--- a/libs/wpp/wpp_private.h
+++ b/libs/wpp/wpp_private.h
@@ -230,6 +230,7 @@ struct pp_status
     int char_number;    /* current char number in line */
     int pedantic;       /* pedantic option */
     int debug;          /* debug messages flag */
+    int ignore_c_code;  /* in #include .c and .h files, ignore non-pp lines  */
 };
 
 extern struct pp_status pp_status;
diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c
index e91661c..49fdaa9 100644
--- a/tools/wrc/wrc.c
+++ b/tools/wrc/wrc.c
@@ -452,6 +452,7 @@ int main(int argc,char *argv[])
 		 */
 
 		chat("Starting preprocess");
+		wpp_ignore_c_code(TRUE);
 
                 if (!preprocess_only)
                 {



More information about the wine-patches mailing list