[Pcre-svn] [904] code/trunk: Additional casts to avoid compi…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [904] code/trunk: Additional casts to avoid compiler warnings, originally from a MS compiler, but
Revision: 904
          http://vcs.pcre.org/viewvc?view=rev&revision=904
Author:   ph10
Date:     2012-01-23 17:30:49 +0000 (Mon, 23 Jan 2012)


Log Message:
-----------
Additional casts to avoid compiler warnings, originally from a MS compiler, but
also given by gcc if you turn on enough warnings.

Modified Paths:
--------------
    code/trunk/pcre_compile.c
    code/trunk/pcre_dfa_exec.c
    code/trunk/pcre_exec.c
    code/trunk/pcre_fullinfo.c
    code/trunk/pcre_ord2utf8.c
    code/trunk/pcregrep.c
    code/trunk/pcreposix.c
    code/trunk/pcretest.c


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcre_compile.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -3067,7 +3067,7 @@
     }
   else
 #endif  /* SUPPORT_UTF */
-  return (c != TABLE_GET(next, cd->fcc, next));  /* Non-UTF-8 mode */
+  return (c != TABLE_GET((unsigned int)next, cd->fcc, next));  /* Non-UTF-8 mode */


   /* For OP_NOT and OP_NOTI, the data is always a single-byte character. These
   opcodes are not used for multi-byte characters, because they are coded using
@@ -3092,7 +3092,7 @@
     }
   else
 #endif  /* SUPPORT_UTF */
-  return (c == TABLE_GET(next, cd->fcc, next));  /* Non-UTF-8 mode */
+  return (c == (int)(TABLE_GET((unsigned int)next, cd->fcc, next)));  /* Non-UTF-8 mode */


   /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.
   When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
@@ -4571,7 +4571,7 @@
 #endif
           {
           unsigned int othercase;
-          if ((othercase = UCD_OTHERCASE(c)) != c)
+          if ((int)(othercase = UCD_OTHERCASE(c)) != c)
             {
             *class_uchardata++ = XCL_SINGLE;
             class_uchardata += PRIV(ord2utf)(othercase, class_uchardata);


Modified: code/trunk/pcre_dfa_exec.c
===================================================================
--- code/trunk/pcre_dfa_exec.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcre_dfa_exec.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -3209,7 +3209,7 @@
   if ((re->flags & PCRE_FIRSTSET) != 0)
     {
     has_first_char = TRUE;
-    first_char = first_char2 = re->first_char;
+    first_char = first_char2 = (pcre_uchar)(re->first_char);
     if ((re->flags & PCRE_FCH_CASELESS) != 0)
       {
       first_char2 = TABLE_GET(first_char, md->tables + fcc_offset, first_char);
@@ -3233,7 +3233,7 @@
 if ((re->flags & PCRE_REQCHSET) != 0)
   {
   has_req_char = TRUE;
-  req_char = req_char2 = re->req_char;
+  req_char = req_char2 = (pcre_uchar)(re->req_char);
   if ((re->flags & PCRE_RCH_CASELESS) != 0)
     {
     req_char2 = TABLE_GET(req_char, md->tables + fcc_offset, req_char);


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcre_exec.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -3508,7 +3508,7 @@
     GETCHARINCTEST(c, eptr);
     if (op == OP_NOTI)         /* The caseless case */
       {
-      register int ch, och;
+      register unsigned int ch, och;
       ch = *ecode++;
 #ifdef COMPILE_PCRE8
       /* ch must be < 128 if UTF is enabled. */
@@ -3654,7 +3654,7 @@
             RRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(d, eptr);
-          if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);
+          if (fc == d || (unsigned int) foc == d) RRETURN(MATCH_NOMATCH);
           }
         }
       else
@@ -3692,7 +3692,7 @@
               RRETURN(MATCH_NOMATCH);
               }
             GETCHARINC(d, eptr);
-            if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);
+            if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
             }
           }
         else
@@ -3735,7 +3735,7 @@
               break;
               }
             GETCHARLEN(d, eptr, len);
-            if (fc == d || foc == d) break;
+            if (fc == d || (unsigned int)foc == d) break;
             eptr += len;
             }
           if (possessive) continue;
@@ -6496,7 +6496,7 @@
   if ((re->flags & PCRE_FIRSTSET) != 0)
     {
     has_first_char = TRUE;
-    first_char = first_char2 = re->first_char;
+    first_char = first_char2 = (pcre_uchar)(re->first_char);
     if ((re->flags & PCRE_FCH_CASELESS) != 0)
       {
       first_char2 = TABLE_GET(first_char, md->fcc, first_char);
@@ -6518,7 +6518,7 @@
 if ((re->flags & PCRE_REQCHSET) != 0)
   {
   has_req_char = TRUE;
-  req_char = req_char2 = re->req_char;
+  req_char = req_char2 = (pcre_uchar)(re->req_char);
   if ((re->flags & PCRE_RCH_CASELESS) != 0)
     {
     req_char2 = TABLE_GET(req_char, md->fcc, req_char);


Modified: code/trunk/pcre_fullinfo.c
===================================================================
--- code/trunk/pcre_fullinfo.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcre_fullinfo.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -148,7 +148,7 @@
   case PCRE_INFO_MINLENGTH:
   *((int *)where) =
     (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
-      study->minlength : -1;
+      (int)(study->minlength) : -1;
   break;


case PCRE_INFO_JIT:

Modified: code/trunk/pcre_ord2utf8.c
===================================================================
--- code/trunk/pcre_ord2utf8.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcre_ord2utf8.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -75,7 +75,7 @@
   cvalue = 0xfffe;


for (i = 0; i < PRIV(utf8_table1_size); i++)
- if (cvalue <= PRIV(utf8_table1)[i]) break;
+ if ((int)cvalue <= PRIV(utf8_table1)[i]) break;
buffer += i;
for (j = i; j > 0; j--)
{

Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcregrep.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -625,7 +625,7 @@
 Returns:     the number of characters read, zero at end of file
 */


-static int
+static unsigned int
read_one_line(char *buffer, int length, FILE *f)
{
int c;

Modified: code/trunk/pcreposix.c
===================================================================
--- code/trunk/pcreposix.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcreposix.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -274,7 +274,7 @@


 if (preg->re_pcre == NULL)
   {
-  return (errorcode < sizeof(eint)/sizeof(const int))?
+  return (errorcode < (int)(sizeof(eint)/sizeof(const int)))?
     eint[errorcode] : REG_BADPAT;
   }



Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2012-01-21 16:37:17 UTC (rev 903)
+++ code/trunk/pcretest.c    2012-01-23 17:30:49 UTC (rev 904)
@@ -1271,7 +1271,7 @@


for (;;)
{
- int rlen = (int)(buffer_size - (here - buffer));
+ size_t rlen = (size_t)(buffer_size - (here - buffer));

   if (rlen > 1000)
     {
@@ -4293,7 +4293,8 @@
             break;


             default:
-            if (count < 0 && (-count) < sizeof(errtexts)/sizeof(const char *))
+            if (count < 0 && 
+                (-count) < (int)(sizeof(errtexts)/sizeof(const char *)))
               fprintf(outfile, "Error %d (%s)\n", count, errtexts[-count]);
             else
               fprintf(outfile, "Error %d (Unexpected value)\n", count);