summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshmuz <shmuz@013net.net>2010-12-15 15:28:01 +0200
committershmuz <shmuz@013net.net>2010-12-15 15:28:01 +0200
commit0cacf0d8726ffa74a679fdab26debbc0da00cc90 (patch)
tree407befb5881fd903fe742255a668f2e3b4449ddf
parentd98644d4b02871422f5688d8c20717ec884f9dd9 (diff)
downloadlrexlib-0cacf0d8726ffa74a679fdab26debbc0da00cc90.tar.gz
1. fix rex.split (offset was out-of-range)
2. PCRE: add new flags from PCRE 8.11
-rw-r--r--src/algo.h20
-rw-r--r--src/pcre/lpcre_f.c6
2 files changed, 18 insertions, 8 deletions
diff --git a/src/algo.h b/src/algo.h
index 2a4288d..a302d09 100644
--- a/src/algo.h
+++ b/src/algo.h
@@ -3,7 +3,7 @@
#include "common.h"
-#define REX_VERSION "Lrexlib 2.5.1"
+#define REX_VERSION "Lrexlib 2.5.3"
/* Forward declarations */
static void gmatch_pushsubject (lua_State *L, TArgExec *argE);
@@ -495,7 +495,9 @@ static int split_iter (lua_State *L) {
if (argE.startoffset > (int)argE.textlen)
return 0;
- newoffset = argE.startoffset + incr;
+ if ((newoffset = argE.startoffset + incr) > (int)argE.textlen)
+ goto nomatch;
+
res = split_exec (ud, &argE, newoffset);
if (ALG_ISMATCH (res)) {
ALG_PUSHEND (L, ud, ALG_BASE(newoffset), 0); /* update start offset */
@@ -515,14 +517,16 @@ static int split_iter (lua_State *L) {
return 2;
}
}
- else if (ALG_NOMATCH (res)) {
- lua_pushinteger (L, argE.textlen + 1); /* mark as last iteration */
- lua_replace (L, lua_upvalueindex (4)); /* update start offset */
- lua_pushlstring (L, argE.text+argE.startoffset, argE.textlen-argE.startoffset);
- return 1;
- }
+ else if (ALG_NOMATCH (res))
+ goto nomatch;
else
return generate_error (L, ud, res);
+
+nomatch:
+ lua_pushinteger (L, argE.textlen + 1); /* mark as last iteration */
+ lua_replace (L, lua_upvalueindex (4)); /* update start offset */
+ lua_pushlstring (L, argE.text+argE.startoffset, argE.textlen-argE.startoffset);
+ return 1;
}
diff --git a/src/pcre/lpcre_f.c b/src/pcre/lpcre_f.c
index 1862c0d..f032f94 100644
--- a/src/pcre/lpcre_f.c
+++ b/src/pcre/lpcre_f.c
@@ -164,6 +164,12 @@ flag_pair pcre_error_flags[] = {
#ifdef PCRE_ERROR_NULLWSLIMIT
{ "ERROR_NULLWSLIMIT", PCRE_ERROR_NULLWSLIMIT },
#endif
+#ifdef PCRE_ERROR_BADOFFSET
+ { "ERROR_BADOFFSET", PCRE_ERROR_BADOFFSET },
+#endif
+#ifdef PCRE_ERROR_SHORTUTF8
+ { "ERROR_SHORTUTF8", PCRE_ERROR_SHORTUTF8 },
+#endif
/*---------------------------------------------------------------------------*/
{ NULL, 0 }
};