Blame regex.h

Packit Service 603f59
/*
Packit Service 603f59
 * regex.h -- regular expression definitions for lsof
Packit Service 603f59
 *
Packit Service 603f59
 * This header file is used only when the dialect has no POSIX-conformant
Packit Service 603f59
 * regular expression function set.  When that is the case, the dialect's
Packit Service 603f59
 * machine.h will define USE_LIB_REGEX.
Packit Service 603f59
 *
Packit Service 603f59
 * When the dialect has a POSIX-conformant regular expression function set,
Packit Service 603f59
 * USE_LIB_REGEX is not defined and this header file #include's <regex.h>.
Packit Service 603f59
 *
Packit Service 603f59
 * V. Abell <abe@purdue.edu>
Packit Service 603f59
 * Purdue University
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Copyright 2000 Purdue Research Foundation, West Lafayette, Indiana
Packit Service 603f59
 * 47907.  All rights reserved.
Packit Service 603f59
 *
Packit Service 603f59
 * Written by Victor A. Abell
Packit Service 603f59
 *
Packit Service 603f59
 * This software is not subject to any license of the American Telephone
Packit Service 603f59
 * and Telegraph Company or the Regents of the University of California.
Packit Service 603f59
 *
Packit Service 603f59
 * This software has been adapted from snprintf.c in sendmail 8.9.3.  It
Packit Service 603f59
 * is subject to the sendmail copyright statements listed below, and the
Packit Service 603f59
 * sendmail licensing terms stated in the sendmail LICENSE file comment
Packit Service 603f59
 * section of this file.
Packit Service 603f59
 *
Packit Service 603f59
 * Permission is granted to anyone to use this software for any purpose on
Packit Service 603f59
 * any computer system, and to alter it and redistribute it freely, subject
Packit Service 603f59
 * to the following restrictions:
Packit Service 603f59
 *
Packit Service 603f59
 * 1. Neither the authors nor Purdue University are responsible for any
Packit Service 603f59
 *    consequences of the use of this software.
Packit Service 603f59
 *
Packit Service 603f59
 * 2. The origin of this software must not be misrepresented, either by
Packit Service 603f59
 *    explicit claim or by omission.  Credit to the authors and Purdue
Packit Service 603f59
 *    University must appear in documentation and sources.
Packit Service 603f59
 *
Packit Service 603f59
 * 3. Altered versions must be plainly marked as such, and must not be
Packit Service 603f59
 *    misrepresented as being the original software.
Packit Service 603f59
 *
Packit Service 603f59
 * 4. This notice may not be removed or altered.
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
#ifdef	USE_LIB_REGEX
Packit Service 603f59
/*
Packit Service 603f59
 * This section comes from GLIBC 2.2.  It is used only when the dialect
Packit Service 603f59
 * has no POSIX-conformant regular expression function set.  When that is
Packit Service 603f59
 * the case, the dialect's machine.h will define USE_LIB_REGEX.
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
/* Definitions for data structures and routines for the regular
Packit Service 603f59
   expression library, version 0.12.
Packit Service 603f59
   Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
Packit Service 603f59
Packit Service 603f59
   This file is part of the GNU C Library.  Its master source is NOT part of
Packit Service 603f59
   the C library, however.  The master source lives in /gd/gnu/lib.
Packit Service 603f59
Packit Service 603f59
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 603f59
   modify it under the terms of the GNU Library General Public License as
Packit Service 603f59
   published by the Free Software Foundation; either version 2 of the
Packit Service 603f59
   License, or (at your option) any later version.
Packit Service 603f59
Packit Service 603f59
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 603f59
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 603f59
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 603f59
   Library General Public License for more details.
Packit Service 603f59
Packit Service 603f59
   You should have received a copy of the GNU Library General Public
Packit Service 603f59
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
Packit Service 603f59
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service 603f59
   Boston, MA 02111-1307, USA.  */
Packit Service 603f59
Packit Service 603f59
#ifndef _REGEX_H
Packit Service 603f59
#define _REGEX_H 1
Packit Service 603f59
Packit Service 603f59
/* Allow the use in C++ code.  */
Packit Service 603f59
#ifdef __cplusplus
Packit Service 603f59
extern "C" {
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
/* POSIX says that <sys/types.h> must be included (by the caller) before
Packit Service 603f59
   <regex.h>.  */
Packit Service 603f59
Packit Service 603f59
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
Packit Service 603f59
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
Packit Service 603f59
   should be there.  */
Packit Service 603f59
# include <stddef.h>
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
/* The following two types have to be signed and unsigned integer type
Packit Service 603f59
   wide enough to hold a value of a pointer.  For most ANSI compilers
Packit Service 603f59
   ptrdiff_t and size_t should be likely OK.  Still size of these two
Packit Service 603f59
   types is 2 for Microsoft C.  Ugh... */
Packit Service 603f59
typedef long int s_reg_t;
Packit Service 603f59
typedef unsigned long int active_reg_t;
Packit Service 603f59
Packit Service 603f59
/* The following bits are used to determine the regexp syntax we
Packit Service 603f59
   recognize.  The set/not-set meanings are chosen so that Emacs syntax
Packit Service 603f59
   remains the value 0.  The bits are given in alphabetical order, and
Packit Service 603f59
   the definitions shifted by one from the previous bit; thus, when we
Packit Service 603f59
   add or remove a bit, only one other definition need change.  */
Packit Service 603f59
typedef unsigned long int reg_syntax_t;
Packit Service 603f59
Packit Service 603f59
/* If this bit is not set, then \ inside a bracket expression is literal.
Packit Service 603f59
   If set, then such a \ quotes the following character.  */
Packit Service 603f59
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is not set, then + and ? are operators, and \+ and \? are
Packit Service 603f59
     literals.
Packit Service 603f59
   If set, then \+ and \? are operators and + and ? are literals.  */
Packit Service 603f59
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then character classes are supported.  They are:
Packit Service 603f59
     [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
Packit Service 603f59
     [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
Packit Service 603f59
   If not set, then character classes are not supported.  */
Packit Service 603f59
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then ^ and $ are always anchors (outside bracket
Packit Service 603f59
     expressions, of course).
Packit Service 603f59
   If this bit is not set, then it depends:
Packit Service 603f59
        ^  is an anchor if it is at the beginning of a regular
Packit Service 603f59
           expression or after an open-group or an alternation operator;
Packit Service 603f59
        $  is an anchor if it is at the end of a regular expression, or
Packit Service 603f59
           before a close-group or an alternation operator.
Packit Service 603f59
Packit Service 603f59
   This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
Packit Service 603f59
   POSIX draft 11.2 says that * etc. in leading positions is undefined.
Packit Service 603f59
   We already implemented a previous draft which made those constructs
Packit Service 603f59
   invalid, though, so we haven't changed the code back.  */
Packit Service 603f59
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then special characters are always special
Packit Service 603f59
     regardless of where they are in the pattern.
Packit Service 603f59
   If this bit is not set, then special characters are special only in
Packit Service 603f59
     some contexts; otherwise they are ordinary.  Specifically,
Packit Service 603f59
     * + ? and intervals are only special when not after the beginning,
Packit Service 603f59
     open-group, or alternation operator.  */
Packit Service 603f59
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
Packit Service 603f59
     immediately after an alternation or begin-group operator.  */
Packit Service 603f59
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then . matches newline.
Packit Service 603f59
   If not set, then it doesn't.  */
Packit Service 603f59
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then . doesn't match NUL.
Packit Service 603f59
   If not set, then it does.  */
Packit Service 603f59
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, nonmatching lists [^...] do not match newline.
Packit Service 603f59
   If not set, they do.  */
Packit Service 603f59
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, either \{...\} or {...} defines an
Packit Service 603f59
     interval, depending on RE_NO_BK_BRACES.
Packit Service 603f59
   If not set, \{, \}, {, and } are literals.  */
Packit Service 603f59
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, +, ? and | aren't recognized as operators.
Packit Service 603f59
   If not set, they are.  */
Packit Service 603f59
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, newline is an alternation operator.
Packit Service 603f59
   If not set, newline is literal.  */
Packit Service 603f59
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
Packit Service 603f59
     are literals.
Packit Service 603f59
  If not set, then `\{...\}' defines an interval.  */
Packit Service 603f59
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, (...) defines a group, and \( and \) are literals.
Packit Service 603f59
   If not set, \(...\) defines a group, and ( and ) are literals.  */
Packit Service 603f59
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then \<digit> matches <digit>.
Packit Service 603f59
   If not set, then \<digit> is a back-reference.  */
Packit Service 603f59
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then | is an alternation operator, and \| is literal.
Packit Service 603f59
   If not set, then \| is an alternation operator, and | is literal.  */
Packit Service 603f59
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then an ending range point collating higher
Packit Service 603f59
     than the starting range point, as in [z-a], is invalid.
Packit Service 603f59
   If not set, then when ending range point collates higher than the
Packit Service 603f59
     starting range point, the range is ignored.  */
Packit Service 603f59
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then an unmatched ) is ordinary.
Packit Service 603f59
   If not set, then an unmatched ) is invalid.  */
Packit Service 603f59
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, succeed as soon as we match the whole pattern,
Packit Service 603f59
   without further backtracking.  */
Packit Service 603f59
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, do not process the GNU regex operators.
Packit Service 603f59
   If not set, then the GNU regex operators are recognized. */
Packit Service 603f59
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, turn on internal regex debugging.
Packit Service 603f59
   If not set, and debugging was on, turn it off.
Packit Service 603f59
   This only works if regex.c is compiled -DDEBUG.
Packit Service 603f59
   We define this bit always, so that all that's needed to turn on
Packit Service 603f59
   debugging is to recompile regex.c; the calling code can always have
Packit Service 603f59
   this bit set, and it won't affect anything in the normal case. */
Packit Service 603f59
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
Packit Service 603f59
Packit Service 603f59
/* This global variable defines the particular regexp syntax to use (for
Packit Service 603f59
   some interfaces).  When a regexp is compiled, the syntax used is
Packit Service 603f59
   stored in the pattern buffer, so changing this does not affect
Packit Service 603f59
   already-compiled regexps.  */
Packit Service 603f59
extern reg_syntax_t re_syntax_options;
Packit Service 603f59

Packit Service 603f59
/* Define combinations of the above bits for the standard possibilities.
Packit Service 603f59
   (The [[[ comments delimit what gets put into the Texinfo file, so
Packit Service 603f59
   don't delete them!)  */
Packit Service 603f59
/* [[[begin syntaxes]]] */
Packit Service 603f59
#define RE_SYNTAX_EMACS 0
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_AWK							\
Packit Service 603f59
  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL			\
Packit Service 603f59
   | RE_NO_BK_PARENS              | RE_NO_BK_REFS			\
Packit Service 603f59
   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES			\
Packit Service 603f59
   | RE_DOT_NEWLINE		  | RE_CONTEXT_INDEP_ANCHORS		\
Packit Service 603f59
   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_GNU_AWK						\
Packit Service 603f59
  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG)	\
Packit Service 603f59
   & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_POSIX_AWK 						\
Packit Service 603f59
  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS		\
Packit Service 603f59
   | RE_INTERVALS	    | RE_NO_GNU_OPS)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_GREP							\
Packit Service 603f59
  (RE_BK_PLUS_QM              | RE_CHAR_CLASSES				\
Packit Service 603f59
   | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS				\
Packit Service 603f59
   | RE_NEWLINE_ALT)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_EGREP							\
Packit Service 603f59
  (RE_CHAR_CLASSES        | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 603f59
   | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE			\
Packit Service 603f59
   | RE_NEWLINE_ALT       | RE_NO_BK_PARENS				\
Packit Service 603f59
   | RE_NO_BK_VBAR)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_POSIX_EGREP						\
Packit Service 603f59
  (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
Packit Service 603f59
Packit Service 603f59
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff.  */
Packit Service 603f59
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
Packit Service 603f59
Packit Service 603f59
/* Syntax bits common to both basic and extended POSIX regex syntax.  */
Packit Service 603f59
#define _RE_SYNTAX_POSIX_COMMON						\
Packit Service 603f59
  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL		\
Packit Service 603f59
   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_POSIX_BASIC						\
Packit Service 603f59
  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
Packit Service 603f59
Packit Service 603f59
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
Packit Service 603f59
   RE_LIMITED_OPS, i.e., \? \+ \| are not recognized.  Actually, this
Packit Service 603f59
   isn't minimal, since other operators, such as \`, aren't disabled.  */
Packit Service 603f59
#define RE_SYNTAX_POSIX_MINIMAL_BASIC					\
Packit Service 603f59
  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
Packit Service 603f59
Packit Service 603f59
#define RE_SYNTAX_POSIX_EXTENDED					\
Packit Service 603f59
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 603f59
   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES				\
Packit Service 603f59
   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR				\
Packit Service 603f59
   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
Packit Service 603f59
Packit Service 603f59
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
Packit Service 603f59
   removed and RE_NO_BK_REFS is added.  */
Packit Service 603f59
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED				\
Packit Service 603f59
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
Packit Service 603f59
   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES				\
Packit Service 603f59
   | RE_NO_BK_PARENS        | RE_NO_BK_REFS				\
Packit Service 603f59
   | RE_NO_BK_VBAR	    | RE_UNMATCHED_RIGHT_PAREN_ORD)
Packit Service 603f59
/* [[[end syntaxes]]] */
Packit Service 603f59

Packit Service 603f59
/* Maximum number of duplicates an interval can allow.  Some systems
Packit Service 603f59
   (erroneously) define this in other header files, but we want our
Packit Service 603f59
   value, so remove any previous define.  */
Packit Service 603f59
#ifdef RE_DUP_MAX
Packit Service 603f59
# undef RE_DUP_MAX
Packit Service 603f59
#endif
Packit Service 603f59
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
Packit Service 603f59
#define RE_DUP_MAX (0x7fff)
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* POSIX `cflags' bits (i.e., information for `regcomp').  */
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then use extended regular expression syntax.
Packit Service 603f59
   If not set, then use basic regular expression syntax.  */
Packit Service 603f59
#define REG_EXTENDED 1
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then ignore case when matching.
Packit Service 603f59
   If not set, then case is significant.  */
Packit Service 603f59
#define REG_ICASE (REG_EXTENDED << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then anchors do not match at newline
Packit Service 603f59
     characters in the string.
Packit Service 603f59
   If not set, then anchors do match at newlines.  */
Packit Service 603f59
#define REG_NEWLINE (REG_ICASE << 1)
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then report only success or fail in regexec.
Packit Service 603f59
   If not set, then returns differ between not matching and errors.  */
Packit Service 603f59
#define REG_NOSUB (REG_NEWLINE << 1)
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* POSIX `eflags' bits (i.e., information for regexec).  */
Packit Service 603f59
Packit Service 603f59
/* If this bit is set, then the beginning-of-line operator doesn't match
Packit Service 603f59
     the beginning of the string (presumably because it's not the
Packit Service 603f59
     beginning of a line).
Packit Service 603f59
   If not set, then the beginning-of-line operator does match the
Packit Service 603f59
     beginning of the string.  */
Packit Service 603f59
#define REG_NOTBOL 1
Packit Service 603f59
Packit Service 603f59
/* Like REG_NOTBOL, except for the end-of-line.  */
Packit Service 603f59
#define REG_NOTEOL (1 << 1)
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* If any error codes are removed, changed, or added, update the
Packit Service 603f59
   `re_error_msg' table in regex.c.  */
Packit Service 603f59
typedef enum
Packit Service 603f59
{
Packit Service 603f59
#ifdef _XOPEN_SOURCE
Packit Service 603f59
  REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
  REG_NOERROR = 0,	/* Success.  */
Packit Service 603f59
  REG_NOMATCH,		/* Didn't find a match (for regexec).  */
Packit Service 603f59
Packit Service 603f59
  /* POSIX regcomp return error codes.  (In the order listed in the
Packit Service 603f59
     standard.)  */
Packit Service 603f59
  REG_BADPAT,		/* Invalid pattern.  */
Packit Service 603f59
  REG_ECOLLATE,		/* Not implemented.  */
Packit Service 603f59
  REG_ECTYPE,		/* Invalid character class name.  */
Packit Service 603f59
  REG_EESCAPE,		/* Trailing backslash.  */
Packit Service 603f59
  REG_ESUBREG,		/* Invalid back reference.  */
Packit Service 603f59
  REG_EBRACK,		/* Unmatched left bracket.  */
Packit Service 603f59
  REG_EPAREN,		/* Parenthesis imbalance.  */
Packit Service 603f59
  REG_EBRACE,		/* Unmatched \{.  */
Packit Service 603f59
  REG_BADBR,		/* Invalid contents of \{\}.  */
Packit Service 603f59
  REG_ERANGE,		/* Invalid range end.  */
Packit Service 603f59
  REG_ESPACE,		/* Ran out of memory.  */
Packit Service 603f59
  REG_BADRPT,		/* No preceding re for repetition op.  */
Packit Service 603f59
Packit Service 603f59
  /* Error codes we've added.  */
Packit Service 603f59
  REG_EEND,		/* Premature end.  */
Packit Service 603f59
  REG_ESIZE,		/* Compiled pattern bigger than 2^16 bytes.  */
Packit Service 603f59
  REG_ERPAREN		/* Unmatched ) or \); not returned from regcomp. */
Packit Service 603f59
} reg_errcode_t;
Packit Service 603f59

Packit Service 603f59
/* This data structure represents a compiled pattern.  Before calling
Packit Service 603f59
   the pattern compiler, the fields `buffer', `allocated', `fastmap',
Packit Service 603f59
   `translate', and `no_sub' can be set.  After the pattern has been
Packit Service 603f59
   compiled, the `re_nsub' field is available.  All other fields are
Packit Service 603f59
   private to the regex routines.  */
Packit Service 603f59
Packit Service 603f59
#ifndef RE_TRANSLATE_TYPE
Packit Service 603f59
# define RE_TRANSLATE_TYPE char *
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
struct re_pattern_buffer
Packit Service 603f59
{
Packit Service 603f59
/* [[[begin pattern_buffer]]] */
Packit Service 603f59
	/* Space that holds the compiled pattern.  It is declared as
Packit Service 603f59
          `unsigned char *' because its elements are
Packit Service 603f59
           sometimes used as array indexes.  */
Packit Service 603f59
  unsigned char *buffer;
Packit Service 603f59
Packit Service 603f59
	/* Number of bytes to which `buffer' points.  */
Packit Service 603f59
  unsigned long int allocated;
Packit Service 603f59
Packit Service 603f59
	/* Number of bytes actually used in `buffer'.  */
Packit Service 603f59
  unsigned long int used;
Packit Service 603f59
Packit Service 603f59
        /* Syntax setting with which the pattern was compiled.  */
Packit Service 603f59
  reg_syntax_t syntax;
Packit Service 603f59
Packit Service 603f59
        /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
Packit Service 603f59
           the fastmap, if there is one, to skip over impossible
Packit Service 603f59
           starting points for matches.  */
Packit Service 603f59
  char *fastmap;
Packit Service 603f59
Packit Service 603f59
        /* Either a translate table to apply to all characters before
Packit Service 603f59
           comparing them, or zero for no translation.  The translation
Packit Service 603f59
           is applied to a pattern when it is compiled and to a string
Packit Service 603f59
           when it is matched.  */
Packit Service 603f59
  RE_TRANSLATE_TYPE translate;
Packit Service 603f59
Packit Service 603f59
	/* Number of subexpressions found by the compiler.  */
Packit Service 603f59
  size_t re_nsub;
Packit Service 603f59
Packit Service 603f59
        /* Zero if this pattern cannot match the empty string, one else.
Packit Service 603f59
           Well, in truth it's used only in `re_search_2', to see
Packit Service 603f59
           whether or not we should use the fastmap, so we don't set
Packit Service 603f59
           this absolutely perfectly; see `re_compile_fastmap' (the
Packit Service 603f59
           `duplicate' case).  */
Packit Service 603f59
  unsigned can_be_null : 1;
Packit Service 603f59
Packit Service 603f59
        /* If REGS_UNALLOCATED, allocate space in the `regs' structure
Packit Service 603f59
             for `max (RE_NREGS, re_nsub + 1)' groups.
Packit Service 603f59
           If REGS_REALLOCATE, reallocate space if necessary.
Packit Service 603f59
           If REGS_FIXED, use what's there.  */
Packit Service 603f59
#define REGS_UNALLOCATED 0
Packit Service 603f59
#define REGS_REALLOCATE 1
Packit Service 603f59
#define REGS_FIXED 2
Packit Service 603f59
  unsigned regs_allocated : 2;
Packit Service 603f59
Packit Service 603f59
        /* Set to zero when `regex_compile' compiles a pattern; set to one
Packit Service 603f59
           by `re_compile_fastmap' if it updates the fastmap.  */
Packit Service 603f59
  unsigned fastmap_accurate : 1;
Packit Service 603f59
Packit Service 603f59
        /* If set, `re_match_2' does not return information about
Packit Service 603f59
           subexpressions.  */
Packit Service 603f59
  unsigned no_sub : 1;
Packit Service 603f59
Packit Service 603f59
        /* If set, a beginning-of-line anchor doesn't match at the
Packit Service 603f59
           beginning of the string.  */
Packit Service 603f59
  unsigned not_bol : 1;
Packit Service 603f59
Packit Service 603f59
        /* Similarly for an end-of-line anchor.  */
Packit Service 603f59
  unsigned not_eol : 1;
Packit Service 603f59
Packit Service 603f59
        /* If true, an anchor at a newline matches.  */
Packit Service 603f59
  unsigned newline_anchor : 1;
Packit Service 603f59
Packit Service 603f59
/* [[[end pattern_buffer]]] */
Packit Service 603f59
};
Packit Service 603f59
Packit Service 603f59
typedef struct re_pattern_buffer regex_t;
Packit Service 603f59

Packit Service 603f59
/* Type for byte offsets within the string.  POSIX mandates this.  */
Packit Service 603f59
typedef int regoff_t;
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* This is the structure we store register match data in.  See
Packit Service 603f59
   regex.texinfo for a full description of what registers match.  */
Packit Service 603f59
struct re_registers
Packit Service 603f59
{
Packit Service 603f59
  unsigned num_regs;
Packit Service 603f59
  regoff_t *start;
Packit Service 603f59
  regoff_t *end;
Packit Service 603f59
};
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
Packit Service 603f59
   `re_match_2' returns information about at least this many registers
Packit Service 603f59
   the first time a `regs' structure is passed.  */
Packit Service 603f59
#ifndef RE_NREGS
Packit Service 603f59
# define RE_NREGS 30
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* POSIX specification for registers.  Aside from the different names than
Packit Service 603f59
   `re_registers', POSIX uses an array of structures, instead of a
Packit Service 603f59
   structure of arrays.  */
Packit Service 603f59
typedef struct
Packit Service 603f59
{
Packit Service 603f59
  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
Packit Service 603f59
  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
Packit Service 603f59
} regmatch_t;
Packit Service 603f59

Packit Service 603f59
/* Declarations for routines.  */
Packit Service 603f59
Packit Service 603f59
/* To avoid duplicating every routine declaration -- once with a
Packit Service 603f59
   prototype (if we are ANSI), and once without (if we aren't) -- we
Packit Service 603f59
   use the following macro to declare argument types.  This
Packit Service 603f59
   unfortunately clutters up the declarations a bit, but I think it's
Packit Service 603f59
   worth it.  */
Packit Service 603f59
Packit Service 603f59
#if __STDC__
Packit Service 603f59
Packit Service 603f59
# define _RE_ARGS(args) args
Packit Service 603f59
Packit Service 603f59
#else /* not __STDC__ */
Packit Service 603f59
Packit Service 603f59
# define _RE_ARGS(args) ()
Packit Service 603f59
Packit Service 603f59
#endif /* not __STDC__ */
Packit Service 603f59
Packit Service 603f59
/* Sets the current default syntax to SYNTAX, and return the old syntax.
Packit Service 603f59
   You can also simply assign to the `re_syntax_options' variable.  */
Packit Service 603f59
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
Packit Service 603f59
Packit Service 603f59
/* Compile the regular expression PATTERN, with length LENGTH
Packit Service 603f59
   and syntax given by the global `re_syntax_options', into the buffer
Packit Service 603f59
   BUFFER.  Return NULL if successful, and an error string if not.  */
Packit Service 603f59
extern const char *re_compile_pattern
Packit Service 603f59
  _RE_ARGS ((const char *pattern, size_t length,
Packit Service 603f59
             struct re_pattern_buffer *buffer));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Compile a fastmap for the compiled pattern in BUFFER; used to
Packit Service 603f59
   accelerate searches.  Return 0 if successful and -2 if was an
Packit Service 603f59
   internal error.  */
Packit Service 603f59
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Search in the string STRING (with length LENGTH) for the pattern
Packit Service 603f59
   compiled into BUFFER.  Start searching at position START, for RANGE
Packit Service 603f59
   characters.  Return the starting position of the match, -1 for no
Packit Service 603f59
   match, or -2 for an internal error.  Also return register
Packit Service 603f59
   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
Packit Service 603f59
extern int re_search
Packit Service 603f59
  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
Packit Service 603f59
            int length, int start, int range, struct re_registers *regs));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Like `re_search', but search in the concatenation of STRING1 and
Packit Service 603f59
   STRING2.  Also, stop searching at index START + STOP.  */
Packit Service 603f59
extern int re_search_2
Packit Service 603f59
  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
Packit Service 603f59
             int length1, const char *string2, int length2,
Packit Service 603f59
             int start, int range, struct re_registers *regs, int stop));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Like `re_search', but return how many characters in STRING the regexp
Packit Service 603f59
   in BUFFER matched, starting at position START.  */
Packit Service 603f59
extern int re_match
Packit Service 603f59
  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
Packit Service 603f59
             int length, int start, struct re_registers *regs));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
Packit Service 603f59
extern int re_match_2
Packit Service 603f59
  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
Packit Service 603f59
             int length1, const char *string2, int length2,
Packit Service 603f59
             int start, struct re_registers *regs, int stop));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
Packit Service 603f59
   ENDS.  Subsequent matches using BUFFER and REGS will use this memory
Packit Service 603f59
   for recording register information.  STARTS and ENDS must be
Packit Service 603f59
   allocated with malloc, and must each be at least `NUM_REGS * sizeof
Packit Service 603f59
   (regoff_t)' bytes long.
Packit Service 603f59
Packit Service 603f59
   If NUM_REGS == 0, then subsequent matches should allocate their own
Packit Service 603f59
   register data.
Packit Service 603f59
Packit Service 603f59
   Unless this function is called, the first search or match using
Packit Service 603f59
   PATTERN_BUFFER will allocate its own register data, without
Packit Service 603f59
   freeing the old data.  */
Packit Service 603f59
extern void re_set_registers
Packit Service 603f59
  _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
Packit Service 603f59
             unsigned num_regs, regoff_t *starts, regoff_t *ends));
Packit Service 603f59
Packit Service 603f59
#if defined _REGEX_RE_COMP || defined _LIBC
Packit Service 603f59
# ifndef _CRAY
Packit Service 603f59
/* 4.2 bsd compatibility.  */
Packit Service 603f59
extern char *re_comp _RE_ARGS ((const char *));
Packit Service 603f59
extern int re_exec _RE_ARGS ((const char *));
Packit Service 603f59
# endif
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
/* GCC 2.95 and later have "__restrict"; C99 compilers have
Packit Service 603f59
   "restrict", and "configure" may have defined "restrict".  */
Packit Service 603f59
#ifndef __restrict
Packit Service 603f59
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
Packit Service 603f59
#  if defined restrict || 199901L <= __STDC_VERSION__
Packit Service 603f59
#   define __restrict restrict
Packit Service 603f59
#  else
Packit Service 603f59
#   define __restrict
Packit Service 603f59
#  endif
Packit Service 603f59
# endif
Packit Service 603f59
#endif
Packit Service 603f59
/* For now unconditionally define __restrict_arr to expand to nothing.
Packit Service 603f59
   Ideally we would have a test for the compiler which allows defining
Packit Service 603f59
   it to restrict.  */
Packit Service 603f59
#define __restrict_arr
Packit Service 603f59
Packit Service 603f59
/* POSIX compatibility.  */
Packit Service 603f59
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
Packit Service 603f59
			      const char *__restrict __pattern,
Packit Service 603f59
			      int __cflags));
Packit Service 603f59
Packit Service 603f59
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
Packit Service 603f59
			      const char *__restrict __string, size_t __nmatch,
Packit Service 603f59
			      regmatch_t __pmatch[__restrict_arr],
Packit Service 603f59
			      int __eflags));
Packit Service 603f59
Packit Service 603f59
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
Packit Service 603f59
				  char *__errbuf, size_t __errbuf_size));
Packit Service 603f59
Packit Service 603f59
extern void regfree _RE_ARGS ((regex_t *__preg));
Packit Service 603f59
Packit Service 603f59
#ifdef __cplusplus
Packit Service 603f59
}
Packit Service 603f59
#endif	/* C++ */
Packit Service 603f59
Packit Service 603f59
#endif /* regex.h */
Packit Service 603f59

Packit Service 603f59
/*
Packit Service 603f59
Local variables:
Packit Service 603f59
make-backup-files: t
Packit Service 603f59
version-control: t
Packit Service 603f59
trim-versions-without-asking: nil
Packit Service 603f59
End:
Packit Service 603f59
*/
Packit Service 603f59
Packit Service 603f59
#else	/* !defined(USE_LIB_REGEX) */
Packit Service 603f59
#include <regex.h>
Packit Service 603f59
#endif	/* defined(USE_LIB_REGEX) */