00001 /* Definitions for data structures and routines for the regular 00002 expression library. 00003 Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006 00004 Free Software Foundation, Inc. 00005 This file is part of the GNU C Library. 00006 00007 The GNU C Library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 The GNU C Library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with the GNU C Library; if not, write to the Free 00019 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00020 02111-1307 USA. */ 00021 00022 #ifndef _REGEX_H 00023 #define _REGEX_H 1 00024 00025 #include <sys/types.h> 00026 00027 /* Allow the use in C++ code. */ 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 /* The following two types have to be signed and unsigned integer type 00033 wide enough to hold a value of a pointer. For most ANSI compilers 00034 ptrdiff_t and size_t should be likely OK. Still size of these two 00035 types is 2 for Microsoft C. Ugh... */ 00036 typedef long int s_reg_t; 00037 typedef unsigned long int active_reg_t; 00038 00039 /* The following bits are used to determine the regexp syntax we 00040 recognize. The set/not-set meanings are chosen so that Emacs syntax 00041 remains the value 0. The bits are given in alphabetical order, and 00042 the definitions shifted by one from the previous bit; thus, when we 00043 add or remove a bit, only one other definition need change. */ 00044 typedef unsigned long int reg_syntax_t; 00045 00046 /* If this bit is not set, then \ inside a bracket expression is literal. 00047 If set, then such a \ quotes the following character. */ 00048 #define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) 00049 00050 /* If this bit is not set, then + and ? are operators, and \+ and \? are 00051 literals. 00052 If set, then \+ and \? are operators and + and ? are literals. */ 00053 #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) 00054 00055 /* If this bit is set, then character classes are supported. They are: 00056 [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], 00057 [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. 00058 If not set, then character classes are not supported. */ 00059 #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) 00060 00061 /* If this bit is set, then ^ and $ are always anchors (outside bracket 00062 expressions, of course). 00063 If this bit is not set, then it depends: 00064 ^ is an anchor if it is at the beginning of a regular 00065 expression or after an open-group or an alternation operator; 00066 $ is an anchor if it is at the end of a regular expression, or 00067 before a close-group or an alternation operator. 00068 00069 This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because 00070 POSIX draft 11.2 says that * etc. in leading positions is undefined. 00071 We already implemented a previous draft which made those constructs 00072 invalid, though, so we haven't changed the code back. */ 00073 #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) 00074 00075 /* If this bit is set, then special characters are always special 00076 regardless of where they are in the pattern. 00077 If this bit is not set, then special characters are special only in 00078 some contexts; otherwise they are ordinary. Specifically, 00079 * + ? and intervals are only special when not after the beginning, 00080 open-group, or alternation operator. */ 00081 #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) 00082 00083 /* If this bit is set, then *, +, ?, and { cannot be first in an re or 00084 immediately after an alternation or begin-group operator. */ 00085 #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) 00086 00087 /* If this bit is set, then . matches newline. 00088 If not set, then it doesn't. */ 00089 #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) 00090 00091 /* If this bit is set, then . doesn't match NUL. 00092 If not set, then it does. */ 00093 #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) 00094 00095 /* If this bit is set, nonmatching lists [^...] do not match newline. 00096 If not set, they do. */ 00097 #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) 00098 00099 /* If this bit is set, either \{...\} or {...} defines an 00100 interval, depending on RE_NO_BK_BRACES. 00101 If not set, \{, \}, {, and } are literals. */ 00102 #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) 00103 00104 /* If this bit is set, +, ? and | aren't recognized as operators. 00105 If not set, they are. */ 00106 #define RE_LIMITED_OPS (RE_INTERVALS << 1) 00107 00108 /* If this bit is set, newline is an alternation operator. 00109 If not set, newline is literal. */ 00110 #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) 00111 00112 /* If this bit is set, then `{...}' defines an interval, and \{ and \} 00113 are literals. 00114 If not set, then `\{...\}' defines an interval. */ 00115 #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) 00116 00117 /* If this bit is set, (...) defines a group, and \( and \) are literals. 00118 If not set, \(...\) defines a group, and ( and ) are literals. */ 00119 #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) 00120 00121 /* If this bit is set, then <digit> matches <digit>. 00122 If not set, then <digit> is a back-reference. */ 00123 #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) 00124 00125 /* If this bit is set, then | is an alternation operator, and \| is literal. 00126 If not set, then \| is an alternation operator, and | is literal. */ 00127 #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) 00128 00129 /* If this bit is set, then an ending range point collating higher 00130 than the starting range point, as in [z-a], is invalid. 00131 If not set, then when ending range point collates higher than the 00132 starting range point, the range is ignored. */ 00133 #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) 00134 00135 /* If this bit is set, then an unmatched ) is ordinary. 00136 If not set, then an unmatched ) is invalid. */ 00137 #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) 00138 00139 /* If this bit is set, succeed as soon as we match the whole pattern, 00140 without further backtracking. */ 00141 #define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) 00142 00143 /* If this bit is set, do not process the GNU regex operators. 00144 If not set, then the GNU regex operators are recognized. */ 00145 #define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) 00146 00147 /* If this bit is set, turn on internal regex debugging. 00148 If not set, and debugging was on, turn it off. 00149 This only works if regex.c is compiled -DDEBUG. 00150 We define this bit always, so that all that's needed to turn on 00151 debugging is to recompile regex.c; the calling code can always have 00152 this bit set, and it won't affect anything in the normal case. */ 00153 #define RE_DEBUG (RE_NO_GNU_OPS << 1) 00154 00155 /* If this bit is set, a syntactically invalid interval is treated as 00156 a string of ordinary characters. For example, the ERE 'a{1' is 00157 treated as 'a\{1'. */ 00158 #define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) 00159 00160 /* If this bit is set, then ignore case when matching. 00161 If not set, then case is significant. */ 00162 #define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) 00163 00164 /* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only 00165 for ^, because it is difficult to scan the regex backwards to find 00166 whether ^ should be special. */ 00167 #define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) 00168 00169 /* If this bit is set, then \{ cannot be first in an bre or 00170 immediately after an alternation or begin-group operator. */ 00171 #define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) 00172 00173 /* If this bit is set, then no_sub will be set to 1 during 00174 re_compile_pattern. */ 00175 #define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) 00176 00177 /* This global variable defines the particular regexp syntax to use (for 00178 some interfaces). When a regexp is compiled, the syntax used is 00179 stored in the pattern buffer, so changing this does not affect 00180 already-compiled regexps. */ 00181 extern reg_syntax_t re_syntax_options; 00182 00183 /* Define combinations of the above bits for the standard possibilities. 00184 (The [[[ comments delimit what gets put into the Texinfo file, so 00185 don't delete them!) */ 00186 /* [[[begin syntaxes]]] */ 00187 #define RE_SYNTAX_EMACS 0 00188 00189 #define RE_SYNTAX_AWK \ 00190 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ 00191 | RE_NO_BK_PARENS | RE_NO_BK_REFS \ 00192 | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ 00193 | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ 00194 | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) 00195 00196 #define RE_SYNTAX_GNU_AWK \ 00197 ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \ 00198 & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ 00199 | RE_CONTEXT_INVALID_OPS )) 00200 00201 #define RE_SYNTAX_POSIX_AWK \ 00202 (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ 00203 | RE_INTERVALS | RE_NO_GNU_OPS) 00204 00205 #define RE_SYNTAX_GREP \ 00206 (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ 00207 | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ 00208 | RE_NEWLINE_ALT) 00209 00210 #define RE_SYNTAX_EGREP \ 00211 (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ 00212 | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ 00213 | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ 00214 | RE_NO_BK_VBAR) 00215 00216 #define RE_SYNTAX_POSIX_EGREP \ 00217 (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ 00218 | RE_INVALID_INTERVAL_ORD) 00219 00220 /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ 00221 #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC 00222 00223 #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC 00224 00225 /* Syntax bits common to both basic and extended POSIX regex syntax. */ 00226 #define _RE_SYNTAX_POSIX_COMMON \ 00227 (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ 00228 | RE_INTERVALS | RE_NO_EMPTY_RANGES) 00229 00230 #define RE_SYNTAX_POSIX_BASIC \ 00231 (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) 00232 00233 /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes 00234 RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this 00235 isn't minimal, since other operators, such as \`, aren't disabled. */ 00236 #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ 00237 (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) 00238 00239 #define RE_SYNTAX_POSIX_EXTENDED \ 00240 (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ 00241 | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ 00242 | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ 00243 | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) 00244 00245 /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is 00246 removed and RE_NO_BK_REFS is added. */ 00247 #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ 00248 (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ 00249 | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ 00250 | RE_NO_BK_PARENS | RE_NO_BK_REFS \ 00251 | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) 00252 /* [[[end syntaxes]]] */ 00253 00254 /* Maximum number of duplicates an interval can allow. Some systems 00255 (erroneously) define this in other header files, but we want our 00256 value, so remove any previous define. */ 00257 #ifdef RE_DUP_MAX 00258 # undef RE_DUP_MAX 00259 #endif 00260 /* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ 00261 #define RE_DUP_MAX (0x7fff) 00262 00263 00264 /* POSIX `cflags' bits (i.e., information for `regcomp'). */ 00265 00266 /* If this bit is set, then use extended regular expression syntax. 00267 If not set, then use basic regular expression syntax. */ 00268 #define REG_EXTENDED 1 00269 00270 /* If this bit is set, then ignore case when matching. 00271 If not set, then case is significant. */ 00272 #define REG_ICASE (REG_EXTENDED << 1) 00273 00274 /* If this bit is set, then anchors do not match at newline 00275 characters in the string. 00276 If not set, then anchors do match at newlines. */ 00277 #define REG_NEWLINE (REG_ICASE << 1) 00278 00279 /* If this bit is set, then report only success or fail in regexec. 00280 If not set, then returns differ between not matching and errors. */ 00281 #define REG_NOSUB (REG_NEWLINE << 1) 00282 00283 00284 /* POSIX `eflags' bits (i.e., information for regexec). */ 00285 00286 /* If this bit is set, then the beginning-of-line operator doesn't match 00287 the beginning of the string (presumably because it's not the 00288 beginning of a line). 00289 If not set, then the beginning-of-line operator does match the 00290 beginning of the string. */ 00291 #define REG_NOTBOL 1 00292 00293 /* Like REG_NOTBOL, except for the end-of-line. */ 00294 #define REG_NOTEOL (1 << 1) 00295 00296 /* Use PMATCH[0] to delimit the start and end of the search in the 00297 buffer. */ 00298 #define REG_STARTEND (1 << 2) 00299 00300 00301 /* If any error codes are removed, changed, or added, update the 00302 `re_error_msg' table in regex.c. */ 00303 typedef enum 00304 { 00305 #ifdef _XOPEN_SOURCE 00306 REG_ENOSYS = -1, /* This will never happen for this implementation. */ 00307 #endif 00308 00309 REG_NOERROR = 0, /* Success. */ 00310 REG_NOMATCH, /* Didn't find a match (for regexec). */ 00311 00312 /* POSIX regcomp return error codes. (In the order listed in the 00313 standard.) */ 00314 REG_BADPAT, /* Invalid pattern. */ 00315 REG_ECOLLATE, /* Inalid collating element. */ 00316 REG_ECTYPE, /* Invalid character class name. */ 00317 REG_EESCAPE, /* Trailing backslash. */ 00318 REG_ESUBREG, /* Invalid back reference. */ 00319 REG_EBRACK, /* Unmatched left bracket. */ 00320 REG_EPAREN, /* Parenthesis imbalance. */ 00321 REG_EBRACE, /* Unmatched \{. */ 00322 REG_BADBR, /* Invalid contents of \{\}. */ 00323 REG_ERANGE, /* Invalid range end. */ 00324 REG_ESPACE, /* Ran out of memory. */ 00325 REG_BADRPT, /* No preceding re for repetition op. */ 00326 00327 /* Error codes we've added. */ 00328 REG_EEND, /* Premature end. */ 00329 REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ 00330 REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ 00331 } reg_errcode_t; 00332 00333 /* This data structure represents a compiled pattern. Before calling 00334 the pattern compiler, the fields `buffer', `allocated', `fastmap', 00335 `translate', and `no_sub' can be set. After the pattern has been 00336 compiled, the `re_nsub' field is available. All other fields are 00337 private to the regex routines. */ 00338 00339 #ifndef RE_TRANSLATE_TYPE 00340 # define RE_TRANSLATE_TYPE unsigned char * 00341 #endif 00342 00343 struct re_pattern_buffer 00344 { 00345 /* Space that holds the compiled pattern. It is declared as 00346 `unsigned char *' because its elements are sometimes used as 00347 array indexes. */ 00348 unsigned char *buffer; 00349 00350 /* Number of bytes to which `buffer' points. */ 00351 unsigned long int allocated; 00352 00353 /* Number of bytes actually used in `buffer'. */ 00354 unsigned long int used; 00355 00356 /* Syntax setting with which the pattern was compiled. */ 00357 reg_syntax_t syntax; 00358 00359 /* Pointer to a fastmap, if any, otherwise zero. re_search uses the 00360 fastmap, if there is one, to skip over impossible starting points 00361 for matches. */ 00362 char *fastmap; 00363 00364 /* Either a translate table to apply to all characters before 00365 comparing them, or zero for no translation. The translation is 00366 applied to a pattern when it is compiled and to a string when it 00367 is matched. */ 00368 RE_TRANSLATE_TYPE translate; 00369 00370 /* Number of subexpressions found by the compiler. */ 00371 size_t re_nsub; 00372 00373 /* Zero if this pattern cannot match the empty string, one else. 00374 Well, in truth it's used only in `re_search_2', to see whether or 00375 not we should use the fastmap, so we don't set this absolutely 00376 perfectly; see `re_compile_fastmap' (the `duplicate' case). */ 00377 unsigned can_be_null : 1; 00378 00379 /* If REGS_UNALLOCATED, allocate space in the `regs' structure 00380 for `max (RE_NREGS, re_nsub + 1)' groups. 00381 If REGS_REALLOCATE, reallocate space if necessary. 00382 If REGS_FIXED, use what's there. */ 00383 #define REGS_UNALLOCATED 0 00384 #define REGS_REALLOCATE 1 00385 #define REGS_FIXED 2 00386 unsigned regs_allocated : 2; 00387 00388 /* Set to zero when `regex_compile' compiles a pattern; set to one 00389 by `re_compile_fastmap' if it updates the fastmap. */ 00390 unsigned fastmap_accurate : 1; 00391 00392 /* If set, `re_match_2' does not return information about 00393 subexpressions. */ 00394 unsigned no_sub : 1; 00395 00396 /* If set, a beginning-of-line anchor doesn't match at the beginning 00397 of the string. */ 00398 unsigned not_bol : 1; 00399 00400 /* Similarly for an end-of-line anchor. */ 00401 unsigned not_eol : 1; 00402 00403 /* If true, an anchor at a newline matches. */ 00404 unsigned newline_anchor : 1; 00405 }; 00406 00407 typedef struct re_pattern_buffer regex_t; 00408 00409 /* Type for byte offsets within the string. POSIX mandates this. */ 00410 typedef int regoff_t; 00411 00412 00413 /* This is the structure we store register match data in. See 00414 regex.texinfo for a full description of what registers match. */ 00415 struct re_registers 00416 { 00417 unsigned num_regs; 00418 regoff_t *start; 00419 regoff_t *end; 00420 }; 00421 00422 00423 /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, 00424 `re_match_2' returns information about at least this many registers 00425 the first time a `regs' structure is passed. */ 00426 #ifndef RE_NREGS 00427 # define RE_NREGS 30 00428 #endif 00429 00430 00431 /* POSIX specification for registers. Aside from the different names than 00432 `re_registers', POSIX uses an array of structures, instead of a 00433 structure of arrays. */ 00434 typedef struct 00435 { 00436 regoff_t rm_so; /* Byte offset from string's start to substring's start. */ 00437 regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ 00438 } regmatch_t; 00439 00440 /* Declarations for routines. */ 00441 00442 /* Sets the current default syntax to SYNTAX, and return the old syntax. 00443 You can also simply assign to the `re_syntax_options' variable. */ 00444 extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); 00445 00446 /* Compile the regular expression PATTERN, with length LENGTH 00447 and syntax given by the global `re_syntax_options', into the buffer 00448 BUFFER. Return NULL if successful, and an error string if not. */ 00449 extern const char *re_compile_pattern (const char *__pattern, size_t __length, 00450 struct re_pattern_buffer *__buffer); 00451 00452 00453 /* Compile a fastmap for the compiled pattern in BUFFER; used to 00454 accelerate searches. Return 0 if successful and -2 if was an 00455 internal error. */ 00456 extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); 00457 00458 00459 /* Search in the string STRING (with length LENGTH) for the pattern 00460 compiled into BUFFER. Start searching at position START, for RANGE 00461 characters. Return the starting position of the match, -1 for no 00462 match, or -2 for an internal error. Also return register 00463 information in REGS (if REGS and BUFFER->no_sub are nonzero). */ 00464 extern int re_search (struct re_pattern_buffer *__buffer, const char *__string, 00465 int __length, int __start, int __range, 00466 struct re_registers *__regs); 00467 00468 00469 /* Like `re_search', but search in the concatenation of STRING1 and 00470 STRING2. Also, stop searching at index START + STOP. */ 00471 extern int re_search_2 (struct re_pattern_buffer *__buffer, 00472 const char *__string1, int __length1, 00473 const char *__string2, int __length2, int __start, 00474 int __range, struct re_registers *__regs, int __stop); 00475 00476 00477 /* Like `re_search', but return how many characters in STRING the regexp 00478 in BUFFER matched, starting at position START. */ 00479 extern int re_match (struct re_pattern_buffer *__buffer, const char *__string, 00480 int __length, int __start, struct re_registers *__regs); 00481 00482 00483 /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ 00484 extern int re_match_2 (struct re_pattern_buffer *__buffer, 00485 const char *__string1, int __length1, 00486 const char *__string2, int __length2, int __start, 00487 struct re_registers *__regs, int __stop); 00488 00489 00490 /* Set REGS to hold NUM_REGS registers, storing them in STARTS and 00491 ENDS. Subsequent matches using BUFFER and REGS will use this memory 00492 for recording register information. STARTS and ENDS must be 00493 allocated with malloc, and must each be at least `NUM_REGS * sizeof 00494 (regoff_t)' bytes long. 00495 00496 If NUM_REGS == 0, then subsequent matches should allocate their own 00497 register data. 00498 00499 Unless this function is called, the first search or match using 00500 PATTERN_BUFFER will allocate its own register data, without 00501 freeing the old data. */ 00502 extern void re_set_registers (struct re_pattern_buffer *__buffer, 00503 struct re_registers *__regs, 00504 unsigned int __num_regs, 00505 regoff_t *__starts, regoff_t *__ends); 00506 00507 #if defined _REGEX_RE_COMP || defined _LIBC 00508 # ifndef _CRAY 00509 /* 4.2 bsd compatibility. */ 00510 extern char *re_comp (const char *); 00511 extern int re_exec (const char *); 00512 # endif 00513 #endif 00514 00515 /* GCC 2.95 and later have "__restrict"; C99 compilers have 00516 "restrict", and "configure" may have defined "restrict". */ 00517 #ifndef __restrict 00518 # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) 00519 # if defined restrict || 199901L <= __STDC_VERSION__ 00520 # define __restrict restrict 00521 # else 00522 # define __restrict 00523 # endif 00524 # endif 00525 #endif 00526 /* gcc 3.1 and up support the [restrict] syntax. */ 00527 #ifndef __restrict_arr 00528 # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \ 00529 && !defined __GNUG__ 00530 # define __restrict_arr __restrict 00531 # else 00532 # define __restrict_arr 00533 # endif 00534 #endif 00535 00536 /* POSIX compatibility. */ 00537 extern int regcomp (regex_t *__restrict __preg, 00538 const char *__restrict __pattern, 00539 int __cflags); 00540 00541 extern int regexec (const regex_t *__restrict __preg, 00542 const char *__restrict __string, size_t __nmatch, 00543 regmatch_t __pmatch[__restrict_arr], 00544 int __eflags); 00545 00546 extern size_t regerror (int __errcode, const regex_t *__restrict __preg, 00547 char *__restrict __errbuf, size_t __errbuf_size); 00548 00549 extern void regfree (regex_t *__preg); 00550 00551 00552 #ifdef __cplusplus 00553 } 00554 #endif /* C++ */ 00555 00556 #endif /* regex.h */