regcustom.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1998, 1999 Henry Spencer.  All rights reserved.
00003  *
00004  * Development of this software was funded, in part, by Cray Research Inc.,
00005  * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
00006  * Corporation, none of whom are responsible for the results. The author
00007  * thanks all of them.
00008  *
00009  * Redistribution and use in source and binary forms - with or without
00010  * modification - are permitted for any purpose, provided that redistributions
00011  * in source form retain this entire copyright notice and indicate the origin
00012  * and nature of any modifications.
00013  *
00014  * I'd appreciate being given credit for this package in the documentation of
00015  * software which uses it, but that is not a requirement.
00016  *
00017  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
00018  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
00019  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00020  * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00021  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00022  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00023  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00024  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00025  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00026  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 /*
00030  * Headers if any.
00031  */
00032 
00033 #include "tclInt.h"
00034 
00035 /*
00036  * Overrides for regguts.h definitions, if any.
00037  */
00038 
00039 #define FUNCPTR(name, args)     (*name)args
00040 #define MALLOC(n)               ckalloc(n)
00041 #define FREE(p)                 ckfree(VS(p))
00042 #define REALLOC(p,n)            ckrealloc(VS(p),n)
00043 
00044 /*
00045  * Do not insert extras between the "begin" and "end" lines - this chunk is
00046  * automatically extracted to be fitted into regex.h.
00047  */
00048 
00049 /* --- begin --- */
00050 /* Ensure certain things don't sneak in from system headers. */
00051 #ifdef __REG_WIDE_T
00052 #undef __REG_WIDE_T
00053 #endif
00054 #ifdef __REG_WIDE_COMPILE
00055 #undef __REG_WIDE_COMPILE
00056 #endif
00057 #ifdef __REG_WIDE_EXEC
00058 #undef __REG_WIDE_EXEC
00059 #endif
00060 #ifdef __REG_REGOFF_T
00061 #undef __REG_REGOFF_T
00062 #endif
00063 #ifdef __REG_VOID_T
00064 #undef __REG_VOID_T
00065 #endif
00066 #ifdef __REG_CONST
00067 #undef __REG_CONST
00068 #endif
00069 #ifdef __REG_NOFRONT
00070 #undef __REG_NOFRONT
00071 #endif
00072 #ifdef __REG_NOCHAR
00073 #undef __REG_NOCHAR
00074 #endif
00075 /* Interface types */
00076 #define __REG_WIDE_T    Tcl_UniChar
00077 #define __REG_REGOFF_T  long    /* Not really right, but good enough... */
00078 #define __REG_VOID_T    void
00079 #define __REG_CONST     const
00080 /* Names and declarations */
00081 #define __REG_WIDE_COMPILE      TclReComp
00082 #define __REG_WIDE_EXEC         TclReExec
00083 #define __REG_NOFRONT           /* Don't want regcomp() and regexec() */
00084 #define __REG_NOCHAR            /* Or the char versions */
00085 #define regfree         TclReFree
00086 #define regerror        TclReError
00087 /* --- end --- */
00088 
00089 /*
00090  * Internal character type and related.
00091  */
00092 
00093 typedef Tcl_UniChar chr;        /* The type itself. */
00094 typedef int pchr;               /* What it promotes to. */
00095 typedef unsigned uchr;          /* Unsigned type that will hold a chr. */
00096 typedef int celt;               /* Type to hold chr, or NOCELT */
00097 #define NOCELT (-1)             /* Celt value which is not valid chr */
00098 #define CHR(c) (UCHAR(c))       /* Turn char literal into chr literal */
00099 #define DIGITVAL(c) ((c)-'0')   /* Turn chr digit into its value */
00100 #if TCL_UTF_MAX > 3
00101 #define CHRBITS 32              /* Bits in a chr; must not use sizeof */
00102 #define CHR_MIN 0x00000000      /* Smallest and largest chr; the value */
00103 #define CHR_MAX 0xffffffff      /* CHR_MAX-CHR_MIN+1 should fit in uchr */
00104 #else
00105 #define CHRBITS 16              /* Bits in a chr; must not use sizeof */
00106 #define CHR_MIN 0x0000          /* Smallest and largest chr; the value */
00107 #define CHR_MAX 0xffff          /* CHR_MAX-CHR_MIN+1 should fit in uchr */
00108 #endif
00109 
00110 /*
00111  * Functions operating on chr.
00112  */
00113 
00114 #define iscalnum(x)     Tcl_UniCharIsAlnum(x)
00115 #define iscalpha(x)     Tcl_UniCharIsAlpha(x)
00116 #define iscdigit(x)     Tcl_UniCharIsDigit(x)
00117 #define iscspace(x)     Tcl_UniCharIsSpace(x)
00118 
00119 /*
00120  * Name the external functions.
00121  */
00122 
00123 #define compile         TclReComp
00124 #define exec            TclReExec
00125 
00126 /*
00127 & Enable/disable debugging code (by whether REG_DEBUG is defined or not).
00128 */
00129 
00130 #if 0                           /* No debug unless requested by makefile. */
00131 #define REG_DEBUG       /* */
00132 #endif
00133 
00134 /*
00135  * Method of allocating a local workspace. We used a thread-specific data
00136  * space to store this because the regular expression engine is never
00137  * reentered from the same thread; it doesn't make any callbacks.
00138  */
00139 
00140 #if 1
00141 #define AllocVars(vPtr) \
00142     static Tcl_ThreadDataKey varsKey; \
00143     register struct vars *vPtr = (struct vars *) \
00144             Tcl_GetThreadData(&varsKey, sizeof(struct vars))
00145 #else
00146 /*
00147  * This strategy for allocating workspace is "more proper" in some sense, but
00148  * quite a bit slower. Using TSD (as above) leads to code that is quite a bit
00149  * faster in practice (measured!)
00150  */
00151 #define AllocVars(vPtr) \
00152     register struct vars *vPtr = (struct vars *) MALLOC(sizeof(struct vars))
00153 #define FreeVars(vPtr) \
00154     FREE(vPtr)
00155 #endif
00156 
00157 /*
00158  * And pick up the standard header.
00159  */
00160 
00161 #include "regex.h"



Generated on Wed Mar 12 12:18:10 2008 by  doxygen 1.5.1