blob: 20c0c3daa3959a5023050270478526d8e7132aab [file] [log] [blame]
rscf7012582003-11-25 01:40:27 +00001#ifndef _REGEXP9_H_
2#define _REGEXP9_H_ 1
3#if defined(__cplusplus)
4extern "C" {
5#endif
rscb2cfc4e2003-09-30 17:47:41 +00006
rsc78e51a82005-01-14 03:45:44 +00007#ifdef AUTOLIB
rsc1a0954a2005-01-04 21:18:08 +00008AUTOLIB(regexp9)
rsc78e51a82005-01-14 03:45:44 +00009#endif
rsc1a0954a2005-01-04 21:18:08 +000010
rscb2cfc4e2003-09-30 17:47:41 +000011#include <utf.h>
12
13typedef struct Resub Resub;
14typedef struct Reclass Reclass;
15typedef struct Reinst Reinst;
16typedef struct Reprog Reprog;
17
18/*
19 * Sub expression matches
20 */
21struct 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 */
37struct Reclass{
38 Rune *end;
39 Rune spans[64];
40};
41
42/*
43 * Machine instructions
44 */
45struct 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 */
62struct Reprog{
63 Reinst *startinst; /* start pc */
64 Reclass class[16]; /* .data */
65 Reinst firstinst[5]; /* .text */
66};
67
rsc54952ce2003-11-24 22:48:39 +000068extern Reprog *regcomp9(char*);
69extern Reprog *regcomplit9(char*);
70extern Reprog *regcompnl9(char*);
71extern void regerror9(char*);
72extern int regexec9(Reprog*, char*, Resub*, int);
73extern void regsub9(char*, char*, int, Resub*, int);
rscb2cfc4e2003-09-30 17:47:41 +000074
rsc54952ce2003-11-24 22:48:39 +000075extern int rregexec9(Reprog*, Rune*, Resub*, int);
rsc230d62c2004-03-05 05:48:32 +000076extern void rregsub9(Rune*, Rune*, int, Resub*, int);
rsc54952ce2003-11-24 22:48:39 +000077
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
rscb2cfc4e2003-09-30 17:47:41 +000092
rscf7012582003-11-25 01:40:27 +000093#if defined(__cplusplus)
94}
95#endif
rscb2cfc4e2003-09-30 17:47:41 +000096#endif