History

Better pragma once guard

This takes care of case-insensitive filenames (like on win32)

Vlad Vissoultchev committed 10 years ago

Commit b3782c31 parent 98ffeaa2 files · +9 −5Browse files

Unified · Split

2 files
  1. tcc.c +1 −1
  2. tccpp.c +8 −4
tcc.c+1−1
@@ -99,7 +99,7 @@ static void help(void) · 98 unmodified lines
9999 " -Usym undefine 'sym'\n"
100100 " -E preprocess only\n"
101101 " -P[1] no/alternative output of #line directives with -E\n"
102− " -dD -dM dump defines (only with -E)\n"
102+ " -d{D|M} dump defines (only with -E)\n"
103103 "Linker options:\n"
104104 " -Ldir add library path 'dir'\n"
105105 " -llib link with dynamic or static library 'lib'\n"
tccpp.c+8−4
@@ -1444,6 +1444,8 @@ static inline void add_cached_include(TCCState *s1, const char *filename, int if · 1443 unmodified lines
14441444 s1->cached_includes_hash[h] = s1->nb_cached_includes;
14451445 }
14461446
1447+#define ONCE_PREFIX "#ONCE#"
1448+
14471449 static void pragma_parse(TCCState *s1)
14481450 {
14491451 next_nomacro();
@@ -1475,10 +1477,12 @@ static void pragma_parse(TCCState *s1) · 25 unmodified lines
14751477 tcc_warning("unbalanced #pragma pop_macro");
14761478
14771479 } else if (tok == TOK_once) {
1478− char buf1[sizeof file->filename];
1479−
1480− pstrcpy(buf1, sizeof(buf1), "#once#");
1481− pstrcat(buf1, sizeof(buf1), file->filename);
1480+ char buf1[sizeof(file->filename) + sizeof(ONCE_PREFIX)];
1481+ strcpy(buf1, ONCE_PREFIX);
1482+ strcat(buf1, file->filename);
1483+#if PATHCMP==stricmp
1484+ strupr(buf1);
1485+#endif
14821486 add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);
14831487 } else if (s1->ppfp) {
14841488 /* tcc -E: keep pragmas below unchanged */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t