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
13341334 tcc_strdup(filename));
13351335
13361336 parse_flags = 0;
1337−#ifdef CONFIG_TCC_ASM
13381337 /* if .S file, define __ASSEMBLER__ like gcc does */
13391338 if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {
13401339 tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
13411340 parse_flags = PARSE_FLAG_ASM_FILE;
13421341 }
1343−#endif
13441342
13451343 if (flags & AFF_PREPROCESS) {
13461344 ret = tcc_preprocess(s1);
tccpp.c+9−8
@@ -1773,7 +1773,7 @@ ST_FUNC void preprocess(int is_bof) · 1772 unmodified lines
17731773 buf1[0] = 0;
17741774
17751775 } else if (i == 1) {
1776− /* search in current dir if "header.h" */
1776+ /* search in file's dir if "header.h" */
17771777 if (c != '\"')
17781778 continue;
17791779 path = file->filename;
@@ -1860,16 +1860,17 @@ include_done: · 80 unmodified lines
18601860 if (c > 1)
18611861 tcc_error("#elif after #else");
18621862 /* last #if/#elif expression was true: we skip */
1863− if (c == 1)
1864− goto skip;
1865− c = expr_preprocess();
1866− s1->ifdef_stack_ptr[-1] = c;
1863+ if (c == 1) {
1864+ c = 0;
1865+ } else {
1866+ c = expr_preprocess();
1867+ s1->ifdef_stack_ptr[-1] = c;
1868+ }
18671869 test_else:
18681870 if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
18691871 file->ifndef_macro = 0;
18701872 test_skip:
18711873 if (!(c & 1)) {
1872− skip:
18731874 preprocess_skip();
18741875 is_bof = 0;
18751876 goto redo;
@@ -1899,10 +1900,10 @@ include_done: · 23 unmodified lines
18991900 case TOK_LINE:
19001901 next();
19011902 if (tok != TOK_CINT)
1902−_line_err:
1903+ _line_err:
19031904 tcc_error("wrong #line format");
19041905 n = tokc.i;
1905−_line_num:
1906+ _line_num:
19061907 next();
19071908 if (tok != TOK_LINEFEED) {
19081909 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