regex.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. 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.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifdef HAVE_CONFIG_H
  18. #include "config.h"
  19. #endif
  20. /* uClibc addons */
  21. #include <features.h>
  22. #ifdef __UCLIBC__
  23. #undef _LIBC
  24. #undef internal_function
  25. #define _REGEX_RE_COMP
  26. #include <stdbool.h>
  27. #include <stdint.h>
  28. #ifdef __UCLIBC_HAS_WCHAR__
  29. #define RE_ENABLE_I18N
  30. #include <wchar.h>
  31. #include <wctype.h>
  32. extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc,
  33. mbstate_t *__restrict __ps) attribute_hidden;
  34. extern wint_t __btowc (int __c) attribute_hidden;
  35. extern wctype_t __wctype (__const char *__property) attribute_hidden;
  36. extern int __iswctype (wint_t __wc, wctype_t __desc) /*attribute_hidden*/;
  37. #endif
  38. #endif
  39. /* Make sure noone compiles this code with a C++ compiler. */
  40. #ifdef __cplusplus
  41. # error "This is C code, use a C compiler"
  42. #endif
  43. #if defined _LIBC || defined __UCLIBC__
  44. /* We have to keep the namespace clean. */
  45. # define regfree(preg) __regfree (preg)
  46. # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
  47. # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
  48. # define regerror(errcode, preg, errbuf, errbuf_size) \
  49. __regerror(errcode, preg, errbuf, errbuf_size)
  50. # define re_set_registers(bu, re, nu, st, en) \
  51. __re_set_registers (bu, re, nu, st, en)
  52. # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
  53. __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
  54. # define re_match(bufp, string, size, pos, regs) \
  55. __re_match (bufp, string, size, pos, regs)
  56. # define re_search(bufp, string, size, startpos, range, regs) \
  57. __re_search (bufp, string, size, startpos, range, regs)
  58. # define re_compile_pattern(pattern, length, bufp) \
  59. __re_compile_pattern (pattern, length, bufp)
  60. # define re_set_syntax(syntax) __re_set_syntax (syntax)
  61. # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
  62. __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
  63. # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
  64. #ifndef __UCLIBC__
  65. # include "../locale/localeinfo.h"
  66. #endif
  67. #endif
  68. /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
  69. GNU regex allows. Include it before <regex.h>, which correctly
  70. #undefs RE_DUP_MAX and sets it to the right value. */
  71. #include <limits.h>
  72. #ifdef __UCLIBC__
  73. #include "_regex.h"
  74. #else
  75. #include <regex.h>
  76. #endif
  77. #include "regex_internal.h"
  78. #include "regex_internal.c"
  79. #include "regcomp.c"
  80. #include "regexec.c"
  81. /* Binary backward compatibility. */
  82. #if _LIBC
  83. # include <shlib-compat.h>
  84. # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
  85. link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
  86. int re_max_failures = 2000;
  87. # endif
  88. #endif