Build changes to support EXV_HAVE_REGEX and EXV_HAVE_REGEX_H

v0.27.3
clanmills 8 years ago
parent 780088d493
commit 2828b11cf7

@ -50,9 +50,12 @@
#define EXV_ICONV_CONST
#endif
// Definition to indicate if you have the <regex.h> header file.
// Definition to indicate if you have the <regex> header file.
#cmakedefine EXV_HAVE_REGEX
// Definition to indicate if you have the <regex.h> header file.
#cmakedefine EXV_HAVE_REGEX_H
// Definition to indicate you have the <memory.h> header file.
#cmakedefine EXV_HAVE_MEMORY_H

@ -47,8 +47,11 @@
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define to 1 if you have the <regex> header file. */
#undef HAVE_REGEX
/* Define to 1 if you have the <regex.h> header file. */
#define HAVE_REGEX 1
#undef HAVE_REGEX_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

@ -56,7 +56,7 @@ AM_ICONV
# Checks for header files.
# ---------------------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS([libintl.h locale.h malloc.h stdint.h stdlib.h string.h unistd.h sys/mman.h utime.h regex.h])
AC_CHECK_HEADERS([libintl.h locale.h malloc.h stdint.h stdlib.h string.h unistd.h sys/mman.h utime.h regex.h regex])
# ---------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
@ -401,7 +401,7 @@ if test "$ADOBE" = "2016" -o "$ADOBE" = "2014" -o "$ADOBE" = "2013" ; then
if test "$ADOBE" == "2013" ; then ADOBE_SDK=XMP-Toolkit-SDK-CC201306; fi
ENABLE_XMP=$ADOBE
XMPSDK_CPPFLAGS="-Ixmpsdk/Adobe/$ADOBE_SDK/public/include"
XMPSDK_LDFLAGS="-Lxmpsdk/Adobe/$ADOBE_SDK"
XMPSDK_LDFLAGS="-Lxmpsdk/Adobe/$ADOBE_SDK -lXMPCore"
case "$host_os" in
*arwin*)
EXV_DARWIN_FLAGS="-stdlib=libstdc++ -Wno-deprecated"

@ -43,7 +43,8 @@ check_include_file( "strings.h" EXV_HAVE_STRINGS_H )
check_include_file( "sys/mman.h" EXV_HAVE_SYS_MMAN_H )
check_include_file( "sys/stat.h" EXV_HAVE_SYS_STAT_H )
check_include_file( "sys/types.h" EXV_HAVE_SYS_TYPES_H )
check_include_file( "regex.h" EXV_HAVE_REGEX )
check_include_file( "regex" EXV_HAVE_REGEX )
check_include_file( "regex.h" EXV_HAVE_REGEX_H )
check_include_file( "inttypes.h" EXV_HAVE_INTTYPES_H )
if (NOT EXV_HAVE_LIBINTL_H)

@ -37,20 +37,14 @@
// + standard includes
#include <vector>
/*!
@brief CPLUSPLUS11 is the value of macro --cplusplus for C++11
*/
#define CPLUSPLUS11 201103L
#if __cplusplus >= CPLUSPLUS11
#if defined(HAVE_REGEX)
# include <regex>
/*!
@brief exv_grep_keys_t is a vector of keys to match to strings
*/
typedef std::vector<std::regex> exv_grep_keys_t ;
#else
# ifdef EXV_HAVE_REGEX
# include <regex.h>
#elif defined(EXV_HAVE_REGEX_H)
# include <regex.h>
/*!
@brief exv_grep_keys_t is a vector of keys to match to strings
*/
@ -76,7 +70,6 @@
@brief exv_grep_keys_t is a vector of keys to match to strings
*/
typedef std::vector<Exiv2_grep_key_t> exv_grep_keys_t ;
# endif
#endif
/*!

@ -591,11 +591,10 @@ namespace Action {
for (Params::Greps::const_iterator g = Params::instance().greps_.begin();
!result && g != Params::instance().greps_.end(); ++g)
{
#if __cplusplus >= CPLUSPLUS11
#if defined(EXV_HAVE_REGEX)
std::smatch m;
result = std::regex_search(key,m, *g);
#else
#ifdef EXV_HAVE_REGEX
#elif defined(EXV_HAVE_REGEX_H)
result = regexec( &(*g), key.c_str(), 0, NULL, 0) == 0 ;
#else
std::string Pattern(g->pattern_);
@ -606,7 +605,6 @@ namespace Action {
std::transform(Key.begin() , Key.end() ,Key.begin() , ::tolower);
}
result = Key.find(Pattern) != std::string::npos;
#endif
#endif
}
return result ;

@ -47,7 +47,9 @@ EXIV2_RCSID("@(#) $Id$")
#include <cassert>
#include <cctype>
#ifdef EXV_HAVE_REGEX
#if defined(EXV_HAVE_REGEX)
#include <regex>
#elif defined(EXV_HAVE_REGEX_H)
#include <regex.h>
#endif
@ -451,10 +453,9 @@ int Params::evalGrep( const std::string& optarg)
std::string pattern;
std::string ignoreCase("/i");
bool bIgnoreCase = ends_with(optarg,ignoreCase,pattern);
#if __cplusplus >= CPLUSPLUS11
#if defined(EXV_HAVE_REGEX)
greps_.push_back( std::regex(pattern, bIgnoreCase ? std::regex::icase|std::regex::extended : std::regex::extended) );
#else
#ifdef EXV_HAVE_REGEX
#elif defined(EXV_HAVE_REGEX_H)
// try to compile a reg-exp from the input argument and store it in the vector
const size_t i = greps_.size();
greps_.resize(i + 1);
@ -478,7 +479,6 @@ int Params::evalGrep( const std::string& optarg)
}
#else
greps_.push_back(Exiv2_grep_key_t(pattern,bIgnoreCase));
#endif
#endif
return result;
} // Params::evalGrep

@ -173,11 +173,10 @@ static bool shouldOutput(const exv_grep_keys_t& greps,const char* key,const std:
!bPrint && g != greps.end() ; ++g
) {
std::string Key(key);
#if __cplusplus >= CPLUSPLUS11
#if defined(EXV_HAVE_REGEX)
std::smatch m;
bPrint = std::regex_search(Key,m,*g) || std::regex_search(value,m,*g);
#else
#ifdef EXV_HAVE_REGEX
#elif defined(EXV_HAVE_REGEX_H)
bPrint = ( 0 == regexec( &(*g), key , 0, NULL, 0)
|| 0 == regexec( &(*g), value.c_str(), 0, NULL, 0)
);
@ -191,7 +190,6 @@ static bool shouldOutput(const exv_grep_keys_t& greps,const char* key,const std:
std::transform(Value.begin() , Value.end() ,Value.begin() , ::tolower);
}
bPrint = Key.find(Pattern) != std::string::npos || Value.find(Pattern) != std::string::npos;
#endif
#endif
}
return bPrint;

Loading…
Cancel
Save