Blob


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