1 /* Compatibility symbols for the obsolete <regexp.h> interface.
2 Copyright (C) 1996-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* regexp.h now contains only an #error directive, so it cannot be
22 The function that would produce an 'expbuf' to use as the second
23 argument to 'step' and 'advance' was defined only in regexp.h,
24 as its definition depended on macros defined by the user. */
28 #include <shlib-compat.h>
30 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
32 /* Define the variables used for the interface. */
35 compat_symbol (libc
, loc1
, loc1
, GLIBC_2_0
);
36 compat_symbol (libc
, loc2
, loc2
, GLIBC_2_0
);
38 /* Although we do not support the use we define this variable as well. */
40 compat_symbol (libc
, locs
, locs
, GLIBC_2_0
);
43 /* Find the next match in STRING. The compiled regular expression is
44 found in the buffer starting at EXPBUF. `loc1' will return the
45 first character matched and `loc2' points to the next unmatched
48 weak_function attribute_compat_text_section
49 step (const char *string
, const char *expbuf
)
51 regmatch_t match
; /* We only need info about the full match. */
53 expbuf
+= __alignof (regex_t
*);
54 expbuf
-= ((uintptr_t) expbuf
) % __alignof__ (regex_t
*);
56 if (__regexec ((const regex_t
*) expbuf
, string
, 1, &match
, REG_NOTEOL
)
60 loc1
= (char *) string
+ match
.rm_so
;
61 loc2
= (char *) string
+ match
.rm_eo
;
64 compat_symbol (libc
, step
, step
, GLIBC_2_0
);
67 /* Match the beginning of STRING with the compiled regular expression
68 in EXPBUF. If the match is successful `loc2' will contain the
69 position of the first unmatched character. */
71 weak_function attribute_compat_text_section
72 advance (const char *string
, const char *expbuf
)
74 regmatch_t match
; /* We only need info about the full match. */
76 expbuf
+= __alignof__ (regex_t
*);
77 expbuf
-= ((uintptr_t) expbuf
) % __alignof__ (regex_t
*);
79 if (__regexec ((const regex_t
*) expbuf
, string
, 1, &match
, REG_NOTEOL
)
81 /* We have to check whether the check is at the beginning of the
86 loc2
= (char *) string
+ match
.rm_eo
;
89 compat_symbol (libc
, advance
, advance
, GLIBC_2_0
);
92 #endif /* SHLIB_COMPAT (2.0, 2.23) */