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 #define EXV_ICONV_CONST
#endif #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 #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. // Definition to indicate you have the <memory.h> header file.
#cmakedefine EXV_HAVE_MEMORY_H #cmakedefine EXV_HAVE_MEMORY_H

@ -47,8 +47,11 @@
/* Define to 1 if you have the <libintl.h> header file. */ /* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H #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 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. */ /* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H #undef HAVE_MEMORY_H

@ -56,7 +56,7 @@ AM_ICONV
# Checks for header files. # Checks for header files.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
AC_HEADER_STDC 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. # 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 if test "$ADOBE" == "2013" ; then ADOBE_SDK=XMP-Toolkit-SDK-CC201306; fi
ENABLE_XMP=$ADOBE ENABLE_XMP=$ADOBE
XMPSDK_CPPFLAGS="-Ixmpsdk/Adobe/$ADOBE_SDK/public/include" 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 case "$host_os" in
*arwin*) *arwin*)
EXV_DARWIN_FLAGS="-stdlib=libstdc++ -Wno-deprecated" 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/mman.h" EXV_HAVE_SYS_MMAN_H )
check_include_file( "sys/stat.h" EXV_HAVE_SYS_STAT_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( "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 ) check_include_file( "inttypes.h" EXV_HAVE_INTTYPES_H )
if (NOT EXV_HAVE_LIBINTL_H) if (NOT EXV_HAVE_LIBINTL_H)

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

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

@ -47,7 +47,9 @@ EXIV2_RCSID("@(#) $Id$")
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#ifdef EXV_HAVE_REGEX #if defined(EXV_HAVE_REGEX)
#include <regex>
#elif defined(EXV_HAVE_REGEX_H)
#include <regex.h> #include <regex.h>
#endif #endif
@ -451,10 +453,9 @@ int Params::evalGrep( const std::string& optarg)
std::string pattern; std::string pattern;
std::string ignoreCase("/i"); std::string ignoreCase("/i");
bool bIgnoreCase = ends_with(optarg,ignoreCase,pattern); 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) ); greps_.push_back( std::regex(pattern, bIgnoreCase ? std::regex::icase|std::regex::extended : std::regex::extended) );
#else #elif defined(EXV_HAVE_REGEX_H)
#ifdef EXV_HAVE_REGEX
// try to compile a reg-exp from the input argument and store it in the vector // try to compile a reg-exp from the input argument and store it in the vector
const size_t i = greps_.size(); const size_t i = greps_.size();
greps_.resize(i + 1); greps_.resize(i + 1);
@ -478,7 +479,6 @@ int Params::evalGrep( const std::string& optarg)
} }
#else #else
greps_.push_back(Exiv2_grep_key_t(pattern,bIgnoreCase)); greps_.push_back(Exiv2_grep_key_t(pattern,bIgnoreCase));
#endif
#endif #endif
return result; return result;
} // Params::evalGrep } // 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 !bPrint && g != greps.end() ; ++g
) { ) {
std::string Key(key); std::string Key(key);
#if __cplusplus >= CPLUSPLUS11 #if defined(EXV_HAVE_REGEX)
std::smatch m; std::smatch m;
bPrint = std::regex_search(Key,m,*g) || std::regex_search(value,m,*g); bPrint = std::regex_search(Key,m,*g) || std::regex_search(value,m,*g);
#else #elif defined(EXV_HAVE_REGEX_H)
#ifdef EXV_HAVE_REGEX
bPrint = ( 0 == regexec( &(*g), key , 0, NULL, 0) bPrint = ( 0 == regexec( &(*g), key , 0, NULL, 0)
|| 0 == regexec( &(*g), value.c_str(), 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); std::transform(Value.begin() , Value.end() ,Value.begin() , ::tolower);
} }
bPrint = Key.find(Pattern) != std::string::npos || Value.find(Pattern) != std::string::npos; bPrint = Key.find(Pattern) != std::string::npos || Value.find(Pattern) != std::string::npos;
#endif
#endif #endif
} }
return bPrint; return bPrint;

Loading…
Cancel
Save