genevent : -a bugfix
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 30 Jul 2005 15:50:07 +0000 (15:50 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sat, 30 Jul 2005 15:50:07 +0000 (15:50 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1003 04897980-b3bd-0310-b5e0-8ef037075253

genevent/genevent.c

index f2698bebba1d30f9eb7bb0c1fa9766f18c328fe7..67ecbd402d78a817a1ff3b0eac0c2aceae205a2f 100644 (file)
@@ -75,59 +75,59 @@ int main(int argc, char** argv)
   for(i = 1 ; i < argc ; i++) {
 
                if(strcmp("-a", argv[i])==0) {
-                       if(i < argc-1) {
+                       if(i >= argc-1) {
                                printf("Error : missing argument to -a\n");
                                exit(1);
                        } else i++;
                        alignment = atoi(argv[i]);
-               }
+               } else {
                
-    in.lineno = 0;
-    in.name = allocAndCopy(argv[i]);
-
-    in.fp = fopen(in.name, "r");
-    if(!in.fp ){
-      in.error(&in,"cannot open facility input file");
-    }
+                       in.lineno = 0;
+                       in.name = allocAndCopy(argv[i]);
 
-    while(1){
-      token = getToken(&in);
-      if(in.type == ENDFILE) break;
-
-      if(strcmp(token, "<")) in.error(&in,"not a facility file");
-      token = getName(&in);
-    
-      if(strcmp("facility",token) == 0) {
-        fac = memAlloc(sizeof(facility));
-        fac->name = NULL;
-        fac->description = NULL;
-        sequence_init(&(fac->events));
-        table_init(&(fac->named_types));
-        sequence_init(&(fac->unnamed_types));
-        
-        parseFacility(&in, fac);
-        
-        //check if any namedType is not defined
-        checkNamedTypesImplemented(&fac->named_types);
-      }
-      else in.error(&in,"facility token was expected");
-
-      generateFile(argv[i]);
-
-      free(fac->name);
-      free(fac->description);
-      freeEvents(&fac->events);
-      sequence_dispose(&fac->events);
-      freeNamedType(&fac->named_types);
-      table_dispose(&fac->named_types);
-      freeTypes(&fac->unnamed_types);
-      sequence_dispose(&fac->unnamed_types);      
-      free(fac);      
-    }
+                       in.fp = fopen(in.name, "r");
+                       if(!in.fp ){
+                               in.error(&in,"cannot open facility input file");
+                       }
 
-    free(in.name);
-    fclose(in.fp);
+                       while(1){
+                               token = getToken(&in);
+                               if(in.type == ENDFILE) break;
+
+                               if(strcmp(token, "<")) in.error(&in,"not a facility file");
+                               token = getName(&in);
+                       
+                               if(strcmp("facility",token) == 0) {
+                                       fac = memAlloc(sizeof(facility));
+                                       fac->name = NULL;
+                                       fac->description = NULL;
+                                       sequence_init(&(fac->events));
+                                       table_init(&(fac->named_types));
+                                       sequence_init(&(fac->unnamed_types));
+                                       
+                                       parseFacility(&in, fac);
+                                       
+                                       //check if any namedType is not defined
+                                       checkNamedTypesImplemented(&fac->named_types);
+                               }
+                               else in.error(&in,"facility token was expected");
+
+                               generateFile(argv[i]);
+
+                               free(fac->name);
+                               free(fac->description);
+                               freeEvents(&fac->events);
+                               sequence_dispose(&fac->events);
+                               freeNamedType(&fac->named_types);
+                               table_dispose(&fac->named_types);
+                               freeTypes(&fac->unnamed_types);
+                               sequence_dispose(&fac->unnamed_types);      
+                               free(fac);      
+                       }
 
+                       free(in.name);
+                       fclose(in.fp);
+               }
   }
   return 0;
 }
This page took 0.028168 seconds and 4 git commands to generate.