* modules/regex (Files): Add lib/regex_internal.c,
[gnulib.git] / lib / regex.c
1 /* Extended regular expression matching and search library.
2    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program 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
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License along
17    with this program; if not, write to the Free Software Foundation,
18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #ifdef _AIX
25 #pragma alloca
26 #else
27 # ifndef allocax           /* predefined by HP cc +Olibcalls */
28 #  ifdef __GNUC__
29 #   define alloca(size) __builtin_alloca (size)
30 #  else
31 #   if HAVE_ALLOCA_H
32 #    include <alloca.h>
33 #   else
34 #    ifdef __hpux
35         void *alloca ();
36 #    else
37 #     if !defined __OS2__ && !defined WIN32
38         char *alloca ();
39 #     else
40 #      include <malloc.h>       /* OS/2 defines alloca in here */
41 #     endif
42 #    endif
43 #   endif
44 #  endif
45 # endif
46 #endif
47
48 #ifdef _LIBC
49 /* We have to keep the namespace clean.  */
50 # define regfree(preg) __regfree (preg)
51 # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
52 # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
53 # define regerror(errcode, preg, errbuf, errbuf_size) \
54         __regerror(errcode, preg, errbuf, errbuf_size)
55 # define re_set_registers(bu, re, nu, st, en) \
56         __re_set_registers (bu, re, nu, st, en)
57 # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
58         __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
59 # define re_match(bufp, string, size, pos, regs) \
60         __re_match (bufp, string, size, pos, regs)
61 # define re_search(bufp, string, size, startpos, range, regs) \
62         __re_search (bufp, string, size, startpos, range, regs)
63 # define re_compile_pattern(pattern, length, bufp) \
64         __re_compile_pattern (pattern, length, bufp)
65 # define re_set_syntax(syntax) __re_set_syntax (syntax)
66 # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
67         __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
68 # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
69
70 # include "../locale/localeinfo.h"
71 #endif
72
73 /* POSIX says that <sys/types.h> must be included (by the caller) before
74    <regex.h>.  */
75 #include <sys/types.h>
76
77 /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
78    GNU regex allows.  Include it before <regex.h>, which correctly
79    #undefs RE_DUP_MAX and sets it to the right value.  */
80 #include <limits.h>
81
82 #include <regex.h>
83 #include "regex_internal.h"
84
85 #include "regex_internal.c"
86 #include "regcomp.c"
87 #include "regexec.c"
88
89 /* Binary backward compatibility.  */
90 #if _LIBC
91 # include <shlib-compat.h>
92 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
93 link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
94 int re_max_failures = 2000;
95 # endif
96 #endif