OSDN Git Service

- Version bumped ACC to 1.47.
authorRandy Heit <rheit@zdoom.fake>
Thu, 18 Dec 2008 02:24:55 +0000 (02:24 +0000)
committerRandy Heit <rheit@zdoom.fake>
Thu, 18 Dec 2008 02:24:55 +0000 (02:24 +0000)
- Improved include file handling when with and without drive letters on Windows/MS-DOS machines.
- Fixed: ACC considered anything non-NeXT as using backslashes for directory delimiters.

SVN r1323 (trunk)

error.c
misc.c
misc.h
token.c

diff --git a/error.c b/error.c
index 64de2c5..31197bf 100644 (file)
--- a/error.c
+++ b/error.c
@@ -364,7 +364,7 @@ static char *ErrorFileName(void)
        }\r
        else\r
        {\r
-               strcat(errFileName, DIRECTORY_DELIMITER ERROR_FILE_NAME);\r
+               strcat(errFileName, ERROR_FILE_NAME);\r
        }\r
        return errFileName;\r
 }\r
diff --git a/misc.c b/misc.c
index 94b9b7e..db4f84e 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -279,8 +279,7 @@ void MS_SuggestFileExt(char *base, char *extension)
        char *search;\r
 \r
        search = base+strlen(base)-1;\r
-       while(*search != ASCII_SLASH && *search != ASCII_BACKSLASH\r
-               && search != base)\r
+       while(!MS_IsDirectoryDelimiter(*search) && search != base)\r
        {\r
                if(*search-- == '.')\r
                {\r
@@ -292,6 +291,22 @@ void MS_SuggestFileExt(char *base, char *extension)
 \r
 //==========================================================================\r
 //\r
+// MS_IsDirectoryDelimiter\r
+//\r
+//==========================================================================\r
+\r
+boolean MS_IsDirectoryDelimiter(char foo)\r
+{\r
+#if defined(_WIN32) || defined(__MSDOS__)\r
+       return foo == '/' || foo == '\\' || foo == ':';\r
+#else\r
+       return foo == '/';\r
+#endif\r
+}\r
+\r
+\r
+//==========================================================================\r
+//\r
 // MS_StripFileExt\r
 //\r
 //==========================================================================\r
@@ -301,8 +316,7 @@ void MS_StripFileExt(char *name)
        char *search;\r
 \r
        search = name+strlen(name)-1;\r
-       while(*search != ASCII_SLASH && *search != ASCII_BACKSLASH\r
-               && search != name)\r
+       while(!MS_IsDirectoryDelimiter(*search) && search != name)\r
        {\r
                if(*search == '.')\r
                {\r
@@ -317,6 +331,8 @@ void MS_StripFileExt(char *name)
 //\r
 // MS_StripFilename\r
 //\r
+// [RH] This now leaves the directory delimiter in place.\r
+//\r
 //==========================================================================\r
 \r
 boolean MS_StripFilename(char *name)\r
@@ -330,8 +346,8 @@ boolean MS_StripFilename(char *name)
                { // No directory delimiter\r
                        return NO;\r
                }\r
-       } while(*c != DIRECTORY_DELIMITER_CHAR);\r
-       *c = 0;\r
+       } while(!MS_IsDirectoryDelimiter(*c));\r
+       *(c+1) = 0;\r
        return YES;\r
 }\r
 \r
@@ -380,15 +396,13 @@ void MS_Message(msg_t type, char *text, ...)
 \r
 boolean MS_IsPathAbsolute(char *name)\r
 {\r
-#ifdef WIN32\r
-       // In windows, the second character must be : if it is an\r
+#if defined(_WIN32) || defined(__MSDOS__)\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
+       // or the first character is either / or \ for absolute path\r
+       if((name[0] != '\0') && (name[1] == ':'))\r
+               return TRUE;\r
 #endif\r
+       // In Unix-land, the first character must be / for a root path\r
+       return MS_IsDirectoryDelimiter(name[0]);\r
 }\r
diff --git a/misc.h b/misc.h
index 9234db0..4e57baf 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -15,9 +15,6 @@
 \r
 // MACROS ------------------------------------------------------------------\r
 \r
-#define ASCII_SLASH 47\r
-#define ASCII_BACKSLASH 92\r
-\r
 // TYPES -------------------------------------------------------------------\r
 \r
 typedef enum\r
@@ -45,6 +42,7 @@ void MS_StripFileExt(char *name);
 boolean MS_StripFilename(char *path);\r
 void MS_Message(msg_t type, char *text, ...);\r
 boolean MS_IsPathAbsolute(char *name);\r
+boolean MS_IsDirectoryDelimiter(char test);\r
 \r
 // PUBLIC DATA DECLARATIONS ------------------------------------------------\r
 \r
diff --git a/token.c b/token.c
index 1c2ae41..bc19cc9 100644 (file)
--- a/token.c
+++ b/token.c
@@ -320,10 +320,10 @@ void TK_AddIncludePath(char *sourcePath)
                strcpy(IncludePaths[NumIncludePaths], sourcePath);\r
                \r
                // Not ending with directory delimiter?\r
-               if(*(IncludePaths[NumIncludePaths] + strlen(IncludePaths[NumIncludePaths]) - 1) != DIRECTORY_DELIMITER_CHAR)\r
+               if(!MS_IsDirectoryDelimiter(*(IncludePaths[NumIncludePaths] + strlen(IncludePaths[NumIncludePaths]) - 1)))\r
                {\r
                        // Add a directory delimiter to the include path\r
-                       strcat(IncludePaths[NumIncludePaths], DIRECTORY_DELIMITER);\r
+                       strcat(IncludePaths[NumIncludePaths], "/");\r
                }\r
                NumIncludePaths++;\r
        }\r
@@ -346,11 +346,6 @@ static void SetLocalIncludePath(char *sourceName)
        {\r
                IncludePaths[0][0] = 0;\r
        }\r
-       else\r
-       {\r
-               // Add a directory delimiter to the include path\r
-               strcat(IncludePaths[0], DIRECTORY_DELIMITER);\r
-       }\r
 }\r
 \r
 \r
@@ -386,7 +381,24 @@ void TK_Include(char *fileName)
        // Handle absolute paths\r
        if(MS_IsPathAbsolute(fileName))\r
        {\r
+#if defined(_WIN32) || defined(__MSDOS__)\r
+               sourceName[0] = '\0';\r
+               if(MS_IsDirectoryDelimiter(fileName[0]))\r
+               {\r
+                       // The source file is absolute for the drive, but does not\r
+                       // specify a drive. Use the path for the current file to\r
+                       // get the drive letter, if it has one.\r
+                       if(IncludePaths[0][0] != '\0' && IncludePaths[0][1] == ':')\r
+                       {\r
+                               sourceName[0] = IncludePaths[0][0];\r
+                               sourceName[1] = ':';\r
+                               sourceName[2] = '\0';\r
+                       }\r
+               }\r
+               strcat(sourceName, fileName);\r
+#else\r
                strcpy(sourceName, fileName);\r
+#endif\r
                foundfile = MS_FileExists(sourceName);\r
        }\r
        else\r
@@ -410,7 +422,9 @@ void TK_Include(char *fileName)
                ERR_ErrorAt(tk_SourceName, tk_Line);\r
                ERR_Exit(ERR_CANT_FIND_INCLUDE, YES, fileName, tk_SourceName, tk_Line);\r
        }\r
-       \r
+\r
+       MS_Message(MSG_DEBUG, "*Include file found at %s\n", sourceName);\r
+\r
        // Now change the first include path to the file directory\r
        SetLocalIncludePath(sourceName);\r
        \r
@@ -1018,8 +1032,8 @@ static void ProcessQuoteToken(void)
                        *text++ = Chr;\r
                }\r
                // escape the character after a backslash [JB]\r
-               if(Chr == ASCII_BACKSLASH)\r
-                       escaped ^= (Chr == ASCII_BACKSLASH);\r
+               if(Chr == '\\')\r
+                       escaped ^= (Chr == '\\');\r
                else\r
                        escaped = FALSE;\r
                NextChr();\r