]> git.ipfire.org Git - thirdparty/glibc.git/blame - misc/regexp.c
aarch64: add STO_AARCH64_VARIANT_PCS and DT_AARCH64_VARIANT_PCS
[thirdparty/glibc.git] / misc / regexp.c
CommitLineData
1c70b6f1 1/* Compatibility symbols for the obsolete <regexp.h> interface.
688903eb 2 Copyright (C) 1996-2018 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 19
1c70b6f1
ZW
20/* regexp.h now contains only an #error directive, so it cannot be
21 used in this file.
22
23 The function that would produce an 'expbuf' to use as the second
24 argument to 'step' and 'advance' was defined only in regexp.h,
25 as its definition depended on macros defined by the user. */
2ec11c2b
ZW
26
27#include <regex.h>
1c70b6f1
ZW
28#include <shlib-compat.h>
29
30#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
84384f5b 31
388b4f1a
L
32/* Define the variables used for the interface. Avoid .symver on common
33 symbol, which just creates a new common symbol, not an alias. */
34char *loc1 __attribute__ ((nocommon));
35char *loc2 __attribute__ ((nocommon));
1c70b6f1
ZW
36compat_symbol (libc, loc1, loc1, GLIBC_2_0);
37compat_symbol (libc, loc2, loc2, GLIBC_2_0);
84384f5b
UD
38
39/* Although we do not support the use we define this variable as well. */
388b4f1a 40char *locs __attribute__ ((nocommon));
1c70b6f1 41compat_symbol (libc, locs, locs, GLIBC_2_0);
84384f5b
UD
42
43
44/* Find the next match in STRING. The compiled regular expression is
45 found in the buffer starting at EXPBUF. `loc1' will return the
46 first character matched and `loc2' points to the next unmatched
47 character. */
48int
1c70b6f1
ZW
49weak_function attribute_compat_text_section
50step (const char *string, const char *expbuf)
84384f5b
UD
51{
52 regmatch_t match; /* We only need info about the full match. */
53
54 expbuf += __alignof (regex_t *);
55 expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
56
49f3a758 57 if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
84384f5b
UD
58 == REG_NOMATCH)
59 return 0;
60
61 loc1 = (char *) string + match.rm_so;
62 loc2 = (char *) string + match.rm_eo;
63 return 1;
64}
1c70b6f1 65compat_symbol (libc, step, step, GLIBC_2_0);
84384f5b
UD
66
67
68/* Match the beginning of STRING with the compiled regular expression
69 in EXPBUF. If the match is successful `loc2' will contain the
70 position of the first unmatched character. */
71int
1c70b6f1
ZW
72weak_function attribute_compat_text_section
73advance (const char *string, const char *expbuf)
84384f5b
UD
74{
75 regmatch_t match; /* We only need info about the full match. */
76
77 expbuf += __alignof__ (regex_t *);
78 expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
79
49f3a758 80 if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
84384f5b
UD
81 == REG_NOMATCH
82 /* We have to check whether the check is at the beginning of the
83 buffer. */
84 || match.rm_so != 0)
85 return 0;
86
87 loc2 = (char *) string + match.rm_eo;
88 return 1;
89}
1c70b6f1
ZW
90compat_symbol (libc, advance, advance, GLIBC_2_0);
91
92
93#endif /* SHLIB_COMPAT (2.0, 2.23) */