8cec4ba176d633ac375b32125ccebc9a3bdb883f tdreszer Fri Apr 15 22:52:50 2011 -0700 Checked in minor changes from Jim's review. Only think of consequence here is the dyStringLen macro had been using strlen, when the stringSize is part of the structure diff --git src/lib/ra.c src/lib/ra.c index 4d74908..3cb6a41 100644 --- src/lib/ra.c +++ src/lib/ra.c @@ -102,31 +102,32 @@ continue; // More to look forward to. } } dyStringAppend(dyFullLine,clippedText); break; } if (dyStringLen(dyFullLine) > 0) { line = dyStringContents(dyFullLine); *retTag = nextWord(&line); *retVal = trimSpaces(line); } return (*retTag != NULL); } -boolean raNextTagValUnjoined(struct lineFile *lf, char **retTag, char **retVal, struct dyString *dy) +boolean raNextTagValUnjoined(struct lineFile *lf, char **retTag, char **retVal, + struct dyString *dy) // NOTE: this is the former raNextTagVal routine is ignorant of continuation lines. // It is provided in case older RAs need it. // Read next line. Return FALSE at end of file or blank line. Otherwise // fill in *retTag and *retVal and return TRUE. // If dy parameter is non-null, then the text parsed gets appended to dy. { char *line; for (;;) { if (!lineFileNext(lf, &line, NULL)) return FALSE; char *tag = skipLeadingSpaces(line); if (tag[0] == 0) { if (dy) @@ -233,44 +234,46 @@ if (!stanzaStarted && clippedText[0] != 0 && clippedText[0] != '#') stanzaStarted = TRUE; // Comments don't start stanzas and may be followed by blanks } // build full lines dyStringAppend(dyUntouched,line); if (dyStringLen(dyFullLine) == 0) dyStringAppend(dyFullLine,line); // includes first line's whitespace. else if (clippedText[0] != '\0') dyStringAppend(dyFullLine,clippedText); // don't include continued line's leading spaces // Will the next line continue this one? if (clippedText[0] != '\0' && clippedText[0] != '#') // Comment lines can't be continued! { line = dyStringContents(dyFullLine); - char *lastChar = lastNonWhitespaceChar(line); + char *lastChar = lastNonwhitespaceChar(line); if (lastChar != NULL && *lastChar == '\\') { if (lastChar > line && *(lastChar - 1) != '\\') // Not an escaped continuation char { - dyStringResize(dyFullLine,(lastChar - line)); // This clips off the last char and any trailing white-space in dyString + // This clips off the last char and any trailing white-space in dyString + dyStringResize(dyFullLine,(lastChar - line)); dyStringAppendC(dyUntouched,'\n'); // Untouched lines delimited by newlines buildingContinuation = TRUE; continue; } } } if (buildingContinuation) - slPairAdd(&pairs, dyStringContents(dyFullLine), cloneString(dyStringContents(dyUntouched))); + slPairAdd(&pairs, dyStringContents(dyFullLine), + cloneString(dyStringContents(dyUntouched))); else slPairAdd(&pairs, dyStringContents(dyFullLine), NULL); // Ready to start the next full line dyStringClear(dyFullLine); dyStringClear(dyUntouched); buildingContinuation = FALSE; } slReverse(&pairs); dyStringFree(&dyFullLine); dyStringFree(&dyUntouched); return pairs; } struct hash *raFromString(char *string)