History

Improve skip_or_save_block

Stop at level 0 only for matching outer '}' (which is added). Otherwise stop only at stop tokens (which aren't added).

Michael Matz committed 9 years ago

Commit 27ca3031 parent d4fe9ab1 file · +7 −7Browse files

Unified · Split

tccgen.c+7−7
@@ -5867,11 +5867,13 @@ static void block(int *bsym, int *csym, int is_expr) · 5866 unmodified lines
5867}5867}
5868 5868
5869/* This skips over a stream of tokens containing balanced {} and ()5869/* This skips over a stream of tokens containing balanced {} and ()
5870 pairs, stopping at outer ',' ';' and '}'. If STR then allocates5870 pairs, stopping at outer ',' ';' and '}' (or matching '}' if we started
5871 and stores the skipped tokens in *STR. This doesn't check if5871 with a '{'). If STR then allocates and stores the skipped tokens
5872 () and {} are nested correctly, i.e. "({)}" is accepted. */5872 in *STR. This doesn't check if () and {} are nested correctly,
5873 i.e. "({)}" is accepted. */
5873static void skip_or_save_block(TokenString **str)5874static void skip_or_save_block(TokenString **str)
5874{5875{
5876 int braces = tok == '{';
5875 int level = 0;5877 int level = 0;
5876 if (str)5878 if (str)
5877 *str = tok_str_alloc();5879 *str = tok_str_alloc();
@@ -5892,7 +5894,7 @@ static void skip_or_save_block(TokenString **str) · 14 unmodified lines
5892 level++;5894 level++;
5893 } else if (t == '}' || t == ')') {5895 } else if (t == '}' || t == ')') {
5894 level--;5896 level--;
5895 if (level == 0)5897 if (level == 0 && braces && t == '}')
5896 break;5898 break;
5897 }5899 }
5898 }5900 }
@@ -6413,9 +6415,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 514 unmodified lines
6413 But GNU C supports it, so we need to recurse even into6415 But GNU C supports it, so we need to recurse even into
6414 subfields of structs and arrays when size_only is set. */6416 subfields of structs and arrays when size_only is set. */
6415 /* just skip expression */6417 /* just skip expression */
6416 do {6418 skip_or_save_block(NULL);
6417 skip_or_save_block(NULL);
6418 } while (tok != '}' && tok != ',' && tok != -1);
6419 } else {6419 } else {
6420 if (!have_elem) {6420 if (!have_elem) {
6421 /* This should happen only when we haven't parsed6421 /* This should happen only when we haven't parsed

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