Fixed bug in preprocessor expression evaluator. (backslash).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5632 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b44aafbe68
commit
acee037c44
1 changed files with 16 additions and 3 deletions
|
|
@ -200,6 +200,19 @@ Preprocessor_expr_init (void) {
|
||||||
if (!scan) scan = NewSwigScanner();
|
if (!scan) scan = NewSwigScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Tokenizer
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static int expr_token(SwigScanner *s) {
|
||||||
|
int t;
|
||||||
|
while(1) {
|
||||||
|
t = SwigScanner_token(s);
|
||||||
|
if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE))) break;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Preprocessor_expr()
|
* Preprocessor_expr()
|
||||||
*
|
*
|
||||||
|
|
@ -230,7 +243,7 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
switch(stack[sp].op) {
|
switch(stack[sp].op) {
|
||||||
case EXPR_TOP:
|
case EXPR_TOP:
|
||||||
/* An expression. Can be a number or another expression enclosed in parens */
|
/* An expression. Can be a number or another expression enclosed in parens */
|
||||||
token = SwigScanner_token(scan);
|
token = expr_token(scan);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
errmsg = "Expected an expression";
|
errmsg = "Expected an expression";
|
||||||
*error = 1;
|
*error = 1;
|
||||||
|
|
@ -267,7 +280,7 @@ Preprocessor_expr(DOH *s, int *error) {
|
||||||
break;
|
break;
|
||||||
case EXPR_VALUE:
|
case EXPR_VALUE:
|
||||||
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
||||||
token = SwigScanner_token(scan);
|
token = expr_token(scan);
|
||||||
if (!token) {
|
if (!token) {
|
||||||
/* End of input. Might have to reduce if an operator is on stack */
|
/* End of input. Might have to reduce if an operator is on stack */
|
||||||
while (sp > 0) {
|
while (sp > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue