]>
Commit | Line | Data |
---|---|---|
d76ed9a9 AS |
1 | /* classes: h_files */ |
2 | ||
3 | #ifndef INST_RXPOSIXH | |
4 | #define INST_RXPOSIXH | |
5 | /* Copyright (C) 1995, 1996 Tom Lord | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU Library General Public License as published by | |
9 | * the Free Software Foundation; either version 2, or (at your option) | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU Library General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Library General Public License | |
18 | * along with this software; see the file COPYING. If not, write to | |
19 | * the Free Software Foundation, 59 Temple Place - Suite 330, | |
20 | * Boston, MA 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | \f | |
24 | ||
25 | struct rx_posix_regex | |
26 | { | |
27 | struct rexp_node * pattern; | |
28 | struct rexp_node ** subexps; | |
29 | size_t re_nsub; | |
30 | unsigned char * translate; | |
31 | unsigned int newline_anchor:1;/* If true, an anchor at a newline matches.*/ | |
32 | unsigned int no_sub:1; /* If set, don't return register offsets. */ | |
33 | unsigned int is_anchored:1; | |
34 | unsigned int is_nullable:1; | |
35 | unsigned char fastmap[256]; | |
36 | void * owner_data; | |
37 | }; | |
38 | ||
39 | typedef struct rx_posix_regex regex_t; | |
40 | ||
41 | /* Type for byte offsets within the string. POSIX mandates this. */ | |
42 | typedef int regoff_t; | |
43 | ||
44 | typedef struct rx_registers | |
45 | { | |
46 | regoff_t rm_so; /* Byte offset from string's start to substring's start. */ | |
47 | regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ | |
48 | regoff_t final_tag; /* data from the cut operator (only pmatch[0]) */ | |
49 | } regmatch_t; | |
50 | ||
51 | \f | |
52 | ||
53 | /* If any error codes are removed, changed, or added, update the | |
54 | * `rx_error_msg' table. | |
55 | */ | |
56 | #define REG_NOERROR 0 /* Success. */ | |
57 | #define REG_NOMATCH 1 /* Didn't find a match (for regexec). */ | |
58 | ||
59 | /* POSIX regcomp return error codes. | |
60 | * (In the order listed in the standard.) | |
61 | */ | |
62 | #define REG_BADPAT 2 /* Invalid pattern. */ | |
63 | #define REG_ECOLLATE 3 /* Not implemented. */ | |
64 | #define REG_ECTYPE 4 /* Invalid character class name. */ | |
65 | #define REG_EESCAPE 5 /* Trailing backslash. */ | |
66 | #define REG_ESUBREG 6 /* Invalid back reference. */ | |
67 | #define REG_EBRACK 7 /* Unmatched left bracket. */ | |
68 | #define REG_EPAREN 8 /* Parenthesis imbalance. */ | |
69 | #define REG_EBRACE 9 /* Unmatched \{. */ | |
70 | #define REG_BADBR 10 /* Invalid contents of \{\}. */ | |
71 | #define REG_ERANGE 11 /* Invalid range end. */ | |
72 | #define REG_ESPACE 12 /* Ran out of memory. */ | |
73 | #define REG_BADRPT 13 /* No preceding re for repetition op. */ | |
74 | ||
75 | /* Error codes we've added. | |
76 | */ | |
77 | #define REG_EEND 14 /* Premature end. */ | |
78 | #define REG_ESIZE 15 /* Compiled pattern bigger than 2^16 bytes. */ | |
79 | #define REG_ERPAREN 16 /* Unmatched ) or \); not returned from regcomp. */ | |
80 | ||
81 | \f | |
82 | /* | |
83 | * POSIX `cflags' bits (i.e., information for `regcomp'). | |
84 | */ | |
85 | ||
86 | /* If this bit is set, then use extended regular expression syntax. | |
87 | * If not set, then use basic regular expression syntax. | |
88 | */ | |
89 | #define REG_EXTENDED 1 | |
90 | ||
91 | /* If this bit is set, then ignore case when matching. | |
92 | * If not set, then case is significant. | |
93 | */ | |
94 | #define REG_ICASE (REG_EXTENDED << 1) | |
95 | ||
96 | /* If this bit is set, then anchors do not match at newline | |
97 | * characters in the string. | |
98 | * If not set, then anchors do match at newlines. | |
99 | */ | |
100 | #define REG_NEWLINE (REG_ICASE << 1) | |
101 | ||
102 | /* If this bit is set, then report only success or fail in regexec. | |
103 | * If not set, then returns differ between not matching and errors. | |
104 | */ | |
105 | #define REG_NOSUB (REG_NEWLINE << 1) | |
106 | ||
107 | ||
108 | /* | |
109 | * POSIX `eflags' bits (i.e., information for regexec). | |
110 | */ | |
111 | ||
112 | /* If this bit is set, then the beginning-of-line operator doesn't match | |
113 | * the beginning of the string (presumably because it's not the | |
114 | * beginning of a line). | |
115 | * If not set, then the beginning-of-line operator does match the | |
116 | * beginning of the string. | |
117 | */ | |
118 | #define REG_NOTBOL 1 | |
119 | ||
120 | /* Like REG_NOTBOL, except for the end-of-line. | |
121 | */ | |
122 | #define REG_NOTEOL (REG_NOTBOL << 1) | |
123 | ||
124 | /* For regnexec only. Allocate register storage and return that. */ | |
125 | #define REG_ALLOC_REGS (REG_NOTEOL << 1) | |
126 | ||
127 | \f | |
128 | #ifdef __STDC__ | |
129 | extern int regncomp (regex_t * preg, | |
130 | const char * pattern, int len, | |
131 | int cflags); | |
132 | extern int regcomp (regex_t * preg, const char * pattern, int cflags); | |
133 | extern size_t regerror (int errcode, | |
134 | const regex_t *preg, | |
135 | char *errbuf, size_t errbuf_size); | |
136 | extern int regnexec (const regex_t *preg, | |
137 | const char *string, int len, | |
138 | size_t nmatch, regmatch_t **pmatch, | |
139 | int eflags); | |
140 | extern int regexec (const regex_t *preg, | |
141 | const char *string, | |
142 | size_t nmatch, regmatch_t pmatch[], | |
143 | int eflags); | |
144 | extern void regfree (regex_t *preg); | |
145 | ||
146 | #else /* STDC */ | |
147 | extern int regncomp (); | |
148 | extern int regcomp (); | |
149 | extern size_t regerror (); | |
150 | extern int regnexec (); | |
151 | extern int regexec (); | |
152 | extern void regfree (); | |
153 | ||
154 | #endif /* STDC */ | |
155 | #endif /* INST_RXPOSIXH */ |