array fixes
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 9 Nov 2005 04:42:16 +0000 (04:42 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 9 Nov 2005 04:42:16 +0000 (04:42 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1314 04897980-b3bd-0310-b5e0-8ef037075253

genevent-new/genevent.c
genevent-new/test.xml

index 118298ce7bf58fe9552c91ab40f03678425f9fd2..40cba10b1bd4346200a33ccd2e05fe89d9d7c1a7 100644 (file)
@@ -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 */
index a71ad8b916a31303318986f1e7f78c3910638554..34ca9b097e544e5d763e836194485129ef661587 100644 (file)
   </event>
 
        <event name=big_array>
-       <field name="myarray"><array size=10000><pointer></array></field>
+       <field name="myarray"><array size=10000>
+                       <array size = 2>
+                               <struct>
+                                       <field name=a><pointer></field>
+                                       <field name=b><union>
+                                                                                                       <field name=c><pointer></field>
+                                                                                               </union>
+                                       </field>
+                               </struct>
+                       </array></array></field>
        </event>
 
   <type name=tasklet_priority>
This page took 0.025352 seconds and 4 git commands to generate.