]> git.saurik.com Git - wxWidgets.git/blob - src/regex/regfronts.c
reverted Julian's unintentional breakage of wxChoice
[wxWidgets.git] / src / regex / regfronts.c
1 /*
2 * regcomp and regexec - front ends to re_ routines
3 *
4 * Mostly for implementation of backward-compatibility kludges. Note
5 * that these routines exist ONLY in char versions.
6 *
7 * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
8 *
9 * Development of this software was funded, in part, by Cray Research Inc.,
10 * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
11 * Corporation, none of whom are responsible for the results. The author
12 * thanks all of them.
13 *
14 * Redistribution and use in source and binary forms -- with or without
15 * modification -- are permitted for any purpose, provided that
16 * redistributions in source form retain this entire copyright notice and
17 * indicate the origin and nature of any modifications.
18 *
19 * I'd appreciate being given credit for this package in the documentation
20 * of software which uses it, but that is not a requirement.
21 *
22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
25 * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35 #include "regguts.h"
36
37 /*
38 - regcomp - compile regular expression
39 */
40 int
41 regcomp(re, str, flags)
42 regex_t *re;
43 CONST char *str;
44 int flags;
45 {
46 size_t len;
47 int f = flags;
48
49 if (f&REG_PEND) {
50 len = re->re_endp - str;
51 f &= ~REG_PEND;
52 } else
53 len = strlen(str);
54
55 return re_comp(re, str, len, f);
56 }
57
58 /*
59 - regexec - execute regular expression
60 */
61 int
62 regexec(re, str, nmatch, pmatch, flags)
63 regex_t *re;
64 CONST char *str;
65 size_t nmatch;
66 regmatch_t pmatch[];
67 int flags;
68 {
69 CONST char *start;
70 size_t len;
71 int f = flags;
72
73 if (f&REG_STARTEND) {
74 start = str + pmatch[0].rm_so;
75 len = pmatch[0].rm_eo - pmatch[0].rm_so;
76 f &= ~REG_STARTEND;
77 } else {
78 start = str;
79 len = strlen(str);
80 }
81
82 return re_exec(re, start, len, nmatch, pmatch, f);
83 }