regex.c 4.2 KB

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