regex.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Extended regular expression matching and search library.
  2. Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. This program 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
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef _LIBC
  16. # include <config.h>
  17. # if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
  18. # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
  19. # endif
  20. # if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
  21. # pragma GCC diagnostic ignored "-Wtype-limits"
  22. # endif
  23. #endif
  24. /* Make sure no one compiles this code with a C++ compiler. */
  25. #if defined __cplusplus && defined _LIBC
  26. # error "This is C code, use a C compiler"
  27. #endif
  28. #ifdef _LIBC
  29. /* We have to keep the namespace clean. */
  30. # define regfree(preg) __regfree (preg)
  31. # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
  32. # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
  33. # define regerror(errcode, preg, errbuf, errbuf_size) \
  34. __regerror(errcode, preg, errbuf, errbuf_size)
  35. # define re_set_registers(bu, re, nu, st, en) \
  36. __re_set_registers (bu, re, nu, st, en)
  37. # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
  38. __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
  39. # define re_match(bufp, string, size, pos, regs) \
  40. __re_match (bufp, string, size, pos, regs)
  41. # define re_search(bufp, string, size, startpos, range, regs) \
  42. __re_search (bufp, string, size, startpos, range, regs)
  43. # define re_compile_pattern(pattern, length, bufp) \
  44. __re_compile_pattern (pattern, length, bufp)
  45. # define re_set_syntax(syntax) __re_set_syntax (syntax)
  46. # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
  47. __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
  48. # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
  49. # include "../locale/localeinfo.h"
  50. #endif
  51. /* On some systems, limits.h sets RE_DUP_MAX to a lower value than
  52. GNU regex allows. Include it before <regex.h>, which correctly
  53. #undefs RE_DUP_MAX and sets it to the right value. */
  54. #include <limits.h>
  55. #include <regex.h>
  56. #include "regex_internal.h"
  57. #include "regex_internal.c"
  58. #include "regcomp.c"
  59. #include "regexec.c"
  60. /* Binary backward compatibility. */
  61. #if _LIBC
  62. # include <shlib-compat.h>
  63. # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
  64. link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
  65. int re_max_failures = 2000;
  66. # endif
  67. #endif