Strip C comments from the java typemaps when determining to use the premature garbage collection prevention parameter

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9982 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-10-12 21:31:22 +00:00
commit 2c46b7832c
3 changed files with 62 additions and 4 deletions

View file

@ -71,6 +71,51 @@ void Swig_banner(File *f) {
}
/* -----------------------------------------------------------------------------
* Swig_strip_c_comments()
*
* Return a new string with C comments stripped from the input string. Null is
* returned if there aren't any.
* ----------------------------------------------------------------------------- */
String *Swig_strip_c_comments(const String *s) {
const char *c = Char(s);
const char *comment_begin = 0;
const char *comment_end = 0;
while (*c) {
if (!comment_begin && *c == '/') {
++c;
if (!*c)
break;
if (*c == '*')
comment_begin = c-1;
} else if (comment_begin && !comment_end && *c == '*') {
++c;
if (*c == '/')
comment_end = c;
break;
}
++c;
}
String *stripped = 0;
if (comment_begin && comment_end) {
int size = comment_begin - Char(s);
stripped = NewStringWithSize(s, size);
Printv(stripped, comment_end + 1, NIL);
String *stripmore = 0;
do {
stripmore = Swig_strip_c_comments(stripped);
if (stripmore) {
Delete(stripped);
stripped = stripmore;
}
} while (stripmore);
}
return stripped;
}
/* -----------------------------------------------------------------------------
* Swig_string_escape()
*

View file

@ -281,6 +281,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_set_fakeversion(const char *version);
extern const char *Swig_package_version(void);
extern void Swig_banner(File *f);
extern String *Swig_strip_c_comments(const String *s);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(String *s, String **prefix, String **last);