Import regex from tcl 8.4.5

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/RXSPENCER@22026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ryan Norton
2003-07-16 22:03:52 +00:00
parent 4f4987da94
commit 7b43e63a7b

View File

@@ -24,69 +24,97 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/ */
/* headers if any */ /* headers if any */
#include <sys/types.h> #include "tclInt.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#ifndef wxCHECK_GCC_VERSION
#define wxCHECK_GCC_VERSION( major, minor ) \
( defined(__GNUC__) && defined(__GNUC_MINOR__) \
&& ( ( __GNUC__ > (major) ) \
|| ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) )
#endif
#ifdef wxUSE_NEW_REGEX
#if !wxUSE_UNICODE
# define wx_wchar char
#else // Unicode
#if (defined(__GNUC__) && !wxCHECK_GCC_VERSION(2, 96))
# define wx_wchar __WCHAR_TYPE__
#else // __WCHAR_TYPE__ and gcc < 2.96
// standard case
# define wx_wchar wchar_t
#endif // __WCHAR_TYPE__
#endif // ASCII/Unicode
#else
#define wx_wchar char
#endif
/* overrides for regguts.h definitions, if any */ /* overrides for regguts.h definitions, if any */
#define FUNCPTR(name, args) (*name) args #define FUNCPTR(name, args) (*name) _ANSI_ARGS_(args)
#define MALLOC(n) malloc(n) #define MALLOC(n) ckalloc(n)
#define FREE(p) free(VS(p)) #define FREE(p) ckfree(VS(p))
#define REALLOC(p,n) realloc(VS(p),n) #define REALLOC(p,n) ckrealloc(VS(p),n)
/*
* Do not insert extras between the "begin" and "end" lines -- this
* chunk is automatically extracted to be fitted into regex.h.
*/
/* --- begin --- */
/* ensure certain things don't sneak in from system headers */
#ifdef __REG_WIDE_T
#undef __REG_WIDE_T
#endif
#ifdef __REG_WIDE_COMPILE
#undef __REG_WIDE_COMPILE
#endif
#ifdef __REG_WIDE_EXEC
#undef __REG_WIDE_EXEC
#endif
#ifdef __REG_REGOFF_T
#undef __REG_REGOFF_T
#endif
#ifdef __REG_VOID_T
#undef __REG_VOID_T
#endif
#ifdef __REG_CONST
#undef __REG_CONST
#endif
#ifdef __REG_NOFRONT
#undef __REG_NOFRONT
#endif
#ifdef __REG_NOCHAR
#undef __REG_NOCHAR
#endif
/* interface types */
#define __REG_WIDE_T Tcl_UniChar
#define __REG_REGOFF_T long /* not really right, but good enough... */
#define __REG_VOID_T VOID
#define __REG_CONST CONST
/* names and declarations */
#define __REG_WIDE_COMPILE TclReComp
#define __REG_WIDE_EXEC TclReExec
#define __REG_NOFRONT /* don't want regcomp() and regexec() */
#define __REG_NOCHAR /* or the char versions */
#define regfree TclReFree
#define regerror TclReError
/* --- end --- */
/* internal character type and related */ /* internal character type and related */
typedef wx_wchar chr; /* the type itself */ typedef Tcl_UniChar chr; /* the type itself */
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 typedef int celt; /* type to hold chr, MCCE number, or NOCELT */
* NOCELT */ #define NOCELT (-1) /* celt value which is not valid chr or MCCE */
#define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */
#define NOCELT (-1) /* celt value which is not valid chr or
* MCCE */
#define CHR(c) ((unsigned char) (c)) /* turn char literal into chr
* literal */
#define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ #define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */
#if TCL_UTF_MAX > 3
#define CHRBITS 32 /* bits in a chr; must not use sizeof */ #define CHRBITS 32 /* bits in a chr; must not use sizeof */
#define CHR_MIN 0x00000000 /* smallest and largest chr; the value */ #define CHR_MIN 0x00000000 /* smallest and largest chr; the value */
#define CHR_MAX 0xfffffffe /* CHR_MAX-CHR_MIN+1 should fit in uchr */ #define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
#else
#define CHRBITS 16 /* bits in a chr; must not use sizeof */
#define CHR_MIN 0x0000 /* smallest and largest chr; the value */
#define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
#endif
/* functions operating on chr */ /* functions operating on chr */
#define iscalnum(x) wx_isalnum(x) #define iscalnum(x) Tcl_UniCharIsAlnum(x)
#define iscalpha(x) wx_isalpha(x) #define iscalpha(x) Tcl_UniCharIsAlpha(x)
#define iscdigit(x) wx_isdigit(x) #define iscdigit(x) Tcl_UniCharIsDigit(x)
#define iscspace(x) wx_isspace(x) #define iscspace(x) Tcl_UniCharIsSpace(x)
/* name the external functions */
#define compile TclReComp
#define exec TclReExec
/* enable/disable debugging code (by whether REG_DEBUG is defined or not) */
#if 0 /* no debug unless requested by makefile */
#define REG_DEBUG /* */
#endif
/* and pick up the standard header */ /* and pick up the standard header */
#include "regex.h" #include "regex.h"