From 2547941ebe77f7a3c7fa3e6603ade1fd63eb6448 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Tue, 4 Mar 2003 02:41:45 +0000 Subject: [PATCH] Fixed William's weird typemap local variable replacement bug (I think). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4427 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typemap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index b65d9b515..a47e14b95 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -693,6 +693,15 @@ void replace_local_types(ParmList *p, String *name, String *rep) { } } +static +int check_locals(ParmList *p, const char *s) { + while (p) { + char *c = GetChar(p,"type"); + if (strstr(c,s)) return 1; + p = nextSibling(p); + } +} + static void typemap_replace_vars(String *s, ParmList *locals, SwigType *type, String *pname, String *lname, int index) { @@ -764,7 +773,7 @@ void typemap_replace_vars(String *s, ParmList *locals, SwigType *type, String *p sc = Char(s); - if (strstr(sc,"type")) { + if (strstr(sc,"type") || check_locals(locals,"type")) { /* Given type : $type */ ts = SwigType_str(type,0); if (index == 1) { @@ -777,7 +786,7 @@ void typemap_replace_vars(String *s, ParmList *locals, SwigType *type, String *p Delete(ts); sc = Char(s); } - if (strstr(sc,"ltype")) { + if (strstr(sc,"ltype") || check_locals(locals,"ltype")) { /* Local type: $ltype */ ltype = SwigType_ltype(type); ts = SwigType_str(ltype,0);