Alexandre Julliard : wrc: Support only single directories with the -I option.

Alexandre Julliard julliard at winehq.org
Fri Nov 12 16:16:03 CST 2021


Module: wine
Branch: master
Commit: 4f0bb2e45fb14d19a5e3d9a10900e6b0036b844d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4f0bb2e45fb14d19a5e3d9a10900e6b0036b844d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Nov 12 11:39:31 2021 +0100

wrc: Support only single directories with the -I option.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/widl/widl.c      |  2 +-
 tools/widl/widl.man.in |  2 +-
 tools/wrc/wpp.c        | 57 ++++++++++++++------------------------------------
 tools/wrc/wrc.c        |  2 +-
 tools/wrc/wrc.man.in   |  7 +++----
 5 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 79c92e2f338..325a55fff8d 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -54,7 +54,7 @@ static const char usage[] =
 "   --help             Display this help and exit\n"
 "   -h                 Generate headers\n"
 "   -H file            Name of header file (default is infile.h)\n"
-"   -I path            Set include search dir to path (multiple -I allowed)\n"
+"   -I directory       Add directory to the include search path (multiple -I allowed)\n"
 "   --local-stubs=file Write empty stubs for call_as/local methods to file\n"
 "   -m32, -m64         Set the target architecture (Win32 or Win64)\n"
 "   -N                 Do not preprocess input\n"
diff --git a/tools/widl/widl.man.in b/tools/widl/widl.man.in
index 010b7f04e2d..234f512f962 100644
--- a/tools/widl/widl.man.in
+++ b/tools/widl/widl.man.in
@@ -102,7 +102,7 @@ names. The default output filename is \fBdlldata.c\fR.
 .PP
 .B Preprocessor options:
 .IP "\fB-I \fIpath\fR"
-Add a header search directory to path. Multiple search
+Add a directory to the include search path. Multiple include
 directories are allowed.
 .IP "\fB-D \fIid\fR[\fB=\fIval\fR]"
 Define preprocessor macro \fIid\fR with value \fIval\fR.
diff --git a/tools/wrc/wpp.c b/tools/wrc/wpp.c
index 18a7b015be0..d8d5052870a 100644
--- a/tools/wrc/wpp.c
+++ b/tools/wrc/wpp.c
@@ -54,9 +54,9 @@ struct define
 };
 
 static struct list cmdline_defines = LIST_INIT( cmdline_defines );
+static struct strarray includes;
 
-static char *wpp_lookup(const char *name, int type, const char *parent_name,
-                        char **include_path, int include_path_count)
+static char *wpp_lookup(const char *name, int type, const char *parent_name)
 {
     char *cpy;
     char *cptr;
@@ -96,9 +96,9 @@ static char *wpp_lookup(const char *name, int type, const char *parent_name,
         free( path );
     }
     /* Search -I path */
-    for(i = 0; i < include_path_count; i++)
+    for(i = 0; i < includes.count; i++)
     {
-        path = strmake("%s/%s", include_path[i], cpy);
+        path = strmake("%s/%s", includes.str[i], cpy);
         fd = open( path, O_RDONLY );
         if (fd != -1)
         {
@@ -294,51 +294,26 @@ pp_entry_t *pp_add_macro(char *id, char *args[], int nargs, mtext_t *exp)
  * Include management
  *-------------------------------------------------------------------------
  */
-#if defined(_WIN32) || defined(__MSDOS__)
-#define INCLUDESEPARATOR	";"
-#else
-#define INCLUDESEPARATOR	":"
-#endif
-
-static char **includepath;
-static int nincludepath = 0;
-
 void wpp_add_include_path(const char *path)
 {
-	char *tok;
-	char *cpy = xstrdup(path);
+	char *dir = xstrdup(path);
+	char *cptr;
 
-	tok = strtok(cpy, INCLUDESEPARATOR);
-	while(tok)
+	for(cptr = dir; *cptr; cptr++)
 	{
-		if(*tok) {
-			char *dir;
-			char *cptr;
-
-			dir = xstrdup(tok);
-			for(cptr = dir; *cptr; cptr++)
-			{
-				/* Convert to forward slash */
-				if(*cptr == '\\')
-					*cptr = '/';
-			}
-			/* Kill eventual trailing '/' */
-			if(*(cptr = dir + strlen(dir)-1) == '/')
-				*cptr = '\0';
-
-			/* Add to list */
-			includepath = xrealloc(includepath, (nincludepath+1) * sizeof(*includepath));
-			includepath[nincludepath] = dir;
-			nincludepath++;
-		}
-		tok = strtok(NULL, INCLUDESEPARATOR);
+		/* Convert to forward slash */
+		if(*cptr == '\\')
+			*cptr = '/';
 	}
-	free(cpy);
+	/* Kill eventual trailing '/' */
+	if(*(cptr = dir + strlen(dir)-1) == '/') *cptr = '\0';
+
+        strarray_add( &includes, dir );
 }
 
 char *wpp_find_include(const char *name, const char *parent_name)
 {
-    return wpp_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
+    return wpp_lookup(name, !!parent_name, parent_name);
 }
 
 void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
@@ -346,7 +321,7 @@ void *pp_open_include(const char *name, int type, const char *parent_name, char
     char *path;
     void *fp;
 
-    if (!(path = wpp_lookup(name, type, parent_name, includepath, nincludepath))) return NULL;
+    if (!(path = wpp_lookup(name, type, parent_name))) return NULL;
     fp = fopen(path, "rt");
 
     if (fp)
diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c
index 56cc2d6e83d..f848b30a0f8 100644
--- a/tools/wrc/wrc.c
+++ b/tools/wrc/wrc.c
@@ -51,7 +51,7 @@ static const char usage[] =
 	"   -fo FILE                   Synonym for -o for compatibility with windres\n"
 	"   -h, --help                 Prints this summary\n"
 	"   -i, --input=FILE           The name of the input file\n"
-	"   -I, --include-dir=PATH     Set include search dir to path (multiple -I allowed)\n"
+	"   -I, --include-dir=DIR      Add dir to the include search path (multiple -I allowed)\n"
 	"   -J, --input-format=FORMAT  The input format (either `rc' or `rc16')\n"
 	"   -l, --language=LANG        Set default language to LANG (default is neutral {0, 0})\n"
 	"   -m16                       Build a 16-bit resource file\n"
diff --git a/tools/wrc/wrc.man.in b/tools/wrc/wrc.man.in
index 99f555b6f12..807c66ad006 100644
--- a/tools/wrc/wrc.man.in
+++ b/tools/wrc/wrc.man.in
@@ -46,10 +46,9 @@ will use the first non-option argument as the input file name. If there
 are no non-option arguments, then \fBwrc\fR will read from standard input.
 .TP
 .I \fB\-I\fR, \fB\-\-include\-dir\fR=\fIpath\fR
-Add \fIpath\fR to include search directories. \fIpath\fR may contain
-multiple directories, separated with ':'. It is allowed to specify
-\fB\-I\fR multiple times. Include files are searched in the order in
-which the \fB\-I\fR options were specified.
+Add \fIpath\fR to the list of directories to search for includes. It
+is allowed to specify \fB\-I\fR multiple times. Include files are
+searched in the order in which the \fB\-I\fR options were specified.
 .br
 The search is compatible with gcc, in which '<>' quoted filenames are
 searched exclusively via the \fB\-I\fR set path, whereas the '""' quoted




More information about the wine-cvs mailing list