8d0d5287f55ebcea838f9e510a7fb32f6e5d4498 tdreszer Tue Apr 19 13:38:33 2011 -0700 startsWithWordByDelimit failed when the line only contained the word. diff --git src/lib/common.c src/lib/common.c index 0c263a5..17d875e 100644 --- src/lib/common.c +++ src/lib/common.c @@ -1400,31 +1400,34 @@ int len = strlen(firstWord); int i; for (i=0; i<len; ++i) if (firstWord[i] != line[i]) return FALSE; char c = line[len]; return c == 0 || isspace(c); } boolean startsWithWordByDelimiter(char *firstWord,char delimit, char *line) /* Return TRUE if first word in line is same as firstWord as delimited by delimit. Comparison is case sensitive. Delimit of ' ' uses isspace() */ { if(delimit == ' ') return startsWithWord(firstWord,line); -return (startsWith(firstWord,line) && line[strlen(firstWord)] == delimit); +if (!startsWith(firstWord,line)) + return FALSE; +char c = line[strlen(firstWord)]; +return (c == '\0' || c == delimit); } char * findWordByDelimiter(char *word,char delimit, char *line) /* Return pointer to first occurance of word in line broken by 'delimit' char Comparison is case sensitive. Delimit of ' ' uses isspace() */ { int ix; char *p=line; while(p!=NULL && *p!='\0') { for (ix = 0; word[ix] != '\0' && word[ix] == *p; ix++,p++); // advance as long as they match if(ix == strlen(word)) {