diff --git a/lib/asn1/check-gen.c b/check-gen.c similarity index 99% rename from lib/asn1/check-gen.c rename to check-gen.c index 68c8b5c36..087c31e4f 100644 --- a/lib/asn1/check-gen.c +++ b/check-gen.c @@ -57,7 +57,7 @@ static char *nada_tgt_principal[] = { "krbtgt", "NADA.KTH.SE" }; #define IF_OPT_COMPARE(ac,bc,e) \ - if (((ac)->e == NULL && (bc)->e != NULL) || (((ac)->e != NULL && (bc)->e == NULL))) return 1; if ((ab)->e) + if (((ac)->e == NULL && (bc)->e != NULL) || (((ac)->e != NULL && (bc)->e == NULL))) return 1; if ((ac)->e) #define COMPARE_OPT_STRING(ac,bc,e) \ do { if (strcmp(*(ac)->e, *(bc)->e) != 0) return 1; } while(0) #define COMPARE_OPT_OCTECT_STRING(ac,bc,e) \ diff --git a/lib/asn1/gen_template.c b/lib/asn1/gen_template.c index c6ef733c2..f0b94d75a 100644 --- a/lib/asn1/gen_template.c +++ b/lib/asn1/gen_template.c @@ -867,9 +867,11 @@ generate_template_type(const char *varname, int optional, int isstruct, int need_offset) { struct tlist *tl; - const char *dup; + const char *d; + char *szt = NULL; int have_ellipsis = 0; int implicit = 0; + int n; tl = tlist_new(varname); @@ -889,23 +891,34 @@ generate_template_type(const char *varname, } } + if (isstruct) + if (name) + n = asprintf(&szt, "struct %s_%s", basetype, name); + else + n = asprintf(&szt, "struct %s", basetype); + else + n = asprintf(&szt, "%s", basetype); + if (n < 0 || szt == NULL) + errx(1, "malloc"); + if (ASN1_TAILQ_EMPTY(&tl->template) && compact_tag(type)->type != TNull) errx(1, "Tag %s...%s with no content ?", basetype, name ? name : ""); fprintf(get_code_file(), "/* generate_template_type: %s */\n", tl->name); - tlist_header(tl, "{ 0%s%s, sizeof(%s%s), ((void *)%lu) }", + tlist_header(tl, "{ 0%s%s, sizeof(%s), ((void *)%lu) }", (symname && preserve_type(symname)) ? "|A1_HF_PRESERVE" : "", - have_ellipsis ? "|A1_HF_ELLIPSIS" : "", - isstruct ? "struct " : "", basetype, tlist_count(tl)); + have_ellipsis ? "|A1_HF_ELLIPSIS" : "", szt, tlist_count(tl)); - dup = tlist_find_dup(tl); - if (dup) { + free(szt); + + d = tlist_find_dup(tl); + if (d) { #if 0 - if (strcmp(dup, tl->name) == 0) - errx(1, "found dup of ourself: %s", dup); + if (strcmp(d, tl->name) == 0) + errx(1, "found dup of ourself: %s", d); #endif - *dupname = dup; + *dupname = d; } else { *dupname = tl->name; tlist_print(tl);