mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
138 lines
5.2 KiB
C
138 lines
5.2 KiB
C
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
|
* *
|
|
* regular.h.. *
|
|
* *
|
|
* Function:..Routine for TWEB *
|
|
* *
|
|
* *
|
|
* *
|
|
* Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
|
|
* Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
|
|
* neuer Dienste, Universitaet Tuebingen, GERMANY *
|
|
* *
|
|
* ZZZZZ DDD V V *
|
|
* Creation date: Z D D V V *
|
|
* January 20 1998 Z D D V V *
|
|
* Last modification: Z D D V V *
|
|
* December 31 1998 ZZZZZ DDD V *
|
|
* *
|
|
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
|
|
/*
|
|
* $Id: regular.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
|
|
*
|
|
*/
|
|
|
|
#ifndef _REGULAR_
|
|
#define _REGULAR_
|
|
|
|
|
|
/* definition number opnd? meaning */
|
|
#define END 0 /* no End of program. */
|
|
#define BOL 1 /* no Match "" at beginning of line. */
|
|
#define EOL 2 /* no Match "" at end of line. */
|
|
#define ANY 3 /* no Match any one character. */
|
|
#define ANYOF 4 /* str Match any character in this string. */
|
|
#define ANYBUT 5 /* str Match any character not in this string. */
|
|
#define BRANCH 6 /* node Match this alternative, or the next... */
|
|
#define BACK 7 /* no Match "", "next" ptr points backward. */
|
|
#define EXACTLY 8 /* str Match this string. */
|
|
#define NOTHING 9 /* no Match empty string. */
|
|
#define STAR 10 /* node Match this (simple) thing 0 or more times. */
|
|
#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
|
|
#define OPEN 20 /* no Mark this point in input as start of #n. */
|
|
/* OPEN+1 is number 1, etc. */
|
|
#define CLOSE ((OPEN)+(NSUBEXP)+1) /* no Analogous to OPEN. */
|
|
|
|
/*
|
|
* Opcode notes:
|
|
*
|
|
* BRANCH The set of branches constituting a single choice are hooked
|
|
* together with their "next" pointers, since precedence prevents
|
|
* anything being concatenated to any individual branch. The
|
|
* "next" pointer of the last BRANCH in a choice points to the
|
|
* thing following the whole choice. This is also where the
|
|
* final "next" pointer of each individual branch points; each
|
|
* branch starts with the operand node of a BRANCH node.
|
|
*
|
|
* BACK Normal "next" pointers all implicitly point forward; BACK
|
|
* exists to make loop structures possible.
|
|
*
|
|
* STAR,PLUS '?', and complex '*' and '+', are implemented as circular
|
|
* BRANCH structures using BACK. Simple cases (one character
|
|
* per match) are implemented with STAR and PLUS for speed
|
|
* and to minimize recursive plunges.
|
|
*
|
|
* OPEN,CLOSE ...are numbered at compile time.
|
|
*/
|
|
|
|
/*
|
|
* A node is one char of opcode followed by two chars of "next" pointer.
|
|
* "Next" pointers are stored as two 8-bit pieces, high order first. The
|
|
* value is a positive offset from the opcode of the node containing it.
|
|
* An operand, if any, simply follows the node. (Note that much of the
|
|
* code generation knows about this implicit relationship.)
|
|
*
|
|
* Using two bytes for the "next" pointer is vast overkill for most things,
|
|
* but allows patterns to get big without disasters.
|
|
*/
|
|
#define OP(p) (*(p))
|
|
#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
|
|
#define OPERAND(p) ((p) + 3)
|
|
|
|
/*
|
|
* See regmagic.h for one further detail of program structure.
|
|
*/
|
|
|
|
|
|
/*
|
|
* Utility definitions.
|
|
*/
|
|
#ifndef CHARBITS
|
|
#define UCHARAT(p) ((int)*(unsigned char *)(p))
|
|
#else
|
|
#define UCHARAT(p) ((int)*(p)&CHARBITS)
|
|
#endif
|
|
|
|
#define FAIL(m) { tweb_regerror(m); return(NULL); }
|
|
#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
|
|
#define META "^$.[()|?+*\\"
|
|
|
|
/*
|
|
* Flags to be passed up and down.
|
|
*/
|
|
#define HASWIDTH 01 /* Known never to match null string. */
|
|
#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
|
|
#define SPSTART 04 /* Starts with * or +. */
|
|
#define WORST 0 /* Worst case. */
|
|
|
|
/*
|
|
* Global work variables for regcomp().
|
|
*/
|
|
PRIVATE char *regparse; /* Input-scan pointer. */
|
|
PRIVATE int regnpar; /* () count. */
|
|
PRIVATE char regdummy;
|
|
PRIVATE char *regcode; /* Code-emit pointer; ®dummy = don't. */
|
|
PRIVATE long regsize; /* Code size. */
|
|
|
|
/*
|
|
* Forward declarations for regcomp()'s friends.
|
|
*/
|
|
#ifndef STATIC
|
|
#define STATIC static
|
|
#endif
|
|
PRIVATE char *tweb_reg();
|
|
PRIVATE char *tweb_regbranch();
|
|
PRIVATE char *tweb_regpiece();
|
|
PRIVATE char *tweb_regatom();
|
|
PRIVATE char *tweb_regnode();
|
|
PRIVATE char *tweb_regnext();
|
|
PRIVATE void tweb_regc();
|
|
PRIVATE void tweb_reginsert();
|
|
PRIVATE void tweb_regtail();
|
|
PRIVATE void tweb_regoptail();
|
|
#ifdef STRCSPN
|
|
STATIC int tweb_strcspn();
|
|
#endif
|
|
|
|
#endif /* _REGULAR_ */
|