regex.c 4.2 KB

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