Preserve "\n" in continued lines.

Set a flag if parser encounters [expr].
This commit is contained in:
David F. Skoll
2008-03-15 14:06:12 -04:00
parent d818dd9c80
commit af81bbb299
3 changed files with 5 additions and 2 deletions

View File

@@ -140,7 +140,7 @@ static int ReadLineFromFile(void)
}
l = DBufLen(&buf);
if (l && (DBufValue(&buf)[l-1] == '\\')) {
DBufValue(&buf)[l-1] = 0;
DBufValue(&buf)[l-1] = '\n';
if (DBufPuts(&LineBuffer, DBufValue(&buf)) != OK) {
DBufFree(&buf);
DBufFree(&LineBuffer);

View File

@@ -345,6 +345,7 @@ int ParseChar(ParsePtr p, int *err, int peek)
return *(p->pos++);
}
}
p->expr_happened = 1;
p->pos++;
r = EvalExpr(&(p->pos), &val);
if (r) {
@@ -563,6 +564,7 @@ void CreateParser(char const *s, ParsePtr p)
p->etext = NULL;
p->allownested = 1;
p->tokenPushed = NULL;
p->expr_happened = 0;
DBufInit(&p->pushedToken);
}

View File

@@ -71,7 +71,7 @@ typedef struct {
/* The parse pointer */
typedef struct {
char isnested; /* Is it a nested expression? */
char isnested; /* Is it a nested expression? */
char allownested;
char const *text; /* Start of text */
char const *pos; /* Current position */
@@ -79,6 +79,7 @@ typedef struct {
char const *epos; /* Position in substituted text */
DynamicBuffer pushedToken; /* Pushed-back token */
char const *tokenPushed; /* NULL if no pushed-back token */
char expr_happened; /* Did we encounter an [expression] ? */
} Parser;
typedef Parser *ParsePtr; /* Pointer to parser structure */