aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
diff options
context:
space:
mode:
authorVlad Vissoultchev <wqweto@gmail.com>2016-04-11 01:26:32 +0300
committerVlad Vissoultchev <wqweto@gmail.com>2016-04-13 11:18:40 +0300
commitb3782c3cf5e66f74207303c381a305daabccdb12 (patch)
tree419082ba4ae5a1c0ceb1d85ce4493d4dc52496e4 /tccpp.c
parent98ffeaa0c504dbc5c27c19b2b84ce4bc504b3527 (diff)
downloadtinycc-b3782c3cf5e66f74207303c381a305daabccdb12.tar.gz
tinycc-b3782c3cf5e66f74207303c381a305daabccdb12.tar.bz2
Better pragma once guard
This takes care of case-insensitive filenames (like on win32)
Diffstat (limited to 'tccpp.c')
-rw-r--r--tccpp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tccpp.c b/tccpp.c
index f499774..58eb5f6 100644
--- a/tccpp.c
+++ b/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;
}
+#define ONCE_PREFIX "#ONCE#"
+
static void pragma_parse(TCCState *s1)
{
next_nomacro();
@@ -1475,10 +1477,12 @@ static void pragma_parse(TCCState *s1)
tcc_warning("unbalanced #pragma pop_macro");
} else if (tok == TOK_once) {
- char buf1[sizeof file->filename];
-
- pstrcpy(buf1, sizeof(buf1), "#once#");
- pstrcat(buf1, sizeof(buf1), file->filename);
+ char buf1[sizeof(file->filename) + sizeof(ONCE_PREFIX)];
+ strcpy(buf1, ONCE_PREFIX);
+ strcat(buf1, file->filename);
+#if PATHCMP==stricmp
+ strupr(buf1);
+#endif
add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);
} else if (s1->ppfp) {
/* tcc -E: keep pragmas below unchanged */