summaryrefslogtreecommitdiff
path: root/Source/CParse/cscanner.c
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CParse/cscanner.c')
-rw-r--r--Source/CParse/cscanner.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index de00e2b1f..d86c4590a 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -40,6 +40,9 @@ int cparse_cplusplus = 0;
/* Generate C++ compatible code when wrapping C code */
int cparse_cplusplusout = 0;
+/* To allow better error reporting */
+String *cparse_unknown_directive = 0;
+
/* Private vars */
static int scan_init = 0;
static int num_brace = 0;
@@ -147,7 +150,7 @@ String *get_raw_text_balanced(int startchar, int endchar) {
* friend ostream& operator<<(ostream&, const char *s);
*
* or
- * friend ostream& operator<<(ostream&, const char *s) { };
+ * friend ostream& operator<<(ostream&, const char *s) { }
*
* ------------------------------------------------------------------------- */
@@ -801,8 +804,11 @@ int yylex(void) {
if (strcmp(yytext, "inline") == 0)
return (yylex());
- /* SWIG directives */
} else {
+ Delete(cparse_unknown_directive);
+ cparse_unknown_directive = NULL;
+
+ /* SWIG directives */
if (strcmp(yytext, "%module") == 0)
return (MODULE);
if (strcmp(yytext, "%insert") == 0)
@@ -878,6 +884,9 @@ int yylex(void) {
}
if (strcmp(yytext, "%warn") == 0)
return (WARN);
+
+ /* Note down the apparently unknown directive for error reporting. */
+ cparse_unknown_directive = Swig_copy_string(yytext);
}
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */