From a95c468076ffb9afdf5f768b8f5b64b42607ca5a Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 17 Mar 2004 08:27:02 +0000 Subject: [PATCH] Using the unused 'Swig_string_mangle' method to implement the #@ preprocessor mangling git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5751 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index b05c6bdaa..81bb37ca5 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -196,6 +196,7 @@ String *Swig_string_typecode(String *s) { * ----------------------------------------------------------------------------- */ String *Swig_string_mangle(String *s) { +#if 0 String *t = Copy(s); char *c = Char(t); while (*c) { @@ -203,6 +204,57 @@ String *Swig_string_mangle(String *s) { c++; } return t; +#else + char *pc; + String *b = Copy(s); + if (SwigType_istemplate(b)) { + String *t = SwigType_namestr(b); + Delete(b); + b = t ; + } + pc = Char(b); + String *result = NewString(""); + int space = 0; + int state = 0; + while (*pc) { + char c = *pc; + if (isalnum((int)c)) { + state = 1; + if (space && (space == state)) { + Printf(result,"_b"); + } + space = 0; + Printf(result,"%c",c); + } else { + if (isspace((int)c)) { + space = state; + ++pc; + continue; + } else { + state = 3; + space = 0; + } + if (c == '*') c = 'p'; + else if (c == '&') c = 'R'; + else if (c == ':') c = 's'; + else if (c == ',') c = 'c'; + else if (c == '<') c = 't'; + else if (c == '>') c = 'T'; + else if (c == '[') c = 'a'; + else if (c == ']') c = 'A'; + else if (c == '(') c = 'f'; + else if (c == ')') c = 'F'; + if (isalpha((int)c)) { + Printf(result,"_%c",(int)c); + } else{ + Printf(result,"_%02X",(int)c); + } + } + ++pc; + } + Delete(b); + return result; +#endif } /* -----------------------------------------------------------------------------