Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genksyms: Minor parser cleanup

Move the identical logic for recording a struct/union/enum definition to
a function.

+15 -18
+15 -18
scripts/genksyms/parse.y
··· 51 51 free_list(b, e); 52 52 } 53 53 54 + /* Record definition of a struct/union/enum */ 55 + static void record_compound(struct string_list **keyw, 56 + struct string_list **ident, 57 + struct string_list **body, 58 + enum symbol_type type) 59 + { 60 + struct string_list *b = *body, *i = *ident, *r; 61 + r = copy_node(i); r->tag = type; 62 + r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; 63 + add_symbol(i->string, type, b, is_extern); 64 + } 65 + 54 66 %} 55 67 56 68 %token ASM_KEYW ··· 227 215 228 216 /* Full definitions of an s/u/e. Record it. */ 229 217 | STRUCT_KEYW IDENT class_body 230 - { struct string_list *s = *$3, *i = *$2, *r; 231 - r = copy_node(i); r->tag = SYM_STRUCT; 232 - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; 233 - add_symbol(i->string, SYM_STRUCT, s, is_extern); 234 - $$ = $3; 235 - } 218 + { record_compound($1, $2, $3, SYM_STRUCT); $$ = $3; } 236 219 | UNION_KEYW IDENT class_body 237 - { struct string_list *s = *$3, *i = *$2, *r; 238 - r = copy_node(i); r->tag = SYM_UNION; 239 - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; 240 - add_symbol(i->string, SYM_UNION, s, is_extern); 241 - $$ = $3; 242 - } 220 + { record_compound($1, $2, $3, SYM_UNION); $$ = $3; } 243 221 | ENUM_KEYW IDENT enum_body 244 - { struct string_list *s = *$3, *i = *$2, *r; 245 - r = copy_node(i); r->tag = SYM_ENUM; 246 - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; 247 - add_symbol(i->string, SYM_ENUM, s, is_extern); 248 - $$ = $3; 249 - } 222 + { record_compound($1, $2, $3, SYM_ENUM); $$ = $3; } 250 223 /* 251 224 * Anonymous enum definition. Tell add_symbol() to restart its counter. 252 225 */