[Pcre-svn] [1114] code/trunk: pcre32: Remove unnecessary ifd…

Startseite
Nachricht löschen
Autor: Subversion repository
Datum:  
To: pcre-svn
Betreff: [Pcre-svn] [1114] code/trunk: pcre32: Remove unnecessary ifdefing
Revision: 1114
          http://vcs.pcre.org/viewvc?view=rev&revision=1114
Author:   chpe
Date:     2012-10-16 16:57:16 +0100 (Tue, 16 Oct 2012)


Log Message:
-----------
pcre32: Remove unnecessary ifdefing

Just define HAS_EXTRALEN etc to 0. This reduces the amount of #ifdef COMPILE_PCRE32.

Modified Paths:
--------------
    code/trunk/pcre_compile.c
    code/trunk/pcre_internal.h
    code/trunk/pcre_jit_compile.c
    code/trunk/pcre_study.c


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2012-10-16 15:57:12 UTC (rev 1113)
+++ code/trunk/pcre_compile.c    2012-10-16 15:57:16 UTC (rev 1114)
@@ -1854,7 +1854,7 @@
     case OP_NOTI:
     branchlength++;
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -1868,7 +1868,7 @@
     case OP_NOTEXACTI:
     branchlength += (int)GET2(cc,1);
     cc += 2 + IMM2_SIZE;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -4115,7 +4115,7 @@
       {
       const pcre_uchar *oldptr;


-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (utf && HAS_EXTRALEN(c))
         {                           /* Braces are required because the */
         GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
@@ -5505,7 +5505,7 @@
       else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
         {
         tempcode += PRIV(OP_lengths)[*tempcode];
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
         if (utf && HAS_EXTRALEN(tempcode[-1]))
           tempcode += GET_EXTRALEN(tempcode[-1]);
 #endif
@@ -6949,7 +6949,7 @@
     mclength = 1;
     mcbuffer[0] = c;


-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(c))
       ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
 #endif


Modified: code/trunk/pcre_internal.h
===================================================================
--- code/trunk/pcre_internal.h    2012-10-16 15:57:12 UTC (rev 1113)
+++ code/trunk/pcre_internal.h    2012-10-16 15:57:16 UTC (rev 1114)
@@ -914,13 +914,14 @@


#elif defined COMPILE_PCRE32

-/* These are unnecessary for the 32-bit library */
-#undef MAX_VALUE_FOR_SINGLE_CHAR
-#undef HAS_EXTRALEN
-#undef GET_EXTRALEN
-#undef NOT_FIRSTCHAR
+/* These are trivial for the 32-bit library, since all UTF-32 characters fit
+into one pcre_uchar unit. */
+#define MAX_VALUE_FOR_SINGLE_CHAR (0x10ffffu)
+#define HAS_EXTRALEN(c) (0)
+#define GET_EXTRALEN(c) (0)
+#define NOT_FIRSTCHAR(c) (0)

-#define UTF32_MASK (0x1ffffful)
+#define UTF32_MASK (0x1fffffu)

/* Get the next UTF-32 character, not advancing the pointer. This is called when
we know we are in UTF-32 mode. */
@@ -989,7 +990,8 @@
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-32 mode - we don't put a test within the
macro because almost all calls are already within a block of UTF-32 only
-code. */
+code.
+These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */

#define BACKCHAR(eptr) do { } while (0)


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2012-10-16 15:57:12 UTC (rev 1113)
+++ code/trunk/pcre_jit_compile.c    2012-10-16 15:57:16 UTC (rev 1114)
@@ -591,7 +591,7 @@
   case OP_NOTPOSPLUSI:
   case OP_NOTPOSQUERYI:
   cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
   if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
   return cc;
@@ -613,7 +613,7 @@
   case OP_NOTEXACTI:
   case OP_NOTPOSUPTOI:
   cc += 2 + IMM2_SIZE;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
   if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
   return cc;
@@ -936,7 +936,7 @@
     if (size < 0)
       {
       cc += -size;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
       }
@@ -1076,7 +1076,7 @@
     if (size < 0)
       {
       cc += -size;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
       }
@@ -1320,7 +1320,7 @@
     if (PRIVATE_DATA(cc))
       private_data_length++;
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -1329,7 +1329,7 @@
     if (PRIVATE_DATA(cc))
       private_data_length += 2;
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -1338,7 +1338,7 @@
     if (PRIVATE_DATA(cc))
       private_data_length += 2;
     cc += 2 + IMM2_SIZE;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -1497,7 +1497,7 @@
         srcw[0] = PRIVATE_DATA(cc);
         }
       cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
       break;
@@ -1510,7 +1510,7 @@
         srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);
         }
       cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
       break;
@@ -1523,7 +1523,7 @@
         srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);
         }
       cc += 2 + IMM2_SIZE;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
       if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
       break;
@@ -2643,7 +2643,7 @@
       break;


len = 1;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
if (common->utf && HAS_EXTRALEN(cc[0])) len += GET_EXTRALEN(cc[0]);
#endif

@@ -3563,10 +3563,8 @@

#ifdef SUPPORT_UTF
utflength = 1;
-#ifndef COMPILE_PCRE32
if (common->utf && HAS_EXTRALEN(*cc))
utflength += GET_EXTRALEN(*cc);
-#endif

 do
   {
@@ -3759,7 +3757,7 @@
   if (*cc == XCL_SINGLE)
     {
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
 #ifdef SUPPORT_UCP
@@ -3769,11 +3767,11 @@
   else if (*cc == XCL_RANGE)
     {
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     cc++;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
 #ifdef SUPPORT_UCP
@@ -4467,7 +4465,7 @@
   case OP_CHAR:
   case OP_CHARI:
   length = 1;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
   if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
 #endif
   if (common->mode == JIT_COMPILE && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0))
@@ -4662,7 +4660,7 @@
   if (*cc == OP_CHAR)
     {
     size = 1;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (common->utf && HAS_EXTRALEN(cc[1]))
       size += GET_EXTRALEN(cc[1]);
 #endif
@@ -4675,10 +4673,8 @@
       {
       if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
         size = 0;
-#ifndef COMPILE_PCRE32
       else if (HAS_EXTRALEN(cc[1]))
         size += GET_EXTRALEN(cc[1]);
-#endif
       }
     else
 #endif
@@ -6266,7 +6262,7 @@
 if (end != NULL)
   {
   *end = cc + 1;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
   if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);
 #endif
   }


Modified: code/trunk/pcre_study.c
===================================================================
--- code/trunk/pcre_study.c    2012-10-16 15:57:12 UTC (rev 1113)
+++ code/trunk/pcre_study.c    2012-10-16 15:57:16 UTC (rev 1114)
@@ -224,7 +224,7 @@
     case OP_NOTPOSPLUSI:
     branchlength++;
     cc += 2;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -245,7 +245,7 @@
     case OP_NOTEXACTI:
     branchlength += GET2(cc,1);
     cc += 2 + IMM2_SIZE;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;
@@ -486,7 +486,7 @@
     case OP_NOTPOSQUERYI:


     cc += PRIV(OP_lengths)[op];
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
+#ifdef SUPPORT_UTF
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
 #endif
     break;