push back ltt_isalpha and ltt_isalnum, now static
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 8 Aug 2004 21:15:53 +0000 (21:15 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Sun, 8 Aug 2004 21:15:53 +0000 (21:15 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@681 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/facility.c
ltt/branches/poly/ltt/parser.c
ltt/branches/poly/ltt/parser.h

index 2964021ddc67a8edf7faf2d461b514f464970e1d..f8e8962ffdb089e33e8b4508d57e1f178cd232aa 100644 (file)
@@ -88,9 +88,9 @@ void ltt_facility_open(LttTrace * t, char * pathname)
       parseFacility(&in, fac);
 
       //check if any namedType is not defined
-      checkNamedTypesImplemented(&fac->named_types);
+      g_assert(checkNamedTypesImplemented(&fac->named_types) == 0);
     
-      generateChecksum(fac->name, &checksum, &fac->events);
+      g_assert(generateChecksum(fac->name, &checksum, &fac->events) == 0);
 
       f = g_new(LttFacility,1);    
       f->base_id = 0;
index e4917ce5d2166ab3a9e6acd4ddee5626c4257c49..bee3b5f98a6de52bc97d7c6271cfdb5a6590075e 100644 (file)
@@ -43,6 +43,21 @@ This program is distributed in the hope that it will be useful,
 #include "parser.h"
 
 
+static int ltt_isalpha(char c)
+{
+  int i,j;
+  if(c == '_')return 1;
+  i = c - 'a';
+  j = c - 'A';
+  if((i>=0 && i<26) || (j>=0 && j<26)) return 1;
+  return 0;
+}
+
+static int ltt_isalnum(char c)
+{
+  return (ltt_isalpha(c) || isdigit(c));
+}
+
 /*****************************************************************************
  *Function name
  *    getSize    : translate from string to integer
@@ -86,7 +101,6 @@ void error_callback(parse_file *in, char *msg)
     printf("Error in file %s, line %d: %s\n", in->name, in->lineno, msg);
   else
     printf("%s\n",msg);
-  exit(1);
 }
 
 /*****************************************************************************
@@ -816,11 +830,11 @@ char *getToken(parse_file * in)
         if(pos == BUFFER_SIZE) in->error(in, "number token too large");
         in->type = NUMBER;
       }    
-      else if(isalpha(car)) {
+      else if(ltt_isalpha(car)) {
         in->buffer[0] = car;
         pos = 1;
         while((car = getc(fp)) != EOF && pos < BUFFER_SIZE) {
-          if(!isalnum(car)) {
+          if(!ltt_isalnum(car)) {
             ungetc(car,fp);
             break;
           }
@@ -867,9 +881,10 @@ void skipEOL(parse_file * in)
 /*****************************************************************************
  *Function name
  *    checkNamedTypesImplemented : check if all named types have definition
+ *    returns -1 on error, 0 if ok
  ****************************************************************************/
 
-void checkNamedTypesImplemented(table * named_types)
+int checkNamedTypesImplemented(table * named_types)
 {
   type_descriptor *t;
   int pos;
@@ -878,10 +893,13 @@ void checkNamedTypesImplemented(table * named_types)
   for(pos = 0 ; pos < named_types->values.position; pos++) {
     t = (type_descriptor *) named_types->values.array[pos];
     if(t->type == NONE){
-      sprintf(str,"named type '%s' has no definition",(char*)named_types->keys.array[pos]);
-      error_callback(NULL,str);   
+      sprintf(str,"named type '%s' has no definition",
+              (char*)named_types->keys.array[pos]);
+      error_callback(NULL,str);
+      return -1;
     }
   }
+  return 0;
 }
 
 
@@ -894,7 +912,7 @@ void checkNamedTypesImplemented(table * named_types)
  *    checksum          : checksum for the facility
  ****************************************************************************/
 
-void generateChecksum( char* facName, unsigned long * checksum, sequence * events)
+int generateChecksum(char* facName, unsigned long * checksum, sequence * events)
 {
   unsigned long crc ;
   int pos;
@@ -909,10 +927,12 @@ void generateChecksum( char* facName, unsigned long * checksum, sequence * event
     if(ev->type->type != STRUCT){
       sprintf(str,"event '%s' has a type other than STRUCT",ev->name);
       error_callback(NULL, str);
+      return -1;
     }
     crc = getTypeChecksum(crc, ev->type);
   }
   *checksum = crc;
+  return 0;
 }
 
 /*****************************************************************************
index c82493de013ebb8f5326b88cdbbbcd302323912b..37dd38bb10bfeff71f3ba8850fa8b47ba8b6d5fc 100644 (file)
@@ -157,9 +157,9 @@ void parseEvent(parse_file *in, event_t *ev, sequence * unnamed_types, table * n
 void parseTypeDefinition(parse_file *in, sequence * unnamed_types, table * named_types);
 type_descriptor *parseType(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
 void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
-void checkNamedTypesImplemented(table * namedTypes);
+int checkNamedTypesImplemented(table * namedTypes);
 type_descriptor * find_named_type(char *name, table * named_types);
-void generateChecksum(char * facName, unsigned long * checksum, sequence * events);
+int generateChecksum(char * facName, unsigned long * checksum, sequence * events);
 
 
 /* get attributes */
This page took 0.028013 seconds and 4 git commands to generate.