mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-10 06:50:10 +08:00
Better pragma once guard
This takes care of case-insensitive filenames (like on win32)
This commit is contained in:
parent
98ffeaa0c5
commit
b3782c3cf5
2
tcc.c
2
tcc.c
@ -99,7 +99,7 @@ static void help(void)
|
|||||||
" -Usym undefine 'sym'\n"
|
" -Usym undefine 'sym'\n"
|
||||||
" -E preprocess only\n"
|
" -E preprocess only\n"
|
||||||
" -P[1] no/alternative output of #line directives with -E\n"
|
" -P[1] no/alternative output of #line directives with -E\n"
|
||||||
" -dD -dM dump defines (only with -E)\n"
|
" -d{D|M} dump defines (only with -E)\n"
|
||||||
"Linker options:\n"
|
"Linker options:\n"
|
||||||
" -Ldir add library path 'dir'\n"
|
" -Ldir add library path 'dir'\n"
|
||||||
" -llib link with dynamic or static library 'lib'\n"
|
" -llib link with dynamic or static library 'lib'\n"
|
||||||
|
12
tccpp.c
12
tccpp.c
@ -1444,6 +1444,8 @@ static inline void add_cached_include(TCCState *s1, const char *filename, int if
|
|||||||
s1->cached_includes_hash[h] = s1->nb_cached_includes;
|
s1->cached_includes_hash[h] = s1->nb_cached_includes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ONCE_PREFIX "#ONCE#"
|
||||||
|
|
||||||
static void pragma_parse(TCCState *s1)
|
static void pragma_parse(TCCState *s1)
|
||||||
{
|
{
|
||||||
next_nomacro();
|
next_nomacro();
|
||||||
@ -1475,10 +1477,12 @@ static void pragma_parse(TCCState *s1)
|
|||||||
tcc_warning("unbalanced #pragma pop_macro");
|
tcc_warning("unbalanced #pragma pop_macro");
|
||||||
|
|
||||||
} else if (tok == TOK_once) {
|
} else if (tok == TOK_once) {
|
||||||
char buf1[sizeof file->filename];
|
char buf1[sizeof(file->filename) + sizeof(ONCE_PREFIX)];
|
||||||
|
strcpy(buf1, ONCE_PREFIX);
|
||||||
pstrcpy(buf1, sizeof(buf1), "#once#");
|
strcat(buf1, file->filename);
|
||||||
pstrcat(buf1, sizeof(buf1), file->filename);
|
#if PATHCMP==stricmp
|
||||||
|
strupr(buf1);
|
||||||
|
#endif
|
||||||
add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);
|
add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);
|
||||||
} else if (s1->ppfp) {
|
} else if (s1->ppfp) {
|
||||||
/* tcc -E: keep pragmas below unchanged */
|
/* tcc -E: keep pragmas below unchanged */
|
||||||
|
Loading…
Reference in New Issue
Block a user