Blob


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