From 5bd59b2a4775e5f3aeb73ae12a5b329d1403c85e Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 11 Sep 2005 18:20:13 +0000 Subject: [PATCH] fix incomplete module name replacement when using the -module flag #1282637 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7428 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/CParse/parser.y | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/SWIG/Source/CParse/parser.y b/SWIG/Source/CParse/parser.y index c30ceeca6..69ec86740 100644 --- a/SWIG/Source/CParse/parser.y +++ b/SWIG/Source/CParse/parser.y @@ -166,6 +166,11 @@ static String *class_rename = 0; #define CPLUS_PRIVATE 2 #define CPLUS_PROTECTED 3 +/* include types */ +static int include_type = 0; +#define INCLUDE_MODE 1 +#define IMPORT_MODE 2 + void SWIG_typemap_lang(const char *tm_lang) { typemap_lang = Swig_copy_string(tm_lang); } @@ -1766,8 +1771,8 @@ include_directive: includetype options string LBRACKET { } ; -includetype : INCLUDE { $$.type = (char *) "include"; } - | IMPORT { $$.type = (char *) "import"; } +includetype : INCLUDE { $$.type = (char *) "include"; include_type = INCLUDE_MODE;} + | IMPORT { $$.type = (char *) "import"; include_type = IMPORT_MODE;} ; /* ------------------------------------------------------------ @@ -1872,7 +1877,14 @@ module_directive: MODULE options idstring { } } if (!ModuleName) ModuleName = NewString($3); - Setattr($$,"name",ModuleName); + if (include_type == INCLUDE_MODE) { + /* first module included, we apply global + ModuleName, which can be modify by -module */ + Setattr($$,"name",Copy(ModuleName)); + } else { + /* import mode, we just pass the idstring */ + Setattr($$,"name",$3); + } if (!module_node) module_node = $$; } ;