applied patch 890642: wxRE_ADVANCED flag and docs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25866 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-02-19 16:57:15 +00:00
parent 3ca4086b22
commit 1701c4d421
5 changed files with 399 additions and 261 deletions

View File

@@ -31,9 +31,9 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************** **********************************************************************
PostgreSQL adopted the code out of Tcl 8.4.1. Portions of regc_locale.c wxWindows adopted the code out of Tcl 8.4.5. Portions of regc_locale.c
and re_syntax.n were developed by Tcl developers other than Henry; these and re_syntax.n were developed by Tcl developers other than Henry Spencer;
files bear the Tcl copyright and license notice: these files bear the Tcl copyright and license notice:
********************************************************************** **********************************************************************
@@ -80,31 +80,7 @@ terms specified in this license.
********************************************************************** **********************************************************************
Subsequent modifications to the code by the PostgreSQL project follow The wxWindows license applies to further modifications to regcustom.h
the same license terms as the rest of PostgreSQL. and regc_locale.c.
(License follows)
****************************************************************************
PostgreSQL Database Management System
(formerly known as Postgres, then as Postgres95)
Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this
paragraph and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
**************************************************************************** ****************************************************************************

View File

@@ -1,69 +1,41 @@
wxWindows regex wxWindows regex
---------------- ---------------
This is a version of Henry Spencer's regex, This is a version of Henry Spencer's regex, which was taken from the
which was taken from postresql, which was source of TCL (Toolkit Command Language). It implements POSIX regular
taken from the source of TCL (Toolkit Command Language). expressions and also supports Unicode and some Perl5 extensions.
This is version of Henry Spencer's library is The modifications made by the wxWindows team are as follows:
modified by the wxWindows team. The modifications
made by the wxWindows team are as follows:
regcustom.h (all source code)
regex.h (function wrappers, other)
regc_locale.c (A function or two).
All the rest (Using standard c library routines instead of
postresql routines, various cleanup/optimizations)
The source code that is wxWindows-specific is as follows: regcustom.h
regcustom.h (all source code, see comments in source on how to replace) -----------
regex.h (where noted with comments in source, compiler workarounds) Types and constants appropriate for our use of the library are defined
regcomp.c (a few of the functions prefixed with wx_, here.
these may be replaced by c library routines)
This newer library was chosen over the old one because regex.h
Henry Spencer's old library did not support unicode and -------
had some other bugs that were fixed by this one, and This is unmodified. Note though, that a portion of it (clearly marked)
the license was incompatible with the wxWindows license is copied from regcustom.h as part of the build process.
and the gpl.
Regular Expression syntax documentation is in re_syntax.n. regc_locale.c
Programming information (from older regex, but with -------------
the function wrappers implemented in the wxWindows This module provides character classifications.
version, the usage is somewhat the same) is in regex.3.
Modifications made by the wxWindows team are not licensed. The current version from Tcl supports only a Unicode build. The
Contact - Ryan Norton <wxprojects@comcast.net> original code from Henry Spencer, on the other hand, was ASCII only.
Therefore, in order to support both, code from the ASCII version has been
incorporated into the Unicode version, conditionally compiled depending
on wxUSE_UNICODE.
The original readme (from the TCL distribution) follows: The only non-trivial dependencies were: Tcl_UniCharToUpper,
Tcl_UniCharToLower and Tcl_UniCharToTitle. The implementations of these
have also been incorporated (from Tcl). These in turn depend only the data
tables in tclUniData.c (which is unmodified). At some point wxWindows
may have it's own Unicode character classification code, at which point
these should be used instead.
alpha3.8 release. Other dependencies (on Tcl_DString) have been eliminated using wxWindows
Tue Aug 10 15:51:48 EDT 1999 wxChar functions.
henry@spsystems.net (formerly henry@zoo.toronto.edu)
See WHATSNEW for change listing. The ASCII version has also been extended to support character
classifications based on the current locale rather than ASCII only.
installation notes:
--------
Read the comments at the beginning of Makefile before running.
Utils.h contains some things that just might have to be modified on
some systems, as well as a nested include (ugh) of <assert.h>.
The "fake" directory contains quick-and-dirty fakes for some header
files and routines that old systems may not have. Note also that
-DUSEBCOPY will make utils.h substitute bcopy() for memmove().
After that, "make r" will build regcomp.o, regexec.o, regfree.o,
and regerror.o (the actual routines), bundle them together into a test
program, and run regression tests on them. No output is good output.
"make lib" builds just the .o files for the actual routines (when
you're happy with testing and have adjusted CFLAGS for production),
and puts them together into libregex.a. You can pick up either the
library or *.o ("make lib" makes sure there are no other .o files left
around to confuse things).
Main.c, debug.c, split.c are used for regression testing but are not part
of the RE routines themselves.
Regex.h goes in /usr/include. All other .h files are internal only.
--------

View File

@@ -10,112 +10,120 @@
* of this file, and for a DISCLAIMER OF ALL WARRANTIES. * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* *
* RCS: @(#) $Id$ * RCS: @(#) $Id$
*
* wxWindows:
* The Scriptics license can be found in the file COPYRIGHT. Modifications
* for wxWindows are under the wxWindows licence, see README for details.
*/ */
#define CONST const
/* ASCII character-name table */ /* ASCII character-name table */
static struct cname { static struct cname {
char *name; chr *name;
char code; char code;
} cnames[] = { } cnames[] = {
{"NUL", '\0'}, {_T("NUL"), '\0'},
{"SOH", '\001'}, {_T("SOH"), '\001'},
{"STX", '\002'}, {_T("STX"), '\002'},
{"ETX", '\003'}, {_T("ETX"), '\003'},
{"EOT", '\004'}, {_T("EOT"), '\004'},
{"ENQ", '\005'}, {_T("ENQ"), '\005'},
{"ACK", '\006'}, {_T("ACK"), '\006'},
{"BEL", '\007'}, {_T("BEL"), '\007'},
{"alert", '\007'}, {_T("alert"), '\007'},
{"BS", '\010'}, {_T("BS"), '\010'},
{"backspace", '\b'}, {_T("backspace"), '\b'},
{"HT", '\011'}, {_T("HT"), '\011'},
{"tab", '\t'}, {_T("tab"), '\t'},
{"LF", '\012'}, {_T("LF"), '\012'},
{"newline", '\n'}, {_T("newline"), '\n'},
{"VT", '\013'}, {_T("VT"), '\013'},
{"vertical-tab", '\v'}, {_T("vertical-tab"), '\v'},
{"FF", '\014'}, {_T("FF"), '\014'},
{"form-feed", '\f'}, {_T("form-feed"), '\f'},
{"CR", '\015'}, {_T("CR"), '\015'},
{"carriage-return", '\r'}, {_T("carriage-return"), '\r'},
{"SO", '\016'}, {_T("SO"), '\016'},
{"SI", '\017'}, {_T("SI"), '\017'},
{"DLE", '\020'}, {_T("DLE"), '\020'},
{"DC1", '\021'}, {_T("DC1"), '\021'},
{"DC2", '\022'}, {_T("DC2"), '\022'},
{"DC3", '\023'}, {_T("DC3"), '\023'},
{"DC4", '\024'}, {_T("DC4"), '\024'},
{"NAK", '\025'}, {_T("NAK"), '\025'},
{"SYN", '\026'}, {_T("SYN"), '\026'},
{"ETB", '\027'}, {_T("ETB"), '\027'},
{"CAN", '\030'}, {_T("CAN"), '\030'},
{"EM", '\031'}, {_T("EM"), '\031'},
{"SUB", '\032'}, {_T("SUB"), '\032'},
{"ESC", '\033'}, {_T("ESC"), '\033'},
{"IS4", '\034'}, {_T("IS4"), '\034'},
{"FS", '\034'}, {_T("FS"), '\034'},
{"IS3", '\035'}, {_T("IS3"), '\035'},
{"GS", '\035'}, {_T("GS"), '\035'},
{"IS2", '\036'}, {_T("IS2"), '\036'},
{"RS", '\036'}, {_T("RS"), '\036'},
{"IS1", '\037'}, {_T("IS1"), '\037'},
{"US", '\037'}, {_T("US"), '\037'},
{"space", ' '}, {_T("space"), ' '},
{"exclamation-mark",'!'}, {_T("exclamation-mark"), '!'},
{"quotation-mark", '"'}, {_T("quotation-mark"), '"'},
{"number-sign", '#'}, {_T("number-sign"), '#'},
{"dollar-sign", '$'}, {_T("dollar-sign"), '$'},
{"percent-sign", '%'}, {_T("percent-sign"), '%'},
{"ampersand", '&'}, {_T("ampersand"), '&'},
{"apostrophe", '\''}, {_T("apostrophe"), '\''},
{"left-parenthesis",'('}, {_T("left-parenthesis"), '('},
{"right-parenthesis", ')'}, {_T("right-parenthesis"), ')'},
{"asterisk", '*'}, {_T("asterisk"), '*'},
{"plus-sign", '+'}, {_T("plus-sign"), '+'},
{"comma", ','}, {_T("comma"), ','},
{"hyphen", '-'}, {_T("hyphen"), '-'},
{"hyphen-minus", '-'}, {_T("hyphen-minus"), '-'},
{"period", '.'}, {_T("period"), '.'},
{"full-stop", '.'}, {_T("full-stop"), '.'},
{"slash", '/'}, {_T("slash"), '/'},
{"solidus", '/'}, {_T("solidus"), '/'},
{"zero", '0'}, {_T("zero"), '0'},
{"one", '1'}, {_T("one"), '1'},
{"two", '2'}, {_T("two"), '2'},
{"three", '3'}, {_T("three"), '3'},
{"four", '4'}, {_T("four"), '4'},
{"five", '5'}, {_T("five"), '5'},
{"six", '6'}, {_T("six"), '6'},
{"seven", '7'}, {_T("seven"), '7'},
{"eight", '8'}, {_T("eight"), '8'},
{"nine", '9'}, {_T("nine"), '9'},
{"colon", ':'}, {_T("colon"), ':'},
{"semicolon", ';'}, {_T("semicolon"), ';'},
{"less-than-sign", '<'}, {_T("less-than-sign"), '<'},
{"equals-sign", '='}, {_T("equals-sign"), '='},
{"greater-than-sign", '>'}, {_T("greater-than-sign"), '>'},
{"question-mark", '?'}, {_T("question-mark"), '?'},
{"commercial-at", '@'}, {_T("commercial-at"), '@'},
{"left-square-bracket", '['}, {_T("left-square-bracket"), '['},
{"backslash", '\\'}, {_T("backslash"), '\\'},
{"reverse-solidus", '\\'}, {_T("reverse-solidus"), '\\'},
{"right-square-bracket", ']'}, {_T("right-square-bracket"), ']'},
{"circumflex", '^'}, {_T("circumflex"), '^'},
{"circumflex-accent", '^'}, {_T("circumflex-accent"), '^'},
{"underscore", '_'}, {_T("underscore"), '_'},
{"low-line", '_'}, {_T("low-line"), '_'},
{"grave-accent", '`'}, {_T("grave-accent"), '`'},
{"left-brace", '{'}, {_T("left-brace"), '{'},
{"left-curly-bracket", '{'}, {_T("left-curly-bracket"), '{'},
{"vertical-line", '|'}, {_T("vertical-line"), '|'},
{"right-brace", '}'}, {_T("right-brace"), '}'},
{"right-curly-bracket", '}'}, {_T("right-curly-bracket"), '}'},
{"tilde", '~'}, {_T("tilde"), '~'},
{"DEL", '\177'}, {_T("DEL"), '\177'},
{NULL, 0} {NULL, 0}
}; };
#if wxUSE_UNICODE
/* Unicode character-class tables */ /* Unicode character-class tables */
typedef struct crange { typedef struct crange {
@@ -518,6 +526,120 @@ static chr graphCharTable[] = {
* End of auto-generated Unicode character ranges declarations. * End of auto-generated Unicode character ranges declarations.
*/ */
/*
* Supply implementations for some tcl functions that this module depends on
* to make it self contained
*/
#include "tclUniData.c"
#define Tcl_UniChar wxChar
/*
* Compute the uppercase equivalent of the given Unicode character.
* Taken from tcl.
*/
Tcl_UniChar Tcl_UniCharToUpper(int ch)
{
int info = GetUniCharInfo(ch);
if (GetCaseType(info) & 0x04) {
return (Tcl_UniChar) (ch - GetDelta(info));
} else {
return ch;
}
}
/*
* Compute the lowercase equivalent of the given Unicode character.
* Taken from tcl.
*/
Tcl_UniChar Tcl_UniCharToLower(int ch)
{
int info = GetUniCharInfo(ch);
if (GetCaseType(info) & 0x02) {
return (Tcl_UniChar) (ch + GetDelta(info));
} else {
return ch;
}
}
/*
* Compute the titlecase equivalent of the given Unicode character.
* Taken from tcl.
*/
Tcl_UniChar Tcl_UniCharToTitle(int ch)
{
int info = GetUniCharInfo(ch);
int mode = GetCaseType(info);
if (mode & 0x1) {
/*
* Subtract or add one depending on the original case.
*/
return (Tcl_UniChar) (ch + ((mode & 0x4) ? -1 : 1));
} else if (mode == 0x4) {
return (Tcl_UniChar) (ch - GetDelta(info));
} else {
return ch;
}
}
#else /* wxUSE_UNICODE */
#include <locale.h>
typedef int (*isfunc_t)(int);
/* ASCII character-class table */
static struct cclass {
char *name;
char *chars;
int hasch;
isfunc_t isfunc;
} cclasses[] = {
{"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789", 1, isalnum},
{"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
1, isalpha},
{"blank", " \t", 0, NULL},
{"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
\25\26\27\30\31\32\33\34\35\36\37\177", 0, iscntrl},
{"digit", "0123456789", 0, isdigit},
{"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
1, isgraph},
{"lower", "abcdefghijklmnopqrstuvwxyz",
1, islower},
{"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
1, isprint},
{"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
0, ispunct},
{"space", "\t\n\v\f\r ", 0, isspace},
{"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
0, isupper},
{"xdigit", "0123456789ABCDEFabcdef",
0, isxdigit},
{NULL, 0, 0, NULL}
};
/*
* Supply implementations for some tcl functions that this module depends on
* to make it self contained
*/
#define Tcl_UniChar wxChar
Tcl_UniChar Tcl_UniCharToUpper(int ch) { return wxToupper(ch); }
Tcl_UniChar Tcl_UniCharToLower(int ch) { return wxTolower(ch); }
Tcl_UniChar Tcl_UniCharToTitle(int ch) { return wxToupper(ch); }
#endif /* !wxUSE_UNICODE */
#define CH NOCELT #define CH NOCELT
/* /*
@@ -569,8 +691,6 @@ element(v, startp, endp)
{ {
struct cname *cn; struct cname *cn;
size_t len; size_t len;
Tcl_DString ds;
CONST char *np;
/* generic: one-chr names stand for themselves */ /* generic: one-chr names stand for themselves */
assert(startp < endp); assert(startp < endp);
@@ -582,14 +702,11 @@ element(v, startp, endp)
NOTE(REG_ULOCALE); NOTE(REG_ULOCALE);
/* search table */ /* search table */
Tcl_DStringInit(&ds);
np = Tcl_UniCharToUtfDString(startp, (int)len, &ds);
for (cn=cnames; cn->name!=NULL; cn++) { for (cn=cnames; cn->name!=NULL; cn++) {
if (strlen(cn->name)==len && strncmp(cn->name, np, len)==0) { if (wxStrlen_(cn->name)==len && wxStrncmp(cn->name, startp, len)==0) {
break; /* NOTE BREAK OUT */ break; /* NOTE BREAK OUT */
} }
} }
Tcl_DStringFree(&ds);
if (cn->name != NULL) { if (cn->name != NULL) {
return CHR(cn->code); return CHR(cn->code);
} }
@@ -708,6 +825,8 @@ eclass(v, c, cases)
return cv; return cv;
} }
#if wxUSE_UNICODE
/* /*
- cclass - supply cvec for a character class - cclass - supply cvec for a character class
* Must include case counterparts on request. * Must include case counterparts on request.
@@ -722,18 +841,17 @@ cclass(v, startp, endp, cases)
{ {
size_t len; size_t len;
struct cvec *cv = NULL; struct cvec *cv = NULL;
Tcl_DString ds; CONST chr *np;
CONST char *np; chr **namePtr;
char **namePtr;
int i, index; int i, index;
/* /*
* The following arrays define the valid character class names. * The following arrays define the valid character class names.
*/ */
static char *classNames[] = { static chr *classNames[] = {
"alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", _T("alnum"), _T("alpha"), _T("ascii"), _T("blank"), _T("cntrl"), _T("digit"), _T("graph"),
"lower", "print", "punct", "space", "upper", "xdigit", NULL _T("lower"), _T("print"), _T("punct"), _T("space"), _T("upper"), _T("xdigit"), NULL
}; };
enum classes { enum classes {
@@ -747,16 +865,15 @@ cclass(v, startp, endp, cases)
*/ */
len = endp - startp; len = endp - startp;
Tcl_DStringInit(&ds); np = startp;
np = Tcl_UniCharToUtfDString(startp, (int)len, &ds);
/* /*
* Remap lower and upper to alpha if the match is case insensitive. * Remap lower and upper to alpha if the match is case insensitive.
*/ */
if (cases && len == 5 && (strncmp("lower", np, 5) == 0 if (cases && len == 5 && (wxStrncmp(_T("lower"), np, 5) == 0
|| strncmp("upper", np, 5) == 0)) { || wxStrncmp(_T("upper"), np, 5) == 0)) {
np = "alpha"; np = _T("alpha");
} }
/* /*
@@ -765,12 +882,11 @@ cclass(v, startp, endp, cases)
index = -1; index = -1;
for (namePtr=classNames,i=0 ; *namePtr!=NULL ; namePtr++,i++) { for (namePtr=classNames,i=0 ; *namePtr!=NULL ; namePtr++,i++) {
if ((strlen(*namePtr) == len) && (strncmp(*namePtr, np, len) == 0)) { if ((wxStrlen_(*namePtr) == len) && (wxStrncmp(*namePtr, np, len) == 0)) {
index = i; index = i;
break; break;
} }
} }
Tcl_DStringInit(&ds);
if (index == -1) { if (index == -1) {
ERR(REG_ECTYPE); ERR(REG_ECTYPE);
return NULL; return NULL;
@@ -919,6 +1035,79 @@ cclass(v, startp, endp, cases)
return cv; return cv;
} }
#else /* wxUSE_UNICODE */
static struct cvec *
cclass(v, startp, endp, cases)
struct vars *v;
chr *startp; /* where the name starts */
chr *endp; /* just past the end of the name */
int cases; /* case-independent? */
{
size_t len;
char *p;
struct cclass *cc;
struct cvec *cv;
chr *np;
int i;
int count;
char buf[256];
const char *loc;
/* find the name */
len = endp - startp;
np = startp;
if (cases && len == 5 && (wxStrncmp(_T("lower"), np, 5) == 0 ||
wxStrncmp(_T("upper"), np, 5) == 0))
np = _T("alpha");
for (cc = cclasses; cc->name != NULL; cc++)
if (wxStrlen_(cc->name) == len && wxStrncmp(cc->name, np, len) == 0)
break; /* NOTE BREAK OUT */
if (cc->name == NULL) {
ERR(REG_ECTYPE);
return NULL;
}
loc = setlocale(LC_CTYPE, NULL);
if (!cc->isfunc || loc == NULL || strcmp(loc, "C") == 0)
{
/* set up vector */
cv = getcvec(v, (int)strlen(cc->chars), 0, 0);
if (cv == NULL) {
ERR(REG_ESPACE);
return NULL;
}
/* fill it in */
for (p = cc->chars; *p != '\0'; p++)
addchr(cv, (chr)*p);
}
else
{
count = 0;
for (i = 0; i < 256; i++)
if (cc->isfunc(i))
buf[count++] = i;
/* set up vector */
cv = getcvec(v, count, 0, 0);
if (cv == NULL) {
ERR(REG_ESPACE);
return NULL;
}
/* fill it in */
for (i = 0; i < count; i++)
addchr(cv, buf[i]);
}
return cv;
}
#endif /* !wxUSE_UNICODE */
/* /*
- allcases - supply cvec for all case counterparts of a chr (including itself) - allcases - supply cvec for all case counterparts of a chr (including itself)
* This is a shortcut, preferably an efficient one, for simple characters; * This is a shortcut, preferably an efficient one, for simple characters;

View File

@@ -27,15 +27,16 @@
*/ */
/* headers if any */ /* headers if any */
#include "tclInt.h" #include "wx/wxchar.h"
/* overrides for regguts.h definitions, if any */ /* overrides for regguts.h definitions, if any */
#define FUNCPTR(name, args) (*name) _ANSI_ARGS_(args) /* regguts only includes standard headers if NULL is not defined, so do it
#define MALLOC(n) ckalloc(n) * ourselves here */
#define FREE(p) ckfree(VS(p)) #include <stdio.h>
#define REALLOC(p,n) ckrealloc(VS(p),n) #include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
/* /*
* Do not insert extras between the "begin" and "end" lines -- this * Do not insert extras between the "begin" and "end" lines -- this
@@ -67,53 +68,57 @@
#ifdef __REG_NOCHAR #ifdef __REG_NOCHAR
#undef __REG_NOCHAR #undef __REG_NOCHAR
#endif #endif
/* interface types */ #if wxUSE_UNICODE
#define __REG_WIDE_T Tcl_UniChar # define __REG_WIDE_T wxChar
#define __REG_REGOFF_T long /* not really right, but good enough... */ # define __REG_WIDE_COMPILE re_comp
#define __REG_VOID_T VOID # define __REG_WIDE_EXEC re_exec
#define __REG_CONST CONST # define __REG_NOCHAR /* don't want the char versions */
/* names and declarations */ #endif
#define __REG_WIDE_COMPILE TclReComp #define __REG_NOFRONT /* don't want regcomp() and regexec() */
#define __REG_WIDE_EXEC TclReExec #define _ANSI_ARGS_(x) x
#define __REG_NOFRONT /* don't want regcomp() and regexec() */
#define __REG_NOCHAR /* or the char versions */
#define regfree TclReFree
#define regerror TclReError
/* --- end --- */ /* --- end --- */
/* internal character type and related */ /* internal character type and related */
typedef Tcl_UniChar chr; /* the type itself */ typedef wxChar chr; /* the type itself */
typedef int pchr; /* what it promotes to */ typedef int pchr; /* what it promotes to */
typedef unsigned uchr; /* unsigned type that will hold a chr */ typedef unsigned uchr; /* unsigned type that will hold a chr */
typedef int celt; /* type to hold chr, MCCE number, or NOCELT */ typedef int celt; /* type to hold chr, MCCE number, or NOCELT */
#define NOCELT (-1) /* celt value which is not valid chr or MCCE */ #define NOCELT (-1) /* celt value which is not valid chr or MCCE */
#define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */ #define UCHAR(c) ((unsigned char) (c))
#define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ #define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */
#if TCL_UTF_MAX > 3 #define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */
#define CHRBITS 32 /* bits in a chr; must not use sizeof */ #if !wxUSE_UNICODE
#define CHR_MIN 0x00000000 /* smallest and largest chr; the value */ # define CHRBITS 8 /* bits in a chr; must not use sizeof */
#define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ # define CHR_MIN 0x00 /* smallest and largest chr; the value */
# define CHR_MAX 0xff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
#elif SIZEOF_WCHAR_T == 4
# define CHRBITS 32 /* bits in a chr; must not use sizeof */
# define CHR_MIN 0x00000000 /* smallest and largest chr; the value */
# define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
#else #else
#define CHRBITS 16 /* bits in a chr; must not use sizeof */ # define CHRBITS 16 /* bits in a chr; must not use sizeof */
#define CHR_MIN 0x0000 /* smallest and largest chr; the value */ # define CHR_MIN 0x0000 /* smallest and largest chr; the value */
#define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ # define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
#endif #endif
/* functions operating on chr */ /*
#define iscalnum(x) Tcl_UniCharIsAlnum(x) * I'm using isalpha et al. instead of wxIsalpha since BCC 5.5's iswalpha
#define iscalpha(x) Tcl_UniCharIsAlpha(x) * seems not to work on Windows 9x? Note that these are only used by the
#define iscdigit(x) Tcl_UniCharIsDigit(x) * lexer, and although they must work for wxChars, they need only return
#define iscspace(x) Tcl_UniCharIsSpace(x) * true for characters within the ascii range.
*/
#define iscalnum(x) ((wxUChar)(x) < 128 && isalnum(x))
#define iscalpha(x) ((wxUChar)(x) < 128 && isalpha(x))
#define iscdigit(x) ((wxUChar)(x) < 128 && isdigit(x))
#define iscspace(x) ((wxUChar)(x) < 128 && isspace(x))
/* name the external functions */ /* name the external functions */
#define compile TclReComp #define compile re_comp
#define exec TclReExec #define exec re_exec
/* enable/disable debugging code (by whether REG_DEBUG is defined or not) */ /* enable/disable debugging code (by whether REG_DEBUG is defined or not) */
#if 0 /* no debug unless requested by makefile */ #if 0 /* no debug unless requested by makefile */
#define REG_DEBUG /* */ #define REG_DEBUG /* */
#endif #endif
/* and pick up the standard header */ /* and pick up the standard header */

View File

@@ -107,18 +107,14 @@ extern "C" {
#ifdef __REG_NOCHAR #ifdef __REG_NOCHAR
#undef __REG_NOCHAR #undef __REG_NOCHAR
#endif #endif
/* interface types */ #if wxUSE_UNICODE
#define __REG_WIDE_T Tcl_UniChar # define __REG_WIDE_T wxChar
#define __REG_REGOFF_T long /* not really right, but good enough... */ # define __REG_WIDE_COMPILE re_comp
#define __REG_VOID_T VOID # define __REG_WIDE_EXEC re_exec
#define __REG_CONST CONST # define __REG_NOCHAR /* don't want the char versions */
/* names and declarations */ #endif
#define __REG_WIDE_COMPILE TclReComp #define __REG_NOFRONT /* don't want regcomp() and regexec() */
#define __REG_WIDE_EXEC TclReExec #define _ANSI_ARGS_(x) x
#define __REG_NOFRONT /* don't want regcomp() and regexec() */
#define __REG_NOCHAR /* or the char versions */
#define regfree TclReFree
#define regerror TclReError
/* --- end --- */ /* --- end --- */