comparison m4/acinclude.m4 @ 31424:d1165473e4b0

allow Octave to use PCRE2 (bug #61542) * acinclude.m4 (OCTAVE_CHECK_LIB_PCRE2_OK): New macro. * configure.ac: Check for libpcre2-8 and pcre2.h before checking for libpcre and pcre.h. If PCRE2 is found, also define PCRE_CPPFLAGS, PCRE_LDFLAGS, and PCRE_LIBS. Error if neither library is found. * lo-regexp.h (regexp::match_element::match_element): New constructor that accepts int values for start and end. * lo-regexp.cc: Include either PCRE2 or PCRE headers. Fail if neither HAVE_PCRE2 or HAVE_PCRE is defined. (octave_pcre_code, OCTAVE_PCRE_SIZE): New typedefs. (OCTAVE_PCRE_CASELESS, OCTAVE_PCRE_DOTALL, OCTAVE_PCRE_MULTILINE, OCTAVE_PCRE_EXTENDED, OCTAVE_PCRE_UTF, OCTAVE_PCRE_INFO_CAPTURECOUNT, OCTAVE_PCRE_INFO_NAMECOUNT, OCTAVE_PCRE_INFO_NAMEENTRYSIZE, OCTAVE_PCRE_INFO_NAMETABLE): New macro definitions. (octave_pcre_code_free): Define function pointer that references either pcre2_code_free or pcre_free depending on the library in use. (regexp::free): Call octave_pcre_code_free to free m_code. (octave_pcre_pattern_info): New function. (regexp::compile_internal): Allow use of either PCRE2 or PCRE. Use new macros and functions to hide differences in library interfaces.
author Rafael Laboissiere <rafael@laboissiere.net>
date Sun, 13 Nov 2022 10:17:17 -0500
parents 00e2eafd1c0f
children 212e9ad58f69
comparison
equal deleted inserted replaced
31423:fcd4bc97f5f7 31424:d1165473e4b0
1521 octave_cv_lib_pcre_ok=no, 1521 octave_cv_lib_pcre_ok=no,
1522 octave_cv_lib_pcre_ok=yes) 1522 octave_cv_lib_pcre_ok=yes)
1523 AC_LANG_POP(C++) 1523 AC_LANG_POP(C++)
1524 ]) 1524 ])
1525 if test $octave_cv_lib_pcre_ok = yes; then 1525 if test $octave_cv_lib_pcre_ok = yes; then
1526 $1
1527 :
1528 else
1529 $2
1530 :
1531 fi
1532 ])
1533 dnl
1534 dnl Check whether PCRE2 is compiled with --enable-utf.
1535 dnl
1536 AC_DEFUN([OCTAVE_CHECK_LIB_PCRE2_OK], [
1537 AC_CACHE_CHECK([whether PCRE2 library was compiled with UTF support],
1538 [octave_cv_lib_pcre2_ok],
1539 [AC_LANG_PUSH(C++)
1540 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1541 #include <stdio.h>
1542 #define PCRE2_CODE-uNIT_WIDTH 8
1543 #if defined (HAVE_PCRE2_H)
1544 # include <pcre2.h>
1545 #elif defined (HAVE_PCRE2_PCRE2_H)
1546 # include <pcre2/pcre2.h>
1547 #endif
1548 ]], [[
1549 const char *pattern = "test";
1550 int err;
1551 PCRE2_SIZE erroffset;
1552 pcre2_code *data = pcre2_compile ((PCRE2_SPTR) pattern, PCRE2_ZERO_TERMINATED, PCRE2_UTF, &err, &erroffset, nullptr);
1553 return (! data);
1554 ]])],
1555 octave_cv_lib_pcre2_ok=yes,
1556 octave_cv_lib_pcre2_ok=no,
1557 octave_cv_lib_pcre2_ok=yes)
1558 AC_LANG_POP(C++)
1559 ])
1560 if test $octave_cv_lib_pcre2_ok = yes; then
1526 $1 1561 $1
1527 : 1562 :
1528 else 1563 else
1529 $2 1564 $2
1530 : 1565 :