regex.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #define HAVE_MEMPCPY
  26. #define HAVE_LANGINFO
  27. #define HAVE_LANGINFO_CODESET
  28. #include <stdbool.h>
  29. #include <stdint.h>
  30. #include <string.h>
  31. #include <stdlib.h>
  32. #ifdef __UCLIBC_HAS_WCHAR__
  33. #define RE_ENABLE_I18N
  34. #include <wchar.h>
  35. #include <wctype.h>
  36. #define __iswctype iswctype
  37. #define __wcrtomb wcrtomb
  38. #define __btowc btowc
  39. #define __wctype wctype
  40. libc_hidden_proto(wcscoll)
  41. libc_hidden_proto(wcrtomb)
  42. libc_hidden_proto(mbrtowc)
  43. libc_hidden_proto(iswctype)
  44. libc_hidden_proto(iswlower)
  45. libc_hidden_proto(iswalnum)
  46. libc_hidden_proto(towlower)
  47. libc_hidden_proto(towupper)
  48. libc_hidden_proto(mbsinit)
  49. libc_hidden_proto(btowc)
  50. libc_hidden_proto(wctype)
  51. #endif
  52. #include <ctype.h>
  53. #ifdef __UCLIBC_HAS_CTYPE_TABLES__
  54. #define __toupper toupper
  55. #define __tolower tolower
  56. #endif
  57. #define __mempcpy mempcpy
  58. #ifdef __UCLIBC_HAS_XLOCALE__
  59. libc_hidden_proto(__ctype_b_loc)
  60. libc_hidden_proto(__ctype_toupper_loc)
  61. #else
  62. libc_hidden_proto(__ctype_b)
  63. libc_hidden_proto(__ctype_toupper)
  64. #endif
  65. libc_hidden_proto(toupper)
  66. libc_hidden_proto(tolower)
  67. libc_hidden_proto(memcmp)
  68. libc_hidden_proto(memcpy)
  69. libc_hidden_proto(memmove)
  70. libc_hidden_proto(memset)
  71. libc_hidden_proto(strchr)
  72. libc_hidden_proto(strcmp)
  73. libc_hidden_proto(strlen)
  74. libc_hidden_proto(strncpy)
  75. libc_hidden_proto(getenv)
  76. libc_hidden_proto(strcasecmp)
  77. libc_hidden_proto(mempcpy)
  78. libc_hidden_proto(abort)
  79. #endif
  80. /* Make sure noone compiles this code with a C++ compiler. */
  81. #ifdef __cplusplus
  82. # error "This is C code, use a C compiler"
  83. #endif
  84. #if defined _LIBC || defined __UCLIBC__
  85. /* We have to keep the namespace clean. */
  86. # define regfree(preg) __regfree (preg)
  87. # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
  88. # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
  89. # define regerror(errcode, preg, errbuf, errbuf_size) \
  90. __regerror(errcode, preg, errbuf, errbuf_size)
  91. # define re_set_registers(bu, re, nu, st, en) \
  92. __re_set_registers (bu, re, nu, st, en)
  93. # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
  94. __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
  95. # define re_match(bufp, string, size, pos, regs) \
  96. __re_match (bufp, string, size, pos, regs)
  97. # define re_search(bufp, string, size, startpos, range, regs) \
  98. __re_search (bufp, string, size, startpos, range, regs)
  99. # define re_compile_pattern(pattern, length, bufp) \
  100. __re_compile_pattern (pattern, length, bufp)
  101. # define re_set_syntax(syntax) __re_set_syntax (syntax)
  102. # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
  103. __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
  104. # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
  105. #ifndef __UCLIBC__
  106. # include "../locale/localeinfo.h"
  107. #endif
  108. #endif
  109. /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
  110. GNU regex allows. Include it before <regex.h>, which correctly
  111. #undefs RE_DUP_MAX and sets it to the right value. */
  112. #include <limits.h>
  113. #ifdef __UCLIBC__
  114. #include "_regex.h"
  115. #else
  116. #include <regex.h>
  117. #endif
  118. #include "regex_internal.h"
  119. #include "regex_internal.c"
  120. #include "regcomp.c"
  121. #include "regexec.c"
  122. /* Binary backward compatibility. */
  123. #if _LIBC
  124. # include <shlib-compat.h>
  125. # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
  126. link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
  127. int re_max_failures = 2000;
  128. # endif
  129. #endif