Mercurial > octave
comparison configure.ac @ 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 | f990f14d4b0c |
comparison
equal
deleted
inserted
replaced
31423:fcd4bc97f5f7 | 31424:d1165473e4b0 |
---|---|
1373 if test $ENABLE_VM_EVALUATOR = yes; then | 1373 if test $ENABLE_VM_EVALUATOR = yes; then |
1374 AC_DEFINE(OCTAVE_ENABLE_VM_EVALUATOR, 1, | 1374 AC_DEFINE(OCTAVE_ENABLE_VM_EVALUATOR, 1, |
1375 [Define to 1 to build experimental Virtual Machine evaluator.]) | 1375 [Define to 1 to build experimental Virtual Machine evaluator.]) |
1376 fi | 1376 fi |
1377 | 1377 |
1378 ### Check for PCRE regex library. | 1378 ### Check for PCRE2 or PCRE regex library, requiring one to exist. |
1379 | 1379 |
1380 OCTAVE_CHECK_LIB(pcre, PCRE, | 1380 have_pcre2=no |
1381 [], [pcre.h pcre/pcre.h], [pcre_compile], [], [], | 1381 have_pcre=no |
1382 [OCTAVE_CHECK_LIB_PCRE_OK([], | 1382 save_CPPLAGS="$CPPFLAGS" |
1383 [AC_MSG_ERROR([PCRE library must be built with UTF support (--enable-utf)])]) | 1383 CPPFLAGS="-DPCRE2_CODE_UNIT_WIDTH=8 $CPPFLAGS" |
1384 ], | 1384 OCTAVE_CHECK_LIB(pcre2, PCRE2, |
1385 [libpcre], [REQUIRED]) | 1385 [], [pcre2.h pcre2/pcre2.h], [pcre2_compile_8], [], [], |
1386 [OCTAVE_CHECK_LIB_PCRE2_OK([have_pcre2=yes], | |
1387 [AC_MSG_ERROR([PCRE2 library must be built with UTF support (--enable-utf)])])], | |
1388 [libpcre2-8]) | |
1389 CPPFLAGS="$save_CPPFLAGS" | |
1390 | |
1391 if test $have_pcre2 = no; then | |
1392 OCTAVE_CHECK_LIB(pcre, PCRE, | |
1393 [], [pcre.h pcre/pcre.h], [pcre_compile], [], [], | |
1394 [OCTAVE_CHECK_LIB_PCRE_OK([have_pcre=yes], | |
1395 [AC_MSG_ERROR([PCRE library must be built with UTF support (--enable-utf)])])], | |
1396 [libpcre]) | |
1397 fi | |
1398 | |
1399 if test $have_pcre2 = yes; then | |
1400 AC_DEFINE(HAVE_PCRE2, 1, [Define to 1 if PCRE2 is available.]) | |
1401 | |
1402 ## Only one of PCRE2 or PCRE is used, so avoid having to define and use | |
1403 ## both PCRE2_* and PCRE_* variables everywhere. | |
1404 | |
1405 PCRE_CPPFLAGS="$PCRE2_CPPFLAGS" | |
1406 PCRE_LDFLAGS="$PCRE2_LDFLAGS" | |
1407 PCRE_LIBS="$PCRE2_LIBS" | |
1408 | |
1409 elif test $have_pcre = yes; then | |
1410 AC_DEFINE(HAVE_PCRE, 1, [Define to 1 if PCRE is available.]) | |
1411 else | |
1412 AC_MSG_ERROR([to build Octave, you must have the PCRE or PCRE2 library and header files installed]) | |
1413 fi | |
1386 | 1414 |
1387 ### Check for Qhull library. | 1415 ### Check for Qhull library. |
1388 | 1416 |
1389 QHULL_CPPFLAGS= | 1417 QHULL_CPPFLAGS= |
1390 QHULL_LDFLAGS= | 1418 QHULL_LDFLAGS= |