Initial sources of crywrap 0.2.1.
[crywrap.git] / lib / compat / compat-regex.h
blob3945087c50c791bf97bfc04aca9c8ac4ed64434c
1 /* Definitions for data structures and routines for the regular
2 expression library.
3 Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003
4 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 /* Cleaned from _RE_ARGS and other stuff for Thy. */
24 #ifndef __DOXYGEN__
26 #if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP) && \
27 defined(HAVE_WORKING_REGEX_H)
28 #include <sys/types.h>
29 #include <regex.h>
30 #else
32 #warning You are using the compatilibty regex definitions.
33 #warning They might not match your system!
35 #ifndef _COMPAT_REGEX_H
36 #define _COMPAT_REGEX_H 1
38 #include <sys/types.h>
40 /* The following bits are used to determine the regexp syntax we
41 recognize. The set/not-set meanings are chosen so that Emacs syntax
42 remains the value 0. The bits are given in alphabetical order, and
43 the definitions shifted by one from the previous bit; thus, when we
44 add or remove a bit, only one other definition need change. */
45 typedef unsigned long int reg_syntax_t;
47 /* POSIX `cflags' bits (i.e., information for `regcomp'). */
49 /* If this bit is set, then use extended regular expression syntax.
50 If not set, then use basic regular expression syntax. */
51 #define REG_EXTENDED 1
54 #define REG_NOERROR 0
55 #define REG_NOMATCH 1
57 /* This data structure represents a compiled pattern. Before calling
58 the pattern compiler, the fields `buffer', `allocated', `fastmap',
59 `translate', and `no_sub' can be set. After the pattern has been
60 compiled, the `re_nsub' field is available. All other fields are
61 private to the regex routines. */
63 #ifndef RE_TRANSLATE_TYPE
64 # define RE_TRANSLATE_TYPE char *
65 #endif
67 struct re_pattern_buffer
69 /* [[[begin pattern_buffer]]] */
70 /* Space that holds the compiled pattern. It is declared as
71 `unsigned char *' because its elements are
72 sometimes used as array indexes. */
73 unsigned char *buffer;
75 /* Number of bytes to which `buffer' points. */
76 unsigned long int allocated;
78 /* Number of bytes actually used in `buffer'. */
79 unsigned long int used;
81 /* Syntax setting with which the pattern was compiled. */
82 reg_syntax_t syntax;
84 /* Pointer to a fastmap, if any, otherwise zero. re_search uses
85 the fastmap, if there is one, to skip over impossible
86 starting points for matches. */
87 char *fastmap;
89 /* Either a translate table to apply to all characters before
90 comparing them, or zero for no translation. The translation
91 is applied to a pattern when it is compiled and to a string
92 when it is matched. */
93 RE_TRANSLATE_TYPE translate;
95 /* Number of subexpressions found by the compiler. */
96 size_t re_nsub;
98 /* Zero if this pattern cannot match the empty string, one else.
99 Well, in truth it's used only in `re_search_2', to see
100 whether or not we should use the fastmap, so we don't set
101 this absolutely perfectly; see `re_compile_fastmap' (the
102 `duplicate' case). */
103 unsigned can_be_null : 1;
105 /* If REGS_UNALLOCATED, allocate space in the `regs' structure
106 for `max (RE_NREGS, re_nsub + 1)' groups.
107 If REGS_REALLOCATE, reallocate space if necessary.
108 If REGS_FIXED, use what's there. */
109 #define REGS_UNALLOCATED 0
110 #define REGS_REALLOCATE 1
111 #define REGS_FIXED 2
112 unsigned regs_allocated : 2;
114 /* Set to zero when `regex_compile' compiles a pattern; set to one
115 by `re_compile_fastmap' if it updates the fastmap. */
116 unsigned fastmap_accurate : 1;
118 /* If set, `re_match_2' does not return information about
119 subexpressions. */
120 unsigned no_sub : 1;
122 /* If set, a beginning-of-line anchor doesn't match at the
123 beginning of the string. */
124 unsigned not_bol : 1;
126 /* Similarly for an end-of-line anchor. */
127 unsigned not_eol : 1;
129 /* If true, an anchor at a newline matches. */
130 unsigned newline_anchor : 1;
132 /* [[[end pattern_buffer]]] */
135 typedef struct re_pattern_buffer regex_t;
137 /* Type for byte offsets within the string. POSIX mandates this. */
138 typedef int regoff_t;
140 /* POSIX specification for registers. Aside from the different names
141 than `re_registers', POSIX uses an array of structures, instead of
142 a structure of arrays. */
143 typedef struct
145 regoff_t rm_so; /* Byte offset from string's start to substring's
146 start. */
147 regoff_t rm_eo; /* Byte offset from string's start to substring's
148 end. */
149 } regmatch_t;
151 /* POSIX compatibility. */
152 extern int regcomp (regex_t * ,
153 const char * __pattern,
154 int __cflags);
156 extern int regexec (const regex_t * ,
157 const char * __string, size_t __nmatch,
158 regmatch_t __pmatch[],
159 int __eflags);
161 extern size_t regerror (int __errcode, const regex_t *,
162 char *__errbuf, size_t __errbuf_size);
164 extern void regfree (regex_t *);
166 #endif /* compat-regex.h */
168 #endif /* !defined(HAVE_REGEX_H) || !defined(HAVE_REGCOMP) */
170 #endif /* !__DOXYGEN__ */
173 Local variables:
174 make-backup-files: t
175 version-control: t
176 trim-versions-without-asking: nil
177 arch-tag: 37e0fa64-c2a0-4600-8ea8-eb41ca0dc002
178 End: