Fixed a bug with comments that don't have a newline after them.

This commit is contained in:
Brian Koropoff 2002-03-24 06:55:52 +00:00
parent 7c4cecd700
commit 807e7de22e

View file

@ -309,6 +309,7 @@ void
extract_line (dstring_t * buffer, dstring_t * line) extract_line (dstring_t * buffer, dstring_t * line)
{ {
int i, squotes = 0, dquotes = 0, braces = 0, n; int i, squotes = 0, dquotes = 0, braces = 0, n;
char *tmp;
for (i = 0; buffer->str[i]; i++) { for (i = 0; buffer->str[i]; i++) {
if (buffer->str[i] == '\'' && !escaped (buffer->str, i) if (buffer->str[i] == '\'' && !escaped (buffer->str, i)
@ -329,10 +330,12 @@ extract_line (dstring_t * buffer, dstring_t * line)
if (buffer->str[i] == '/' && buffer->str[i + 1] == '/' if (buffer->str[i] == '/' && buffer->str[i + 1] == '/'
&& !squotes && !dquotes) { && !squotes && !dquotes) {
// Filter out comments until newline // Filter out comments until newline
for (n = 0; if ((tmp = strchr (buffer->str+i, '\n')))
buffer->str[i + n] != '\n' && buffer->str[i + n] != '\r'; n = tmp - (buffer->str+i);
n++) else if ((tmp = strchr (buffer->str+i, '\r')))
; n = tmp - (buffer->str+i);
else
n = strlen(buffer->str+i); // snip till \0
dstring_snip (buffer, i, n); dstring_snip (buffer, i, n);
} }
if (buffer->str[i] == '\n' || buffer->str[i] == '\r') { if (buffer->str[i] == '\n' || buffer->str[i] == '\r') {