Merge PR99 and its fixes to support parsing Information Object and Information Object Set
This is a collection of works :
1. Based on @zhanglei002's pull request 99.
2. A fix by @AuthenticEshkinKot and merged by @mouse07410 at
commit 2c8d366bbe1fc4e4c041e9b0eb9779f8a42d754b of https://github.com/mouse07410/asn1c
to support parsing of Information Object and Information Object Set
3. A fix by @Uri Blumenthal in asn1fix_derefv.c at :
commit ec0ade4f87c807e763e3f35fc5466adb6dda3473 of https://github.com/mouse07410/asn1c
to solve crash on asn1p_value_free().
4. My pull request 18 to @mouse07410's https://github.com/mouse07410/asn1c to solve
problems found during parsing ASN.1 modules of S1AP, RANAP and J2735-201603.
5. My pull request 22 to @mouse07410's https://github.com/mouse07410/asn1c to solve issue 147
and to solve the problem during parsing ASN.1 module of NBAP.
6. My pull request 23 to @mouse07410's https://github.com/mouse07410/asn1c to fix memory leakage
introduced in aforementioned commits.
Most code changes are the same as pull request 153 to this repository.
7. A fix of my bug in item 6 which result asn1c crash, fixed by @mouse07410.
diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c
index a6c9732..f7aa012 100644
--- a/libasn1compiler/asn1c_save.c
+++ b/libasn1compiler/asn1c_save.c
@@ -89,7 +89,7 @@
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
safe_fprintf(mkf, "\t\\\n\t%s.c",
- arg->expr->Identifier);
+ asn1c_make_identifier(AMI_MASK_ONLY_SPACES, arg->expr, 0));
}
}
}
@@ -99,7 +99,7 @@
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
safe_fprintf(mkf, "\t\\\n\t%s.h",
- arg->expr->Identifier);
+ asn1c_make_identifier(AMI_MASK_ONLY_SPACES, arg->expr, 0));
}
}
}
@@ -245,6 +245,7 @@
char *header_id;
const char *c_retained = "";
const char *h_retained = "";
+ char *filename;
if(cs == NULL) {
safe_fprintf(stderr, "Cannot compile %s at line %d\n",
@@ -252,8 +253,9 @@
return -1;
}
- fp_c = asn1c_open_file(expr->Identifier, ".c", &tmpname_c);
- fp_h = asn1c_open_file(expr->Identifier, ".h", &tmpname_h);
+ filename = strdup(asn1c_make_identifier(AMI_MASK_ONLY_SPACES, expr, (char*)0));
+ fp_c = asn1c_open_file(filename, ".c", &tmpname_c);
+ fp_h = asn1c_open_file(filename, ".h", &tmpname_h);
if(fp_c == NULL || fp_h == NULL) {
if(fp_c) { unlink(tmpname_c); free(tmpname_c); fclose(fp_c); }
if(fp_h) { unlink(tmpname_h); free(tmpname_h); fclose(fp_h); }
@@ -297,7 +299,7 @@
safe_fprintf(fp_h, "\n#endif\t/* _%s_H_ */\n", header_id);
HINCLUDE("asn_internal.h");
- safe_fprintf(fp_c, "#include \"%s.h\"\n\n", expr->Identifier);
+ safe_fprintf(fp_c, "#include \"%s.h\"\n\n", filename);
if(arg->flags & A1C_NO_INCLUDE_DEPS)
SAVE_STREAM(fp_c, OT_POST_INCLUDE, "", 1);
TQ_FOR(ot, &(cs->destination[OT_CTABLES].chunks), next)
@@ -314,9 +316,9 @@
fclose(fp_c);
fclose(fp_h);
- name_buf = alloca(strlen(expr->Identifier) + 3);
+ name_buf = alloca(strlen(filename) + 3);
- sprintf(name_buf, "%s.c", expr->Identifier);
+ sprintf(name_buf, "%s.c", filename);
if(identical_files(name_buf, tmpname_c)) {
c_retained = " (contents unchanged)";
unlink(tmpname_c);
@@ -330,7 +332,7 @@
}
}
- sprintf(name_buf, "%s.h", expr->Identifier);
+ sprintf(name_buf, "%s.h", filename);
if(identical_files(name_buf, tmpname_h)) {
h_retained = " (contents unchanged)";
unlink(tmpname_h);
@@ -348,9 +350,10 @@
free(tmpname_h);
safe_fprintf(stderr, "Compiled %s.c%s\n",
- expr->Identifier, c_retained);
+ filename, c_retained);
safe_fprintf(stderr, "Compiled %s.h%s\n",
- expr->Identifier, h_retained);
+ filename, h_retained);
+ free(filename);
return 0;
}