[Pcre-svn] [779] code/trunk: Added (int) casts to reduce 64-…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [779] code/trunk: Added (int) casts to reduce 64-bit warnings.
Revision: 779
          http://vcs.pcre.org/viewvc?view=rev&revision=779
Author:   ph10
Date:     2011-12-02 10:39:32 +0000 (Fri, 02 Dec 2011)


Log Message:
-----------
Added (int) casts to reduce 64-bit warnings.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/pcre_dfa_exec.c
    code/trunk/pcre_exec.c
    code/trunk/pcre_valid_utf8.c
    code/trunk/pcregrep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/ChangeLog    2011-12-02 10:39:32 UTC (rev 779)
@@ -93,6 +93,9 @@
 22. A caseless match of a UTF-8 character whose other case uses fewer bytes did 
     not work when the shorter character appeared right at the end of the 
     subject string.
+    
+23. Added some (int) casts to non-JIT modules to reduce warnings on 64-bit 
+    systems. 



Version 8.20 21-Oct-2011

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/pcre_compile.c    2011-12-02 10:39:32 UTC (rev 779)
@@ -3683,7 +3683,7 @@


       if (lengthptr != NULL)
         {
-        *lengthptr += class_utf8data - class_utf8data_base;
+        *lengthptr += (int)(class_utf8data - class_utf8data_base);
         class_utf8data = class_utf8data_base;
         }


@@ -4382,7 +4382,7 @@

       /* Now fill in the complete length of the item */


-      PUT(previous, 1, code - previous);
+      PUT(previous, 1, (int)(code - previous));
       break;   /* End of class handling */
       }
 #endif
@@ -4524,7 +4524,7 @@
         {
         uschar *lastchar = code - 1;
         while((*lastchar & 0xc0) == 0x80) lastchar--;
-        c = code - lastchar;            /* Length of UTF-8 character */
+        c = (int)(code - lastchar);     /* Length of UTF-8 character */
         memcpy(utf8_char, lastchar, c); /* Save the char */
         c |= 0x80;                      /* Flag c as a length */
         }


Modified: code/trunk/pcre_dfa_exec.c
===================================================================
--- code/trunk/pcre_dfa_exec.c    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/pcre_dfa_exec.c    2011-12-02 10:39:32 UTC (rev 779)
@@ -2781,7 +2781,7 @@
             {
             const uschar *p = ptr;
             const uschar *pp = local_ptr;
-            charcount = pp - p;
+            charcount = (int)(pp - p);
             while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;
             ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));
             }


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/pcre_exec.c    2011-12-02 10:39:32 UTC (rev 779)
@@ -217,7 +217,7 @@
   while (length-- > 0) if (*p++ != *eptr++) return -1;
   }


-return eptr - eptr_start;
+return (int)(eptr - eptr_start);
}


@@ -1070,7 +1070,7 @@
     if (offset < md->offset_max)
       {
       matched_once = FALSE;
-      code_offset = ecode - md->start_code;
+      code_offset = (int)(ecode - md->start_code);


       save_offset1 = md->offset_vector[offset];
       save_offset2 = md->offset_vector[offset+1];
@@ -1160,7 +1160,7 @@


     POSSESSIVE_NON_CAPTURE:
     matched_once = FALSE;
-    code_offset = ecode - md->start_code;
+    code_offset = (int)(ecode - md->start_code);


     for (;;)
       {


Modified: code/trunk/pcre_valid_utf8.c
===================================================================
--- code/trunk/pcre_valid_utf8.c    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/pcre_valid_utf8.c    2011-12-02 10:39:32 UTC (rev 779)
@@ -111,7 +111,7 @@
 if (length < 0)
   {
   for (p = string; *p != 0; p++);
-  length = p - string;
+  length = (int)(p - string);
   }


for (p = string; length-- > 0; p++)
@@ -123,20 +123,20 @@

   if (c < 0xc0)                         /* Isolated 10xx xxxx byte */
     {
-    *erroroffset = p - string;
+    *erroroffset = (int)(p - string);
     return PCRE_UTF8_ERR20;
     }


   if (c >= 0xfe)                        /* Invalid 0xfe or 0xff bytes */
     {
-    *erroroffset = p - string;
+    *erroroffset = (int)(p - string);
     return PCRE_UTF8_ERR21;
     }


   ab = _pcre_utf8_table4[c & 0x3f];     /* Number of additional bytes */
   if (length < ab)
     {
-    *erroroffset = p - string;          /* Missing bytes */
+    *erroroffset = (int)(p - string);          /* Missing bytes */
     return ab - length;                 /* Codes ERR1 to ERR5 */
     }
   length -= ab;                         /* Length remaining */
@@ -145,7 +145,7 @@


   if (((d = *(++p)) & 0xc0) != 0x80)
     {
-    *erroroffset = p - string - 1;
+    *erroroffset = (int)(p - string) - 1;
     return PCRE_UTF8_ERR6;
     }


@@ -160,7 +160,7 @@

     case 1: if ((c & 0x3e) == 0)
       {
-      *erroroffset = p - string - 1;
+      *erroroffset = (int)(p - string) - 1;
       return PCRE_UTF8_ERR15;
       }
     break;
@@ -172,17 +172,17 @@
     case 2:
     if ((*(++p) & 0xc0) != 0x80)     /* Third byte */
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR7;
       }
     if (c == 0xe0 && (d & 0x20) == 0)
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR16;
       }
     if (c == 0xed && d >= 0xa0)
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR14;
       }
     break;
@@ -194,22 +194,22 @@
     case 3:
     if ((*(++p) & 0xc0) != 0x80)     /* Third byte */
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR7;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Fourth byte */
       {
-      *erroroffset = p - string - 3;
+      *erroroffset = (int)(p - string) - 3;
       return PCRE_UTF8_ERR8;
       }
     if (c == 0xf0 && (d & 0x30) == 0)
       {
-      *erroroffset = p - string - 3;
+      *erroroffset = (int)(p - string) - 3;
       return PCRE_UTF8_ERR17;
       }
     if (c > 0xf4 || (c == 0xf4 && d > 0x8f))
       {
-      *erroroffset = p - string - 3;
+      *erroroffset = (int)(p - string) - 3;
       return PCRE_UTF8_ERR13;
       }
     break;
@@ -225,22 +225,22 @@
     case 4:
     if ((*(++p) & 0xc0) != 0x80)     /* Third byte */
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR7;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Fourth byte */
       {
-      *erroroffset = p - string - 3;
+      *erroroffset = (int)(p - string) - 3;
       return PCRE_UTF8_ERR8;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Fifth byte */
       {
-      *erroroffset = p - string - 4;
+      *erroroffset = (int)(p - string) - 4;
       return PCRE_UTF8_ERR9;
       }
     if (c == 0xf8 && (d & 0x38) == 0)
       {
-      *erroroffset = p - string - 4;
+      *erroroffset = (int)(p - string) - 4;
       return PCRE_UTF8_ERR18;
       }
     break;
@@ -251,27 +251,27 @@
     case 5:
     if ((*(++p) & 0xc0) != 0x80)     /* Third byte */
       {
-      *erroroffset = p - string - 2;
+      *erroroffset = (int)(p - string) - 2;
       return PCRE_UTF8_ERR7;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Fourth byte */
       {
-      *erroroffset = p - string - 3;
+      *erroroffset = (int)(p - string) - 3;
       return PCRE_UTF8_ERR8;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Fifth byte */
       {
-      *erroroffset = p - string - 4;
+      *erroroffset = (int)(p - string) - 4;
       return PCRE_UTF8_ERR9;
       }
     if ((*(++p) & 0xc0) != 0x80)     /* Sixth byte */
       {
-      *erroroffset = p - string - 5;
+      *erroroffset = (int)(p - string) - 5;
       return PCRE_UTF8_ERR10;
       }
     if (c == 0xfc && (d & 0x3c) == 0)
       {
-      *erroroffset = p - string - 5;
+      *erroroffset = (int)(p - string) - 5;
       return PCRE_UTF8_ERR19;
       }
     break;
@@ -283,7 +283,7 @@


   if (ab > 3)
     {
-    *erroroffset = p - string - ab;
+    *erroroffset = (int)(p - string) - ab;
     return (ab == 4)? PCRE_UTF8_ERR11 : PCRE_UTF8_ERR12;
     }
   }


Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2011-12-01 17:38:47 UTC (rev 778)
+++ code/trunk/pcregrep.c    2011-12-02 10:39:32 UTC (rev 779)
@@ -1410,7 +1410,7 @@
         and its line-ending characters (if they matched the pattern), so there
         may be no more to print. */


-        plength = (linelength + endlinelength) - startoffset;
+        plength = (int)((linelength + endlinelength) - startoffset);
         if (plength > 0) FWRITE(ptr + startoffset, 1, plength, stdout);
         }


@@ -1462,7 +1462,7 @@

   if (input_line_buffered && bufflength < (size_t)bufsize)
     {
-    int add = read_one_line(ptr, bufsize - (ptr - main_buffer), in);
+    int add = read_one_line(ptr, bufsize - (int)(ptr - main_buffer), in);
     bufflength += add;
     endptr += add;
     }