1/*
2 * regex.h -- regular expression definitions for lsof
3 *
4 * This header file is used only when the dialect has no POSIX-conformant
5 * regular expression function set.  When that is the case, the dialect's
6 * machine.h will define USE_LIB_REGEX.
7 *
8 * When the dialect has a POSIX-conformant regular expression function set,
9 * USE_LIB_REGEX is not defined and this header file #include's <regex.h>.
10 *
11 * V. Abell <abe@purdue.edu>
12 * Purdue University
13 */
14
15
16/*
17 * Copyright 2000 Purdue Research Foundation, West Lafayette, Indiana
18 * 47907.  All rights reserved.
19 *
20 * Written by Victor A. Abell
21 *
22 * This software is not subject to any license of the American Telephone
23 * and Telegraph Company or the Regents of the University of California.
24 *
25 * This software has been adapted from snprintf.c in sendmail 8.9.3.  It
26 * is subject to the sendmail copyright statements listed below, and the
27 * sendmail licensing terms stated in the sendmail LICENSE file comment
28 * section of this file.
29 *
30 * Permission is granted to anyone to use this software for any purpose on
31 * any computer system, and to alter it and redistribute it freely, subject
32 * to the following restrictions:
33 *
34 * 1. Neither the authors nor Purdue University are responsible for any
35 *    consequences of the use of this software.
36 *
37 * 2. The origin of this software must not be misrepresented, either by
38 *    explicit claim or by omission.  Credit to the authors and Purdue
39 *    University must appear in documentation and sources.
40 *
41 * 3. Altered versions must be plainly marked as such, and must not be
42 *    misrepresented as being the original software.
43 *
44 * 4. This notice may not be removed or altered.
45 */
46
47
48#ifdef	USE_LIB_REGEX
49/*
50 * This section comes from GLIBC 2.2.  It is used only when the dialect
51 * has no POSIX-conformant regular expression function set.  When that is
52 * the case, the dialect's machine.h will define USE_LIB_REGEX.
53 */
54
55/* Definitions for data structures and routines for the regular
56   expression library, version 0.12.
57   Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
58
59   This file is part of the GNU C Library.  Its master source is NOT part of
60   the C library, however.  The master source lives in /gd/gnu/lib.
61
62   The GNU C Library is free software; you can redistribute it and/or
63   modify it under the terms of the GNU Library General Public License as
64   published by the Free Software Foundation; either version 2 of the
65   License, or (at your option) any later version.
66
67   The GNU C Library is distributed in the hope that it will be useful,
68   but WITHOUT ANY WARRANTY; without even the implied warranty of
69   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
70   Library General Public License for more details.
71
72   You should have received a copy of the GNU Library General Public
73   License along with the GNU C Library; see the file COPYING.LIB.  If not,
74   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
75   Boston, MA 02111-1307, USA.  */
76
77#ifndef _REGEX_H
78#define _REGEX_H 1
79
80/* Allow the use in C++ code.  */
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85/* POSIX says that <sys/types.h> must be included (by the caller) before
86   <regex.h>.  */
87
88#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
89/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
90   should be there.  */
91# include <stddef.h>
92#endif
93
94/* The following two types have to be signed and unsigned integer type
95   wide enough to hold a value of a pointer.  For most ANSI compilers
96   ptrdiff_t and size_t should be likely OK.  Still size of these two
97   types is 2 for Microsoft C.  Ugh... */
98typedef long int s_reg_t;
99typedef unsigned long int active_reg_t;
100
101/* The following bits are used to determine the regexp syntax we
102   recognize.  The set/not-set meanings are chosen so that Emacs syntax
103   remains the value 0.  The bits are given in alphabetical order, and
104   the definitions shifted by one from the previous bit; thus, when we
105   add or remove a bit, only one other definition need change.  */
106typedef unsigned long int reg_syntax_t;
107
108/* If this bit is not set, then \ inside a bracket expression is literal.
109   If set, then such a \ quotes the following character.  */
110#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
111
112/* If this bit is not set, then + and ? are operators, and \+ and \? are
113     literals.
114   If set, then \+ and \? are operators and + and ? are literals.  */
115#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
116
117/* If this bit is set, then character classes are supported.  They are:
118     [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
119     [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
120   If not set, then character classes are not supported.  */
121#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
122
123/* If this bit is set, then ^ and $ are always anchors (outside bracket
124     expressions, of course).
125   If this bit is not set, then it depends:
126        ^  is an anchor if it is at the beginning of a regular
127           expression or after an open-group or an alternation operator;
128        $  is an anchor if it is at the end of a regular expression, or
129           before a close-group or an alternation operator.
130
131   This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
132   POSIX draft 11.2 says that * etc. in leading positions is undefined.
133   We already implemented a previous draft which made those constructs
134   invalid, though, so we haven't changed the code back.  */
135#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
136
137/* If this bit is set, then special characters are always special
138     regardless of where they are in the pattern.
139   If this bit is not set, then special characters are special only in
140     some contexts; otherwise they are ordinary.  Specifically,
141     * + ? and intervals are only special when not after the beginning,
142     open-group, or alternation operator.  */
143#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
144
145/* If this bit is set, then *, +, ?, and { cannot be first in an re or
146     immediately after an alternation or begin-group operator.  */
147#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
148
149/* If this bit is set, then . matches newline.
150   If not set, then it doesn't.  */
151#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
152
153/* If this bit is set, then . doesn't match NUL.
154   If not set, then it does.  */
155#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
156
157/* If this bit is set, nonmatching lists [^...] do not match newline.
158   If not set, they do.  */
159#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
160
161/* If this bit is set, either \{...\} or {...} defines an
162     interval, depending on RE_NO_BK_BRACES.
163   If not set, \{, \}, {, and } are literals.  */
164#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
165
166/* If this bit is set, +, ? and | aren't recognized as operators.
167   If not set, they are.  */
168#define RE_LIMITED_OPS (RE_INTERVALS << 1)
169
170/* If this bit is set, newline is an alternation operator.
171   If not set, newline is literal.  */
172#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
173
174/* If this bit is set, then `{...}' defines an interval, and \{ and \}
175     are literals.
176  If not set, then `\{...\}' defines an interval.  */
177#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
178
179/* If this bit is set, (...) defines a group, and \( and \) are literals.
180   If not set, \(...\) defines a group, and ( and ) are literals.  */
181#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
182
183/* If this bit is set, then \<digit> matches <digit>.
184   If not set, then \<digit> is a back-reference.  */
185#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
186
187/* If this bit is set, then | is an alternation operator, and \| is literal.
188   If not set, then \| is an alternation operator, and | is literal.  */
189#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
190
191/* If this bit is set, then an ending range point collating higher
192     than the starting range point, as in [z-a], is invalid.
193   If not set, then when ending range point collates higher than the
194     starting range point, the range is ignored.  */
195#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
196
197/* If this bit is set, then an unmatched ) is ordinary.
198   If not set, then an unmatched ) is invalid.  */
199#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
200
201/* If this bit is set, succeed as soon as we match the whole pattern,
202   without further backtracking.  */
203#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
204
205/* If this bit is set, do not process the GNU regex operators.
206   If not set, then the GNU regex operators are recognized. */
207#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
208
209/* If this bit is set, turn on internal regex debugging.
210   If not set, and debugging was on, turn it off.
211   This only works if regex.c is compiled -DDEBUG.
212   We define this bit always, so that all that's needed to turn on
213   debugging is to recompile regex.c; the calling code can always have
214   this bit set, and it won't affect anything in the normal case. */
215#define RE_DEBUG (RE_NO_GNU_OPS << 1)
216
217/* This global variable defines the particular regexp syntax to use (for
218   some interfaces).  When a regexp is compiled, the syntax used is
219   stored in the pattern buffer, so changing this does not affect
220   already-compiled regexps.  */
221extern reg_syntax_t re_syntax_options;
222
223/* Define combinations of the above bits for the standard possibilities.
224   (The [[[ comments delimit what gets put into the Texinfo file, so
225   don't delete them!)  */
226/* [[[begin syntaxes]]] */
227#define RE_SYNTAX_EMACS 0
228
229#define RE_SYNTAX_AWK							\
230  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL			\
231   | RE_NO_BK_PARENS              | RE_NO_BK_REFS			\
232   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES			\
233   | RE_DOT_NEWLINE		  | RE_CONTEXT_INDEP_ANCHORS		\
234   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
235
236#define RE_SYNTAX_GNU_AWK						\
237  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG)	\
238   & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
239
240#define RE_SYNTAX_POSIX_AWK 						\
241  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS		\
242   | RE_INTERVALS	    | RE_NO_GNU_OPS)
243
244#define RE_SYNTAX_GREP							\
245  (RE_BK_PLUS_QM              | RE_CHAR_CLASSES				\
246   | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS				\
247   | RE_NEWLINE_ALT)
248
249#define RE_SYNTAX_EGREP							\
250  (RE_CHAR_CLASSES        | RE_CONTEXT_INDEP_ANCHORS			\
251   | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE			\
252   | RE_NEWLINE_ALT       | RE_NO_BK_PARENS				\
253   | RE_NO_BK_VBAR)
254
255#define RE_SYNTAX_POSIX_EGREP						\
256  (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
257
258/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff.  */
259#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
260
261#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
262
263/* Syntax bits common to both basic and extended POSIX regex syntax.  */
264#define _RE_SYNTAX_POSIX_COMMON						\
265  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL		\
266   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)
267
268#define RE_SYNTAX_POSIX_BASIC						\
269  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
270
271/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
272   RE_LIMITED_OPS, i.e., \? \+ \| are not recognized.  Actually, this
273   isn't minimal, since other operators, such as \`, aren't disabled.  */
274#define RE_SYNTAX_POSIX_MINIMAL_BASIC					\
275  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
276
277#define RE_SYNTAX_POSIX_EXTENDED					\
278  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
279   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES				\
280   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR				\
281   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
282
283/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
284   removed and RE_NO_BK_REFS is added.  */
285#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED				\
286  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
287   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES				\
288   | RE_NO_BK_PARENS        | RE_NO_BK_REFS				\
289   | RE_NO_BK_VBAR	    | RE_UNMATCHED_RIGHT_PAREN_ORD)
290/* [[[end syntaxes]]] */
291
292/* Maximum number of duplicates an interval can allow.  Some systems
293   (erroneously) define this in other header files, but we want our
294   value, so remove any previous define.  */
295#ifdef RE_DUP_MAX
296# undef RE_DUP_MAX
297#endif
298/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
299#define RE_DUP_MAX (0x7fff)
300
301
302/* POSIX `cflags' bits (i.e., information for `regcomp').  */
303
304/* If this bit is set, then use extended regular expression syntax.
305   If not set, then use basic regular expression syntax.  */
306#define REG_EXTENDED 1
307
308/* If this bit is set, then ignore case when matching.
309   If not set, then case is significant.  */
310#define REG_ICASE (REG_EXTENDED << 1)
311
312/* If this bit is set, then anchors do not match at newline
313     characters in the string.
314   If not set, then anchors do match at newlines.  */
315#define REG_NEWLINE (REG_ICASE << 1)
316
317/* If this bit is set, then report only success or fail in regexec.
318   If not set, then returns differ between not matching and errors.  */
319#define REG_NOSUB (REG_NEWLINE << 1)
320
321
322/* POSIX `eflags' bits (i.e., information for regexec).  */
323
324/* If this bit is set, then the beginning-of-line operator doesn't match
325     the beginning of the string (presumably because it's not the
326     beginning of a line).
327   If not set, then the beginning-of-line operator does match the
328     beginning of the string.  */
329#define REG_NOTBOL 1
330
331/* Like REG_NOTBOL, except for the end-of-line.  */
332#define REG_NOTEOL (1 << 1)
333
334
335/* If any error codes are removed, changed, or added, update the
336   `re_error_msg' table in regex.c.  */
337typedef enum
338{
339#ifdef _XOPEN_SOURCE
340  REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
341#endif
342
343  REG_NOERROR = 0,	/* Success.  */
344  REG_NOMATCH,		/* Didn't find a match (for regexec).  */
345
346  /* POSIX regcomp return error codes.  (In the order listed in the
347     standard.)  */
348  REG_BADPAT,		/* Invalid pattern.  */
349  REG_ECOLLATE,		/* Not implemented.  */
350  REG_ECTYPE,		/* Invalid character class name.  */
351  REG_EESCAPE,		/* Trailing backslash.  */
352  REG_ESUBREG,		/* Invalid back reference.  */
353  REG_EBRACK,		/* Unmatched left bracket.  */
354  REG_EPAREN,		/* Parenthesis imbalance.  */
355  REG_EBRACE,		/* Unmatched \{.  */
356  REG_BADBR,		/* Invalid contents of \{\}.  */
357  REG_ERANGE,		/* Invalid range end.  */
358  REG_ESPACE,		/* Ran out of memory.  */
359  REG_BADRPT,		/* No preceding re for repetition op.  */
360
361  /* Error codes we've added.  */
362  REG_EEND,		/* Premature end.  */
363  REG_ESIZE,		/* Compiled pattern bigger than 2^16 bytes.  */
364  REG_ERPAREN		/* Unmatched ) or \); not returned from regcomp. */
365} reg_errcode_t;
366
367/* This data structure represents a compiled pattern.  Before calling
368   the pattern compiler, the fields `buffer', `allocated', `fastmap',
369   `translate', and `no_sub' can be set.  After the pattern has been
370   compiled, the `re_nsub' field is available.  All other fields are
371   private to the regex routines.  */
372
373#ifndef RE_TRANSLATE_TYPE
374# define RE_TRANSLATE_TYPE char *
375#endif
376
377struct re_pattern_buffer
378{
379/* [[[begin pattern_buffer]]] */
380	/* Space that holds the compiled pattern.  It is declared as
381          `unsigned char *' because its elements are
382           sometimes used as array indexes.  */
383  unsigned char *buffer;
384
385	/* Number of bytes to which `buffer' points.  */
386  unsigned long int allocated;
387
388	/* Number of bytes actually used in `buffer'.  */
389  unsigned long int used;
390
391        /* Syntax setting with which the pattern was compiled.  */
392  reg_syntax_t syntax;
393
394        /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
395           the fastmap, if there is one, to skip over impossible
396           starting points for matches.  */
397  char *fastmap;
398
399        /* Either a translate table to apply to all characters before
400           comparing them, or zero for no translation.  The translation
401           is applied to a pattern when it is compiled and to a string
402           when it is matched.  */
403  RE_TRANSLATE_TYPE translate;
404
405	/* Number of subexpressions found by the compiler.  */
406  size_t re_nsub;
407
408        /* Zero if this pattern cannot match the empty string, one else.
409           Well, in truth it's used only in `re_search_2', to see
410           whether or not we should use the fastmap, so we don't set
411           this absolutely perfectly; see `re_compile_fastmap' (the
412           `duplicate' case).  */
413  unsigned can_be_null : 1;
414
415        /* If REGS_UNALLOCATED, allocate space in the `regs' structure
416             for `max (RE_NREGS, re_nsub + 1)' groups.
417           If REGS_REALLOCATE, reallocate space if necessary.
418           If REGS_FIXED, use what's there.  */
419#define REGS_UNALLOCATED 0
420#define REGS_REALLOCATE 1
421#define REGS_FIXED 2
422  unsigned regs_allocated : 2;
423
424        /* Set to zero when `regex_compile' compiles a pattern; set to one
425           by `re_compile_fastmap' if it updates the fastmap.  */
426  unsigned fastmap_accurate : 1;
427
428        /* If set, `re_match_2' does not return information about
429           subexpressions.  */
430  unsigned no_sub : 1;
431
432        /* If set, a beginning-of-line anchor doesn't match at the
433           beginning of the string.  */
434  unsigned not_bol : 1;
435
436        /* Similarly for an end-of-line anchor.  */
437  unsigned not_eol : 1;
438
439        /* If true, an anchor at a newline matches.  */
440  unsigned newline_anchor : 1;
441
442/* [[[end pattern_buffer]]] */
443};
444
445typedef struct re_pattern_buffer regex_t;
446
447/* Type for byte offsets within the string.  POSIX mandates this.  */
448typedef int regoff_t;
449
450
451/* This is the structure we store register match data in.  See
452   regex.texinfo for a full description of what registers match.  */
453struct re_registers
454{
455  unsigned num_regs;
456  regoff_t *start;
457  regoff_t *end;
458};
459
460
461/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
462   `re_match_2' returns information about at least this many registers
463   the first time a `regs' structure is passed.  */
464#ifndef RE_NREGS
465# define RE_NREGS 30
466#endif
467
468
469/* POSIX specification for registers.  Aside from the different names than
470   `re_registers', POSIX uses an array of structures, instead of a
471   structure of arrays.  */
472typedef struct
473{
474  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
475  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
476} regmatch_t;
477
478/* Declarations for routines.  */
479
480/* To avoid duplicating every routine declaration -- once with a
481   prototype (if we are ANSI), and once without (if we aren't) -- we
482   use the following macro to declare argument types.  This
483   unfortunately clutters up the declarations a bit, but I think it's
484   worth it.  */
485
486#if __STDC__
487
488# define _RE_ARGS(args) args
489
490#else /* not __STDC__ */
491
492# define _RE_ARGS(args) ()
493
494#endif /* not __STDC__ */
495
496/* Sets the current default syntax to SYNTAX, and return the old syntax.
497   You can also simply assign to the `re_syntax_options' variable.  */
498extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
499
500/* Compile the regular expression PATTERN, with length LENGTH
501   and syntax given by the global `re_syntax_options', into the buffer
502   BUFFER.  Return NULL if successful, and an error string if not.  */
503extern const char *re_compile_pattern
504  _RE_ARGS ((const char *pattern, size_t length,
505             struct re_pattern_buffer *buffer));
506
507
508/* Compile a fastmap for the compiled pattern in BUFFER; used to
509   accelerate searches.  Return 0 if successful and -2 if was an
510   internal error.  */
511extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
512
513
514/* Search in the string STRING (with length LENGTH) for the pattern
515   compiled into BUFFER.  Start searching at position START, for RANGE
516   characters.  Return the starting position of the match, -1 for no
517   match, or -2 for an internal error.  Also return register
518   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
519extern int re_search
520  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
521            int length, int start, int range, struct re_registers *regs));
522
523
524/* Like `re_search', but search in the concatenation of STRING1 and
525   STRING2.  Also, stop searching at index START + STOP.  */
526extern int re_search_2
527  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
528             int length1, const char *string2, int length2,
529             int start, int range, struct re_registers *regs, int stop));
530
531
532/* Like `re_search', but return how many characters in STRING the regexp
533   in BUFFER matched, starting at position START.  */
534extern int re_match
535  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
536             int length, int start, struct re_registers *regs));
537
538
539/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
540extern int re_match_2
541  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
542             int length1, const char *string2, int length2,
543             int start, struct re_registers *regs, int stop));
544
545
546/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
547   ENDS.  Subsequent matches using BUFFER and REGS will use this memory
548   for recording register information.  STARTS and ENDS must be
549   allocated with malloc, and must each be at least `NUM_REGS * sizeof
550   (regoff_t)' bytes long.
551
552   If NUM_REGS == 0, then subsequent matches should allocate their own
553   register data.
554
555   Unless this function is called, the first search or match using
556   PATTERN_BUFFER will allocate its own register data, without
557   freeing the old data.  */
558extern void re_set_registers
559  _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
560             unsigned num_regs, regoff_t *starts, regoff_t *ends));
561
562#if defined _REGEX_RE_COMP || defined _LIBC
563# ifndef _CRAY
564/* 4.2 bsd compatibility.  */
565extern char *re_comp _RE_ARGS ((const char *));
566extern int re_exec _RE_ARGS ((const char *));
567# endif
568#endif
569
570/* GCC 2.95 and later have "__restrict"; C99 compilers have
571   "restrict", and "configure" may have defined "restrict".  */
572#ifndef __restrict
573# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
574#  if defined restrict || 199901L <= __STDC_VERSION__
575#   define __restrict restrict
576#  else
577#   define __restrict
578#  endif
579# endif
580#endif
581/* For now unconditionally define __restrict_arr to expand to nothing.
582   Ideally we would have a test for the compiler which allows defining
583   it to restrict.  */
584#define __restrict_arr
585
586/* POSIX compatibility.  */
587extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
588			      const char *__restrict __pattern,
589			      int __cflags));
590
591extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
592			      const char *__restrict __string, size_t __nmatch,
593			      regmatch_t __pmatch[__restrict_arr],
594			      int __eflags));
595
596extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
597				  char *__errbuf, size_t __errbuf_size));
598
599extern void regfree _RE_ARGS ((regex_t *__preg));
600
601#ifdef __cplusplus
602}
603#endif	/* C++ */
604
605#endif /* regex.h */
606
607/*
608Local variables:
609make-backup-files: t
610version-control: t
611trim-versions-without-asking: nil
612End:
613*/
614
615#else	/* !defined(USE_LIB_REGEX) */
616#include <regex.h>
617#endif	/* defined(USE_LIB_REGEX) */
618