Remove old experimental rxspencer encoder and rxsmatch function.
They are replaced with the new, officially supported PCRE-based regex and regexmatch. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12175 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
70c5bb5a47
commit
587d843521
6 changed files with 17 additions and 181 deletions
|
|
@ -9,6 +9,17 @@ Version 2.0.1 (in progress)
|
|||
Fix wrapping of function pointers and member function pointers when the function
|
||||
returns by reference.
|
||||
|
||||
2010-07-13: vadz
|
||||
Removed support for the old experimental "rxspencer" encoder and
|
||||
"[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
|
||||
officially supported "regex" encoder and "[not]regexmatch" checks
|
||||
should be used instead (see the two previous entries). Please
|
||||
replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
|
||||
when upgrading. Notice that you will also need to replace the back-
|
||||
references of form "@1" with the more standard "\\1" and may need to
|
||||
adjust your regular expressions syntax as the new regex encoder uses
|
||||
Perl-compatible syntax and not (extended) POSIX syntax as the old one.
|
||||
|
||||
2010-07-13: vadz
|
||||
Add "regexmatch", "regextarget" and "notregexmatch" which can be
|
||||
used to apply %rename directives to the declarations matching the
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
|
||||
|
||||
// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code
|
||||
// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
|
||||
%rename(May) M_May;
|
||||
%rename(May) S_May;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
%rename(awk_cmd) "";
|
||||
|
||||
%rename("%(title)s",rxsmatch$parentNode$type="enum .*") "";
|
||||
%rename("%(title)s",regexmatch$parentNode$type="enum .*") "";
|
||||
|
||||
%inline
|
||||
{
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
}
|
||||
|
||||
%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) "";
|
||||
%rename("%(lowercase)s",sourcefmt="%(regex:/GSL_(.*)/\\1/)s",%$isfunction) "";
|
||||
%inline {
|
||||
void GSL_Hello() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1108,112 +1108,6 @@ String *Swig_string_strip(String *s) {
|
|||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_rxspencer()
|
||||
*
|
||||
* Executes a regexp substitution via the RxSpencer library. For example:
|
||||
*
|
||||
* Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
|
||||
const char *skip_delim(char pb, char pe, const char *ce) {
|
||||
int end = 0;
|
||||
int lb = 0;
|
||||
while (!end && *ce != '\0') {
|
||||
if (*ce == pb) {
|
||||
++lb;
|
||||
}
|
||||
if (*ce == pe) {
|
||||
if (!lb) {
|
||||
end = 1;
|
||||
--ce;
|
||||
} else {
|
||||
--lb;
|
||||
}
|
||||
}
|
||||
++ce;
|
||||
}
|
||||
return end ? ce : 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
String *res = 0;
|
||||
if (Len(s)) {
|
||||
const char *cs = Char(s);
|
||||
const char *cb;
|
||||
const char *ce;
|
||||
if (*cs == '[') {
|
||||
int retval;
|
||||
regex_t compiled;
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
char bregexp[512];
|
||||
strncpy(bregexp, cb, ce - cb);
|
||||
bregexp[ce - cb] = '\0';
|
||||
++ce;
|
||||
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
|
||||
if (retval == 0) {
|
||||
cs = ce;
|
||||
if (*cs == '[') {
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
const char *cvalue = ce + 1;
|
||||
int nsub = (int) compiled.re_nsub + 1;
|
||||
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
|
||||
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
|
||||
if (retval != REG_NOMATCH) {
|
||||
char *spos = 0;
|
||||
res = NewStringWithSize(cb, ce - cb);
|
||||
spos = Strchr(res, '@');
|
||||
while (spos) {
|
||||
char cd = *(++spos);
|
||||
if (isdigit(cd)) {
|
||||
char arg[8];
|
||||
size_t len;
|
||||
int i = cd - '0';
|
||||
sprintf(arg, "@%d", i);
|
||||
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
|
||||
char value[256];
|
||||
strncpy(value, cvalue + pmatch[i].rm_so, len);
|
||||
value[len] = 0;
|
||||
Replaceall(res, arg, value);
|
||||
} else {
|
||||
Replaceall(res, arg, "");
|
||||
}
|
||||
spos = Strchr(res, '@');
|
||||
} else if (cd == '@') {
|
||||
spos = strchr(spos + 1, '@');
|
||||
}
|
||||
}
|
||||
}
|
||||
free(pmatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
regfree(&compiled);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!res)
|
||||
res = NewStringEmpty();
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
(void) s;
|
||||
return NewStringEmpty();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
|
|
@ -1338,7 +1232,6 @@ void Swig_init() {
|
|||
DohEncoding("typecode", Swig_string_typecode);
|
||||
DohEncoding("mangle", Swig_string_emangle);
|
||||
DohEncoding("command", Swig_string_command);
|
||||
DohEncoding("rxspencer", Swig_string_rxspencer);
|
||||
DohEncoding("schemify", Swig_string_schemify);
|
||||
DohEncoding("strip", Swig_string_strip);
|
||||
DohEncoding("regex", Swig_string_regex);
|
||||
|
|
|
|||
|
|
@ -1061,13 +1061,10 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|
|||
if (ckey) {
|
||||
const char **rkey;
|
||||
int isnotmatch = 0;
|
||||
int isrxsmatch = 0;
|
||||
int isregexmatch = 0;
|
||||
if ((strncmp(ckey, "match", 5) == 0)
|
||||
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
|
||||
|| (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
|
||||
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|
||||
|| (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))
|
||||
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
|
||||
Hash *mi = NewHash();
|
||||
List *attrlist = Swig_make_attrlist(ckey);
|
||||
|
|
@ -1075,14 +1072,8 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|
|||
matchlist = NewList();
|
||||
Setattr(mi, "value", Getattr(kw, "value"));
|
||||
Setattr(mi, "attrlist", attrlist);
|
||||
#ifdef SWIG_DEBUG
|
||||
if (isrxsmatch)
|
||||
Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
|
||||
#endif
|
||||
if (isnotmatch)
|
||||
SetFlag(mi, "notmatch");
|
||||
if (isrxsmatch)
|
||||
SetFlag(mi, "rxsmatch");
|
||||
if (isregexmatch)
|
||||
SetFlag(mi, "regexmatch");
|
||||
Delete(attrlist);
|
||||
|
|
@ -1205,37 +1196,6 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
|
|||
|
||||
#endif /* HAVE_PCRE/!HAVE_PCRE */
|
||||
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
int match = 0;
|
||||
char *cvalue = Char(value);
|
||||
char *cmvalue = Char(mvalue);
|
||||
regex_t compiled;
|
||||
int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
|
||||
if (retval != 0)
|
||||
return 0;
|
||||
retval = regexec(&compiled, cvalue, 0, 0, 0);
|
||||
match = (retval == REG_NOMATCH) ? 0 : 1;
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
|
||||
#endif
|
||||
regfree(&compiled);
|
||||
return match;
|
||||
}
|
||||
#else
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
(void) mvalue;
|
||||
(void) value;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int Swig_name_match_value(String *mvalue, String *value) {
|
||||
#if defined(SWIG_USE_SIMPLE_MATCHOR)
|
||||
int match = 0;
|
||||
|
|
@ -1277,19 +1237,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
|
|||
List *lattr = Getattr(mi, "attrlist");
|
||||
String *nval = Swig_get_lattr(n, lattr);
|
||||
int notmatch = GetFlag(mi, "notmatch");
|
||||
int rxsmatch = GetFlag(mi, "rxsmatch");
|
||||
int regexmatch = GetFlag(mi, "regexmatch");
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
|
||||
if (rxsmatch) {
|
||||
Printf(stdout, "rxsmatch %s\n", lattr);
|
||||
}
|
||||
#endif
|
||||
match = 0;
|
||||
if (nval) {
|
||||
String *kwval = Getattr(mi, "value");
|
||||
match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
|
||||
: regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
|
||||
match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
|
||||
: Swig_name_match_value(kwval, nval);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
|
||||
|
|
@ -1329,7 +1281,6 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
String *sfmt = Getattr(rn, "sourcefmt");
|
||||
String *sname = 0;
|
||||
int fullname = GetFlag(rn, "fullname");
|
||||
int rxstarget = GetFlag(rn, "rxstarget");
|
||||
int regextarget = GetFlag(rn, "regextarget");
|
||||
if (sfmt) {
|
||||
if (fullname && prefix) {
|
||||
|
|
@ -1347,8 +1298,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
DohIncref(name);
|
||||
}
|
||||
}
|
||||
match = rxstarget ? Swig_name_rxsmatch_value(tname, sname)
|
||||
: regextarget ? Swig_name_regexmatch_value(n, tname, sname)
|
||||
match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
|
||||
: Swig_name_match_value(tname, sname);
|
||||
Delete(sname);
|
||||
} else {
|
||||
|
|
@ -1448,7 +1398,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
|
|||
|
||||
ParmList *declparms = declaratorparms;
|
||||
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", "regextarget", 0 };
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
|
||||
Swig_name_object_attach_keys(rename_keys, newname);
|
||||
|
||||
/* Add the name */
|
||||
|
|
|
|||
18
configure.in
18
configure.in
|
|
@ -73,24 +73,6 @@ AS_IF([test "x$with_pcre" != xno],
|
|||
])
|
||||
|
||||
|
||||
dnl Look for RxSpencer
|
||||
AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes")
|
||||
if test x"${with_rxspencer}" = xyes ; then
|
||||
#check first for the header
|
||||
AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no")
|
||||
if test x"${with_rxspencer}" = xyes ; then
|
||||
# now check for the library
|
||||
AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no")
|
||||
fi
|
||||
if test x"${with_rxspencer}" = xyes ; then
|
||||
# library and header are available
|
||||
AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available])
|
||||
LIBS="$LIBS -lrxspencer"
|
||||
else
|
||||
AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl CCache
|
||||
AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes])
|
||||
AC_MSG_CHECKING([whether to enable ccache-swig])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue