Mercurial > hg > octave-lyh
changeset 12464:dfeea9cae79e
require PCRE to build Octave
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 21 Feb 2011 03:50:59 -0500 |
parents | 189baf055143 |
children | 6b2abcd20fef |
files | ChangeLog NEWS configure.ac src/ChangeLog src/DLD-FUNCTIONS/regexp.cc |
diffstat | 5 files changed, 37 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-02-21 John W. Eaton <jwe@octave.org> + + * NEWS: Note that PCRE is now required to build Octave. + * configure.ac: Improve check for PCRE, which is now required. + Don't check for -lregex. + 2011-02-19 Rik <octave@nomad.inbox5.com> * README.MacOS: Keep line length below 80, use 2 spaces to start
--- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ spchol splchol unmark_command spchol2inv split unmark_rawcommand + ** The PCRE library is now required to build Octave. + Summary of important user-visible changes for version 3.4: ---------------------------------------------------------
--- a/configure.ac +++ b/configure.ac @@ -637,61 +637,43 @@ AC_DEFINE(HAVE_QHULL, 1, [Define if QHull is available.])], [ warn_qhull="Qhull library found, but seems not to work properly -- this will result in loss of functionality of some geometry functions. Please try recompiling the library with -fno-strict-aliasing."])]) -### Check for pcre/regex library. +### Check for pcre regex library. + +REGEX_LIBS= + +pcre_fail_msg="to build Octave, you must have the PCRE library and header files installed" -## check for pcre-config, and if so, set XTRA_CXXFLAGS appropriately -AC_CHECK_PROG(WITH_PCRE_CONFIG, pcre-config, yes, no) -if test $WITH_PCRE_CONFIG = yes ; then - XTRA_CXXFLAGS="$XTRA_CXXFLAGS $(pcre-config --cflags)" -fi - -## NB: no need to do separate check for pcre.h header -- checking macros is good enough -AC_CACHE_CHECK([whether pcre.h defines the macros we need], [ac_cv_pcre_h_macros_present], [ - AC_EGREP_CPP([PCRE_HAS_MACROS_WE_NEED], [ +## NB: no need to do separate check for pcre.h header -- checking +## macros is good enough +AC_CACHE_CHECK([whether pcre.h defines the macros we need], + [ac_cv_pcre_h_macros_present], + [AC_EGREP_CPP([PCRE_HAS_MACROS_WE_NEED], [ #include <pcre.h> #if defined (PCRE_INFO_NAMECOUNT) \ && defined (PCRE_INFO_NAMEENTRYSIZE) \ && defined (PCRE_INFO_NAMETABLE) PCRE_HAS_MACROS_WE_NEED #endif], ac_cv_pcre_h_macros_present=yes, ac_cv_pcre_h_macros_present=no)]) -WITH_PCRE="$ac_cv_pcre_h_macros_present" -REGEX_LIBS= - -using_pcre=no -using_regex=no - -if test "$WITH_PCRE" = yes; then - if test "$WITH_PCRE_CONFIG" = yes; then - REGEX_LIBS=$(pcre-config --libs) +if test $ac_cv_pcre_h_macros_present = yes; then + ## check for pcre-config, and if so, set XTRA_CXXFLAGS appropriately + AC_CHECK_PROG(HAVE_PCRE_CONFIG, pcre-config, [yes], [no]) + if test $HAVE_PCRE_CONFIG = yes; then + XTRA_CXXFLAGS="$XTRA_CXXFLAGS `pcre-config --cflags`" + REGEX_LIBS="`pcre-config --libs`" else - REGEX_LIBS=-lpcre + REGEX_LIBS="-lpcre" fi save_LIBS="$LIBS" LIBS="$REGEX_LIBS $LIBS" - AC_CHECK_FUNCS(pcre_compile, [using_pcre=yes - AC_DEFINE(HAVE_PCRE, 1, [Define if PCRE library is available.])], [ - REGEX_LIBS= - warn_pcre="PCRE library not found. This will result in some loss of functionality for the regular expression matching functions." - AC_MSG_WARN([$warn_pcre])]) + AC_CHECK_FUNCS(pcre_compile, + [AC_SUBST(REGEX_LIBS)], + [AC_MSG_ERROR([$pcre_fail_msg])]) LIBS="$save_LIBS" else - warn_pcre="PCRE library not found. This will result in some loss of functionality for the regular expression matching functions." - AC_MSG_WARN([$warn_pcre]) + AC_MSG_ERROR([$pcre_fail_msg]) fi -AC_CHECK_FUNCS(regexec, [using_regex=yes], [ - AC_CHECK_LIB(regex, regexec, [using_regex=yes - REGEX_LIBS="-lregex $REGEX_LIBS"], [ - warn_regex="regular expression functions not found. The regular expression matching functions will be disabled." - AC_MSG_WARN([$warn_regex])])]) - -if test "$using_regex" = yes; then - AC_DEFINE(HAVE_REGEX, 1, [Define if regex library is available.]) -fi - -AC_SUBST(REGEX_LIBS) - ### Check for ZLIB library. OCTAVE_CHECK_LIBRARY(z, ZLIB,
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-02-21 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/regexp.cc: Assume we have PCRE. + 2010-02-19 Rik <octave@nomad.inbox5.com> * src/DLD-FUNCTIONS/regexp.cc: Use PCRE regular expressions everywhere
--- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -41,15 +41,7 @@ #include "parse.h" #include "oct-locbuf.h" -#if defined (HAVE_PCRE) #include <pcre.h> -#elif defined (HAVE_REGEX) -#if defined (__MINGW32__) -#define __restrict -#endif -#include <sys/types.h> -#include <regex.h> -#endif // Define the maximum number of retries for a pattern that // possibly results in an infinite recursion. @@ -92,7 +84,7 @@ string_vector &named, int &nopts, bool &once) { int sz = 0; -#if defined (HAVE_REGEX) || defined (HAVE_PCRE) + int nargin = args.length(); bool lineanchors = false; bool dotexceptnewline = false; @@ -157,7 +149,7 @@ freespacing = false; nopts--; } -#if HAVE_PCRE + // Only accept these options with pcre else if (str.find("dotexceptnewline", 0) == 0) { @@ -178,17 +170,6 @@ str.find("tokenextents", 0) && str.find("match", 0) && str.find("tokens", 0) && str.find("names", 0)) error ("%s: unrecognized option", nm.c_str()); -#else - else if (str.find("names", 0) == 0 || - str.find("dotexceptnewline", 0) == 0 || - str.find("lineanchors", 0) == 0 || - str.find("freespacing", 0) == 0) - error ("%s: %s not implemented in this version", str.c_str(), nm.c_str()); - else if (str.find("start", 0) && str.find("end", 0) && - str.find("tokenextents", 0) && str.find("match", 0) && - str.find("tokens", 0)) - error ("%s: unrecognized option", nm.c_str()); -#endif } if (!error_state) @@ -198,7 +179,6 @@ double s, e; // named tokens "(?<name>...)" are only treated with PCRE not regex. -#if HAVE_PCRE size_t pos = 0; size_t new_pos; @@ -494,79 +474,8 @@ } pcre_free(re); -#else - regex_t compiled; - int err=regcomp(&compiled, pattern.c_str(), REG_EXTENDED | - (case_insensitive ? REG_ICASE : 0)); - if (err) - { - int len = regerror(err, &compiled, 0, 0); - OCTAVE_LOCAL_BUFFER (char, errmsg, len); - regerror(err, &compiled, errmsg, len); - error("%s: %s in pattern (%s)", nm.c_str(), errmsg, - pattern.c_str()); - regfree(&compiled); - return 0; - } - - int subexpr = 1; - int idx = 0; - for (unsigned int i=0; i < pattern.length(); i++) - subexpr += ( pattern[i] == '(' ? 1 : 0 ); - OCTAVE_LOCAL_BUFFER (regmatch_t, match, subexpr ); - - while(true) - { - OCTAVE_QUIT; - - if (regexec(&compiled, buffer.c_str() + idx, subexpr, - match, (idx ? REG_NOTBOL : 0)) == 0) - { - // Count actual matches - int matches = 0; - while (matches < subexpr && match[matches].rm_so >= 0) - matches++; - - if (matches == 0 || match[0].rm_eo == 0) - break; + } - s = double (match[0].rm_so+1+idx); - e = double (match[0].rm_eo+idx); - Matrix te(matches-1,2); - for (int i = 1; i < matches; i++) - { - te(i-1,0) = double (match[i].rm_so+1+idx); - te(i-1,1) = double (match[i].rm_eo+idx); - } - - m = buffer.substr (match[0].rm_so+idx, - match[0].rm_eo-match[0].rm_so); - - Cell cell_t (dim_vector(1,matches-1)); - for (int i = 1; i < matches; i++) - cell_t(i-1) = buffer.substr (match[i].rm_so+idx, - match[i].rm_eo-match[i].rm_so); - t = cell_t; - - idx += match[0].rm_eo; - - string_vector sv; - regexp_elem new_elem (sv, t, m, te, s, e); - lst.push_back (new_elem); - sz++; - - if (once) - break; - } - else - break; - } - regfree(&compiled); -#endif - } -#else - error ("%s: not available in this version of Octave", nm.c_str()); -#endif return sz; } @@ -587,8 +496,8 @@ // Converted the linked list in the correct form for the return values octave_idx_type i = 0; -#ifdef HAVE_PCRE octave_scalar_map nmap; + if (sz == 1) { for (int j = 0; j < named.length(); j++) @@ -607,9 +516,6 @@ } retval(5) = nmap; } -#else - retval(5) = octave_scalar_map (); -#endif if (once) retval(4) = sz ? lst.front ().t : Cell();