wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

regexp9.h (1708B)


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