diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-11-14 11:04:58 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-11-14 11:04:58 (GMT) |
commit | 45b2a969f63ab7f6184c8acaec8bb3d525650090 (patch) | |
tree | 145f0b7237a0fa87bff299c233682cca06b5cdd5 /generic/regcustom.h | |
parent | 32e51a96573d4ab8a91f7e5484b7ed780b875ae7 (diff) | |
download | tcl-45b2a969f63ab7f6184c8acaec8bb3d525650090.zip tcl-45b2a969f63ab7f6184c8acaec8bb3d525650090.tar.gz tcl-45b2a969f63ab7f6184c8acaec8bb3d525650090.tar.bz2 |
Eliminate multi-char collating element code completely. Simplifies the code
quite a bit. If people still want the full code, it will remain on the 8.4
branch. [Bug 1831425]
Diffstat (limited to 'generic/regcustom.h')
-rw-r--r-- | generic/regcustom.h | 113 |
1 files changed, 69 insertions, 44 deletions
diff --git a/generic/regcustom.h b/generic/regcustom.h index 6b6b38c..ac33087 100644 --- a/generic/regcustom.h +++ b/generic/regcustom.h @@ -3,13 +3,13 @@ * * Development of this software was funded, in part, by Cray Research Inc., * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics - * Corporation, none of whom are responsible for the results. The author + * Corporation, none of whom are responsible for the results. The author * thanks all of them. * - * Redistribution and use in source and binary forms -- with or without - * modification -- are permitted for any purpose, provided that - * redistributions in source form retain this entire copyright notice and - * indicate the origin and nature of any modifications. + * Redistribution and use in source and binary forms - with or without + * modification - are permitted for any purpose, provided that redistributions + * in source form retain this entire copyright notice and indicate the origin + * and nature of any modifications. * * I'd appreciate being given credit for this package in the documentation of * software which uses it, but that is not a requirement. @@ -26,23 +26,28 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* headers if any */ +/* + * Headers if any. + */ + #include "tclInt.h" -/* overrides for regguts.h definitions, if any */ -#define FUNCPTR(name, args) (*name) _ANSI_ARGS_(args) +/* + * Overrides for regguts.h definitions, if any. + */ + +#define FUNCPTR(name, args) (*name)args #define MALLOC(n) ckalloc(n) #define FREE(p) ckfree(VS(p)) #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. + * 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 */ +/* Ensure certain things don't sneak in from system headers. */ #ifdef __REG_WIDE_T #undef __REG_WIDE_T #endif @@ -67,70 +72,90 @@ #ifdef __REG_NOCHAR #undef __REG_NOCHAR #endif -/* interface types */ +/* 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_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 __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 Tcl_UniChar chr; /* the type itself */ -typedef int pchr; /* what it promotes to */ -typedef unsigned uchr; /* unsigned type that will hold a chr */ -typedef int celt; /* type to hold chr, MCCE number, or 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 DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ +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 int celt; /* Type to hold chr, or NOCELT */ +#define NOCELT (-1) /* Celt value which is not valid chr */ +#define CHR(c) (UCHAR(c)) /* Turn char literal into chr literal */ +#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 CHR_MIN 0x00000000 /* smallest and largest chr; the value */ -#define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */ +#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 -#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 */ +#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) Tcl_UniCharIsAlnum(x) #define iscalpha(x) Tcl_UniCharIsAlpha(x) #define iscdigit(x) Tcl_UniCharIsDigit(x) #define iscspace(x) Tcl_UniCharIsSpace(x) -/* name the external functions */ +/* + * 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 */ +/* +& Enable/disable debugging code (by whether REG_DEBUG is defined or not). +*/ + +#if 0 /* No debug unless requested by makefile. */ #define REG_DEBUG /* */ #endif -/* method of allocating a local workspace */ +/* + * Method of allocating a local workspace. We used a thread-specific data + * space to store this because the regular expression engine is never + * reentered from the same thread; it doesn't make any callbacks. + */ + #if 1 #define AllocVars(vPtr) \ static Tcl_ThreadDataKey varsKey; \ register struct vars *vPtr = (struct vars *) \ - Tcl_GetThreadData(&varsKey, sizeof(struct vars)) + Tcl_GetThreadData(&varsKey, sizeof(struct vars)) #else -/* This strategy for allocating workspace is "more proper" in some sense, but +/* + * This strategy for allocating workspace is "more proper" in some sense, but * quite a bit slower. Using TSD (as above) leads to code that is quite a bit - * faster in practice. */ + * faster in practice (measured!) + */ #define AllocVars(vPtr) \ register struct vars *vPtr = (struct vars *) MALLOC(sizeof(struct vars)) #define FreeVars(vPtr) \ FREE(vPtr) #endif -/* and pick up the standard header */ +/* + * And pick up the standard header. + */ + #include "regex.h" |