diff options
author | Patrick McHardy <kaber@trash.net> | 2014-12-13 07:50:34 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2014-12-16 18:20:54 +0100 |
commit | cde2b8bac620caf3858ccab16e82005b3ef27bee (patch) | |
tree | 410f58e25b8dc87880ce070947d07948647b03fd /src | |
parent | f8aa0c23dc864760bf4ab6420477546ba2ba683a (diff) |
datatype: generate name for concat types
The name of a concat type is the names of the individual types concatenated
using a '.'.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/datatype.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/datatype.c b/src/datatype.c index 7f730776..807b0f18 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -928,12 +928,16 @@ const struct datatype *concat_type_alloc(const struct expr *expr) struct datatype *dtype; struct expr *i; char desc[256] = "concatenation of ("; + char name[256] = ""; unsigned int type = 0, size = 0; list_for_each_entry(i, &expr->expressions, list) { - if (size != 0) + if (size != 0) { strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1); + strncat(name, " . ", sizeof(name) - strlen(name) - 1); + } strncat(desc, i->dtype->desc, sizeof(desc) - strlen(desc) - 1); + strncat(name, i->dtype->name, sizeof(name) - strlen(name) - 1); type <<= 8; type |= i->dtype->type; @@ -944,6 +948,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr) dtype = dtype_alloc(); dtype->type = type; dtype->size = size; + dtype->name = xstrdup(name); dtype->desc = xstrdup(desc); dtype->parse = concat_type_parse; @@ -953,6 +958,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr) void concat_type_destroy(const struct datatype *dtype) { if (dtype->flags & DTYPE_F_ALLOC) { + xfree(dtype->name); xfree(dtype->desc); xfree(dtype); } |