version 1.498, 2020/12/19 15:29:28 |
version 1.499, 2020/12/19 16:05:33 |
Line 2791 typedef enum GetLineMode { |
|
Line 2791 typedef enum GetLineMode { |
|
* Backslash line continuations are folded into a single space. |
* Backslash line continuations are folded into a single space. |
* A trailing comment, if any, is discarded. |
* A trailing comment, if any, is discarded. |
*/ |
*/ |
PARSE_NORMAL, |
GLM_NONEMPTY, |
|
|
/* |
/* |
* Return the next line, even if it is empty or a comment. |
* Return the next line, even if it is empty or a comment. |
|
* Preserve backslash-newline to keep the line numbers correct. |
* |
* |
* Used in .for loops to collect the body of the loop while waiting |
* Used in .for loops to collect the body of the loop while waiting |
* for the corresponding .endfor. |
* for the corresponding .endfor. |
*/ |
*/ |
PARSE_RAW, |
GLM_FOR_BODY, |
|
|
/* |
/* |
* Return the next line that is a directive. |
* Return the next line that starts with a dot. |
* Backslash line continuations are folded into a single space. |
* Backslash line continuations are folded into a single space. |
* A trailing comment, if any, is discarded. |
* A trailing comment, if any, is discarded. |
* |
* |
* Used in .if directives to skip over irrelevant branches while |
* Used in .if directives to skip over irrelevant branches while |
* waiting for the corresponding .endif. |
* waiting for the corresponding .endif. |
*/ |
*/ |
PARSE_SKIP |
GLM_DOT |
} GetLineMode; |
} GetLineMode; |
|
|
/* Return the next "interesting" logical line from the current file. */ |
/* Return the next "interesting" logical line from the current file. */ |
Line 2832 ParseGetLine(GetLineMode mode) |
|
Line 2833 ParseGetLine(GetLineMode mode) |
|
if (line_end == line || firstComment == line) { |
if (line_end == line || firstComment == line) { |
if (res == PRLR_EOF) |
if (res == PRLR_EOF) |
return NULL; |
return NULL; |
if (mode != PARSE_RAW) |
if (mode != GLM_FOR_BODY) |
continue; |
continue; |
} |
} |
|
|
/* We now have a line of data */ |
/* We now have a line of data */ |
*line_end = '\0'; |
*line_end = '\0'; |
|
|
if (mode == PARSE_RAW) { |
if (mode == GLM_FOR_BODY) |
/* Leave '\' (etc) in line buffer (eg 'for' lines) */ |
return line; /* Don't join the physical lines. */ |
return line; |
|
} |
|
|
|
if (mode == PARSE_SKIP) { |
if (mode == GLM_DOT && line[0] != '.') |
/* Completely ignore non-directives */ |
continue; |
if (line[0] != '.') |
|
continue; |
|
/* |
|
* We could do more of the .else/.elif/.endif checks |
|
* here. |
|
*/ |
|
} |
|
break; |
break; |
} |
} |
|
|
Line 2891 ParseReadLine(void) |
|
Line 2883 ParseReadLine(void) |
|
int rval; |
int rval; |
|
|
for (;;) { |
for (;;) { |
line = ParseGetLine(PARSE_NORMAL); |
line = ParseGetLine(GLM_NONEMPTY); |
if (line == NULL) |
if (line == NULL) |
return NULL; |
return NULL; |
|
|
Line 2904 ParseReadLine(void) |
|
Line 2896 ParseReadLine(void) |
|
*/ |
*/ |
switch (Cond_EvalLine(line)) { |
switch (Cond_EvalLine(line)) { |
case COND_SKIP: |
case COND_SKIP: |
while ((line = ParseGetLine(PARSE_SKIP)) != NULL) { |
while ((line = ParseGetLine(GLM_DOT)) != NULL) { |
if (Cond_EvalLine(line) == COND_PARSE) |
if (Cond_EvalLine(line) == COND_PARSE) |
break; |
break; |
/* |
/* |
Line 2939 ParseReadLine(void) |
|
Line 2931 ParseReadLine(void) |
|
lineno = CurFile()->lineno; |
lineno = CurFile()->lineno; |
/* Accumulate loop lines until matching .endfor */ |
/* Accumulate loop lines until matching .endfor */ |
do { |
do { |
line = ParseGetLine(PARSE_RAW); |
line = ParseGetLine(GLM_FOR_BODY); |
if (line == NULL) { |
if (line == NULL) { |
Parse_Error(PARSE_FATAL, |
Parse_Error(PARSE_FATAL, |
"Unexpected end of file " |
"Unexpected end of file " |