Blame deps/regex/regex.h

Packit Service 20376f
#include <stdio.h>
Packit Service 20376f
#include <stddef.h>
Packit Service 20376f
Packit Service 20376f
/* Definitions for data structures and routines for the regular
Packit Service 20376f
   expression library.
Packit Service 20376f
   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
Packit Service 20376f
   Free Software Foundation, Inc.
Packit Service 20376f
   This file is part of the GNU C Library.
Packit Service 20376f
Packit Service 20376f
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 20376f
   modify it under the terms of the GNU Lesser General Public
Packit Service 20376f
   License as published by the Free Software Foundation; either
Packit Service 20376f
   version 2.1 of the License, or (at your option) any later version.
Packit Service 20376f
Packit Service 20376f
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 20376f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 20376f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 20376f
   Lesser General Public License for more details.
Packit Service 20376f
Packit Service 20376f
   You should have received a copy of the GNU Lesser General Public
Packit Service 20376f
   License along with the GNU C Library; if not, write to the Free
Packit Service 20376f
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 20376f
   02110-1301 USA.  */
Packit Service 20376f
Packit Service 20376f
#ifndef _REGEX_H
Packit Service 20376f
#define _REGEX_H 1
Packit Service 20376f
Packit Service 20376f
#ifdef HAVE_STDDEF_H
Packit Service 20376f
#include <stddef.h>
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifdef HAVE_SYS_TYPES_H
Packit Service 20376f
#include <sys/types.h>
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifndef _LIBC
Packit Service 20376f
#define __USE_GNU	1
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/* Allow the use in C++ code.  */
Packit Service 20376f
#ifdef __cplusplus
Packit Service 20376f
extern "C" {
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/* The following two types have to be signed and unsigned integer type
Packit Service 20376f
   wide enough to hold a value of a pointer.  For most ANSI compilers
Packit Service 20376f
   ptrdiff_t and size_t should be likely OK.  Still size of these two
Packit Service 20376f
   types is 2 for Microsoft C.  Ugh... */
Packit Service 20376f
typedef long int s_reg_t;
Packit Service 20376f
typedef unsigned long int active_reg_t;
Packit Service 20376f
Packit Service 20376f
/* The following bits are used to determine the regexp syntax we
Packit Service 20376f
   recognize.  The set/not-set meanings are chosen so that Emacs syntax
Packit Service 20376f
   remains the value 0.  The bits are given in alphabetical order, and
Packit Service 20376f
   the definitions shifted by one from the previous bit; thus, when we
Packit Service 20376f
   add or remove a bit, only one other definition need change.  */
Packit Service 20376f
typedef unsigned long int reg_syntax_t;
Packit Service 20376f
Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
/* If this bit is not set, then \ inside a bracket expression is literal.
Packit Service 20376f
   If set, then such a \ quotes the following character.  */
Packit Service 20376f
# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is not set, then + and ? are operators, and \+ and \? are
Packit Service 20376f
     literals.
Packit Service 20376f
   If set, then \+ and \? are operators and + and ? are literals.  */
Packit Service 20376f
# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then character classes are supported.  They are:
Packit Service 20376f
     [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
Packit Service 20376f
     [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
Packit Service 20376f
   If not set, then character classes are not supported.  */
Packit Service 20376f
# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then ^ and $ are always anchors (outside bracket
Packit Service 20376f
     expressions, of course).
Packit Service 20376f
   If this bit is not set, then it depends:
Packit Service 20376f
        ^  is an anchor if it is at the beginning of a regular
Packit Service 20376f
           expression or after an open-group or an alternation operator;
Packit Service 20376f
        $  is an anchor if it is at the end of a regular expression, or
Packit Service 20376f
           before a close-group or an alternation operator.
Packit Service 20376f
Packit Service 20376f
   This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
Packit Service 20376f
   POSIX draft 11.2 says that * etc. in leading positions is undefined.
Packit Service 20376f
   We already implemented a previous draft which made those constructs
Packit Service 20376f
   invalid, though, so we haven't changed the code back.  */
Packit Service 20376f
# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then special characters are always special
Packit Service 20376f
     regardless of where they are in the pattern.
Packit Service 20376f
   If this bit is not set, then special characters are special only in
Packit Service 20376f
     some contexts; otherwise they are ordinary.  Specifically,
Packit Service 20376f
     * + ? and intervals are only special when not after the beginning,
Packit Service 20376f
     open-group, or alternation operator.  */
Packit Service 20376f
# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
Packit Service 20376f
     immediately after an alternation or begin-group operator.  */
Packit Service 20376f
# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then . matches newline.
Packit Service 20376f
   If not set, then it doesn't.  */
Packit Service 20376f
# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then . doesn't match NUL.
Packit Service 20376f
   If not set, then it does.  */
Packit Service 20376f
# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, nonmatching lists [^...] do not match newline.
Packit Service 20376f
   If not set, they do.  */
Packit Service 20376f
# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, either \{...\} or {...} defines an
Packit Service 20376f
     interval, depending on RE_NO_BK_BRACES.
Packit Service 20376f
   If not set, \{, \}, {, and } are literals.  */
Packit Service 20376f
# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, +, ? and | aren't recognized as operators.
Packit Service 20376f
   If not set, they are.  */
Packit Service 20376f
# define RE_LIMITED_OPS (RE_INTERVALS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, newline is an alternation operator.
Packit Service 20376f
   If not set, newline is literal.  */
Packit Service 20376f
# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
Packit Service 20376f
     are literals.
Packit Service 20376f
  If not set, then `\{...\}' defines an interval.  */
Packit Service 20376f
# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, (...) defines a group, and \( and \) are literals.
Packit Service 20376f
   If not set, \(...\) defines a group, and ( and ) are literals.  */
Packit Service 20376f
# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then \<digit> matches <digit>.
Packit Service 20376f
   If not set, then \<digit> is a back-reference.  */
Packit Service 20376f
# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then | is an alternation operator, and \| is literal.
Packit Service 20376f
   If not set, then \| is an alternation operator, and | is literal.  */
Packit Service 20376f
# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then an ending range point collating higher
Packit Service 20376f
     than the starting range point, as in [z-a], is invalid.
Packit Service 20376f
   If not set, then when ending range point collates higher than the
Packit Service 20376f
     starting range point, the range is ignored.  */
Packit Service 20376f
# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then an unmatched ) is ordinary.
Packit Service 20376f
   If not set, then an unmatched ) is invalid.  */
Packit Service 20376f
# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, succeed as soon as we match the whole pattern,
Packit Service 20376f
   without further backtracking.  */
Packit Service 20376f
# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, do not process the GNU regex operators.
Packit Service 20376f
   If not set, then the GNU regex operators are recognized. */
Packit Service 20376f
# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, a syntactically invalid interval is treated as
Packit Service 20376f
   a string of ordinary characters.  For example, the ERE 'a{1' is
Packit Service 20376f
   treated as 'a\{1'.  */
Packit Service 20376f
# define RE_INVALID_INTERVAL_ORD (RE_NO_GNU_OPS << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then ignore case when matching.
Packit Service 20376f
   If not set, then case is significant.  */
Packit Service 20376f
# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
Packit Service 20376f
Packit Service 20376f
/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
Packit Service 20376f
   for ^, because it is difficult to scan the regex backwards to find
Packit Service 20376f
   whether ^ should be special.  */
Packit Service 20376f
# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then \{ cannot be first in an bre or
Packit Service 20376f
   immediately after an alternation or begin-group operator.  */
Packit Service 20376f
# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then no_sub will be set to 1 during
Packit Service 20376f
   re_compile_pattern.  */
Packit Service 20376f
#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/* This global variable defines the particular regexp syntax to use (for
Packit Service 20376f
   some interfaces).  When a regexp is compiled, the syntax used is
Packit Service 20376f
   stored in the pattern buffer, so changing this does not affect
Packit Service 20376f
   already-compiled regexps.  */
Packit Service 20376f
extern reg_syntax_t re_syntax_options;
Packit Service 20376f

Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
/* Define combinations of the above bits for the standard possibilities.
Packit Service 20376f
   (The [[[ comments delimit what gets put into the Texinfo file, so
Packit Service 20376f
   don't delete them!)  */
Packit Service 20376f
/* [[[begin syntaxes]]] */
Packit Service 20376f
#define RE_SYNTAX_EMACS 0
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_AWK							\
Packit Service 20376f
  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL			\
Packit Service 20376f
   | RE_NO_BK_PARENS              | RE_NO_BK_REFS			\
Packit Service 20376f
   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES			\
Packit Service 20376f
   | RE_DOT_NEWLINE		  | RE_CONTEXT_INDEP_ANCHORS		\
Packit Service 20376f
   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_GNU_AWK						\
Packit Service 20376f
  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS		\
Packit Service 20376f
   | RE_INVALID_INTERVAL_ORD)						\
Packit Service 20376f
   & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS				\
Packit Service 20376f
       | RE_CONTEXT_INVALID_OPS ))
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_POSIX_AWK						\
Packit Service 20376f
  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS		\
Packit Service 20376f
   | RE_INTERVALS	    | RE_NO_GNU_OPS				\
Packit Service 20376f
   | RE_INVALID_INTERVAL_ORD)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_GREP							\
Packit Service 20376f
  (RE_BK_PLUS_QM              | RE_CHAR_CLASSES				\
Packit Service 20376f
   | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS				\
Packit Service 20376f
   | RE_NEWLINE_ALT)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_EGREP							\
Packit Service 20376f
  (RE_CHAR_CLASSES        | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 20376f
   | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE			\
Packit Service 20376f
   | RE_NEWLINE_ALT       | RE_NO_BK_PARENS				\
Packit Service 20376f
   | RE_NO_BK_VBAR)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_POSIX_EGREP						\
Packit Service 20376f
  (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES			\
Packit Service 20376f
   | RE_INVALID_INTERVAL_ORD)
Packit Service 20376f
Packit Service 20376f
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff.  */
Packit Service 20376f
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
Packit Service 20376f
Packit Service 20376f
/* Syntax bits common to both basic and extended POSIX regex syntax.  */
Packit Service 20376f
#define _RE_SYNTAX_POSIX_COMMON						\
Packit Service 20376f
  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL		\
Packit Service 20376f
   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_POSIX_BASIC						\
Packit Service 20376f
  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
Packit Service 20376f
Packit Service 20376f
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
Packit Service 20376f
   RE_LIMITED_OPS, i.e., \? \+ \| are not recognized.  Actually, this
Packit Service 20376f
   isn't minimal, since other operators, such as \`, aren't disabled.  */
Packit Service 20376f
#define RE_SYNTAX_POSIX_MINIMAL_BASIC					\
Packit Service 20376f
  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
Packit Service 20376f
Packit Service 20376f
#define RE_SYNTAX_POSIX_EXTENDED					\
Packit Service 20376f
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 20376f
   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES				\
Packit Service 20376f
   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR				\
Packit Service 20376f
   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
Packit Service 20376f
Packit Service 20376f
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
Packit Service 20376f
   removed and RE_NO_BK_REFS is added.  */
Packit Service 20376f
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED				\
Packit Service 20376f
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 20376f
   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES				\
Packit Service 20376f
   | RE_NO_BK_PARENS        | RE_NO_BK_REFS				\
Packit Service 20376f
   | RE_NO_BK_VBAR	    | RE_UNMATCHED_RIGHT_PAREN_ORD)
Packit Service 20376f
/* [[[end syntaxes]]] */
Packit Service 20376f

Packit Service 20376f
/* Maximum number of duplicates an interval can allow.  Some systems
Packit Service 20376f
   (erroneously) define this in other header files, but we want our
Packit Service 20376f
   value, so remove any previous define.  */
Packit Service 20376f
# ifdef RE_DUP_MAX
Packit Service 20376f
#  undef RE_DUP_MAX
Packit Service 20376f
# endif
Packit Service 20376f
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
Packit Service 20376f
# define RE_DUP_MAX (0x7fff)
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* POSIX `cflags' bits (i.e., information for `regcomp').  */
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then use extended regular expression syntax.
Packit Service 20376f
   If not set, then use basic regular expression syntax.  */
Packit Service 20376f
#define REG_EXTENDED 1
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then ignore case when matching.
Packit Service 20376f
   If not set, then case is significant.  */
Packit Service 20376f
#define REG_ICASE (REG_EXTENDED << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then anchors do not match at newline
Packit Service 20376f
     characters in the string.
Packit Service 20376f
   If not set, then anchors do match at newlines.  */
Packit Service 20376f
#define REG_NEWLINE (REG_ICASE << 1)
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then report only success or fail in regexec.
Packit Service 20376f
   If not set, then returns differ between not matching and errors.  */
Packit Service 20376f
#define REG_NOSUB (REG_NEWLINE << 1)
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* POSIX `eflags' bits (i.e., information for regexec).  */
Packit Service 20376f
Packit Service 20376f
/* If this bit is set, then the beginning-of-line operator doesn't match
Packit Service 20376f
     the beginning of the string (presumably because it's not the
Packit Service 20376f
     beginning of a line).
Packit Service 20376f
   If not set, then the beginning-of-line operator does match the
Packit Service 20376f
     beginning of the string.  */
Packit Service 20376f
#define REG_NOTBOL 1
Packit Service 20376f
Packit Service 20376f
/* Like REG_NOTBOL, except for the end-of-line.  */
Packit Service 20376f
#define REG_NOTEOL (1 << 1)
Packit Service 20376f
Packit Service 20376f
/* Use PMATCH[0] to delimit the start and end of the search in the
Packit Service 20376f
   buffer.  */
Packit Service 20376f
#define REG_STARTEND (1 << 2)
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* If any error codes are removed, changed, or added, update the
Packit Service 20376f
   `re_error_msg' table in regex.c.  */
Packit Service 20376f
typedef enum
Packit Service 20376f
{
Packit Service 20376f
#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
Packit Service 20376f
  REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
  REG_NOERROR = 0,	/* Success.  */
Packit Service 20376f
  REG_NOMATCH,		/* Didn't find a match (for regexec).  */
Packit Service 20376f
Packit Service 20376f
  /* POSIX regcomp return error codes.  (In the order listed in the
Packit Service 20376f
     standard.)  */
Packit Service 20376f
  REG_BADPAT,		/* Invalid pattern.  */
Packit Service 20376f
  REG_ECOLLATE,		/* Inalid collating element.  */
Packit Service 20376f
  REG_ECTYPE,		/* Invalid character class name.  */
Packit Service 20376f
  REG_EESCAPE,		/* Trailing backslash.  */
Packit Service 20376f
  REG_ESUBREG,		/* Invalid back reference.  */
Packit Service 20376f
  REG_EBRACK,		/* Unmatched left bracket.  */
Packit Service 20376f
  REG_EPAREN,		/* Parenthesis imbalance.  */
Packit Service 20376f
  REG_EBRACE,		/* Unmatched \{.  */
Packit Service 20376f
  REG_BADBR,		/* Invalid contents of \{\}.  */
Packit Service 20376f
  REG_ERANGE,		/* Invalid range end.  */
Packit Service 20376f
  REG_ESPACE,		/* Ran out of memory.  */
Packit Service 20376f
  REG_BADRPT,		/* No preceding re for repetition op.  */
Packit Service 20376f
Packit Service 20376f
  /* Error codes we've added.  */
Packit Service 20376f
  REG_EEND,		/* Premature end.  */
Packit Service 20376f
  REG_ESIZE,		/* Compiled pattern bigger than 2^16 bytes.  */
Packit Service 20376f
  REG_ERPAREN		/* Unmatched ) or \); not returned from regcomp.  */
Packit Service 20376f
} reg_errcode_t;
Packit Service 20376f

Packit Service 20376f
/* This data structure represents a compiled pattern.  Before calling
Packit Service 20376f
   the pattern compiler, the fields `buffer', `allocated', `fastmap',
Packit Service 20376f
   `translate', and `no_sub' can be set.  After the pattern has been
Packit Service 20376f
   compiled, the `re_nsub' field is available.  All other fields are
Packit Service 20376f
   private to the regex routines.  */
Packit Service 20376f
Packit Service 20376f
#ifndef RE_TRANSLATE_TYPE
Packit Service 20376f
# define __RE_TRANSLATE_TYPE unsigned char *
Packit Service 20376f
# ifdef __USE_GNU
Packit Service 20376f
#  define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
Packit Service 20376f
# endif
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
# define __REPB_PREFIX(name) name
Packit Service 20376f
#else
Packit Service 20376f
# define __REPB_PREFIX(name) __##name
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
struct re_pattern_buffer
Packit Service 20376f
{
Packit Service 20376f
  /* Space that holds the compiled pattern.  It is declared as
Packit Service 20376f
     `unsigned char *' because its elements are sometimes used as
Packit Service 20376f
     array indexes.  */
Packit Service 20376f
  unsigned char *__REPB_PREFIX(buffer);
Packit Service 20376f
Packit Service 20376f
  /* Number of bytes to which `buffer' points.  */
Packit Service 20376f
  unsigned long int __REPB_PREFIX(allocated);
Packit Service 20376f
Packit Service 20376f
  /* Number of bytes actually used in `buffer'.  */
Packit Service 20376f
  unsigned long int __REPB_PREFIX(used);
Packit Service 20376f
Packit Service 20376f
  /* Syntax setting with which the pattern was compiled.  */
Packit Service 20376f
  reg_syntax_t __REPB_PREFIX(syntax);
Packit Service 20376f
Packit Service 20376f
  /* Pointer to a fastmap, if any, otherwise zero.  re_search uses the
Packit Service 20376f
     fastmap, if there is one, to skip over impossible starting points
Packit Service 20376f
     for matches.  */
Packit Service 20376f
  char *__REPB_PREFIX(fastmap);
Packit Service 20376f
Packit Service 20376f
  /* Either a translate table to apply to all characters before
Packit Service 20376f
     comparing them, or zero for no translation.  The translation is
Packit Service 20376f
     applied to a pattern when it is compiled and to a string when it
Packit Service 20376f
     is matched.  */
Packit Service 20376f
  __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
Packit Service 20376f
Packit Service 20376f
  /* Number of subexpressions found by the compiler.  */
Packit Service 20376f
  size_t re_nsub;
Packit Service 20376f
Packit Service 20376f
  /* Zero if this pattern cannot match the empty string, one else.
Packit Service 20376f
     Well, in truth it's used only in `re_search_2', to see whether or
Packit Service 20376f
     not we should use the fastmap, so we don't set this absolutely
Packit Service 20376f
     perfectly; see `re_compile_fastmap' (the `duplicate' case).  */
Packit Service 20376f
  unsigned __REPB_PREFIX(can_be_null) : 1;
Packit Service 20376f
Packit Service 20376f
  /* If REGS_UNALLOCATED, allocate space in the `regs' structure
Packit Service 20376f
     for `max (RE_NREGS, re_nsub + 1)' groups.
Packit Service 20376f
     If REGS_REALLOCATE, reallocate space if necessary.
Packit Service 20376f
     If REGS_FIXED, use what's there.  */
Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
# define REGS_UNALLOCATED 0
Packit Service 20376f
# define REGS_REALLOCATE 1
Packit Service 20376f
# define REGS_FIXED 2
Packit Service 20376f
#endif
Packit Service 20376f
  unsigned __REPB_PREFIX(regs_allocated) : 2;
Packit Service 20376f
Packit Service 20376f
  /* Set to zero when `regex_compile' compiles a pattern; set to one
Packit Service 20376f
     by `re_compile_fastmap' if it updates the fastmap.  */
Packit Service 20376f
  unsigned __REPB_PREFIX(fastmap_accurate) : 1;
Packit Service 20376f
Packit Service 20376f
  /* If set, `re_match_2' does not return information about
Packit Service 20376f
     subexpressions.  */
Packit Service 20376f
  unsigned __REPB_PREFIX(no_sub) : 1;
Packit Service 20376f
Packit Service 20376f
  /* If set, a beginning-of-line anchor doesn't match at the beginning
Packit Service 20376f
     of the string.  */
Packit Service 20376f
  unsigned __REPB_PREFIX(not_bol) : 1;
Packit Service 20376f
Packit Service 20376f
  /* Similarly for an end-of-line anchor.  */
Packit Service 20376f
  unsigned __REPB_PREFIX(not_eol) : 1;
Packit Service 20376f
Packit Service 20376f
  /* If true, an anchor at a newline matches.  */
Packit Service 20376f
  unsigned __REPB_PREFIX(newline_anchor) : 1;
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
typedef struct re_pattern_buffer regex_t;
Packit Service 20376f

Packit Service 20376f
/* Type for byte offsets within the string.  POSIX mandates this.  */
Packit Service 20376f
typedef int regoff_t;
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
/* This is the structure we store register match data in.  See
Packit Service 20376f
   regex.texinfo for a full description of what registers match.  */
Packit Service 20376f
struct re_registers
Packit Service 20376f
{
Packit Service 20376f
  unsigned num_regs;
Packit Service 20376f
  regoff_t *start;
Packit Service 20376f
  regoff_t *end;
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
Packit Service 20376f
   `re_match_2' returns information about at least this many registers
Packit Service 20376f
   the first time a `regs' structure is passed.  */
Packit Service 20376f
# ifndef RE_NREGS
Packit Service 20376f
#  define RE_NREGS 30
Packit Service 20376f
# endif
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* POSIX specification for registers.  Aside from the different names than
Packit Service 20376f
   `re_registers', POSIX uses an array of structures, instead of a
Packit Service 20376f
   structure of arrays.  */
Packit Service 20376f
typedef struct
Packit Service 20376f
{
Packit Service 20376f
  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
Packit Service 20376f
  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
Packit Service 20376f
} regmatch_t;
Packit Service 20376f

Packit Service 20376f
/* Declarations for routines.  */
Packit Service 20376f
Packit Service 20376f
#ifdef __USE_GNU
Packit Service 20376f
/* Sets the current default syntax to SYNTAX, and return the old syntax.
Packit Service 20376f
   You can also simply assign to the `re_syntax_options' variable.  */
Packit Service 20376f
extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
Packit Service 20376f
Packit Service 20376f
/* Compile the regular expression PATTERN, with length LENGTH
Packit Service 20376f
   and syntax given by the global `re_syntax_options', into the buffer
Packit Service 20376f
   BUFFER.  Return NULL if successful, and an error string if not.  */
Packit Service 20376f
extern const char *re_compile_pattern (const char *__pattern, size_t __length,
Packit Service 20376f
				       struct re_pattern_buffer *__buffer);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Compile a fastmap for the compiled pattern in BUFFER; used to
Packit Service 20376f
   accelerate searches.  Return 0 if successful and -2 if was an
Packit Service 20376f
   internal error.  */
Packit Service 20376f
extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Search in the string STRING (with length LENGTH) for the pattern
Packit Service 20376f
   compiled into BUFFER.  Start searching at position START, for RANGE
Packit Service 20376f
   characters.  Return the starting position of the match, -1 for no
Packit Service 20376f
   match, or -2 for an internal error.  Also return register
Packit Service 20376f
   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
Packit Service 20376f
extern int re_search (struct re_pattern_buffer *__buffer, const char *__cstring,
Packit Service 20376f
		      int __length, int __start, int __range,
Packit Service 20376f
		      struct re_registers *__regs);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Like `re_search', but search in the concatenation of STRING1 and
Packit Service 20376f
   STRING2.  Also, stop searching at index START + STOP.  */
Packit Service 20376f
extern int re_search_2 (struct re_pattern_buffer *__buffer,
Packit Service 20376f
			const char *__string1, int __length1,
Packit Service 20376f
			const char *__string2, int __length2, int __start,
Packit Service 20376f
			int __range, struct re_registers *__regs, int __stop);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Like `re_search', but return how many characters in STRING the regexp
Packit Service 20376f
   in BUFFER matched, starting at position START.  */
Packit Service 20376f
extern int re_match (struct re_pattern_buffer *__buffer, const char *__cstring,
Packit Service 20376f
		     int __length, int __start, struct re_registers *__regs);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
Packit Service 20376f
extern int re_match_2 (struct re_pattern_buffer *__buffer,
Packit Service 20376f
		       const char *__string1, int __length1,
Packit Service 20376f
		       const char *__string2, int __length2, int __start,
Packit Service 20376f
		       struct re_registers *__regs, int __stop);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
Packit Service 20376f
   ENDS.  Subsequent matches using BUFFER and REGS will use this memory
Packit Service 20376f
   for recording register information.  STARTS and ENDS must be
Packit Service 20376f
   allocated with malloc, and must each be at least `NUM_REGS * sizeof
Packit Service 20376f
   (regoff_t)' bytes long.
Packit Service 20376f
Packit Service 20376f
   If NUM_REGS == 0, then subsequent matches should allocate their own
Packit Service 20376f
   register data.
Packit Service 20376f
Packit Service 20376f
   Unless this function is called, the first search or match using
Packit Service 20376f
   PATTERN_BUFFER will allocate its own register data, without
Packit Service 20376f
   freeing the old data.  */
Packit Service 20376f
extern void re_set_registers (struct re_pattern_buffer *__buffer,
Packit Service 20376f
			      struct re_registers *__regs,
Packit Service 20376f
			      unsigned int __num_regs,
Packit Service 20376f
			      regoff_t *__starts, regoff_t *__ends);
Packit Service 20376f
#endif	/* Use GNU */
Packit Service 20376f
Packit Service 20376f
#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
Packit Service 20376f
# ifndef _CRAY
Packit Service 20376f
/* 4.2 bsd compatibility.  */
Packit Service 20376f
extern char *re_comp (const char *);
Packit Service 20376f
extern int re_exec (const char *);
Packit Service 20376f
# endif
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/* GCC 2.95 and later have "__restrict"; C99 compilers have
Packit Service 20376f
   "restrict", and "configure" may have defined "restrict".  */
Packit Service 20376f
#ifndef __restrict
Packit Service 20376f
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
Packit Service 20376f
#  if defined restrict || 199901L <= __STDC_VERSION__
Packit Service 20376f
#   define __restrict restrict
Packit Service 20376f
#  else
Packit Service 20376f
#   define __restrict
Packit Service 20376f
#  endif
Packit Service 20376f
# endif
Packit Service 20376f
#endif
Packit Service 20376f
/* gcc 3.1 and up support the [restrict] syntax.  */
Packit Service 20376f
#ifndef __restrict_arr
Packit Service 20376f
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
Packit Service 20376f
     && !defined __GNUG__
Packit Service 20376f
#  define __restrict_arr __restrict
Packit Service 20376f
# else
Packit Service 20376f
#  define __restrict_arr
Packit Service 20376f
# endif
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/* POSIX compatibility.  */
Packit Service 20376f
extern int regcomp (regex_t *__restrict __preg,
Packit Service 20376f
		    const char *__restrict __pattern,
Packit Service 20376f
		    int __cflags);
Packit Service 20376f
Packit Service 20376f
extern int regexec (const regex_t *__restrict __preg,
Packit Service 20376f
		    const char *__restrict __cstring, size_t __nmatch,
Packit Service 20376f
		    regmatch_t __pmatch[__restrict_arr],
Packit Service 20376f
		    int __eflags);
Packit Service 20376f
Packit Service 20376f
extern size_t regerror (int __errcode, const regex_t *__restrict __preg,
Packit Service 20376f
			char *__restrict __errbuf, size_t __errbuf_size);
Packit Service 20376f
Packit Service 20376f
extern void regfree (regex_t *__preg);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
#ifdef __cplusplus
Packit Service 20376f
}
Packit Service 20376f
#endif	/* C++ */
Packit Service 20376f
Packit Service 20376f
#endif /* regex.h */