- 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)
}\r
else\r
{\r
- strcat(errFileName, DIRECTORY_DELIMITER ERROR_FILE_NAME);\r
+ strcat(errFileName, ERROR_FILE_NAME);\r
}\r
return errFileName;\r
}\r
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
\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
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
//\r
// MS_StripFilename\r
//\r
+// [RH] This now leaves the directory delimiter in place.\r
+//\r
//==========================================================================\r
\r
boolean MS_StripFilename(char *name)\r
{ // 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
\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
\r
// MACROS ------------------------------------------------------------------\r
\r
-#define ASCII_SLASH 47\r
-#define ASCII_BACKSLASH 92\r
-\r
// TYPES -------------------------------------------------------------------\r
\r
typedef enum\r
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
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
{\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
// 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
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
*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