Changed internal handling of string literals. Added new typemap specification syntax with strings.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@704 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-08-28 20:15:08 +00:00
commit b746069e7d
10 changed files with 219 additions and 107 deletions

View file

@ -13,6 +13,7 @@ static char cvsroot[] = "$Header$";
#include "swig.h"
#include "swigver.h"
#include <ctype.h>
/* -----------------------------------------------------------------------------
* Swig_copy_string()
@ -99,5 +100,39 @@ DOH *Swig_temp_result(DOH *x) {
return x;
}
/* -----------------------------------------------------------------------------
* Swig_string_escape()
*
* Takes a string object and produces a string with escape codes added to it.
* ----------------------------------------------------------------------------- */
String *Swig_string_escape(String *s) {
String *ns;
int c;
ns = NewString("");
while ((c = Getc(s)) != EOF) {
if (c == '\n') {
Printf(ns,"\\n");
} else if (c == '\r') {
Printf(ns,"\\r");
} else if (c == '\t') {
Printf(ns,"\\t");
} else if (c == '\\') {
Printf(ns,"\\\\");
} else if (c == '\'') {
Printf(ns,"\\'");
} else if (c == '\"') {
Printf(ns,"\\\"");
} else if (c == ' ') {
Putc(c,ns);
} else if (!isgraph(c)) {
Printf(ns,"\\0%o", c);
} else {
Putc(c,ns);
}
}
return ns;
}

View file

@ -277,6 +277,7 @@ extern DOH *Swig_map_match(Hash *ruleset, Hash *parms, int *nmatch);
extern char *Swig_copy_string(const char *c);
extern void Swig_banner(File *f);
extern DOH *Swig_temp_result(DOH *x);
extern String *Swig_string_escape(String *s);
/* --- C Wrappers --- */
extern String *Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value);