History

tccpp: no cache for include if #elif seen

#ifndef guards are cached, however after #elif on the same level, the file must be re-read.

grischka committed 10 years ago

Commit 1c4cf181 parent 5805b072 files · +9 −10Browse files

Unified · Split

2 files
  1. libtcc.c +0 −2
  2. tccpp.c +9 −8
libtcc.c+0−2
@@ -1334,13 +1334,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1333 unmodified lines
1334 tcc_strdup(filename));1334 tcc_strdup(filename));
1335 1335
1336 parse_flags = 0;1336 parse_flags = 0;
1337#ifdef CONFIG_TCC_ASM
1338 /* if .S file, define __ASSEMBLER__ like gcc does */1337 /* if .S file, define __ASSEMBLER__ like gcc does */
1339 if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {1338 if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {
1340 tcc_define_symbol(s1, "__ASSEMBLER__", NULL);1339 tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
1341 parse_flags = PARSE_FLAG_ASM_FILE;1340 parse_flags = PARSE_FLAG_ASM_FILE;
1342 }1341 }
1343#endif
1344 1342
1345 if (flags & AFF_PREPROCESS) {1343 if (flags & AFF_PREPROCESS) {
1346 ret = tcc_preprocess(s1);1344 ret = tcc_preprocess(s1);
tccpp.c+9−8
@@ -1773,7 +1773,7 @@ ST_FUNC void preprocess(int is_bof) · 1772 unmodified lines
1773 buf1[0] = 0;1773 buf1[0] = 0;
1774 1774
1775 } else if (i == 1) {1775 } else if (i == 1) {
1776 /* search in current dir if "header.h" */1776 /* search in file's dir if "header.h" */
1777 if (c != '\"')1777 if (c != '\"')
1778 continue;1778 continue;
1779 path = file->filename;1779 path = file->filename;
@@ -1860,16 +1860,17 @@ include_done: · 80 unmodified lines
1860 if (c > 1)1860 if (c > 1)
1861 tcc_error("#elif after #else");1861 tcc_error("#elif after #else");
1862 /* last #if/#elif expression was true: we skip */1862 /* last #if/#elif expression was true: we skip */
1863 if (c == 1)1863 if (c == 1) {
1864 goto skip;1864 c = 0;
1865 c = expr_preprocess();1865 } else {
1866 s1->ifdef_stack_ptr[-1] = c;1866 c = expr_preprocess();
1867 s1->ifdef_stack_ptr[-1] = c;
1868 }
1867 test_else:1869 test_else:
1868 if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)1870 if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
1869 file->ifndef_macro = 0;1871 file->ifndef_macro = 0;
1870 test_skip:1872 test_skip:
1871 if (!(c & 1)) {1873 if (!(c & 1)) {
1872 skip:
1873 preprocess_skip();1874 preprocess_skip();
1874 is_bof = 0;1875 is_bof = 0;
1875 goto redo;1876 goto redo;
@@ -1899,10 +1900,10 @@ include_done: · 23 unmodified lines
1899 case TOK_LINE:1900 case TOK_LINE:
1900 next();1901 next();
1901 if (tok != TOK_CINT)1902 if (tok != TOK_CINT)
1902_line_err:1903 _line_err:
1903 tcc_error("wrong #line format");1904 tcc_error("wrong #line format");
1904 n = tokc.i;1905 n = tokc.i;
1905_line_num:1906 _line_num:
1906 next();1907 next();
1907 if (tok != TOK_LINEFEED) {1908 if (tok != TOK_LINEFEED) {
1908 if (tok == TOK_STR)1909 if (tok == TOK_STR)

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