diff options
author | David Howells <dhowells@redhat.com> | 2015-07-29 16:14:00 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2015-08-07 11:26:13 -0400 |
commit | c05cae9a58dca6dcbc6e66b228a9589c6b60880c (patch) | |
tree | 578331203665715ac54c36ca2846a5aabe4e5dab /scripts | |
parent | ae44a2f6a03338cb9d2bd32864f686c732b7841f (diff) |
ASN.1: Copy string names to tokens in ASN.1 compiler
Copy string names to tokens in ASN.1 compiler rather than storing a pointer
into the source text. This means we don't have to use "%*.*s" all over the
place.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/asn1_compiler.c | 155 |
1 files changed, 73 insertions, 82 deletions
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index 6e4ba992a51f..e000f44e37b8 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c | |||
@@ -294,8 +294,8 @@ static const char *const directives[NR__DIRECTIVES] = { | |||
294 | 294 | ||
295 | struct action { | 295 | struct action { |
296 | struct action *next; | 296 | struct action *next; |
297 | char *name; | ||
297 | unsigned char index; | 298 | unsigned char index; |
298 | char name[]; | ||
299 | }; | 299 | }; |
300 | 300 | ||
301 | static struct action *action_list; | 301 | static struct action *action_list; |
@@ -306,7 +306,7 @@ struct token { | |||
306 | enum token_type token_type : 8; | 306 | enum token_type token_type : 8; |
307 | unsigned char size; | 307 | unsigned char size; |
308 | struct action *action; | 308 | struct action *action; |
309 | const char *value; | 309 | char *content; |
310 | struct type *type; | 310 | struct type *type; |
311 | }; | 311 | }; |
312 | 312 | ||
@@ -328,11 +328,9 @@ static int directive_compare(const void *_key, const void *_pdir) | |||
328 | dlen = strlen(dir); | 328 | dlen = strlen(dir); |
329 | clen = (dlen < token->size) ? dlen : token->size; | 329 | clen = (dlen < token->size) ? dlen : token->size; |
330 | 330 | ||
331 | //debug("cmp(%*.*s,%s) = ", | 331 | //debug("cmp(%s,%s) = ", token->content, dir); |
332 | // (int)token->size, (int)token->size, token->value, | ||
333 | // dir); | ||
334 | 332 | ||
335 | val = memcmp(token->value, dir, clen); | 333 | val = memcmp(token->content, dir, clen); |
336 | if (val != 0) { | 334 | if (val != 0) { |
337 | //debug("%d [cmp]\n", val); | 335 | //debug("%d [cmp]\n", val); |
338 | return val; | 336 | return val; |
@@ -352,7 +350,7 @@ static int directive_compare(const void *_key, const void *_pdir) | |||
352 | static void tokenise(char *buffer, char *end) | 350 | static void tokenise(char *buffer, char *end) |
353 | { | 351 | { |
354 | struct token *tokens; | 352 | struct token *tokens; |
355 | char *line, *nl, *p, *q; | 353 | char *line, *nl, *start, *p, *q; |
356 | unsigned tix, lineno; | 354 | unsigned tix, lineno; |
357 | 355 | ||
358 | /* Assume we're going to have half as many tokens as we have | 356 | /* Assume we're going to have half as many tokens as we have |
@@ -411,11 +409,11 @@ static void tokenise(char *buffer, char *end) | |||
411 | break; | 409 | break; |
412 | 410 | ||
413 | tokens[tix].line = lineno; | 411 | tokens[tix].line = lineno; |
414 | tokens[tix].value = p; | 412 | start = p; |
415 | 413 | ||
416 | /* Handle string tokens */ | 414 | /* Handle string tokens */ |
417 | if (isalpha(*p)) { | 415 | if (isalpha(*p)) { |
418 | const char **dir; | 416 | const char **dir, *start = p; |
419 | 417 | ||
420 | /* Can be a directive, type name or element | 418 | /* Can be a directive, type name or element |
421 | * name. Find the end of the name. | 419 | * name. Find the end of the name. |
@@ -426,10 +424,18 @@ static void tokenise(char *buffer, char *end) | |||
426 | tokens[tix].size = q - p; | 424 | tokens[tix].size = q - p; |
427 | p = q; | 425 | p = q; |
428 | 426 | ||
427 | tokens[tix].content = malloc(tokens[tix].size + 1); | ||
428 | if (!tokens[tix].content) { | ||
429 | perror(NULL); | ||
430 | exit(1); | ||
431 | } | ||
432 | memcpy(tokens[tix].content, start, tokens[tix].size); | ||
433 | tokens[tix].content[tokens[tix].size] = 0; | ||
434 | |||
429 | /* If it begins with a lowercase letter then | 435 | /* If it begins with a lowercase letter then |
430 | * it's an element name | 436 | * it's an element name |
431 | */ | 437 | */ |
432 | if (islower(tokens[tix].value[0])) { | 438 | if (islower(tokens[tix].content[0])) { |
433 | tokens[tix++].token_type = TOKEN_ELEMENT_NAME; | 439 | tokens[tix++].token_type = TOKEN_ELEMENT_NAME; |
434 | continue; | 440 | continue; |
435 | } | 441 | } |
@@ -458,6 +464,13 @@ static void tokenise(char *buffer, char *end) | |||
458 | q++; | 464 | q++; |
459 | tokens[tix].size = q - p; | 465 | tokens[tix].size = q - p; |
460 | p = q; | 466 | p = q; |
467 | tokens[tix].content = malloc(tokens[tix].size + 1); | ||
468 | if (!tokens[tix].content) { | ||
469 | perror(NULL); | ||
470 | exit(1); | ||
471 | } | ||
472 | memcpy(tokens[tix].content, start, tokens[tix].size); | ||
473 | tokens[tix].content[tokens[tix].size] = 0; | ||
461 | tokens[tix++].token_type = TOKEN_NUMBER; | 474 | tokens[tix++].token_type = TOKEN_NUMBER; |
462 | continue; | 475 | continue; |
463 | } | 476 | } |
@@ -466,6 +479,7 @@ static void tokenise(char *buffer, char *end) | |||
466 | if (memcmp(p, "::=", 3) == 0) { | 479 | if (memcmp(p, "::=", 3) == 0) { |
467 | p += 3; | 480 | p += 3; |
468 | tokens[tix].size = 3; | 481 | tokens[tix].size = 3; |
482 | tokens[tix].content = "::="; | ||
469 | tokens[tix++].token_type = TOKEN_ASSIGNMENT; | 483 | tokens[tix++].token_type = TOKEN_ASSIGNMENT; |
470 | continue; | 484 | continue; |
471 | } | 485 | } |
@@ -475,12 +489,14 @@ static void tokenise(char *buffer, char *end) | |||
475 | if (memcmp(p, "({", 2) == 0) { | 489 | if (memcmp(p, "({", 2) == 0) { |
476 | p += 2; | 490 | p += 2; |
477 | tokens[tix].size = 2; | 491 | tokens[tix].size = 2; |
492 | tokens[tix].content = "({"; | ||
478 | tokens[tix++].token_type = TOKEN_OPEN_ACTION; | 493 | tokens[tix++].token_type = TOKEN_OPEN_ACTION; |
479 | continue; | 494 | continue; |
480 | } | 495 | } |
481 | if (memcmp(p, "})", 2) == 0) { | 496 | if (memcmp(p, "})", 2) == 0) { |
482 | p += 2; | 497 | p += 2; |
483 | tokens[tix].size = 2; | 498 | tokens[tix].size = 2; |
499 | tokens[tix].content = "})"; | ||
484 | tokens[tix++].token_type = TOKEN_CLOSE_ACTION; | 500 | tokens[tix++].token_type = TOKEN_CLOSE_ACTION; |
485 | continue; | 501 | continue; |
486 | } | 502 | } |
@@ -491,22 +507,27 @@ static void tokenise(char *buffer, char *end) | |||
491 | switch (*p) { | 507 | switch (*p) { |
492 | case '{': | 508 | case '{': |
493 | p += 1; | 509 | p += 1; |
510 | tokens[tix].content = "{"; | ||
494 | tokens[tix++].token_type = TOKEN_OPEN_CURLY; | 511 | tokens[tix++].token_type = TOKEN_OPEN_CURLY; |
495 | continue; | 512 | continue; |
496 | case '}': | 513 | case '}': |
497 | p += 1; | 514 | p += 1; |
515 | tokens[tix].content = "}"; | ||
498 | tokens[tix++].token_type = TOKEN_CLOSE_CURLY; | 516 | tokens[tix++].token_type = TOKEN_CLOSE_CURLY; |
499 | continue; | 517 | continue; |
500 | case '[': | 518 | case '[': |
501 | p += 1; | 519 | p += 1; |
520 | tokens[tix].content = "["; | ||
502 | tokens[tix++].token_type = TOKEN_OPEN_SQUARE; | 521 | tokens[tix++].token_type = TOKEN_OPEN_SQUARE; |
503 | continue; | 522 | continue; |
504 | case ']': | 523 | case ']': |
505 | p += 1; | 524 | p += 1; |
525 | tokens[tix].content = "]"; | ||
506 | tokens[tix++].token_type = TOKEN_CLOSE_SQUARE; | 526 | tokens[tix++].token_type = TOKEN_CLOSE_SQUARE; |
507 | continue; | 527 | continue; |
508 | case ',': | 528 | case ',': |
509 | p += 1; | 529 | p += 1; |
530 | tokens[tix].content = ","; | ||
510 | tokens[tix++].token_type = TOKEN_COMMA; | 531 | tokens[tix++].token_type = TOKEN_COMMA; |
511 | continue; | 532 | continue; |
512 | default: | 533 | default: |
@@ -527,10 +548,7 @@ static void tokenise(char *buffer, char *end) | |||
527 | { | 548 | { |
528 | int n; | 549 | int n; |
529 | for (n = 0; n < nr_tokens; n++) | 550 | for (n = 0; n < nr_tokens; n++) |
530 | debug("Token %3u: '%*.*s'\n", | 551 | debug("Token %3u: '%s'\n", n, token_list[n].content); |
531 | n, | ||
532 | (int)token_list[n].size, (int)token_list[n].size, | ||
533 | token_list[n].value); | ||
534 | } | 552 | } |
535 | #endif | 553 | #endif |
536 | } | 554 | } |
@@ -709,7 +727,7 @@ static int type_index_compare(const void *_a, const void *_b) | |||
709 | if ((*a)->name->size != (*b)->name->size) | 727 | if ((*a)->name->size != (*b)->name->size) |
710 | return (*a)->name->size - (*b)->name->size; | 728 | return (*a)->name->size - (*b)->name->size; |
711 | else | 729 | else |
712 | return memcmp((*a)->name->value, (*b)->name->value, | 730 | return memcmp((*a)->name->content, (*b)->name->content, |
713 | (*a)->name->size); | 731 | (*a)->name->size); |
714 | } | 732 | } |
715 | 733 | ||
@@ -722,7 +740,7 @@ static int type_finder(const void *_key, const void *_ti) | |||
722 | if (token->size != type->name->size) | 740 | if (token->size != type->name->size) |
723 | return token->size - type->name->size; | 741 | return token->size - type->name->size; |
724 | else | 742 | else |
725 | return memcmp(token->value, type->name->value, | 743 | return memcmp(token->content, type->name->content, |
726 | token->size); | 744 | token->size); |
727 | } | 745 | } |
728 | 746 | ||
@@ -776,10 +794,7 @@ static void build_type_list(void) | |||
776 | #if 0 | 794 | #if 0 |
777 | for (n = 0; n < nr_types; n++) { | 795 | for (n = 0; n < nr_types; n++) { |
778 | struct type *type = type_index[n]; | 796 | struct type *type = type_index[n]; |
779 | debug("- %*.*s\n", | 797 | debug("- %*.*s\n", type->name->content); |
780 | (int)type->name->size, | ||
781 | (int)type->name->size, | ||
782 | type->name->value); | ||
783 | } | 798 | } |
784 | #endif | 799 | #endif |
785 | } | 800 | } |
@@ -809,9 +824,8 @@ static void parse(void) | |||
809 | type->element->type_def = type; | 824 | type->element->type_def = type; |
810 | 825 | ||
811 | if (cursor != type[1].name) { | 826 | if (cursor != type[1].name) { |
812 | fprintf(stderr, "%s:%d: Parse error at token '%*.*s'\n", | 827 | fprintf(stderr, "%s:%d: Parse error at token '%s'\n", |
813 | filename, cursor->line, | 828 | filename, cursor->line, cursor->content); |
814 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
815 | exit(1); | 829 | exit(1); |
816 | } | 830 | } |
817 | 831 | ||
@@ -878,34 +892,31 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
878 | cursor++; | 892 | cursor++; |
879 | break; | 893 | break; |
880 | default: | 894 | default: |
881 | fprintf(stderr, "%s:%d: Unrecognised tag class token '%*.*s'\n", | 895 | fprintf(stderr, "%s:%d: Unrecognised tag class token '%s'\n", |
882 | filename, cursor->line, | 896 | filename, cursor->line, cursor->content); |
883 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
884 | exit(1); | 897 | exit(1); |
885 | } | 898 | } |
886 | 899 | ||
887 | if (cursor >= end) | 900 | if (cursor >= end) |
888 | goto overrun_error; | 901 | goto overrun_error; |
889 | if (cursor->token_type != TOKEN_NUMBER) { | 902 | if (cursor->token_type != TOKEN_NUMBER) { |
890 | fprintf(stderr, "%s:%d: Missing tag number '%*.*s'\n", | 903 | fprintf(stderr, "%s:%d: Missing tag number '%s'\n", |
891 | filename, cursor->line, | 904 | filename, cursor->line, cursor->content); |
892 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
893 | exit(1); | 905 | exit(1); |
894 | } | 906 | } |
895 | 907 | ||
896 | element->tag &= ~0x1f; | 908 | element->tag &= ~0x1f; |
897 | element->tag |= strtoul(cursor->value, &p, 10); | 909 | element->tag |= strtoul(cursor->content, &p, 10); |
898 | element->flags |= ELEMENT_TAG_SPECIFIED; | 910 | element->flags |= ELEMENT_TAG_SPECIFIED; |
899 | if (p - cursor->value != cursor->size) | 911 | if (p - cursor->content != cursor->size) |
900 | abort(); | 912 | abort(); |
901 | cursor++; | 913 | cursor++; |
902 | 914 | ||
903 | if (cursor >= end) | 915 | if (cursor >= end) |
904 | goto overrun_error; | 916 | goto overrun_error; |
905 | if (cursor->token_type != TOKEN_CLOSE_SQUARE) { | 917 | if (cursor->token_type != TOKEN_CLOSE_SQUARE) { |
906 | fprintf(stderr, "%s:%d: Missing closing square bracket '%*.*s'\n", | 918 | fprintf(stderr, "%s:%d: Missing closing square bracket '%s'\n", |
907 | filename, cursor->line, | 919 | filename, cursor->line, cursor->content); |
908 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
909 | exit(1); | 920 | exit(1); |
910 | } | 921 | } |
911 | cursor++; | 922 | cursor++; |
@@ -1005,9 +1016,8 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
1005 | ref = bsearch(cursor, type_index, nr_types, sizeof(type_index[0]), | 1016 | ref = bsearch(cursor, type_index, nr_types, sizeof(type_index[0]), |
1006 | type_finder); | 1017 | type_finder); |
1007 | if (!ref) { | 1018 | if (!ref) { |
1008 | fprintf(stderr, "%s:%d: Type '%*.*s' undefined\n", | 1019 | fprintf(stderr, "%s:%d: Type '%s' undefined\n", |
1009 | filename, cursor->line, | 1020 | filename, cursor->line, cursor->content); |
1010 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1011 | exit(1); | 1021 | exit(1); |
1012 | } | 1022 | } |
1013 | cursor->type = *ref; | 1023 | cursor->type = *ref; |
@@ -1056,9 +1066,8 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
1056 | break; | 1066 | break; |
1057 | 1067 | ||
1058 | default: | 1068 | default: |
1059 | fprintf(stderr, "%s:%d: Token '%*.*s' does not introduce a type\n", | 1069 | fprintf(stderr, "%s:%d: Token '%s' does not introduce a type\n", |
1060 | filename, cursor->line, | 1070 | filename, cursor->line, cursor->content); |
1061 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1062 | exit(1); | 1071 | exit(1); |
1063 | } | 1072 | } |
1064 | 1073 | ||
@@ -1075,20 +1084,18 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
1075 | if (cursor >= end) | 1084 | if (cursor >= end) |
1076 | goto overrun_error; | 1085 | goto overrun_error; |
1077 | if (cursor->token_type != TOKEN_ELEMENT_NAME) { | 1086 | if (cursor->token_type != TOKEN_ELEMENT_NAME) { |
1078 | fprintf(stderr, "%s:%d: Token '%*.*s' is not an action function name\n", | 1087 | fprintf(stderr, "%s:%d: Token '%s' is not an action function name\n", |
1079 | filename, cursor->line, | 1088 | filename, cursor->line, cursor->content); |
1080 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1081 | exit(1); | 1089 | exit(1); |
1082 | } | 1090 | } |
1083 | 1091 | ||
1084 | action = malloc(sizeof(struct action) + cursor->size + 1); | 1092 | action = malloc(sizeof(struct action)); |
1085 | if (!action) { | 1093 | if (!action) { |
1086 | perror(NULL); | 1094 | perror(NULL); |
1087 | exit(1); | 1095 | exit(1); |
1088 | } | 1096 | } |
1089 | action->index = 0; | 1097 | action->index = 0; |
1090 | memcpy(action->name, cursor->value, cursor->size); | 1098 | action->name = cursor->content; |
1091 | action->name[cursor->size] = 0; | ||
1092 | 1099 | ||
1093 | for (ppaction = &action_list; | 1100 | for (ppaction = &action_list; |
1094 | *ppaction; | 1101 | *ppaction; |
@@ -1118,9 +1125,8 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
1118 | if (cursor >= end) | 1125 | if (cursor >= end) |
1119 | goto overrun_error; | 1126 | goto overrun_error; |
1120 | if (cursor->token_type != TOKEN_CLOSE_ACTION) { | 1127 | if (cursor->token_type != TOKEN_CLOSE_ACTION) { |
1121 | fprintf(stderr, "%s:%d: Missing close action, got '%*.*s'\n", | 1128 | fprintf(stderr, "%s:%d: Missing close action, got '%s'\n", |
1122 | filename, cursor->line, | 1129 | filename, cursor->line, cursor->content); |
1123 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1124 | exit(1); | 1130 | exit(1); |
1125 | } | 1131 | } |
1126 | cursor++; | 1132 | cursor++; |
@@ -1130,9 +1136,8 @@ static struct element *parse_type(struct token **_cursor, struct token *end, | |||
1130 | return top; | 1136 | return top; |
1131 | 1137 | ||
1132 | parse_error: | 1138 | parse_error: |
1133 | fprintf(stderr, "%s:%d: Unexpected token '%*.*s'\n", | 1139 | fprintf(stderr, "%s:%d: Unexpected token '%s'\n", |
1134 | filename, cursor->line, | 1140 | filename, cursor->line, cursor->content); |
1135 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1136 | exit(1); | 1141 | exit(1); |
1137 | 1142 | ||
1138 | overrun_error: | 1143 | overrun_error: |
@@ -1150,9 +1155,8 @@ static struct element *parse_compound(struct token **_cursor, struct token *end, | |||
1150 | struct token *cursor = *_cursor, *name; | 1155 | struct token *cursor = *_cursor, *name; |
1151 | 1156 | ||
1152 | if (cursor->token_type != TOKEN_OPEN_CURLY) { | 1157 | if (cursor->token_type != TOKEN_OPEN_CURLY) { |
1153 | fprintf(stderr, "%s:%d: Expected compound to start with brace not '%*.*s'\n", | 1158 | fprintf(stderr, "%s:%d: Expected compound to start with brace not '%s'\n", |
1154 | filename, cursor->line, | 1159 | filename, cursor->line, cursor->content); |
1155 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1156 | exit(1); | 1160 | exit(1); |
1157 | } | 1161 | } |
1158 | cursor++; | 1162 | cursor++; |
@@ -1193,9 +1197,8 @@ static struct element *parse_compound(struct token **_cursor, struct token *end, | |||
1193 | children->flags &= ~ELEMENT_CONDITIONAL; | 1197 | children->flags &= ~ELEMENT_CONDITIONAL; |
1194 | 1198 | ||
1195 | if (cursor->token_type != TOKEN_CLOSE_CURLY) { | 1199 | if (cursor->token_type != TOKEN_CLOSE_CURLY) { |
1196 | fprintf(stderr, "%s:%d: Expected compound closure, got '%*.*s'\n", | 1200 | fprintf(stderr, "%s:%d: Expected compound closure, got '%s'\n", |
1197 | filename, cursor->line, | 1201 | filename, cursor->line, cursor->content); |
1198 | (int)cursor->size, (int)cursor->size, cursor->value); | ||
1199 | exit(1); | 1202 | exit(1); |
1200 | } | 1203 | } |
1201 | cursor++; | 1204 | cursor++; |
@@ -1212,10 +1215,8 @@ static void dump_element(const struct element *e, int level) | |||
1212 | { | 1215 | { |
1213 | const struct element *c; | 1216 | const struct element *c; |
1214 | const struct type *t = e->type_def; | 1217 | const struct type *t = e->type_def; |
1215 | const char *name = e->name ? e->name->value : "."; | 1218 | const char *name = e->name ? e->name->content : "."; |
1216 | int nsize = e->name ? e->name->size : 1; | 1219 | const char *tname = t && t->name ? t->name->content : "."; |
1217 | const char *tname = t && t->name ? t->name->value : "."; | ||
1218 | int tnsize = t && t->name ? t->name->size : 1; | ||
1219 | char tag[32]; | 1220 | char tag[32]; |
1220 | 1221 | ||
1221 | if (e->class == 0 && e->method == 0 && e->tag == 0) | 1222 | if (e->class == 0 && e->method == 0 && e->tag == 0) |
@@ -1231,7 +1232,7 @@ static void dump_element(const struct element *e, int level) | |||
1231 | asn1_methods[e->method], | 1232 | asn1_methods[e->method], |
1232 | e->tag); | 1233 | e->tag); |
1233 | 1234 | ||
1234 | printf("%c%c%c%c%c %c %*s[*] \e[33m%s\e[m %*.*s %*.*s \e[35m%s\e[m\n", | 1235 | printf("%c%c%c%c%c %c %*s[*] \e[33m%s\e[m %s %s \e[35m%s\e[m\n", |
1235 | e->flags & ELEMENT_IMPLICIT ? 'I' : '-', | 1236 | e->flags & ELEMENT_IMPLICIT ? 'I' : '-', |
1236 | e->flags & ELEMENT_EXPLICIT ? 'E' : '-', | 1237 | e->flags & ELEMENT_EXPLICIT ? 'E' : '-', |
1237 | e->flags & ELEMENT_TAG_SPECIFIED ? 'T' : '-', | 1238 | e->flags & ELEMENT_TAG_SPECIFIED ? 'T' : '-', |
@@ -1240,8 +1241,8 @@ static void dump_element(const struct element *e, int level) | |||
1240 | "-tTqQcaro"[e->compound], | 1241 | "-tTqQcaro"[e->compound], |
1241 | level, "", | 1242 | level, "", |
1242 | tag, | 1243 | tag, |
1243 | tnsize, tnsize, tname, | 1244 | tname, |
1244 | nsize, nsize, name, | 1245 | name, |
1245 | e->action ? e->action->name : ""); | 1246 | e->action ? e->action->name : ""); |
1246 | if (e->compound == TYPE_REF) | 1247 | if (e->compound == TYPE_REF) |
1247 | dump_element(e->type->type->element, level + 3); | 1248 | dump_element(e->type->type->element, level + 3); |
@@ -1454,9 +1455,7 @@ static void render_element(FILE *out, struct element *e, struct element *tag) | |||
1454 | outofline = 1; | 1455 | outofline = 1; |
1455 | 1456 | ||
1456 | if (e->type_def && out) { | 1457 | if (e->type_def && out) { |
1457 | render_more(out, "\t// %*.*s\n", | 1458 | render_more(out, "\t// %s\n", e->type_def->name->content); |
1458 | (int)e->type_def->name->size, (int)e->type_def->name->size, | ||
1459 | e->type_def->name->value); | ||
1460 | } | 1459 | } |
1461 | 1460 | ||
1462 | /* Render the operation */ | 1461 | /* Render the operation */ |
@@ -1468,9 +1467,7 @@ static void render_element(FILE *out, struct element *e, struct element *tag) | |||
1468 | render_opcode(out, "ASN1_OP_%sMATCH_ANY%s%s,", | 1467 | render_opcode(out, "ASN1_OP_%sMATCH_ANY%s%s,", |
1469 | cond, act, skippable ? "_OR_SKIP" : ""); | 1468 | cond, act, skippable ? "_OR_SKIP" : ""); |
1470 | if (e->name) | 1469 | if (e->name) |
1471 | render_more(out, "\t\t// %*.*s", | 1470 | render_more(out, "\t\t// %s", e->name->content); |
1472 | (int)e->name->size, (int)e->name->size, | ||
1473 | e->name->value); | ||
1474 | render_more(out, "\n"); | 1471 | render_more(out, "\n"); |
1475 | goto dont_render_tag; | 1472 | goto dont_render_tag; |
1476 | 1473 | ||
@@ -1503,9 +1500,7 @@ static void render_element(FILE *out, struct element *e, struct element *tag) | |||
1503 | 1500 | ||
1504 | x = tag ?: e; | 1501 | x = tag ?: e; |
1505 | if (x->name) | 1502 | if (x->name) |
1506 | render_more(out, "\t\t// %*.*s", | 1503 | render_more(out, "\t\t// %s", x->name->content); |
1507 | (int)x->name->size, (int)x->name->size, | ||
1508 | x->name->value); | ||
1509 | render_more(out, "\n"); | 1504 | render_more(out, "\n"); |
1510 | 1505 | ||
1511 | /* Render the tag */ | 1506 | /* Render the tag */ |
@@ -1543,10 +1538,8 @@ dont_render_tag: | |||
1543 | * skipability */ | 1538 | * skipability */ |
1544 | render_opcode(out, "_jump_target(%u),", e->entry_index); | 1539 | render_opcode(out, "_jump_target(%u),", e->entry_index); |
1545 | if (e->type_def && e->type_def->name) | 1540 | if (e->type_def && e->type_def->name) |
1546 | render_more(out, "\t\t// --> %*.*s", | 1541 | render_more(out, "\t\t// --> %s", |
1547 | (int)e->type_def->name->size, | 1542 | e->type_def->name->content); |
1548 | (int)e->type_def->name->size, | ||
1549 | e->type_def->name->value); | ||
1550 | render_more(out, "\n"); | 1543 | render_more(out, "\n"); |
1551 | if (!(e->flags & ELEMENT_RENDERED)) { | 1544 | if (!(e->flags & ELEMENT_RENDERED)) { |
1552 | e->flags |= ELEMENT_RENDERED; | 1545 | e->flags |= ELEMENT_RENDERED; |
@@ -1571,10 +1564,8 @@ dont_render_tag: | |||
1571 | * skipability */ | 1564 | * skipability */ |
1572 | render_opcode(out, "_jump_target(%u),", e->entry_index); | 1565 | render_opcode(out, "_jump_target(%u),", e->entry_index); |
1573 | if (e->type_def && e->type_def->name) | 1566 | if (e->type_def && e->type_def->name) |
1574 | render_more(out, "\t\t// --> %*.*s", | 1567 | render_more(out, "\t\t// --> %s", |
1575 | (int)e->type_def->name->size, | 1568 | e->type_def->name->content); |
1576 | (int)e->type_def->name->size, | ||
1577 | e->type_def->name->value); | ||
1578 | render_more(out, "\n"); | 1569 | render_more(out, "\n"); |
1579 | if (!(e->flags & ELEMENT_RENDERED)) { | 1570 | if (!(e->flags & ELEMENT_RENDERED)) { |
1580 | e->flags |= ELEMENT_RENDERED; | 1571 | e->flags |= ELEMENT_RENDERED; |