mirror of
https://github.com/ZDoom/acc.git
synced 2024-11-14 08:31:05 +00:00
- Added CodeImp's changes for absolute ACC include paths.
SVN r1322 (trunk)
This commit is contained in:
parent
5fdc889b24
commit
c81e1149e8
3 changed files with 46 additions and 12 deletions
23
misc.c
23
misc.c
|
@ -369,3 +369,26 @@ void MS_Message(msg_t type, char *text, ...)
|
|||
va_end(argPtr);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// MS_IsPathAbsolute
|
||||
//
|
||||
// Pascal 30/11/08
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
boolean MS_IsPathAbsolute(char *name)
|
||||
{
|
||||
#ifdef WIN32
|
||||
// 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;
|
||||
#endif
|
||||
}
|
||||
|
|
1
misc.h
1
misc.h
|
@ -44,6 +44,7 @@ void MS_SuggestFileExt(char *base, char *extension);
|
|||
void MS_StripFileExt(char *name);
|
||||
boolean MS_StripFilename(char *path);
|
||||
void MS_Message(msg_t type, char *text, ...);
|
||||
boolean MS_IsPathAbsolute(char *name);
|
||||
|
||||
// PUBLIC DATA DECLARATIONS ------------------------------------------------
|
||||
|
||||
|
|
34
token.c
34
token.c
|
@ -117,7 +117,7 @@ static boolean IncLineNumber;
|
|||
static char *FileNames;
|
||||
static size_t FileNamesLen, FileNamesMax;
|
||||
|
||||
// Pascal 11/12/08
|
||||
// Pascal 12/11/08
|
||||
// Include paths. Lowest is searched first.
|
||||
// Include path 0 is always set to the directory of the file being parsed.
|
||||
static char IncludePaths[MAX_INCLUDE_PATHS][MAX_FILE_NAME_LENGTH];
|
||||
|
@ -308,7 +308,7 @@ static char *AddFileName(const char *name)
|
|||
// AddIncludePath
|
||||
// This adds an include path with less priority than the ones already added
|
||||
//
|
||||
// Pascal 11/12/08
|
||||
// Pascal 12/11/08
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
@ -335,7 +335,7 @@ void TK_AddIncludePath(char *sourcePath)
|
|||
// SetLocalIncludePath
|
||||
// This sets the first include path
|
||||
//
|
||||
// Pascal 11/12/08
|
||||
// Pascal 12/11/08
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
@ -382,16 +382,26 @@ void TK_Include(char *fileName)
|
|||
info->lastChar = Chr;
|
||||
info->imported = NO;
|
||||
|
||||
// Pascal 11/12/08
|
||||
// Find the file in the include paths
|
||||
for(i = 0; i < NumIncludePaths; i++)
|
||||
// Pascal 30/11/08
|
||||
// Handle absolute paths
|
||||
if(MS_IsPathAbsolute(fileName))
|
||||
{
|
||||
strcpy(sourceName, IncludePaths[i]);
|
||||
strcat(sourceName, fileName);
|
||||
if(MS_FileExists(sourceName))
|
||||
strcpy(sourceName, fileName);
|
||||
foundfile = MS_FileExists(sourceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pascal 12/11/08
|
||||
// Find the file in the include paths
|
||||
for(i = 0; i < NumIncludePaths; i++)
|
||||
{
|
||||
foundfile = TRUE;
|
||||
break;
|
||||
strcpy(sourceName, IncludePaths[i]);
|
||||
strcat(sourceName, fileName);
|
||||
if(MS_FileExists(sourceName))
|
||||
{
|
||||
foundfile = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +465,7 @@ static int PopNestedSource(enum ImportModes *prevMode)
|
|||
tk_Token = TK_NONE;
|
||||
AlreadyGot = FALSE;
|
||||
|
||||
// Pascal 11/12/08
|
||||
// Pascal 12/11/08
|
||||
// Set the first include path back to this file directory
|
||||
SetLocalIncludePath(tk_SourceName);
|
||||
|
||||
|
|
Loading…
Reference in a new issue