From 7b175edccebd73338997eab198b9e01504fe8366 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 9 Nov 2005 04:42:16 +0000 Subject: [PATCH] array fixes git-svn-id: http://ltt.polymtl.ca/svn@1314 04897980-b3bd-0310-b5e0-8ef037075253 --- genevent-new/genevent.c | 15 ++++++++++----- genevent-new/test.xml | 11 ++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/genevent-new/genevent.c b/genevent-new/genevent.c index 118298ce..40cba10b 100644 --- a/genevent-new/genevent.c +++ b/genevent-new/genevent.c @@ -127,7 +127,9 @@ int print_type(type_descriptor_t * td, FILE *fd, unsigned int tabs, basename_len = strlen(basename); } else { /* For a unnamed type, there must be a field name */ - if(basename_len != 0) { + if((basename_len != 0) + && (basename[basename_len-1] != '_') + && (field_name[0] != '\0')) { strncat(basename, "_", PATH_MAX - basename_len); basename_len = strlen(basename); } @@ -216,7 +218,7 @@ int print_type_declaration(type_descriptor_t * td, FILE *fd, unsigned int tabs, char basename[PATH_MAX]; unsigned int basename_len = 0; - strcpy(basename, nest_name); + strncpy(basename, nest_name, PATH_MAX); basename_len = strlen(basename); /* For a named type, we use the type_name directly */ @@ -224,13 +226,15 @@ int print_type_declaration(type_descriptor_t * td, FILE *fd, unsigned int tabs, strncpy(basename, td->type_name, PATH_MAX); basename_len = strlen(basename); } else { - /* For a unnamed type, there must be a field name */ - if(basename_len != 0) { + /* For a unnamed type, there must be a field name, except for + * the array. */ + if((basename_len != 0) + && (basename[basename_len-1] != '_' + && (field_name[0] != '\0'))) { strncat(basename, "_", PATH_MAX - basename_len); basename_len = strlen(basename); } strncat(basename, field_name, PATH_MAX - basename_len); - dprintf("%s\n", field_name); } switch(td->type) { @@ -247,6 +251,7 @@ int print_type_declaration(type_descriptor_t * td, FILE *fd, unsigned int tabs, break; case ARRAY: + dprintf("%s\n", basename); assert(td->size >= 0); if(td->nested_type->type_name == NULL) { /* Not a named nested type : we must print its declaration first */ diff --git a/genevent-new/test.xml b/genevent-new/test.xml index a71ad8b9..34ca9b09 100644 --- a/genevent-new/test.xml +++ b/genevent-new/test.xml @@ -56,7 +56,16 @@ - + + + + + + + + + + -- 2.34.1