]> git.saurik.com Git - wxWidgets.git/blame - src/regex/regex.h
fix gcc warning
[wxWidgets.git] / src / regex / regex.h
CommitLineData
652bbafa
VZ
1#ifndef _REGEX_H_
2#define _REGEX_H_ /* never again */
d37acbdf
RN
3/*
4 * regular expressions
5 *
6 * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
7 *
8 * Development of this software was funded, in part, by Cray Research Inc.,
9 * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
10 * Corporation, none of whom are responsible for the results. The author
11 * thanks all of them.
12 *
13 * Redistribution and use in source and binary forms -- with or without
14 * modification -- are permitted for any purpose, provided that
15 * redistributions in source form retain this entire copyright notice and
16 * indicate the origin and nature of any modifications.
17 *
18 * I'd appreciate being given credit for this package in the documentation
19 * of software which uses it, but that is not a requirement.
20 *
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Id$
33 */
34
35/*
36 * Add your own defines, if needed, here.
37 */
652bbafa
VZ
38#ifdef __cplusplus
39extern "C" {
40#endif
41
04fdd873
DS
42// FreeBSD, Watcom and DMars require this, CW doesn't have nor need it.
43// Others also don't seem to need it. If you have an error related to
44// (not) including <sys/types.h> please report details to
45// wx-dev@lists.wxwindows.org
46#if defined(__UNIX__) || defined(__WATCOMC__) || defined(__DIGITALMARS__)
47# include <sys/types.h>
48#endif
49
d37acbdf
RN
50#include <stdio.h>
51#include <stdlib.h>
52
53#ifndef wxCHECK_GCC_VERSION
54#define wxCHECK_GCC_VERSION( major, minor ) \
55 ( defined(__GNUC__) && defined(__GNUC_MINOR__) \
56 && ( ( __GNUC__ > (major) ) \
57 || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) )
58#endif
59
60#if !wxUSE_UNICODE
61# define wx_wchar char
62#else // Unicode
63 #if (defined(__GNUC__) && !wxCHECK_GCC_VERSION(2, 96))
64# define wx_wchar __WCHAR_TYPE__
65 #else // __WCHAR_TYPE__ and gcc < 2.96
66 // standard case
67# define wx_wchar wchar_t
68 #endif // __WCHAR_TYPE__
69#endif // ASCII/Unicode
70
71/*
72 * interface types etc.
73 */
74
75/*
76 * regoff_t has to be large enough to hold either off_t or ssize_t,
77 * and must be signed; it's only a guess that long is suitable.
78 */
79typedef long regoff_t;
80
81/*
82 * other interface types
83 */
84
85/* the biggie, a compiled RE (or rather, a front end to same) */
86typedef struct
87{
88 int re_magic; /* magic number */
89 size_t re_nsub; /* number of subexpressions */
90 long re_info; /* information about RE */
91#define REG_UBACKREF 000001
92#define REG_ULOOKAHEAD 000002
93#define REG_UBOUNDS 000004
94#define REG_UBRACES 000010
95#define REG_UBSALNUM 000020
96#define REG_UPBOTCH 000040
97#define REG_UBBS 000100
98#define REG_UNONPOSIX 000200
99#define REG_UUNSPEC 000400
100#define REG_UUNPORT 001000
101#define REG_ULOCALE 002000
102#define REG_UEMPTYMATCH 004000
103#define REG_UIMPOSSIBLE 010000
104#define REG_USHORTEST 020000
105 int re_csize; /* sizeof(character) */
106 char *re_endp; /* backward compatibility kludge */
107 /* the rest is opaque pointers to hidden innards */
108 char *re_guts; /* `char *' is more portable than `void *' */
109 char *re_fns;
652bbafa 110} regex_t;
d37acbdf
RN
111
112/* result reporting (may acquire more fields later) */
113typedef struct
114{
115 regoff_t rm_so; /* start of substring */
116 regoff_t rm_eo; /* end of substring */
652bbafa
VZ
117} regmatch_t;
118
d37acbdf
RN
119/* supplementary control and reporting */
120typedef struct
121{
122 regmatch_t rm_extend; /* see REG_EXPECT */
123} rm_detail_t;
652bbafa 124
652bbafa
VZ
125
126
d37acbdf
RN
127/*
128 * regex compilation flags
129 */
130#define REG_BASIC 000000 /* BREs (convenience) */
131#define REG_EXTENDED 000001 /* EREs */
132#define REG_ADVF 000002 /* advanced features in EREs */
133#define REG_ADVANCED 000003 /* AREs (which are also EREs) */
134#define REG_QUOTE 000004 /* no special characters, none */
135#define REG_NOSPEC REG_QUOTE /* historical synonym */
136#define REG_ICASE 000010 /* ignore case */
137#define REG_NOSUB 000020 /* don't care about subexpressions */
138#define REG_EXPANDED 000040 /* expanded format, white space & comments */
139#define REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
140#define REG_NLANCH 000200 /* ^ matches after \n, $ before */
141#define REG_NEWLINE 000300 /* newlines are line terminators */
142#define REG_PEND 000400 /* ugh -- backward-compatibility hack */
143#define REG_EXPECT 001000 /* report details on partial/limited
144 * matches */
145#define REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */
146#define REG_DUMP 004000 /* none of your business :-) */
147#define REG_FAKE 010000 /* none of your business :-) */
148#define REG_PROGRESS 020000 /* none of your business :-) */
652bbafa
VZ
149
150
d37acbdf
RN
151
152/*
153 * regex execution flags
154 */
155#define REG_NOTBOL 0001 /* BOS is not BOL */
156#define REG_NOTEOL 0002 /* EOS is not EOL */
157#define REG_STARTEND 0004 /* backward compatibility kludge */
158#define REG_FTRACE 0010 /* none of your business */
159#define REG_MTRACE 0020 /* none of your business */
160#define REG_SMALL 0040 /* none of your business */
161
162
163/*
164 * error reporting
165 * Be careful if modifying the list of error codes -- the table used by
166 * regerror() is generated automatically from this file!
167 */
168#define REG_OKAY 0 /* no errors detected */
169#define REG_NOMATCH 1 /* failed to match */
170#define REG_BADPAT 2 /* invalid regexp */
171#define REG_ECOLLATE 3 /* invalid collating element */
172#define REG_ECTYPE 4 /* invalid character class */
173#define REG_EESCAPE 5 /* invalid escape \ sequence */
174#define REG_ESUBREG 6 /* invalid backreference number */
175#define REG_EBRACK 7 /* brackets [] not balanced */
176#define REG_EPAREN 8 /* parentheses () not balanced */
177#define REG_EBRACE 9 /* braces {} not balanced */
178#define REG_BADBR 10 /* invalid repetition count(s) */
179#define REG_ERANGE 11 /* invalid character range */
180#define REG_ESPACE 12 /* out of memory */
181#define REG_BADRPT 13 /* quantifier operand invalid */
182#define REG_ASSERT 15 /* "can't happen" -- you found a bug */
183#define REG_INVARG 16 /* invalid argument to regex function */
184#define REG_MIXED 17 /* character widths of regex and string
185 * differ */
186#define REG_BADOPT 18 /* invalid embedded option */
187/* two specials for debugging and testing */
188#define REG_ATOI 101 /* convert error-code name to number */
189#define REG_ITOA 102 /* convert error-code number to name */
190
191
192
193/*
194 * the prototypes for exported functions
195 */
196extern int wx_regcomp(regex_t *, const wx_wchar *, size_t, int);
197extern int regcomp(regex_t *, const wx_wchar *, int);
198extern int wx_regexec(regex_t *, const wx_wchar *, size_t, rm_detail_t *, size_t, regmatch_t[], int);
199extern int regexec(regex_t *, const wx_wchar *, size_t, regmatch_t[], int);
652bbafa 200extern void regfree(regex_t *);
d37acbdf
RN
201extern size_t regerror(int, const regex_t *, char *, size_t);
202extern void wx_regfree(regex_t *);
203extern size_t wx_regerror(int, const regex_t *, char *, size_t);
652bbafa
VZ
204
205#ifdef __cplusplus
206}
207#endif
d37acbdf
RN
208
209#endif /* _REGEX_H_ */