constness fix
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index e5cd8dc..58d119f 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -1375,7 +1375,7 @@
&& etd_spec == ETD_NO_SPECIFICS
&& 0 /* This shortcut is incompatible with XER */
) {
- char *type_name;
+ const char *type_name;
REDIR(OT_FUNC_DECLS);
type_name = asn1c_type_name(arg, expr, TNF_SAFE);
OUT("/* This type is equivalent to %s */\n", type_name);
@@ -2911,7 +2911,7 @@
struct asn1p_type_tag_s outmost_tag_s;
struct asn1p_type_tag_s *outmost_tag;
int complex_contents;
- char *p;
+ const char *p;
if(WITH_MODULE_NAMESPACE(
expr->module, expr_ns,
@@ -3017,7 +3017,7 @@
if(arg->flags & A1C_NO_CONSTRAINTS) {
OUT("0,\t/* No check because of -fno-constraints */\n");
} else {
- char *id = MKID(expr);
+ const char *id = MKID(expr);
if(expr->_anonymous_type
&& !strcmp(expr->Identifier, "Member"))
id = asn1c_type_name(arg, expr, TNF_SAFE);
@@ -3108,7 +3108,7 @@
emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_count, int all_tags_count, int elements_count, enum etd_spec spec) {
asn1p_expr_t *terminal;
int using_type_name = 0;
- char *p = MKID(expr);
+ const char *p = MKID(expr);
char *p2 = (char *)0;
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->ns, expr);
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index 9e2737b..a8054bb 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -92,7 +92,7 @@
break;
}
if(produce_st) {
- char *tname = asn1c_type_name(arg, arg->expr, TNF_SAFE);
+ const char *tname = asn1c_type_name(arg, arg->expr, TNF_SAFE);
OUT("const %s_t *st = (const %s_t *)sptr;\n", tname, tname);
}
@@ -427,7 +427,7 @@
emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
asn1c_integer_t natural_stop;
asn1p_expr_t *terminal;
- char *tname;
+ const char *tname;
terminal = asn1f_find_terminal_type_ex(arg->asn, arg->ns, arg->expr);
if(terminal) {
diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c
index 0f66147..665b748 100644
--- a/libasn1compiler/asn1c_misc.c
+++ b/libasn1compiler/asn1c_misc.c
@@ -168,13 +168,13 @@
return storage;
}
-char *
+const char *
asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
asn1p_expr_t *exprid = 0;
asn1p_expr_t *top_parent;
asn1p_expr_t *terminal = 0;
int stdname = 0;
- char *typename;
+ const char *typename;
/* Rewind to the topmost parent expression */
if((top_parent = expr->parent_expr))
diff --git a/libasn1compiler/asn1c_misc.h b/libasn1compiler/asn1c_misc.h
index 63f3841..ff6d672 100644
--- a/libasn1compiler/asn1c_misc.h
+++ b/libasn1compiler/asn1c_misc.h
@@ -16,6 +16,8 @@
/*
* Return the type name of the specified expression.
+ * The returned string is a pointer to a statically allocated buffer which is
+ * going to be clobbered by the subsequent invocation of this function.
*/
enum tnfmt {
TNF_UNMODIFIED = 0x10, /* Return unmodified type name */
@@ -24,7 +26,7 @@
TNF_SAFE = 0x40, /* Replace unsafe characters with _ */
TNF_RSAFE = 0x50, /* Recursion-safe C type format */
};
-char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
+const char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
/*
* Check whether the specified INTEGER or ENUMERATED type can be represented