regex.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #define _REGEX_RE_COMP
  25. #include <stdbool.h>
  26. #include <stdint.h>
  27. #ifdef __UCLIBC_HAS_WCHAR__
  28. #define RE_ENABLE_I18N
  29. #include <wchar.h>
  30. #include <wctype.h>
  31. extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc,
  32. mbstate_t *__restrict __ps) attribute_hidden;
  33. extern wint_t __btowc (int __c) attribute_hidden;
  34. extern wctype_t __wctype (__const char *__property) attribute_hidden;
  35. extern int __iswctype (wint_t __wc, wctype_t __desc) /*attribute_hidden*/;
  36. #endif
  37. #define memcmp __memcmp
  38. #define memcpy __memcpy
  39. #define memmove __memmove
  40. #define memset __memset
  41. #define strchr __strchr
  42. #define strcmp __strcmp
  43. #define strlen __strlen
  44. #define strncpy __strncpy
  45. #define getenv __getenv
  46. extern void *__mempcpy (void *__restrict __dest,
  47. __const void *__restrict __src, size_t __n) /*attribute_hidden*/;
  48. #endif
  49. /* Make sure noone compiles this code with a C++ compiler. */
  50. #ifdef __cplusplus
  51. # error "This is C code, use a C compiler"
  52. #endif
  53. #if defined _LIBC || defined __UCLIBC__
  54. /* We have to keep the namespace clean. */
  55. # define regfree(preg) __regfree (preg)
  56. # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
  57. # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
  58. # define regerror(errcode, preg, errbuf, errbuf_size) \
  59. __regerror(errcode, preg, errbuf, errbuf_size)
  60. # define re_set_registers(bu, re, nu, st, en) \
  61. __re_set_registers (bu, re, nu, st, en)
  62. # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
  63. __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
  64. # define re_match(bufp, string, size, pos, regs) \
  65. __re_match (bufp, string, size, pos, regs)
  66. # define re_search(bufp, string, size, startpos, range, regs) \
  67. __re_search (bufp, string, size, startpos, range, regs)
  68. # define re_compile_pattern(pattern, length, bufp) \
  69. __re_compile_pattern (pattern, length, bufp)
  70. # define re_set_syntax(syntax) __re_set_syntax (syntax)
  71. # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
  72. __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
  73. # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
  74. #ifndef __UCLIBC__
  75. # include "../locale/localeinfo.h"
  76. #endif
  77. #endif
  78. /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
  79. GNU regex allows. Include it before <regex.h>, which correctly
  80. #undefs RE_DUP_MAX and sets it to the right value. */
  81. #include <limits.h>
  82. #ifdef __UCLIBC__
  83. #include "_regex.h"
  84. #else
  85. #include <regex.h>
  86. #endif
  87. #include "regex_internal.h"
  88. #include "regex_internal.c"
  89. #include "regcomp.c"
  90. #include "regexec.c"
  91. /* Binary backward compatibility. */
  92. #if _LIBC
  93. # include <shlib-compat.h>
  94. # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
  95. link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
  96. int re_max_failures = 2000;
  97. # endif
  98. #endif