sl@0: /* sl@0: * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. sl@0: * sl@0: * Development of this software was funded, in part, by Cray Research Inc., sl@0: * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics sl@0: * Corporation, none of whom are responsible for the results. The author sl@0: * thanks all of them. sl@0: * sl@0: * Redistribution and use in source and binary forms -- with or without sl@0: * modification -- are permitted for any purpose, provided that sl@0: * redistributions in source form retain this entire copyright notice and sl@0: * indicate the origin and nature of any modifications. sl@0: * sl@0: * I'd appreciate being given credit for this package in the documentation sl@0: * of software which uses it, but that is not a requirement. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, sl@0: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY sl@0: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL sl@0: * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, sl@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, sl@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; sl@0: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, sl@0: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR sl@0: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF sl@0: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: */ sl@0: sl@0: /* headers if any */ sl@0: #include "tclInt.h" sl@0: sl@0: /* overrides for regguts.h definitions, if any */ sl@0: #define FUNCPTR(name, args) (*name) _ANSI_ARGS_(args) sl@0: #define MALLOC(n) ckalloc(n) sl@0: #define FREE(p) ckfree(VS(p)) sl@0: #define REALLOC(p,n) ckrealloc(VS(p),n) sl@0: sl@0: sl@0: sl@0: /* sl@0: * Do not insert extras between the "begin" and "end" lines -- this sl@0: * chunk is automatically extracted to be fitted into regex.h. sl@0: */ sl@0: /* --- begin --- */ sl@0: /* ensure certain things don't sneak in from system headers */ sl@0: #ifdef __REG_WIDE_T sl@0: #undef __REG_WIDE_T sl@0: #endif sl@0: #ifdef __REG_WIDE_COMPILE sl@0: #undef __REG_WIDE_COMPILE sl@0: #endif sl@0: #ifdef __REG_WIDE_EXEC sl@0: #undef __REG_WIDE_EXEC sl@0: #endif sl@0: #ifdef __REG_REGOFF_T sl@0: #undef __REG_REGOFF_T sl@0: #endif sl@0: #ifdef __REG_VOID_T sl@0: #undef __REG_VOID_T sl@0: #endif sl@0: #ifdef __REG_CONST sl@0: #undef __REG_CONST sl@0: #endif sl@0: #ifdef __REG_NOFRONT sl@0: #undef __REG_NOFRONT sl@0: #endif sl@0: #ifdef __REG_NOCHAR sl@0: #undef __REG_NOCHAR sl@0: #endif sl@0: /* interface types */ sl@0: #define __REG_WIDE_T Tcl_UniChar sl@0: #define __REG_REGOFF_T long /* not really right, but good enough... */ sl@0: #define __REG_VOID_T VOID sl@0: #define __REG_CONST CONST sl@0: /* names and declarations */ sl@0: #define __REG_WIDE_COMPILE TclReComp sl@0: #define __REG_WIDE_EXEC TclReExec sl@0: #define __REG_NOFRONT /* don't want regcomp() and regexec() */ sl@0: #define __REG_NOCHAR /* or the char versions */ sl@0: #define regfree TclReFree sl@0: #define regerror TclReError sl@0: /* --- end --- */ sl@0: sl@0: sl@0: sl@0: /* internal character type and related */ sl@0: typedef Tcl_UniChar chr; /* the type itself */ sl@0: typedef int pchr; /* what it promotes to */ sl@0: typedef unsigned uchr; /* unsigned type that will hold a chr */ sl@0: typedef int celt; /* type to hold chr, MCCE number, or NOCELT */ sl@0: #define NOCELT (-1) /* celt value which is not valid chr or MCCE */ sl@0: #define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */ sl@0: #define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ sl@0: #if TCL_UTF_MAX > 3 sl@0: #define CHRBITS 32 /* bits in a chr; must not use sizeof */ sl@0: #define CHR_MIN 0x00000000 /* smallest and largest chr; the value */ sl@0: #define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ sl@0: #else sl@0: #define CHRBITS 16 /* bits in a chr; must not use sizeof */ sl@0: #define CHR_MIN 0x0000 /* smallest and largest chr; the value */ sl@0: #define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ sl@0: #endif sl@0: sl@0: /* functions operating on chr */ sl@0: #define iscalnum(x) Tcl_UniCharIsAlnum(x) sl@0: #define iscalpha(x) Tcl_UniCharIsAlpha(x) sl@0: #define iscdigit(x) Tcl_UniCharIsDigit(x) sl@0: #define iscspace(x) Tcl_UniCharIsSpace(x) sl@0: sl@0: /* name the external functions */ sl@0: #define compile TclReComp sl@0: #define exec TclReExec sl@0: sl@0: /* enable/disable debugging code (by whether REG_DEBUG is defined or not) */ sl@0: #if 0 /* no debug unless requested by makefile */ sl@0: #define REG_DEBUG /* */ sl@0: #endif sl@0: sl@0: /* and pick up the standard header */ sl@0: #include "regex.h"