OSDN Git Service

This fixes a problem with the move of libc_hidden_proto to string.h.
[uclinux-h8/uClibc.git] / libc / misc / regex / regex.c
1 /* Extended regular expression matching and search library.
2    Copyright (C) 2002, 2003, 2005 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    The GNU C Library is free software; you can redistribute it and/or
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.
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
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 /* uClibc addons */
26 #include <features.h>
27
28 #ifdef __UCLIBC__
29 #undef _LIBC
30 #define _REGEX_RE_COMP
31 #ifdef __USE_GNU
32 # define HAVE_MEMPCPY
33 #endif
34 #define HAVE_LANGINFO
35 #define HAVE_LANGINFO_CODESET
36 #include <stdbool.h>
37 #include <stdint.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #ifdef __UCLIBC_HAS_WCHAR__
41 #define RE_ENABLE_I18N
42 #include <wchar.h>
43 #include <wctype.h>
44
45 #define __iswctype iswctype
46 #define __wcrtomb wcrtomb
47 #define __btowc btowc
48 #define __wctype wctype
49 libc_hidden_proto(wcscoll)
50 libc_hidden_proto(wcrtomb)
51 libc_hidden_proto(mbrtowc)
52 libc_hidden_proto(iswctype)
53 libc_hidden_proto(iswlower)
54 libc_hidden_proto(iswalnum)
55 libc_hidden_proto(towlower)
56 libc_hidden_proto(towupper)
57 libc_hidden_proto(mbsinit)
58 libc_hidden_proto(btowc)
59 libc_hidden_proto(wctype)
60
61 #endif
62
63 #include <ctype.h>
64 #ifdef __UCLIBC_HAS_CTYPE_TABLES__
65 #define __toupper toupper
66 #define __tolower tolower
67 #endif
68 #define __mempcpy mempcpy
69 #ifdef __UCLIBC_HAS_XLOCALE__
70 libc_hidden_proto(__ctype_b_loc)
71 libc_hidden_proto(__ctype_toupper_loc)
72 #elif defined __UCLIBC_HAS_CTYPE_TABLES__
73 libc_hidden_proto(__ctype_b)
74 libc_hidden_proto(__ctype_toupper)
75 #else
76 libc_hidden_proto(isascii)
77 #endif
78 libc_hidden_proto(toupper)
79 libc_hidden_proto(tolower)
80 /* Experimentally off - libc_hidden_proto(memcmp) */
81 /* Experimentally off - libc_hidden_proto(memcpy) */
82 /* Experimentally off - libc_hidden_proto(memmove) */
83 /* Experimentally off - libc_hidden_proto(memset) */
84 /* Experimentally off - libc_hidden_proto(strchr) */
85 /* Experimentally off - libc_hidden_proto(strcmp) */
86 /* Experimentally off - libc_hidden_proto(strlen) */
87 /* Experimentally off - libc_hidden_proto(strncpy) */
88 libc_hidden_proto(getenv)
89 /* Experimentally off - libc_hidden_proto(strcasecmp) */
90 libc_hidden_proto(abort)
91 #ifdef __USE_GNU
92 /* Experimentally off - libc_hidden_proto(mempcpy) */
93 #endif
94
95 #endif
96
97 /* Make sure noone compiles this code with a C++ compiler.  */
98 #ifdef __cplusplus
99 # error "This is C code, use a C compiler"
100 #endif
101
102 #if defined _LIBC || defined __UCLIBC__
103 /* We have to keep the namespace clean.  */
104 # define regfree(preg) __regfree (preg)
105 # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
106 # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
107 # define regerror(errcode, preg, errbuf, errbuf_size) \
108         __regerror(errcode, preg, errbuf, errbuf_size)
109 # define re_set_registers(bu, re, nu, st, en) \
110         __re_set_registers (bu, re, nu, st, en)
111 # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
112         __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
113 # define re_match(bufp, string, size, pos, regs) \
114         __re_match (bufp, string, size, pos, regs)
115 # define re_search(bufp, string, size, startpos, range, regs) \
116         __re_search (bufp, string, size, startpos, range, regs)
117 # define re_compile_pattern(pattern, length, bufp) \
118         __re_compile_pattern (pattern, length, bufp)
119 # define re_set_syntax(syntax) __re_set_syntax (syntax)
120 # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
121         __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
122 # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
123
124 #ifndef __UCLIBC__
125 # include "../locale/localeinfo.h"
126 #endif
127 #endif
128
129 /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
130    GNU regex allows.  Include it before <regex.h>, which correctly
131    #undefs RE_DUP_MAX and sets it to the right value.  */
132 #include <limits.h>
133
134 #ifdef __UCLIBC__
135 #include "_regex.h"
136 #else
137 #include <regex.h>
138 #endif
139 #include "regex_internal.h"
140
141 #include "regex_internal.c"
142 #include "regcomp.c"
143 #include "regexec.c"
144
145 /* Binary backward compatibility.  */
146 #if _LIBC
147 # include <shlib-compat.h>
148 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
149 link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
150 int re_max_failures = 2000;
151 # endif
152 #endif