From fc063e40663e33543deebe5e57d6847f2aca5da7 Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 8 Aug 2004 21:15:53 +0000 Subject: [PATCH] push back ltt_isalpha and ltt_isalnum, now static git-svn-id: http://ltt.polymtl.ca/svn@681 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/facility.c | 4 ++-- ltt/branches/poly/ltt/parser.c | 34 +++++++++++++++++++++++++------- ltt/branches/poly/ltt/parser.h | 4 ++-- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ltt/branches/poly/ltt/facility.c b/ltt/branches/poly/ltt/facility.c index 2964021d..f8e8962f 100644 --- a/ltt/branches/poly/ltt/facility.c +++ b/ltt/branches/poly/ltt/facility.c @@ -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; diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index e4917ce5..bee3b5f9 100644 --- a/ltt/branches/poly/ltt/parser.c +++ b/ltt/branches/poly/ltt/parser.c @@ -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; } /***************************************************************************** diff --git a/ltt/branches/poly/ltt/parser.h b/ltt/branches/poly/ltt/parser.h index c82493de..37dd38bb 100644 --- a/ltt/branches/poly/ltt/parser.h +++ b/ltt/branches/poly/ltt/parser.h @@ -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 */ -- 2.34.1