From: Marcelo M. <mar...@us...> - 2006-01-10 23:16:44
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3537/Source/Swig Modified Files: misc.c Log Message: add the utitle encoder, the reverse of ctitle Index: misc.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/misc.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** misc.c 2 Jan 2006 04:33:18 -0000 1.36 --- misc.c 10 Jan 2006 23:16:36 -0000 1.37 *************** *** 181,184 **** --- 181,210 ---- /* ----------------------------------------------------------------------------- + * Swig_string_utitle() + * + * This is the reverse case of ctitle, ie + * + * CamelCase -> camel_case + * ----------------------------------------------------------------------------- */ + + String *Swig_string_utitle(String *s) { + String *ns; + int first = 0; + int c; + ns = NewStringEmpty(); + + Seek(s,0,SEEK_SET); + while ((c = Getc(s)) != EOF) { + if (isupper(c)) { + if (!first) Putc('_',ns); + first = 1; + continue; + } + Putc(tolower(c),ns); + } + return ns; + } + + /* ----------------------------------------------------------------------------- * Swig_string_typecode() * *************** *** 697,700 **** --- 723,727 ---- DohEncoding("title", Swig_string_title); DohEncoding("ctitle", Swig_string_ctitle); + DohEncoding("utitle", Swig_string_utitle); DohEncoding("typecode",Swig_string_typecode); DohEncoding("mangle",Swig_string_emangle); |