[PATCH 2/3] wpp: Explicitly pass include type to the lookup callback function.

Matteo Bruni mbruni at codeweavers.com
Wed Jun 13 11:04:21 CDT 2012


Also, always pass the parent name to the callback, d3dcompiler needs
that information.

This fixes bug 30885.
---
 dlls/d3dcompiler_43/compiler.c |    2 +-
 include/wine/wpp.h             |    8 ++++----
 libs/wpp/ppl.l                 |    2 +-
 libs/wpp/preproc.c             |   12 ++++++------
 libs/wpp/wpp_private.h         |    2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c
index 5159db8..27d6504 100644
--- a/dlls/d3dcompiler_43/compiler.c
+++ b/dlls/d3dcompiler_43/compiler.c
@@ -143,7 +143,7 @@ static void wpp_warning(const char *file, int line, int col, const char *near,
     wpp_write_message_var("\n");
 }
 
-static char *wpp_lookup_mem(const char *filename, const char *parent_name,
+static char *wpp_lookup_mem(const char *filename, int type, const char *parent_name,
                             char **include_path, int include_path_count)
 {
     /* Here we return always ok. We will maybe fail on the next wpp_open_mem */
diff --git a/include/wine/wpp.h b/include/wine/wpp.h
index 2d284f1..ac180be 100644
--- a/include/wine/wpp.h
+++ b/include/wine/wpp.h
@@ -29,12 +29,12 @@ struct wpp_callbacks
     /* I/O callbacks */
 
     /* Looks for a file to include, returning the path where it is found */
-    /* parent_name is the directory of the parent source file (for local
-     * includes), includepath is an array of additional include paths */
-    char *(*lookup)( const char *filename, const char *parent_name,
+    /* The type param is true for local (#include "filename.h") includes */
+    /* parent_name is the directory of the parent source file, includepath
+     * is an array of additional include paths */
+    char *(*lookup)( const char *filename, int type, const char *parent_name,
                      char **include_path, int include_path_count );
     /* Opens an include file */
-    /* The type param is true if it is a local ("...") include */
     void *(*open)( const char *filename, int type );
     /* Closes a previously opened file */
     void (*close)( void *file );
diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l
index 8d979dc..70bd213 100644
--- a/libs/wpp/ppl.l
+++ b/libs/wpp/ppl.l
@@ -1601,7 +1601,7 @@ void pp_do_include(char *fname, int type)
 	/* Undo the effect of the quotation */
 	fname[n-1] = '\0';
 
-	if((fp = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
+	if((fp = pp_open_include(fname+1, type, pp_status.input, &newpath)) == NULL)
 	{
 		ppy_error("Unable to open include file %s", fname+1);
 		return;
diff --git a/libs/wpp/preproc.c b/libs/wpp/preproc.c
index b9d8443..233d260 100644
--- a/libs/wpp/preproc.c
+++ b/libs/wpp/preproc.c
@@ -115,7 +115,7 @@ char *pp_xstrdup(const char *str)
 	return memcpy(s, str, len);
 }
 
-static char *wpp_default_lookup(const char *name, const char *parent_name,
+static char *wpp_default_lookup(const char *name, int type, const char *parent_name,
                                 char **include_path, int include_path_count)
 {
     char *cpy;
@@ -144,7 +144,7 @@ static char *wpp_default_lookup(const char *name, const char *parent_name,
     }
     *cptr = '\0';
 
-    if(parent_name)
+    if(type && parent_name)
     {
         /* Search directory of parent include and then -I path */
         const char *p;
@@ -507,17 +507,17 @@ int wpp_add_include_path(const char *path)
 
 char *wpp_find_include(const char *name, const char *parent_name)
 {
-    return wpp_default_lookup(name, parent_name, includepath, nincludepath);
+    return wpp_default_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
 }
 
-void *pp_open_include(const char *name, const char *parent_name, char **newpath)
+void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
 {
     char *path;
     void *fp;
 
-    if (!(path = wpp_callbacks->lookup(name, parent_name, includepath,
+    if (!(path = wpp_callbacks->lookup(name, type, parent_name, includepath,
                                        nincludepath))) return NULL;
-    fp = wpp_callbacks->open(path, !!parent_name);
+    fp = wpp_callbacks->open(path, type);
 
     if (fp)
     {
diff --git a/libs/wpp/wpp_private.h b/libs/wpp/wpp_private.h
index 288d709..4e2aa5b 100644
--- a/libs/wpp/wpp_private.h
+++ b/libs/wpp/wpp_private.h
@@ -207,7 +207,7 @@ void pp_pop_define_state(void);
 pp_entry_t *pp_add_define(const char *def, const char *text);
 pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
 void pp_del_define(const char *name);
-void *pp_open_include(const char *name, const char *parent_name, char **newpath);
+void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
 void pp_push_if(pp_if_state_t s);
 void pp_next_if_state(int);
 pp_if_state_t pp_pop_if(void);
-- 
1.7.3.4




More information about the wine-patches mailing list