- Version bumped ACC to 1.47.

- 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)
This commit is contained in:
Randy Heit 2008-12-18 02:24:55 +00:00
parent c81e1149e8
commit d6914c22ed
4 changed files with 55 additions and 29 deletions

View file

@ -364,7 +364,7 @@ static char *ErrorFileName(void)
}
else
{
strcat(errFileName, DIRECTORY_DELIMITER ERROR_FILE_NAME);
strcat(errFileName, ERROR_FILE_NAME);
}
return errFileName;
}

44
misc.c
View file

@ -279,8 +279,7 @@ void MS_SuggestFileExt(char *base, char *extension)
char *search;
search = base+strlen(base)-1;
while(*search != ASCII_SLASH && *search != ASCII_BACKSLASH
&& search != base)
while(!MS_IsDirectoryDelimiter(*search) && search != base)
{
if(*search-- == '.')
{
@ -290,6 +289,22 @@ void MS_SuggestFileExt(char *base, char *extension)
strcat(base, extension);
}
//==========================================================================
//
// MS_IsDirectoryDelimiter
//
//==========================================================================
boolean MS_IsDirectoryDelimiter(char foo)
{
#if defined(_WIN32) || defined(__MSDOS__)
return foo == '/' || foo == '\\' || foo == ':';
#else
return foo == '/';
#endif
}
//==========================================================================
//
// MS_StripFileExt
@ -301,8 +316,7 @@ void MS_StripFileExt(char *name)
char *search;
search = name+strlen(name)-1;
while(*search != ASCII_SLASH && *search != ASCII_BACKSLASH
&& search != name)
while(!MS_IsDirectoryDelimiter(*search) && search != name)
{
if(*search == '.')
{
@ -317,6 +331,8 @@ void MS_StripFileExt(char *name)
//
// MS_StripFilename
//
// [RH] This now leaves the directory delimiter in place.
//
//==========================================================================
boolean MS_StripFilename(char *name)
@ -330,8 +346,8 @@ boolean MS_StripFilename(char *name)
{ // No directory delimiter
return NO;
}
} while(*c != DIRECTORY_DELIMITER_CHAR);
*c = 0;
} while(!MS_IsDirectoryDelimiter(*c));
*(c+1) = 0;
return YES;
}
@ -380,15 +396,13 @@ void MS_Message(msg_t type, char *text, ...)
boolean MS_IsPathAbsolute(char *name)
{
#ifdef WIN32
// In windows, the second character must be : if it is an
#if defined(_WIN32) || defined(__MSDOS__)
// In Windows, the second character must be : if it is an
// absolute path (the first character indicates the drive)
if(name[0] != '\0')
return (name[1] == ':') ? TRUE : FALSE;
else
return FALSE;
#else
// In linux, the first character must be / for a root path
return (name[0] == '/') ? TRUE : FALSE;
// or the first character is either / or \ for absolute path
if((name[0] != '\0') && (name[1] == ':'))
return TRUE;
#endif
// In Unix-land, the first character must be / for a root path
return MS_IsDirectoryDelimiter(name[0]);
}

4
misc.h
View file

@ -15,9 +15,6 @@
// MACROS ------------------------------------------------------------------
#define ASCII_SLASH 47
#define ASCII_BACKSLASH 92
// TYPES -------------------------------------------------------------------
typedef enum
@ -45,6 +42,7 @@ void MS_StripFileExt(char *name);
boolean MS_StripFilename(char *path);
void MS_Message(msg_t type, char *text, ...);
boolean MS_IsPathAbsolute(char *name);
boolean MS_IsDirectoryDelimiter(char test);
// PUBLIC DATA DECLARATIONS ------------------------------------------------

34
token.c
View file

@ -320,10 +320,10 @@ void TK_AddIncludePath(char *sourcePath)
strcpy(IncludePaths[NumIncludePaths], sourcePath);
// Not ending with directory delimiter?
if(*(IncludePaths[NumIncludePaths] + strlen(IncludePaths[NumIncludePaths]) - 1) != DIRECTORY_DELIMITER_CHAR)
if(!MS_IsDirectoryDelimiter(*(IncludePaths[NumIncludePaths] + strlen(IncludePaths[NumIncludePaths]) - 1)))
{
// Add a directory delimiter to the include path
strcat(IncludePaths[NumIncludePaths], DIRECTORY_DELIMITER);
strcat(IncludePaths[NumIncludePaths], "/");
}
NumIncludePaths++;
}
@ -346,11 +346,6 @@ static void SetLocalIncludePath(char *sourceName)
{
IncludePaths[0][0] = 0;
}
else
{
// Add a directory delimiter to the include path
strcat(IncludePaths[0], DIRECTORY_DELIMITER);
}
}
@ -386,7 +381,24 @@ void TK_Include(char *fileName)
// Handle absolute paths
if(MS_IsPathAbsolute(fileName))
{
#if defined(_WIN32) || defined(__MSDOS__)
sourceName[0] = '\0';
if(MS_IsDirectoryDelimiter(fileName[0]))
{
// The source file is absolute for the drive, but does not
// specify a drive. Use the path for the current file to
// get the drive letter, if it has one.
if(IncludePaths[0][0] != '\0' && IncludePaths[0][1] == ':')
{
sourceName[0] = IncludePaths[0][0];
sourceName[1] = ':';
sourceName[2] = '\0';
}
}
strcat(sourceName, fileName);
#else
strcpy(sourceName, fileName);
#endif
foundfile = MS_FileExists(sourceName);
}
else
@ -410,7 +422,9 @@ void TK_Include(char *fileName)
ERR_ErrorAt(tk_SourceName, tk_Line);
ERR_Exit(ERR_CANT_FIND_INCLUDE, YES, fileName, tk_SourceName, tk_Line);
}
MS_Message(MSG_DEBUG, "*Include file found at %s\n", sourceName);
// Now change the first include path to the file directory
SetLocalIncludePath(sourceName);
@ -1018,8 +1032,8 @@ static void ProcessQuoteToken(void)
*text++ = Chr;
}
// escape the character after a backslash [JB]
if(Chr == ASCII_BACKSLASH)
escaped ^= (Chr == ASCII_BACKSLASH);
if(Chr == '\\')
escaped ^= (Chr == '\\');
else
escaped = FALSE;
NextChr();