mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
Simple-minded fix for bug #50847
bug #50847: #line directive corrupts #include search path Keep a second copy of the filename, that isn't changed by the #line directive, and use that on the initial search path for #include files.
This commit is contained in:
parent
7acf9aa862
commit
37999a4fbf
1
libtcc.c
1
libtcc.c
@ -581,6 +581,7 @@ ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen)
|
||||
bf->buf_end = bf->buffer + initlen;
|
||||
bf->buf_end[0] = CH_EOB; /* put eob symbol */
|
||||
pstrcpy(bf->filename, sizeof(bf->filename), filename);
|
||||
pstrcpy(bf->filename2, sizeof(bf->filename2), filename);
|
||||
#ifdef _WIN32
|
||||
normalize_slashes(bf->filename);
|
||||
#endif
|
||||
|
1
tcc.h
1
tcc.h
@ -546,6 +546,7 @@ typedef struct BufferedFile {
|
||||
int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
|
||||
int include_next_index; /* next search path */
|
||||
char filename[1024]; /* filename */
|
||||
char filename2[1024]; /* filename not modified by # line directive */
|
||||
unsigned char unget[4];
|
||||
unsigned char buffer[1]; /* extra size for CH_EOB char */
|
||||
} BufferedFile;
|
||||
|
3
tccpp.c
3
tccpp.c
@ -1792,7 +1792,8 @@ ST_FUNC void preprocess(int is_bof)
|
||||
/* search in file's dir if "header.h" */
|
||||
if (c != '\"')
|
||||
continue;
|
||||
path = file->filename;
|
||||
/* https://savannah.nongnu.org/bugs/index.php?50847 */
|
||||
path = file->filename2;
|
||||
pstrncpy(buf1, path, tcc_basename(path) - path);
|
||||
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user