Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch all pcrecpp to pcre

  • Loading branch information...
commit b609cdea1e6b4ec0804759b16ca8b9eb043a7afd 1 parent 2d46a7b
@thomasdziedzic thomasdziedzic authored
View
9 CMakeLists.txt
@@ -128,7 +128,7 @@ INCLUDE(FindSDL REQUIRED)
INCLUDE(FindZLIB REQUIRED)
INCLUDE(FindFreetype REQUIRED)
INCLUDE(FindOpenGL REQUIRED)
-INCLUDE(FindPCRECPP REQUIRED)
+INCLUDE(FindPCRE REQUIRED)
INCLUDE(FindFTGL REQUIRED)
INCLUDE(FindGLEW REQUIRED)
IF(UNIX)
@@ -145,8 +145,7 @@ ENDIF(WIN32)
find_package(Boost COMPONENTS filesystem system REQUIRED)
if(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-ENDIF(Boost_FOUND)
-
+ENDIF(Boost_FOUND)
IF(UNIX)
INCLUDE(FindPkgConfig REQUIRED)
pkg_check_modules(EXTRA_LIBS REQUIRED x11 fontconfig cairo)
@@ -194,7 +193,7 @@ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
-INCLUDE_DIRECTORIES(${PCRECPP_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${FTGL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${XMLPP_INCLUDE_DIRS})
@@ -331,7 +330,7 @@ ENDIF (CMAKE_COMPILER_IS_GNUCC)
TARGET_LINK_LIBRARIES(spark ${EXTRA_LIBS_LIBRARIES} ${ZLIB_LIBRARIES}
${Boost_LIBRARIES} ${LLVM_LIBS_CORE} ${LLVM_LIBS_JIT} ${SDL_LIBRARY}
${OPTIONAL_LIBRARIES} ${GTK_LIBRARIES} ${FREETYPE_LIBRARIES}
- ${OPENGL_LIBRARIES} ${FTGL_LIBRARIES} ${GLEW_LIBRARIES} ${PCRECPP_LIBRARIES}
+ ${OPENGL_LIBRARIES} ${FTGL_LIBRARIES} ${GLEW_LIBRARIES} ${PCRE_LIBRARIES}
${Threads_LIBRARIES} ${XMLPP_LIBRARIES} ${CMAKE_DL_LIBS})
SET_TARGET_PROPERTIES(spark PROPERTIES VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
SET_TARGET_PROPERTIES(spark PROPERTIES SOVERSION "${MAJOR_VERSION}.${MINOR_VERSION}")
View
33 conf/FindPCRECPP.cmake
@@ -1,33 +0,0 @@
-# - Find PCRECPP
-# Find the native PCRECPP headers and libraries.
-#
-# PCRECPP_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRECPP_LIBRARIES - List of libraries when using pcrecpp
-# PCRECPP_FOUND - True if pcrecpp found.
-
-# Look for the header file.
-FIND_PATH(PCRECPP_INCLUDE_DIR NAMES pcrecpp.h)
-MARK_AS_ADVANCED(PCRECPP_INCLUDE_DIR)
-
-# Look for the library.
-FIND_LIBRARY(PCRECPP_LIBRARY NAMES
- pcrecpp
- pcrecppd
-)
-MARK_AS_ADVANCED(PCRECPP_LIBRARY)
-
-FIND_LIBRARY(PCRE_LIBRARY NAMES
- pcre
- pcred
-)
-MARK_AS_ADVANCED(PCRE_LIBRARY)
-
-# handle the QUIETLY and REQUIRED arguments and set PCRECPP_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRECPP DEFAULT_MSG PCRECPP_LIBRARY PCRECPP_INCLUDE_DIR PCRE_LIBRARY)
-
-IF(PCRECPP_FOUND)
- SET(PCRECPP_LIBRARIES ${PCRECPP_LIBRARY} ${PCRE_LIBRARY})
- SET(PCRECPP_INCLUDE_DIRS ${PCRECPP_INCLUDE_DIR})
-ENDIF(PCRECPP_FOUND)
View
33 scripting/toplevel.cpp
@@ -19,7 +19,6 @@
#include <list>
#include <algorithm>
-#include <pcrecpp.h>
#include <pcre.h>
#include <string.h>
#include <sstream>
@@ -27,6 +26,7 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include <limits>
+#include <cstdio>
#include "abc.h"
#include "toplevel.h"
@@ -2263,16 +2263,31 @@ ASFUNCTIONBODY(RegExp,exec)
ASFUNCTIONBODY(RegExp,test)
{
RegExp* th=static_cast<RegExp*>(obj);
- pcrecpp::RE_Options opt;
- opt.set_caseless(th->ignoreCase);
- opt.set_extended(th->extended);
- opt.set_multiline(th->multiline);
- pcrecpp::RE pcreRE(th->re,opt);
- assert_and_throw(th->lastIndex==0);
- const tiny_string& arg0=args[0]->toString();
+ const tiny_string& arg0 = args[0]->toString();
+
+ int options = 0;
+ if(th->ignoreCase)
+ options |= PCRE_CASELESS;
+ if(th->extended)
+ options |= PCRE_EXTENDED;
+ if(th->multiline)
+ options |= PCRE_MULTILINE;
+
+ const char * error;
+ int errorOffset;
+ pcre * pcreRE = pcre_compile(th->re.c_str(), options, &error, &errorOffset, NULL);
+ if(error)
+ return new Null;
+
+ const char* str=arg0.raw_buf();
+ int strLen=arg0.len();
+ int ovector[30];
+ int rc = pcre_exec(pcreRE, NULL, str, strLen, 0, PCRE_PARTIAL_SOFT, ovector, 30);
+
+ // either a partial or full match
+ bool ret = ( (rc == PCRE_ERROR_PARTIAL) || (rc >= 0) );
- bool ret=pcreRE.PartialMatch(arg0.raw_buf());
return abstract_b(ret);
}
View
4 tests/RegExp_test.mxml
@@ -16,6 +16,10 @@
Tests.assertArrayEquals(["idenTIfiER_123","idenTIfiER_","123"], ret, "exec(): With capturing groups", true);
Tests.assertEquals("idenTIfiER_", ret.namedCapture, "exec(): With named capturing groups", true);
+ var re2:RegExp = new RegExp("[0-9]+a");
+ var ret2:Boolean = re2.test("012");
+ Tests.assertTrue(ret2, "test(): With partial matching");
+
Tests.report(visual, this.name);
}
]]>
Please sign in to comment.
Something went wrong with that request. Please try again.