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
99 " -Usym undefine 'sym'\n"99 " -Usym undefine 'sym'\n"
100 " -E preprocess only\n"100 " -E preprocess only\n"
101 " -P[1] no/alternative output of #line directives with -E\n"101 " -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"
103 "Linker options:\n"103 "Linker options:\n"
104 " -Ldir add library path 'dir'\n"104 " -Ldir add library path 'dir'\n"
105 " -llib link with dynamic or static library 'lib'\n"105 " -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
1444 s1->cached_includes_hash[h] = s1->nb_cached_includes;1444 s1->cached_includes_hash[h] = s1->nb_cached_includes;
1445}1445}
1446 1446
1447#define ONCE_PREFIX "#ONCE#"
1448
1447static void pragma_parse(TCCState *s1)1449static void pragma_parse(TCCState *s1)
1448{1450{
1449 next_nomacro();1451 next_nomacro();
@@ -1475,10 +1477,12 @@ static void pragma_parse(TCCState *s1) · 25 unmodified lines
1475 tcc_warning("unbalanced #pragma pop_macro");1477 tcc_warning("unbalanced #pragma pop_macro");
1476 1478
1477 } else if (tok == TOK_once) {1479 } else if (tok == TOK_once) {
1478 char buf1[sizeof file->filename];1480 char buf1[sizeof(file->filename) + sizeof(ONCE_PREFIX)];
1479 1481 strcpy(buf1, ONCE_PREFIX);
1480 pstrcpy(buf1, sizeof(buf1), "#once#");1482 strcat(buf1, file->filename);
1481 pstrcat(buf1, sizeof(buf1), file->filename);1483#if PATHCMP==stricmp
1484 strupr(buf1);
1485#endif
1482 add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);1486 add_cached_include(s1, file->filename, tok_alloc(buf1, strlen(buf1))->tok);
1483 } else if (s1->ppfp) {1487 } else if (s1->ppfp) {
1484 /* tcc -E: keep pragmas below unchanged */1488 /* 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