]>
Commit | Line | Data |
---|---|---|
84384f5b | 1 | /* Define function and variables for the obsolete <regexp.h> interface. |
0bb258e3 | 2 | Copyright (C) 1996, 2000 Free Software Foundation, Inc. |
84384f5b UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
84384f5b UD |
10 | |
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
84384f5b | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
84384f5b UD |
19 | |
20 | #define __DO_NOT_DEFINE_COMPILE | |
21 | #include <regexp.h> | |
22 | ||
23 | /* Define the variables used for the interface. */ | |
24 | char *loc1; | |
25 | char *loc2; | |
26 | ||
27 | /* Although we do not support the use we define this variable as well. */ | |
28 | char *locs; | |
29 | ||
30 | ||
31 | /* Find the next match in STRING. The compiled regular expression is | |
32 | found in the buffer starting at EXPBUF. `loc1' will return the | |
33 | first character matched and `loc2' points to the next unmatched | |
34 | character. */ | |
49f3a758 | 35 | extern int __step (const char *string, const char *expbuf); |
84384f5b UD |
36 | int |
37 | __step (const char *string, const char *expbuf) | |
38 | { | |
39 | regmatch_t match; /* We only need info about the full match. */ | |
40 | ||
41 | expbuf += __alignof (regex_t *); | |
42 | expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *); | |
43 | ||
49f3a758 | 44 | if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL) |
84384f5b UD |
45 | == REG_NOMATCH) |
46 | return 0; | |
47 | ||
48 | loc1 = (char *) string + match.rm_so; | |
49 | loc2 = (char *) string + match.rm_eo; | |
50 | return 1; | |
51 | } | |
52 | weak_alias (__step, step) | |
53 | ||
54 | ||
55 | /* Match the beginning of STRING with the compiled regular expression | |
56 | in EXPBUF. If the match is successful `loc2' will contain the | |
57 | position of the first unmatched character. */ | |
49f3a758 | 58 | extern int __advance (const char *string, const char *expbuf); |
84384f5b UD |
59 | int |
60 | __advance (const char *string, const char *expbuf) | |
61 | { | |
62 | regmatch_t match; /* We only need info about the full match. */ | |
63 | ||
64 | expbuf += __alignof__ (regex_t *); | |
65 | expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *); | |
66 | ||
49f3a758 | 67 | if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL) |
84384f5b UD |
68 | == REG_NOMATCH |
69 | /* We have to check whether the check is at the beginning of the | |
70 | buffer. */ | |
71 | || match.rm_so != 0) | |
72 | return 0; | |
73 | ||
74 | loc2 = (char *) string + match.rm_eo; | |
75 | return 1; | |
76 | } | |
77 | weak_alias (__advance, advance) |