1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

Remove symlink resolve from searchpath to maintain behaviour

This commit is contained in:
cosineblast 2024-01-17 00:07:07 -03:00
parent aa47b6c1c7
commit 346dd7df85
3 changed files with 27 additions and 9 deletions

View File

@ -45,6 +45,7 @@
#include "print.h"
#include "strbuf.h"
#include "xmalloc.h"
#include "pathutil.h"
/* cc65 */
#include "codegen.h"
@ -297,6 +298,7 @@ void OpenIncludeFile (const char* Name, InputType IT, StringPool *FilesToIgnore)
/* Open an include file and insert it into the tables. */
{
char* N;
char* M;
FILE* F;
IFile* IF;
AFile* AF;
@ -314,12 +316,23 @@ void OpenIncludeFile (const char* Name, InputType IT, StringPool *FilesToIgnore)
return;
}
if (SP_LookupStr(FilesToIgnore, N) != 0) {
/* This file should not be included. */
/* Resolve real path of file in case of a symlink */
M = FindAbsolutePath(N);
if (M == 0) {
PPError ("Cannot resolve absolute path of '%s'", N);
xfree (N);
return;
}
if (SP_LookupStr(FilesToIgnore, M) != 0) {
/* This file should not be included. */
xfree (M);
xfree (N);
return;
}
xfree (M);
/* Search the list of all input files for this file. If we don't find
** it, create a new IFile object.
*/

View File

@ -48,6 +48,7 @@
#include "abend.h"
#include "searchpath.h"
#include "incpath.h"
#include "pathutil.h"
/* cc65 */
#include "codegen.h"
@ -2972,10 +2973,16 @@ static void DoPragmaOnce (void)
/* Marks the current file as seen by #pragma once. */
{
const char * const Filename = GetCurrentFilename ();
char * const FullPath = SearchFile(UsrIncSearchPath, Filename);
char * const IncludePath = SearchFile(UsrIncSearchPath, Filename);
if (IncludePath == NULL) {
AbEnd ("Cannot find the full path for the file %s", Filename);
}
const char * const FullPath = FindAbsolutePath(IncludePath);
if (FullPath == NULL) {
PPError ("Failed to find the full path for the file %s", Filename);
AbEnd ("Failed to find the full path for the file %s", Filename);
}
SP_AddStr(PragmaOnceSeenFiles, FullPath);

View File

@ -57,7 +57,6 @@
#include "searchpath.h"
#include "strbuf.h"
#include "xmalloc.h"
#include "pathutil.h"
@ -379,11 +378,10 @@ char* SearchFile (const SearchPaths* P, const char* File)
SB_Terminate (&PathName);
/* Find real path of file, if it exists */
Name = FindAbsolutePath(SB_GetBuf(&PathName));
if (Name != 0) {
/* Check if this file exists */
if (access (SB_GetBuf (&PathName), 0) == 0) {
/* The file exists, we're done */
Name = xstrdup (SB_GetBuf (&PathName));
break;
}
}