regex.c 4.4 KB

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