xref: /dragonfly/contrib/grep/lib/regex.c (revision 09d4459f)
195b7b453SJohn Marino /* Extended regular expression matching and search library.
2*09d4459fSDaniel Fojt    Copyright (C) 2002-2020 Free Software Foundation, Inc.
395b7b453SJohn Marino    This file is part of the GNU C Library.
495b7b453SJohn Marino    Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
595b7b453SJohn Marino 
6680a9cb8SJohn Marino    The GNU C Library is free software; you can redistribute it and/or
7680a9cb8SJohn Marino    modify it under the terms of the GNU General Public
8680a9cb8SJohn Marino    License as published by the Free Software Foundation; either
9680a9cb8SJohn Marino    version 3 of the License, or (at your option) any later version.
1095b7b453SJohn Marino 
11680a9cb8SJohn Marino    The GNU C Library is distributed in the hope that it will be useful,
1295b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
13680a9cb8SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14680a9cb8SJohn Marino    General Public License for more details.
1595b7b453SJohn Marino 
16680a9cb8SJohn Marino    You should have received a copy of the GNU General Public
17680a9cb8SJohn Marino    License along with the GNU C Library; if not, see
18*09d4459fSDaniel Fojt    <https://www.gnu.org/licenses/>.  */
1995b7b453SJohn Marino 
20cf28ed85SJohn Marino #ifndef _LIBC
21*09d4459fSDaniel Fojt # include <libc-config.h>
2295b7b453SJohn Marino 
23*09d4459fSDaniel Fojt # if __GNUC_PREREQ (4, 6)
24cf28ed85SJohn Marino #  pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
25cf28ed85SJohn Marino # endif
26*09d4459fSDaniel Fojt # if __GNUC_PREREQ (4, 3)
27680a9cb8SJohn Marino #  pragma GCC diagnostic ignored "-Wold-style-definition"
28cf28ed85SJohn Marino #  pragma GCC diagnostic ignored "-Wtype-limits"
29cf28ed85SJohn Marino # endif
30cf28ed85SJohn Marino #endif
31cf28ed85SJohn Marino 
3295b7b453SJohn Marino /* Make sure no one compiles this code with a C++ compiler.  */
3395b7b453SJohn Marino #if defined __cplusplus && defined _LIBC
3495b7b453SJohn Marino # error "This is C code, use a C compiler"
3595b7b453SJohn Marino #endif
3695b7b453SJohn Marino 
3795b7b453SJohn Marino #ifdef _LIBC
3895b7b453SJohn Marino /* We have to keep the namespace clean.  */
3995b7b453SJohn Marino # define regfree(preg) __regfree (preg)
4095b7b453SJohn Marino # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
4195b7b453SJohn Marino # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
4295b7b453SJohn Marino # define regerror(errcode, preg, errbuf, errbuf_size) \
4395b7b453SJohn Marino 	__regerror(errcode, preg, errbuf, errbuf_size)
4495b7b453SJohn Marino # define re_set_registers(bu, re, nu, st, en) \
4595b7b453SJohn Marino 	__re_set_registers (bu, re, nu, st, en)
4695b7b453SJohn Marino # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
4795b7b453SJohn Marino 	__re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
4895b7b453SJohn Marino # define re_match(bufp, string, size, pos, regs) \
4995b7b453SJohn Marino 	__re_match (bufp, string, size, pos, regs)
5095b7b453SJohn Marino # define re_search(bufp, string, size, startpos, range, regs) \
5195b7b453SJohn Marino 	__re_search (bufp, string, size, startpos, range, regs)
5295b7b453SJohn Marino # define re_compile_pattern(pattern, length, bufp) \
5395b7b453SJohn Marino 	__re_compile_pattern (pattern, length, bufp)
5495b7b453SJohn Marino # define re_set_syntax(syntax) __re_set_syntax (syntax)
5595b7b453SJohn Marino # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
5695b7b453SJohn Marino 	__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
5795b7b453SJohn Marino # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
5895b7b453SJohn Marino 
5995b7b453SJohn Marino # include "../locale/localeinfo.h"
6095b7b453SJohn Marino #endif
6195b7b453SJohn Marino 
6295b7b453SJohn Marino /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
6395b7b453SJohn Marino    GNU regex allows.  Include it before <regex.h>, which correctly
6495b7b453SJohn Marino    #undefs RE_DUP_MAX and sets it to the right value.  */
6595b7b453SJohn Marino #include <limits.h>
6695b7b453SJohn Marino 
6795b7b453SJohn Marino #include <regex.h>
6895b7b453SJohn Marino #include "regex_internal.h"
6995b7b453SJohn Marino 
7095b7b453SJohn Marino #include "regex_internal.c"
7195b7b453SJohn Marino #include "regcomp.c"
7295b7b453SJohn Marino #include "regexec.c"
7395b7b453SJohn Marino 
7495b7b453SJohn Marino /* Binary backward compatibility.  */
7595b7b453SJohn Marino #if _LIBC
7695b7b453SJohn Marino # include <shlib-compat.h>
7795b7b453SJohn Marino # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
7895b7b453SJohn Marino link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
7995b7b453SJohn Marino int re_max_failures = 2000;
8095b7b453SJohn Marino # endif
8195b7b453SJohn Marino #endif
82