hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

regexp9.h (1790B)


      1 #ifndef _REGEXP9_H_
      2 #define _REGEXP9_H_ 1
      3 #if defined(__cplusplus)
      4 extern "C" { 
      5 #endif
      6 
      7 #ifdef AUTOLIB
      8 AUTOLIB(regexp9)
      9 #endif
     10 
     11 #include <utf.h>
     12 
     13 typedef struct Resub		Resub;
     14 typedef struct Reclass		Reclass;
     15 typedef struct Reinst		Reinst;
     16 typedef struct Reprog		Reprog;
     17 
     18 /*
     19  *	Sub expression matches
     20  */
     21 struct Resub{
     22 	union
     23 	{
     24 		char *sp;
     25 		Rune *rsp;
     26 	}s;
     27 	union
     28 	{
     29 		char *ep;
     30 		Rune *rep;
     31 	}e;
     32 };
     33 
     34 /*
     35  *	character class, each pair of rune's defines a range
     36  */
     37 struct Reclass{
     38 	Rune	*end;
     39 	Rune	spans[64];
     40 };
     41 
     42 /*
     43  *	Machine instructions
     44  */
     45 struct Reinst{
     46 	int	type;
     47 	union	{
     48 		Reclass	*cp;		/* class pointer */
     49 		Rune	r;		/* character */
     50 		int	subid;		/* sub-expression id for RBRA and LBRA */
     51 		Reinst	*right;		/* right child of OR */
     52 	}u1;
     53 	union {	/* regexp relies on these two being in the same union */
     54 		Reinst *left;		/* left child of OR */
     55 		Reinst *next;		/* next instruction for CAT & LBRA */
     56 	}u2;
     57 };
     58 
     59 /*
     60  *	Reprogram definition
     61  */
     62 struct Reprog{
     63 	Reinst	*startinst;	/* start pc */
     64 	Reclass	class[16];	/* .data */
     65 	Reinst	firstinst[5];	/* .text */
     66 };
     67 
     68 extern Reprog	*regcomp9(char*);
     69 extern Reprog	*regcomplit9(char*);
     70 extern Reprog	*regcompnl9(char*);
     71 extern void	regerror9(char*);
     72 extern int	regexec9(Reprog*, char*, Resub*, int);
     73 extern void	regsub9(char*, char*, int, Resub*, int);
     74 
     75 extern int	rregexec9(Reprog*, Rune*, Resub*, int);
     76 extern void	rregsub9(Rune*, Rune*, int, Resub*, int);
     77 
     78 /*
     79  * Darwin simply cannot handle having routines that
     80  * override other library routines.
     81  */
     82 #ifndef NOPLAN9DEFINES
     83 #define regcomp regcomp9
     84 #define regcomplit regcomplit9
     85 #define regcompnl regcompnl9
     86 #define regerror regerror9
     87 #define regexec regexec9
     88 #define regsub regsub9
     89 #define rregexec rregexec9
     90 #define rregsub rregsub9
     91 #endif
     92 
     93 #if defined(__cplusplus)
     94 }
     95 #endif
     96 #endif