Revision: 819
http://vcs.pcre.org/viewvc?view=rev&revision=819
Author: zherczeg
Date: 2011-12-22 23:10:09 +0000 (Thu, 22 Dec 2011)
Log Message:
-----------
dfa and other 16 bit fixes
Modified Paths:
--------------
code/branches/pcre16/pcre_compile.c
code/branches/pcre16/pcre_dfa_exec.c
code/branches/pcre16/pcre_jit_compile.c
code/branches/pcre16/pcretest.c
Modified: code/branches/pcre16/pcre_compile.c
===================================================================
--- code/branches/pcre16/pcre_compile.c 2011-12-22 20:11:31 UTC (rev 818)
+++ code/branches/pcre16/pcre_compile.c 2011-12-22 23:10:09 UTC (rev 819)
@@ -685,7 +685,7 @@
newsize - cd->workspace_size < WORK_SIZE_SAFETY_MARGIN)
return ERR72;
-newspace = (PUBL(malloc))(newsize * sizeof(pcre_uchar));
+newspace = (PUBL(malloc))(IN_UCHARS(newsize));
if (newspace == NULL) return ERR21;
memcpy(newspace, cd->start_workspace, cd->workspace_size * sizeof(pcre_uchar));
cd->hwm = (pcre_uchar *)newspace + (cd->hwm - cd->start_workspace);
Modified: code/branches/pcre16/pcre_dfa_exec.c
===================================================================
--- code/branches/pcre16/pcre_dfa_exec.c 2011-12-22 20:11:31 UTC (rev 818)
+++ code/branches/pcre16/pcre_dfa_exec.c 2011-12-22 23:10:09 UTC (rev 819)
@@ -2433,7 +2433,7 @@
if (clen > 0)
{
isinclass = (c > 255)? (codevalue == OP_NCLASS) :
- ((code[1 + c/8] & (1 << (c&7))) != 0);
+ ((((pcre_uint8 *)(code + 1))[c/8] & (1 << (c&7))) != 0);
}
}
@@ -2481,7 +2481,7 @@
{ ADD_ACTIVE(next_state_offset + 1 + 2 * IMM2_SIZE, 0); }
if (isinclass)
{
- int max = GET2(ecode, 3);
+ int max = GET2(ecode, 1 + IMM2_SIZE);
if (++count >= max && max != 0) /* Max 0 => no limit */
{ ADD_NEW(next_state_offset + 1 + 2 * IMM2_SIZE, 0); }
else
@@ -2591,10 +2591,10 @@
else if (condcode == OP_RREF || condcode == OP_NRREF)
{
- int value = GET2(code, LINK_SIZE+2);
+ int value = GET2(code, LINK_SIZE + 2);
if (value != RREF_ANY) return PCRE_ERROR_DFA_UCOND;
if (md->recursive != NULL)
- { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }
+ { ADD_ACTIVE(state_offset + LINK_SIZE + 2 + IMM2_SIZE, 0); }
else { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
}
Modified: code/branches/pcre16/pcre_jit_compile.c
===================================================================
--- code/branches/pcre16/pcre_jit_compile.c 2011-12-22 20:11:31 UTC (rev 818)
+++ code/branches/pcre16/pcre_jit_compile.c 2011-12-22 23:10:09 UTC (rev 819)
@@ -6409,7 +6409,7 @@
}
common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
common->ctypes = (sljit_w)(tables + ctypes_offset);
-common->name_table = (sljit_w)re + re->name_table_offset;
+common->name_table = (sljit_w)((pcre_uchar *)re + re->name_table_offset);
common->name_count = re->name_count;
common->name_entry_size = re->name_entry_size;
common->acceptlabel = NULL;
Modified: code/branches/pcre16/pcretest.c
===================================================================
--- code/branches/pcre16/pcretest.c 2011-12-22 20:11:31 UTC (rev 818)
+++ code/branches/pcre16/pcretest.c 2011-12-22 23:10:09 UTC (rev 819)
@@ -3076,10 +3076,21 @@
options = 0;
+#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
+ if (use_pcre16)
+ {
+ *(PCRE_SCHAR16 *)copynames = 0;
+ *(PCRE_SCHAR16 *)getnames = 0;
+ }
+ else
+ {
+ *copynames = 0;
+ *getnames = 0;
+ }
+#else
*copynames = 0;
- copynames[1] = 0;
*getnames = 0;
- getnames[1] = 0;
+#endif
copynamesptr = copynames;
getnamesptr = getnames;
@@ -3928,8 +3939,18 @@
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF)
&&
start_offset < len - 1 &&
- bptr[start_offset * CHAR_SIZE] == '\r' &&
- bptr[(start_offset + 1) * CHAR_SIZE] == '\n')
+#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16
+ (use_pcre16?
+ ((PCRE_SPTR16)bptr)[start_offset] == '\r'
+ && ((PCRE_SPTR16)bptr)[start_offset + 1] == '\n'
+ :
+ bptr[start_offset] == '\r'
+ && bptr[start_offset + 1] == '\n')
+#else
+ bptr[start_offset] == '\r' &&
+ bptr[start_offset + 1] == '\n'
+#endif
+ )
onechar++;
else if (use_utf)
{