OSDN Git Service

- Added CodeImp's changes for absolute ACC include paths.
authorRandy Heit <rheit@zdoom.fake>
Wed, 17 Dec 2008 05:47:30 +0000 (05:47 +0000)
committerRandy Heit <rheit@zdoom.fake>
Wed, 17 Dec 2008 05:47:30 +0000 (05:47 +0000)
SVN r1322 (trunk)

misc.c
misc.h
token.c

diff --git a/misc.c b/misc.c
index 1b50db6..94b9b7e 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -369,3 +369,26 @@ void MS_Message(msg_t type, char *text, ...)
                va_end(argPtr);\r
        }\r
 }\r
+\r
+//==========================================================================\r
+//\r
+// MS_IsPathAbsolute\r
+//\r
+// Pascal 30/11/08\r
+//\r
+//==========================================================================\r
+\r
+boolean MS_IsPathAbsolute(char *name)\r
+{\r
+#ifdef WIN32\r
+       // In windows, the second character must be : if it is an\r
+       // absolute path (the first character indicates the drive)\r
+       if(name[0] != '\0')\r
+               return (name[1] == ':') ? TRUE : FALSE;\r
+       else\r
+               return FALSE;\r
+#else\r
+       // In linux, the first character must be / for a root path\r
+       return (name[0] == '/') ? TRUE : FALSE;\r
+#endif\r
+}\r
diff --git a/misc.h b/misc.h
index 3011f9a..9234db0 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -44,6 +44,7 @@ void MS_SuggestFileExt(char *base, char *extension);
 void MS_StripFileExt(char *name);\r
 boolean MS_StripFilename(char *path);\r
 void MS_Message(msg_t type, char *text, ...);\r
+boolean MS_IsPathAbsolute(char *name);\r
 \r
 // PUBLIC DATA DECLARATIONS ------------------------------------------------\r
 \r
diff --git a/token.c b/token.c
index cdc4d48..1c2ae41 100644 (file)
--- a/token.c
+++ b/token.c
@@ -117,7 +117,7 @@ static boolean IncLineNumber;
 static char *FileNames;\r
 static size_t FileNamesLen, FileNamesMax;\r
 \r
-// Pascal 11/12/08\r
+// Pascal 12/11/08\r
 // Include paths. Lowest is searched first.\r
 // Include path 0 is always set to the directory of the file being parsed.\r
 static char IncludePaths[MAX_INCLUDE_PATHS][MAX_FILE_NAME_LENGTH];\r
@@ -308,7 +308,7 @@ static char *AddFileName(const char *name)
 // AddIncludePath\r
 // This adds an include path with less priority than the ones already added\r
 // \r
-// Pascal 11/12/08\r
+// Pascal 12/11/08\r
 //\r
 //==========================================================================\r
 \r
@@ -335,7 +335,7 @@ void TK_AddIncludePath(char *sourcePath)
 // SetLocalIncludePath\r
 // This sets the first include path\r
 // \r
-// Pascal 11/12/08\r
+// Pascal 12/11/08\r
 //\r
 //==========================================================================\r
 \r
@@ -382,16 +382,26 @@ void TK_Include(char *fileName)
        info->lastChar = Chr;\r
        info->imported = NO;\r
        \r
-       // Pascal 11/12/08\r
-       // Find the file in the include paths\r
-       for(i = 0; i < NumIncludePaths; i++)\r
+       // Pascal 30/11/08\r
+       // Handle absolute paths\r
+       if(MS_IsPathAbsolute(fileName))\r
        {\r
-               strcpy(sourceName, IncludePaths[i]);\r
-               strcat(sourceName, fileName);\r
-               if(MS_FileExists(sourceName))\r
+               strcpy(sourceName, fileName);\r
+               foundfile = MS_FileExists(sourceName);\r
+       }\r
+       else\r
+       {\r
+               // Pascal 12/11/08\r
+               // Find the file in the include paths\r
+               for(i = 0; i < NumIncludePaths; i++)\r
                {\r
-                       foundfile = TRUE;\r
-                       break;\r
+                       strcpy(sourceName, IncludePaths[i]);\r
+                       strcat(sourceName, fileName);\r
+                       if(MS_FileExists(sourceName))\r
+                       {\r
+                               foundfile = TRUE;\r
+                               break;\r
+                       }\r
                }\r
        }\r
        \r
@@ -455,7 +465,7 @@ static int PopNestedSource(enum ImportModes *prevMode)
        tk_Token = TK_NONE;\r
        AlreadyGot = FALSE;\r
        \r
-       // Pascal 11/12/08\r
+       // Pascal 12/11/08\r
        // Set the first include path back to this file directory\r
        SetLocalIncludePath(tk_SourceName);\r
        \r