regex.c 4.3 KB

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