diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 53e02f723..cf5b65dd1 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -264,10 +264,8 @@ int yylook(void) { while (1) { if ((tok = Scanner_token(scan)) == 0) return 0; - if (tok == SWIG_TOKEN_ERROR) { - Swig_error(Scanner_file(scan), Scanner_errline(scan), Scanner_errmsg(scan)); - continue; - } + if (tok == SWIG_TOKEN_ERROR) + return 0; cparse_start_line = Scanner_start_line(scan); cparse_line = Scanner_line(scan); cparse_file = Scanner_file(scan); diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 7ca5b3ea8..28c512683 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -15,6 +15,9 @@ char cvsroot_scanner_c[] = "$Id$"; #include "swig.h" #include +extern String *cparse_file; +extern int cparse_start_line; + struct Scanner { String *text; /* Current token value */ List *scanobjs; /* Objects being scanned */ @@ -536,7 +539,7 @@ static int look(Scanner * s) { break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated comment"); + Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { @@ -548,7 +551,7 @@ static int look(Scanner * s) { break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated comment"); + Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { @@ -559,7 +562,7 @@ static int look(Scanner * s) { break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated comment"); + Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { @@ -573,7 +576,7 @@ static int look(Scanner * s) { case 2: /* Processing a string */ if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line, "Unterminated string"); + Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { @@ -656,7 +659,7 @@ static int look(Scanner * s) { case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated code block"); + Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') @@ -933,7 +936,7 @@ static int look(Scanner * s) { /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated character constant"); + Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { @@ -1048,7 +1051,7 @@ static int look(Scanner * s) { /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { - set_error(s,s->start_line,"Unterminated character constant"); + Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') {