1 /* Definitions for data structures and routines for the regular
3 Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005
4 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
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 General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24 #include <sys/types.h>
26 /* Allow the use in C++ code. */
31 /* Define _REGEX_SOURCE to get definitions that are incompatible with
33 #if (!defined _REGEX_SOURCE \
34 && (defined _GNU_SOURCE \
35 || (!defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE \
36 && !defined _XOPEN_SOURCE)))
37 # define _REGEX_SOURCE 1
40 #if defined _REGEX_SOURCE && defined VMS
41 /* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
46 /* The following two types have to be signed and unsigned integer type
47 wide enough to hold a value of a pointer. For most ANSI compilers
48 ptrdiff_t and size_t should be likely OK. Still size of these two
49 types is 2 for Microsoft C. Ugh... */
50 typedef long int s_reg_t;
51 typedef unsigned long int active_reg_t;
53 /* The following bits are used to determine the regexp syntax we
54 recognize. The set/not-set meanings are chosen so that Emacs syntax
55 remains the value 0. The bits are given in alphabetical order, and
56 the definitions shifted by one from the previous bit; thus, when we
57 add or remove a bit, only one other definition need change. */
58 typedef unsigned long int reg_syntax_t;
60 /* If this bit is not set, then \ inside a bracket expression is literal.
61 If set, then such a \ quotes the following character. */
62 #define REG_BACKSLASH_ESCAPE_IN_LISTS 1ul
64 /* If this bit is not set, then + and ? are operators, and \+ and \? are
66 If set, then \+ and \? are operators and + and ? are literals. */
67 #define REG_BK_PLUS_QM (1ul << 1)
69 /* If this bit is set, then character classes are supported. They are:
70 [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
71 [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
72 If not set, then character classes are not supported. */
73 #define REG_CHAR_CLASSES (1ul << 2)
75 /* If this bit is set, then ^ and $ are always anchors (outside bracket
76 expressions, of course).
77 If this bit is not set, then it depends:
78 ^ is an anchor if it is at the beginning of a regular
79 expression or after an open-group or an alternation operator;
80 $ is an anchor if it is at the end of a regular expression, or
81 before a close-group or an alternation operator.
83 This bit could be (re)combined with REG_CONTEXT_INDEP_OPS, because
84 POSIX draft 11.2 says that * etc. in leading positions is undefined.
85 We already implemented a previous draft which made those constructs
86 invalid, though, so we haven't changed the code back. */
87 #define REG_CONTEXT_INDEP_ANCHORS (1ul << 3)
89 /* If this bit is set, then special characters are always special
90 regardless of where they are in the pattern.
91 If this bit is not set, then special characters are special only in
92 some contexts; otherwise they are ordinary. Specifically,
93 * + ? and intervals are only special when not after the beginning,
94 open-group, or alternation operator. */
95 #define REG_CONTEXT_INDEP_OPS (1ul << 4)
97 /* If this bit is set, then *, +, ?, and { cannot be first in an re or
98 immediately after an alternation or begin-group operator. */
99 #define REG_CONTEXT_INVALID_OPS (1ul << 5)
101 /* If this bit is set, then . matches newline.
102 If not set, then it doesn't. */
103 #define REG_DOT_NEWLINE (1ul << 6)
105 /* If this bit is set, then . doesn't match NUL.
106 If not set, then it does. */
107 #define REG_DOT_NOT_NULL (1ul << 7)
109 /* If this bit is set, nonmatching lists [^...] do not match newline.
110 If not set, they do. */
111 #define REG_HAT_LISTS_NOT_NEWLINE (1ul << 8)
113 /* If this bit is set, either \{...\} or {...} defines an
114 interval, depending on REG_NO_BK_BRACES.
115 If not set, \{, \}, {, and } are literals. */
116 #define REG_INTERVALS (1ul << 9)
118 /* If this bit is set, +, ? and | aren't recognized as operators.
119 If not set, they are. */
120 #define REG_LIMITED_OPS (1ul << 10)
122 /* If this bit is set, newline is an alternation operator.
123 If not set, newline is literal. */
124 #define REG_NEWLINE_ALT (1ul << 11)
126 /* If this bit is set, then `{...}' defines an interval, and \{ and \}
128 If not set, then `\{...\}' defines an interval. */
129 #define REG_NO_BK_BRACES (1ul << 12)
131 /* If this bit is set, (...) defines a group, and \( and \) are literals.
132 If not set, \(...\) defines a group, and ( and ) are literals. */
133 #define REG_NO_BK_PARENS (1ul << 13)
135 /* If this bit is set, then \<digit> matches <digit>.
136 If not set, then \<digit> is a back-reference. */
137 #define REG_NO_BK_REFS (1ul << 14)
139 /* If this bit is set, then | is an alternation operator, and \| is literal.
140 If not set, then \| is an alternation operator, and | is literal. */
141 #define REG_NO_BK_VBAR (1ul << 15)
143 /* If this bit is set, then an ending range point collating higher
144 than the starting range point, as in [z-a], is invalid.
145 If not set, the containing range is empty and does not match any string. */
146 #define REG_NO_EMPTY_RANGES (1ul << 16)
148 /* If this bit is set, then an unmatched ) is ordinary.
149 If not set, then an unmatched ) is invalid. */
150 #define REG_UNMATCHED_RIGHT_PAREN_ORD (1ul << 17)
152 /* If this bit is set, succeed as soon as we match the whole pattern,
153 without further backtracking. */
154 #define REG_NO_POSIX_BACKTRACKING (1ul << 18)
156 /* If this bit is set, do not process the GNU regex operators.
157 If not set, then the GNU regex operators are recognized. */
158 #define REG_NO_GNU_OPS (1ul << 19)
160 /* If this bit is set, turn on internal regex debugging.
161 If not set, and debugging was on, turn it off.
162 This only works if regex.c is compiled -DDEBUG.
163 We define this bit always, so that all that's needed to turn on
164 debugging is to recompile regex.c; the calling code can always have
165 this bit set, and it won't affect anything in the normal case. */
166 #define REG_DEBUG (1ul << 20)
168 /* If this bit is set, a syntactically invalid interval is treated as
169 a string of ordinary characters. For example, the ERE 'a{1' is
170 treated as 'a\{1'. */
171 #define REG_INVALID_INTERVAL_ORD (1ul << 21)
173 /* If this bit is set, then ignore case when matching.
174 If not set, then case is significant. */
175 #define REG_IGNORE_CASE (1ul << 22)
177 /* This bit is used internally like REG_CONTEXT_INDEP_ANCHORS but only
178 for ^, because it is difficult to scan the regex backwards to find
179 whether ^ should be special. */
180 #define REG_CARET_ANCHORS_HERE (1ul << 23)
182 /* If this bit is set, then \{ cannot be first in an bre or
183 immediately after an alternation or begin-group operator. */
184 #define REG_CONTEXT_INVALID_DUP (1ul << 24)
186 /* If this bit is set, then no_sub will be set to 1 during
187 re_compile_pattern. */
188 #define REG_NO_SUB (1ul << 25)
190 /* This global variable defines the particular regexp syntax to use (for
191 some interfaces). When a regexp is compiled, the syntax used is
192 stored in the pattern buffer, so changing this does not affect
193 already-compiled regexps. */
194 extern reg_syntax_t re_syntax_options;
196 /* Define combinations of the above bits for the standard possibilities.
197 (The [[[ comments delimit what gets put into the Texinfo file, so
198 don't delete them!) */
199 /* [[[begin syntaxes]]] */
200 #define REG_SYNTAX_EMACS 0
202 #define REG_SYNTAX_AWK \
203 (REG_BACKSLASH_ESCAPE_IN_LISTS | REG_DOT_NOT_NULL \
204 | REG_NO_BK_PARENS | REG_NO_BK_REFS \
205 | REG_NO_BK_VBAR | REG_NO_EMPTY_RANGES \
206 | REG_DOT_NEWLINE | REG_CONTEXT_INDEP_ANCHORS \
207 | REG_UNMATCHED_RIGHT_PAREN_ORD | REG_NO_GNU_OPS)
209 #define REG_SYNTAX_GNU_AWK \
210 ((REG_SYNTAX_POSIX_EXTENDED | REG_BACKSLASH_ESCAPE_IN_LISTS \
212 & ~(REG_DOT_NOT_NULL | REG_INTERVALS | REG_CONTEXT_INDEP_OPS \
213 | REG_CONTEXT_INVALID_OPS ))
215 #define REG_SYNTAX_POSIX_AWK \
216 (REG_SYNTAX_POSIX_EXTENDED | REG_BACKSLASH_ESCAPE_IN_LISTS \
217 | REG_INTERVALS | REG_NO_GNU_OPS)
219 #define REG_SYNTAX_GREP \
220 (REG_BK_PLUS_QM | REG_CHAR_CLASSES \
221 | REG_HAT_LISTS_NOT_NEWLINE | REG_INTERVALS \
224 #define REG_SYNTAX_EGREP \
225 (REG_CHAR_CLASSES | REG_CONTEXT_INDEP_ANCHORS \
226 | REG_CONTEXT_INDEP_OPS | REG_HAT_LISTS_NOT_NEWLINE \
227 | REG_NEWLINE_ALT | REG_NO_BK_PARENS \
230 #define REG_SYNTAX_POSIX_EGREP \
231 (REG_SYNTAX_EGREP | REG_INTERVALS | REG_NO_BK_BRACES \
232 | REG_INVALID_INTERVAL_ORD)
234 /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
235 #define REG_SYNTAX_ED REG_SYNTAX_POSIX_BASIC
237 #define REG_SYNTAX_SED REG_SYNTAX_POSIX_BASIC
239 /* Syntax bits common to both basic and extended POSIX regex syntax. */
240 #define _REG_SYNTAX_POSIX_COMMON \
241 (REG_CHAR_CLASSES | REG_DOT_NEWLINE | REG_DOT_NOT_NULL \
242 | REG_INTERVALS | REG_NO_EMPTY_RANGES)
244 #define REG_SYNTAX_POSIX_BASIC \
245 (_REG_SYNTAX_POSIX_COMMON | REG_BK_PLUS_QM | REG_CONTEXT_INVALID_DUP)
247 /* Differs from ..._POSIX_BASIC only in that REG_BK_PLUS_QM becomes
248 REG_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
249 isn't minimal, since other operators, such as \`, aren't disabled. */
250 #define REG_SYNTAX_POSIX_MINIMAL_BASIC \
251 (_REG_SYNTAX_POSIX_COMMON | REG_LIMITED_OPS)
253 #define REG_SYNTAX_POSIX_EXTENDED \
254 (_REG_SYNTAX_POSIX_COMMON | REG_CONTEXT_INDEP_ANCHORS \
255 | REG_CONTEXT_INDEP_OPS | REG_NO_BK_BRACES \
256 | REG_NO_BK_PARENS | REG_NO_BK_VBAR \
257 | REG_CONTEXT_INVALID_OPS | REG_UNMATCHED_RIGHT_PAREN_ORD)
259 /* Differs from ..._POSIX_EXTENDED in that REG_CONTEXT_INDEP_OPS is
260 removed and REG_NO_BK_REFS is added. */
261 #define REG_SYNTAX_POSIX_MINIMAL_EXTENDED \
262 (_REG_SYNTAX_POSIX_COMMON | REG_CONTEXT_INDEP_ANCHORS \
263 | REG_CONTEXT_INVALID_OPS | REG_NO_BK_BRACES \
264 | REG_NO_BK_PARENS | REG_NO_BK_REFS \
265 | REG_NO_BK_VBAR | REG_UNMATCHED_RIGHT_PAREN_ORD)
266 /* [[[end syntaxes]]] */
268 /* Maximum number of duplicates an interval can allow. This is
269 distinct from RE_DUP_MAX, to conform to POSIX name space rules and
270 to avoid collisions with <limits.h>. */
271 #define REG_DUP_MAX 32767
274 /* POSIX `cflags' bits (i.e., information for `regcomp'). */
276 /* If this bit is set, then use extended regular expression syntax.
277 If not set, then use basic regular expression syntax. */
278 #define REG_EXTENDED 1
280 /* If this bit is set, then ignore case when matching.
281 If not set, then case is significant. */
282 #define REG_ICASE (1 << 1)
284 /* If this bit is set, then anchors do not match at newline
285 characters in the string.
286 If not set, then anchors do match at newlines. */
287 #define REG_NEWLINE (1 << 2)
289 /* If this bit is set, then report only success or fail in regexec.
290 If not set, then returns differ between not matching and errors. */
291 #define REG_NOSUB (1 << 3)
294 /* POSIX `eflags' bits (i.e., information for regexec). */
296 /* If this bit is set, then the beginning-of-line operator doesn't match
297 the beginning of the string (presumably because it's not the
298 beginning of a line).
299 If not set, then the beginning-of-line operator does match the
300 beginning of the string. */
303 /* Like REG_NOTBOL, except for the end-of-line. */
304 #define REG_NOTEOL (1 << 1)
306 /* Use PMATCH[0] to delimit the start and end of the search in the
308 #define REG_STARTEND (1 << 2)
311 /* If any error codes are removed, changed, or added, update the
312 `__re_error_msgid' table in regcomp.c. */
316 _REG_ENOSYS = -1, /* This will never happen for this implementation. */
317 #define REG_ENOSYS _REG_ENOSYS
319 _REG_NOERROR, /* Success. */
320 #define REG_NOERROR _REG_NOERROR
322 _REG_NOMATCH, /* Didn't find a match (for regexec). */
323 #define REG_NOMATCH _REG_NOMATCH
325 /* POSIX regcomp return error codes. (In the order listed in the
328 _REG_BADPAT, /* Invalid pattern. */
329 #define REG_BADPAT _REG_BADPAT
331 _REG_ECOLLATE, /* Inalid collating element. */
332 #define REG_ECOLLATE _REG_ECOLLATE
334 _REG_ECTYPE, /* Invalid character class name. */
335 #define REG_ECTYPE _REG_ECTYPE
337 _REG_EESCAPE, /* Trailing backslash. */
338 #define REG_EESCAPE _REG_EESCAPE
340 _REG_ESUBREG, /* Invalid back reference. */
341 #define REG_ESUBREG _REG_ESUBREG
343 _REG_EBRACK, /* Unmatched left bracket. */
344 #define REG_EBRACK _REG_EBRACK
346 _REG_EPAREN, /* Parenthesis imbalance. */
347 #define REG_EPAREN _REG_EPAREN
349 _REG_EBRACE, /* Unmatched \{. */
350 #define REG_EBRACE _REG_EBRACE
352 _REG_BADBR, /* Invalid contents of \{\}. */
353 #define REG_BADBR _REG_BADBR
355 _REG_ERANGE, /* Invalid range end. */
356 #define REG_ERANGE _REG_ERANGE
358 _REG_ESPACE, /* Ran out of memory. */
359 #define REG_ESPACE _REG_ESPACE
361 _REG_BADRPT, /* No preceding re for repetition op. */
362 #define REG_BADRPT _REG_BADRPT
364 /* Error codes we've added. */
366 _REG_EEND, /* Premature end. */
367 #define REG_EEND _REG_EEND
369 _REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
370 #define REG_ESIZE _REG_ESIZE
372 _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
373 #define REG_ERPAREN _REG_ERPAREN
377 /* In the traditional GNU implementation, regex.h defined member names
378 like `buffer' that POSIX does not allow. These members now have
379 names with leading `re_' (e.g., `re_buffer'). Support the old
380 names only if _REGEX_SOURCE is defined. New programs should use
383 # define _REG_RE_NAME(id) id
384 # define _REG_RM_NAME(id) id
386 # define _REG_RE_NAME(id) re_##id
387 # define _REG_RM_NAME(id) rm_##id
390 /* The user can specify the type of the re_translate member by
391 defining the macro REG_TRANSLATE_TYPE. In the traditional GNU
392 implementation, this macro was named RE_TRANSLATE_TYPE, but POSIX
393 does not allow this. Support the old name only if _REGEX_SOURCE
394 and if the new name is not defined. New programs should use the new
396 #ifndef REG_TRANSLATE_TYPE
397 # if defined _REGEX_SOURCE && defined RE_TRANSLATE_TYPE
398 # define REG_TRANSLATE_TYPE RE_TRANSLATE_TYPE
400 # define REG_TRANSLATE_TYPE char *
404 /* This data structure represents a compiled pattern. Before calling
405 the pattern compiler), the fields `re_buffer', `re_allocated', `re_fastmap',
406 `re_translate', and `re_no_sub' can be set. After the pattern has been
407 compiled, the `re_nsub' field is available. All other fields are
408 private to the regex routines. */
410 struct re_pattern_buffer
412 /* [[[begin pattern_buffer]]] */
413 /* Space that holds the compiled pattern. It is declared as
414 `unsigned char *' because its elements are
415 sometimes used as array indexes. */
416 unsigned char *_REG_RE_NAME (buffer);
418 /* Number of bytes to which `re_buffer' points. */
419 unsigned long int _REG_RE_NAME (allocated);
421 /* Number of bytes actually used in `re_buffer'. */
422 unsigned long int _REG_RE_NAME (used);
424 /* Syntax setting with which the pattern was compiled. */
425 reg_syntax_t _REG_RE_NAME (syntax);
427 /* Pointer to a fastmap, if any, otherwise zero. re_search uses
428 the fastmap, if there is one, to skip over impossible
429 starting points for matches. */
430 char *_REG_RE_NAME (fastmap);
432 /* Either a translate table to apply to all characters before
433 comparing them, or zero for no translation. The translation
434 is applied to a pattern when it is compiled and to a string
435 when it is matched. */
436 REG_TRANSLATE_TYPE _REG_RE_NAME (translate);
438 /* Number of subexpressions found by the compiler. */
441 /* Zero if this pattern cannot match the empty string, one else.
442 Well, in truth it's used only in `re_search_2', to see
443 whether or not we should use the fastmap, so we don't set
444 this absolutely perfectly; see `re_compile_fastmap' (the
445 `duplicate' case). */
446 unsigned int _REG_RE_NAME (can_be_null) : 1;
448 /* If REG_UNALLOCATED, allocate space in the `regs' structure
449 for `max (REG_NREGS, re_nsub + 1)' groups.
450 If REG_REALLOCATE, reallocate space if necessary.
451 If REG_FIXED, use what's there. */
452 #define REG_UNALLOCATED 0
453 #define REG_REALLOCATE 1
455 unsigned int _REG_RE_NAME (regs_allocated) : 2;
457 /* Set to zero when `regex_compile' compiles a pattern; set to one
458 by `re_compile_fastmap' if it updates the fastmap. */
459 unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
461 /* If set, `re_match_2' does not return information about
463 unsigned int _REG_RE_NAME (no_sub) : 1;
465 /* If set, a beginning-of-line anchor doesn't match at the
466 beginning of the string. */
467 unsigned int _REG_RE_NAME (not_bol) : 1;
469 /* Similarly for an end-of-line anchor. */
470 unsigned int _REG_RE_NAME (not_eol) : 1;
472 /* If true, an anchor at a newline matches. */
473 unsigned int _REG_RE_NAME (newline_anchor) : 1;
475 /* [[[end pattern_buffer]]] */
478 typedef struct re_pattern_buffer regex_t;
480 /* Type for byte offsets within the string. POSIX mandates this. */
481 typedef int regoff_t;
484 /* This is the structure we store register match data in. See
485 regex.texinfo for a full description of what registers match. */
488 unsigned int _REG_RM_NAME (num_regs);
489 regoff_t *_REG_RM_NAME (start);
490 regoff_t *_REG_RM_NAME (end);
494 /* If `regs_allocated' is REG_UNALLOCATED in the pattern buffer,
495 `re_match_2' returns information about at least this many registers
496 the first time a `regs' structure is passed. */
498 # define REG_NREGS 30
502 /* POSIX specification for registers. Aside from the different names than
503 `re_registers', POSIX uses an array of structures, instead of a
504 structure of arrays. */
507 regoff_t rm_so; /* Byte offset from string's start to substring's start. */
508 regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
511 /* Declarations for routines. */
513 /* Sets the current default syntax to SYNTAX, and return the old syntax.
514 You can also simply assign to the `re_syntax_options' variable. */
515 extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
517 /* Compile the regular expression PATTERN, with length LENGTH
518 and syntax given by the global `re_syntax_options', into the buffer
519 BUFFER. Return NULL if successful, and an error string if not. */
520 extern const char *re_compile_pattern (const char *__pattern, size_t __length,
521 struct re_pattern_buffer *__buffer);
524 /* Compile a fastmap for the compiled pattern in BUFFER; used to
525 accelerate searches. Return 0 if successful and -2 if was an
527 extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
530 /* Search in the string STRING (with length LENGTH) for the pattern
531 compiled into BUFFER. Start searching at position START, for RANGE
532 characters. Return the starting position of the match, -1 for no
533 match, or -2 for an internal error. Also return register
534 information in REGS (if REGS and BUFFER->re_no_sub are nonzero). */
535 extern int re_search (struct re_pattern_buffer *__buffer, const char *__string,
536 int __length, int __start, int __range,
537 struct re_registers *__regs);
540 /* Like `re_search', but search in the concatenation of STRING1 and
541 STRING2. Also, stop searching at index START + STOP. */
542 extern int re_search_2 (struct re_pattern_buffer *__buffer,
543 const char *__string1, int __length1,
544 const char *__string2, int __length2,
545 int __start, int __range, struct re_registers *__regs,
549 /* Like `re_search', but return how many characters in STRING the regexp
550 in BUFFER matched, starting at position START. */
551 extern int re_match (struct re_pattern_buffer *__buffer, const char *__string,
552 int __length, int __start, struct re_registers *__regs);
555 /* Relates to `re_match' as `re_search_2' relates to `re_search'. */
556 extern int re_match_2 (struct re_pattern_buffer *__buffer,
557 const char *__string1, int __length1,
558 const char *__string2, int __length2,
559 int __start, struct re_registers *__regs, int __stop);
562 /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
563 ENDS. Subsequent matches using BUFFER and REGS will use this memory
564 for recording register information. STARTS and ENDS must be
565 allocated with malloc, and must each be at least `NUM_REGS * sizeof
566 (regoff_t)' bytes long.
568 If NUM_REGS == 0, then subsequent matches should allocate their own
571 Unless this function is called, the first search or match using
572 PATTERN_BUFFER will allocate its own register data, without
573 freeing the old data. */
574 extern void re_set_registers (struct re_pattern_buffer *__buffer,
575 struct re_registers *__regs,
576 unsigned int __num_regs,
577 regoff_t *__starts, regoff_t *__ends);
579 #if defined _REGEX_RE_COMP || defined _LIBC
581 /* 4.2 bsd compatibility. */
582 extern char *re_comp (const char *);
583 extern int re_exec (const char *);
587 /* GCC 2.95 and later have "__restrict"; C99 compilers have
588 "restrict", and "configure" may have defined "restrict". */
590 # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
591 # if defined restrict || 199901L <= __STDC_VERSION__
592 # define __restrict restrict
598 /* gcc 3.1 and up support the [restrict] syntax, but g++ doesn't. */
599 #ifndef __restrict_arr
600 # if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) && !defined __cplusplus
601 # define __restrict_arr __restrict
603 # define __restrict_arr
607 /* POSIX compatibility. */
608 extern int regcomp (regex_t *__restrict __preg,
609 const char *__restrict __pattern,
612 extern int regexec (const regex_t *__restrict __preg,
613 const char *__restrict __string, size_t __nmatch,
614 regmatch_t __pmatch[__restrict_arr],
617 extern size_t regerror (int __errcode, const regex_t *__preg,
618 char *__errbuf, size_t __errbuf_size);
620 extern void regfree (regex_t *__preg);
625 /* Define the POSIX-compatible member names in terms of the
626 incompatible (and deprecated) names established by _REG_RE_NAME.
627 New programs should use the re_* names. */
629 # define re_allocated allocated
630 # define re_buffer buffer
631 # define re_can_be_null can_be_null
632 # define re_fastmap fastmap
633 # define re_newline_anchor newline_anchor
634 # define re_no_sub no_sub
635 # define re_not_bol not_bol
636 # define re_not_eol not_eol
637 # define re_regs_allocated regs_allocated
638 # define re_syntax syntax
639 # define re_translate translate
640 # define re_used used
642 /* Similarly for _REG_RM_NAME. */
645 # define rm_num_regs num_regs
646 # define rm_start start
648 /* Undef RE_DUP_MAX first, in case the user has already included a
649 <limits.h> with an incompatible definition.
651 On GNU systems, the most common spelling for RE_DUP_MAX's value in
652 <limits.h> is (0x7ffff), so define RE_DUP_MAX to that, not to
653 REG_DUP_MAX. This avoid some duplicate-macro-definition warnings
654 with programs that include <limits.h> after this file.
656 New programs should not assume that regex.h defines RE_DUP_MAX; to
657 get the value of RE_DUP_MAX, they should instead include <limits.h>
658 and possibly invoke the sysconf function. */
661 # define RE_DUP_MAX (0x7fff)
663 /* Define the following symbols for backward source compatibility.
664 These symbols violate the POSIX name space rules, and new programs
665 should avoid them. */
667 # define REGS_FIXED REG_FIXED
668 # define REGS_REALLOCATE REG_REALLOCATE
669 # define REGS_UNALLOCATED REG_UNALLOCATED
670 # define RE_BACKSLASH_ESCAPE_IN_LISTS REG_BACKSLASH_ESCAPE_IN_LISTS
671 # define RE_BK_PLUS_QM REG_BK_PLUS_QM
672 # define RE_CARET_ANCHORS_HERE REG_CARET_ANCHORS_HERE
673 # define RE_CHAR_CLASSES REG_CHAR_CLASSES
674 # define RE_CONTEXT_INDEP_ANCHORS REG_CONTEXT_INDEP_ANCHORS
675 # define RE_CONTEXT_INDEP_OPS REG_CONTEXT_INDEP_OPS
676 # define RE_CONTEXT_INVALID_DUP REG_CONTEXT_INVALID_DUP
677 # define RE_CONTEXT_INVALID_OPS REG_CONTEXT_INVALID_OPS
678 # define RE_DEBUG REG_DEBUG
679 # define RE_DOT_NEWLINE REG_DOT_NEWLINE
680 # define RE_DOT_NOT_NULL REG_DOT_NOT_NULL
681 # define RE_HAT_LISTS_NOT_NEWLINE REG_HAT_LISTS_NOT_NEWLINE
682 # define RE_ICASE REG_IGNORE_CASE /* avoid collision with REG_ICASE */
683 # define RE_INTERVALS REG_INTERVALS
684 # define RE_INVALID_INTERVAL_ORD REG_INVALID_INTERVAL_ORD
685 # define RE_LIMITED_OPS REG_LIMITED_OPS
686 # define RE_NEWLINE_ALT REG_NEWLINE_ALT
687 # define RE_NO_BK_BRACES REG_NO_BK_BRACES
688 # define RE_NO_BK_PARENS REG_NO_BK_PARENS
689 # define RE_NO_BK_REFS REG_NO_BK_REFS
690 # define RE_NO_BK_VBAR REG_NO_BK_VBAR
691 # define RE_NO_EMPTY_RANGES REG_NO_EMPTY_RANGES
692 # define RE_NO_GNU_OPS REG_NO_GNU_OPS
693 # define RE_NO_POSIX_BACKTRACKING REG_NO_POSIX_BACKTRACKING
694 # define RE_NO_SUB REG_NO_SUB
695 # define RE_NREGS REG_NREGS
696 # define RE_SYNTAX_AWK REG_SYNTAX_AWK
697 # define RE_SYNTAX_ED REG_SYNTAX_ED
698 # define RE_SYNTAX_EGREP REG_SYNTAX_EGREP
699 # define RE_SYNTAX_EMACS REG_SYNTAX_EMACS
700 # define RE_SYNTAX_GNU_AWK REG_SYNTAX_GNU_AWK
701 # define RE_SYNTAX_GREP REG_SYNTAX_GREP
702 # define RE_SYNTAX_POSIX_AWK REG_SYNTAX_POSIX_AWK
703 # define RE_SYNTAX_POSIX_BASIC REG_SYNTAX_POSIX_BASIC
704 # define RE_SYNTAX_POSIX_EGREP REG_SYNTAX_POSIX_EGREP
705 # define RE_SYNTAX_POSIX_EXTENDED REG_SYNTAX_POSIX_EXTENDED
706 # define RE_SYNTAX_POSIX_MINIMAL_BASIC REG_SYNTAX_POSIX_MINIMAL_BASIC
707 # define RE_SYNTAX_POSIX_MINIMAL_EXTENDED REG_SYNTAX_POSIX_MINIMAL_EXTENDED
708 # define RE_SYNTAX_SED REG_SYNTAX_SED
709 # define RE_UNMATCHED_RIGHT_PAREN_ORD REG_UNMATCHED_RIGHT_PAREN_ORD
710 # ifndef RE_TRANSLATE_TYPE
711 # define RE_TRANSLATE_TYPE REG_TRANSLATE_TYPE
714 #endif /* defined _REGEX_SOURCE */
726 trim-versions-without-asking: nil