[Pcre-svn] [492] code/trunk: Fix some picky compiler warning…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [492] code/trunk: Fix some picky compiler warnings
Revision: 492
          http://www.exim.org/viewvc/pcre2?view=rev&revision=492
Author:   ph10
Date:     2016-02-16 10:23:06 +0000 (Tue, 16 Feb 2016)
Log Message:
-----------
Fix some picky compiler warnings


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_compile.c
    code/trunk/src/pcre2_config.c
    code/trunk/src/pcre2_dfa_match.c
    code/trunk/src/pcre2_error.c
    code/trunk/src/pcre2_internal.h
    code/trunk/src/pcre2_intmodedep.h


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/ChangeLog    2016-02-16 10:23:06 UTC (rev 492)
@@ -65,7 +65,11 @@
 13. Detect missing closing parentheses during the pre-pass for group 
 identification.


+14. Changed some integer variable types and put in a number of casts, following
+a report of compiler warnings from Visual Studio 2013 and a few tests with
+gcc's -Wconversion (which still throws up a lot).

+
Version 10.21 12-January-2016
-----------------------------


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_compile.c    2016-02-16 10:23:06 UTC (rev 492)
@@ -81,7 +81,7 @@


/* Function definitions to allow mutual recursion */

-static int
+static unsigned int
   add_list_to_class(uint8_t *, PCRE2_UCHAR **, uint32_t, compile_block *,
     const uint32_t *, unsigned int);


@@ -149,10 +149,17 @@

#define OFLOW_MAX (INT_MAX - 20)

-/* Macro for setting individual bits in class bitmaps. */
+/* Macro for setting individual bits in class bitmaps. It took some
+experimenting to figure out how to stop gcc 5.3.0 from warning with
+-Wconversion. This version gets a warning:

-#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
+ #define SETBIT(a,b) a[(b)/8] |= (uint8_t)(1 << ((b)&7))
+
+Let's hope the apparently less efficient version isn't actually so bad if the
+compiler is clever with identical subexpressions. */

+#define SETBIT(a,b) a[(b)/8] = (uint8_t)(a[(b)/8] | (1 << ((b)&7)))
+
/* Private flags added to firstcu and reqcu. */

 #define REQ_CASELESS    (1 << 0)        /* Indicates caselessness */
@@ -804,7 +811,7 @@
 complete_callout(PCRE2_UCHAR *previous_callout, PCRE2_SPTR ptr,
   compile_block *cb)
 {
-size_t length = ptr - cb->start_pattern - GET(previous_callout, 1);
+size_t length = (size_t)(ptr - cb->start_pattern - GET(previous_callout, 1));
 PUT(previous_callout, 1 + LINK_SIZE, length);
 }


@@ -855,11 +862,11 @@
find_fixedlength(PCRE2_UCHAR *code, BOOL utf, BOOL atend, compile_block *cb,
recurse_check *recurses, int *countptr)
{
-int length = -1;
+uint32_t length = 0xffffffffu; /* Unset */
uint32_t group = 0;
uint32_t groupinfo = 0;
recurse_check this_recurse;
-register int branchlength = 0;
+register uint32_t branchlength = 0;
register PCRE2_UCHAR *cc = code + 1 + LINK_SIZE;

 /* If this is a capturing group, we may have the answer cached, but we can only
@@ -910,7 +917,7 @@
     case OP_COND:
     d = find_fixedlength(cc, utf, atend, cb, recurses, countptr);
     if (d < 0) return d;
-    branchlength += d;
+    branchlength += (uint32_t)d;
     do cc += GET(cc, 1); while (*cc == OP_ALT);
     cc += 1 + LINK_SIZE;
     break;
@@ -926,16 +933,16 @@
     case OP_END:
     case OP_ACCEPT:
     case OP_ASSERT_ACCEPT:
-    if (length < 0) length = branchlength;
+    if (length == 0xffffffffu) length = branchlength;
       else if (length != branchlength) goto ISNOTFIXED;
     if (*cc != OP_ALT)
       {
       if (group > 0)
         {
-        groupinfo |= (GI_SET_FIXED_LENGTH | length);
+        groupinfo |= (uint32_t)(GI_SET_FIXED_LENGTH | length);
         cb->groupinfo[group] = groupinfo;
         }
-      return length;
+      return (int)length;
       }
     cc += 1 + LINK_SIZE;
     branchlength = 0;
@@ -960,7 +967,7 @@
     this_recurse.group = cs;
     d = find_fixedlength(cs, utf, atend, cb, &this_recurse, countptr);
     if (d < 0) return d;
-    branchlength += d;
+    branchlength += (uint32_t)d;
     cc += 1 + LINK_SIZE;
     break;


@@ -1039,7 +1046,7 @@
     case OP_EXACTI:
     case OP_NOTEXACT:
     case OP_NOTEXACTI:
-    branchlength += (int)GET2(cc,1);
+    branchlength += GET2(cc,1);
     cc += 2 + IMM2_SIZE;
 #ifdef SUPPORT_UNICODE
     if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
@@ -1115,7 +1122,7 @@
       case OP_CRMINRANGE:
       case OP_CRPOSRANGE:
       if (GET2(cc,1) != GET2(cc,1+IMM2_SIZE)) goto ISNOTFIXED;
-      branchlength += (int)GET2(cc,1);
+      branchlength += GET2(cc,1);
       cc += 1 + 2 * IMM2_SIZE;
       break;


@@ -1941,7 +1948,7 @@
         overflow = TRUE;
         break;
         }
-      s = s * 10 + (int)(*(++ptr) - CHAR_0);
+      s = s * 10 + (unsigned int)(*(++ptr) - CHAR_0);
       }
     if (overflow) /* Integer overflow */
       {
@@ -2005,7 +2012,7 @@
           overflow = TRUE;
           break;
           }
-        s = s * 10 + (int)(*(++ptr) - CHAR_0);
+        s = s * 10 + (unsigned int)(*(++ptr) - CHAR_0);
         }
       if (overflow) /* Integer overflow */
         {
@@ -2285,7 +2292,7 @@
   unsigned int *pdataptr, int *errorcodeptr, compile_block *cb)
 {
 register PCRE2_UCHAR c;
-int i, bot, top;
+size_t i, bot, top;
 PCRE2_SPTR ptr = *ptrptr;
 PCRE2_UCHAR name[32];


@@ -2753,13 +2760,13 @@
                 the pointer to extra data is updated
 */


-static int
+static unsigned int
add_to_class(uint8_t *classbits, PCRE2_UCHAR **uchardptr, uint32_t options,
compile_block *cb, uint32_t start, uint32_t end)
{
uint32_t c;
uint32_t classbits_end = (end <= 0xff ? end : 0xff);
-int n8 = 0;
+unsigned int n8 = 0;

 /* If caseless matching is required, scan the range and process alternate
 cases. In Unicode, there are 8-bit characters that have alternate cases that
@@ -2907,14 +2914,14 @@
                 the pointer to extra data is updated
 */


-static int
+static unsigned int
 add_list_to_class(uint8_t *classbits, PCRE2_UCHAR **uchardptr, uint32_t options,
   compile_block *cb, const uint32_t *p, unsigned int except)
 {
-int n8 = 0;
+unsigned int n8 = 0;
 while (p[0] < NOTACHAR)
   {
-  int n = 0;
+  unsigned int n = 0;
   if (p[0] != except)
     {
     while(p[n+1] == p[0] + n + 1) n++;
@@ -2945,12 +2952,12 @@
                 the pointer to extra data is updated
 */


-static int
+static unsigned int
add_not_list_to_class(uint8_t *classbits, PCRE2_UCHAR **uchardptr,
uint32_t options, compile_block *cb, const uint32_t *p)
{
BOOL utf = (options & PCRE2_UTF) != 0;
-int n8 = 0;
+unsigned int n8 = 0;
if (p[0] > 0)
n8 += add_to_class(classbits, uchardptr, options, cb, 0, p[0] - 1);
while (p[0] < NOTACHAR)
@@ -3099,7 +3106,7 @@

   /* Not UTF */
     {
-    if (code != NULL) *code++ = x;
+    if (code != NULL) *code++ = (PCRE2_UCHAR)x;
     }


arglen++;
@@ -3173,14 +3180,14 @@
#define NSF_EXTENDED 0x0002u
#define NSF_DUPNAMES 0x0004u

-static uint32_t scan_for_captures(PCRE2_SPTR *ptrptr, uint32_t options,
+static int scan_for_captures(PCRE2_SPTR *ptrptr, uint32_t options,
compile_block *cb)
{
uint32_t c;
uint32_t delimiter;
-uint32_t nest_depth = 0;
uint32_t set, unset, *optset;
uint32_t skiptoket = 0;
+uint16_t nest_depth = 0;
int errorcode = 0;
int escape;
int namelen;
@@ -3438,8 +3445,8 @@

       if (*ptr == CHAR_VERTICAL_LINE)
         {
-        top_nest->reset_group = cb->bracount;
-        top_nest->max_group = cb->bracount;
+        top_nest->reset_group = (uint16_t)cb->bracount;
+        top_nest->max_group = (uint16_t)cb->bracount;
         top_nest->flags |= NSF_RESET;
         cb->external_flags |= PCRE2_DUPCAPUSED;
         break;
@@ -3474,9 +3481,10 @@
           case CHAR_U:
           break;


-          default:  errorcode = ERR11;
-                    ptr--;    /* Correct the offset */
-                    goto FAILED;
+          default:  
+          errorcode = ERR11;
+          ptr--;    /* Correct the offset */
+          goto FAILED;
           }
         }


@@ -3652,7 +3660,7 @@
         }


       if (namelen + IMM2_SIZE + 1 > cb->name_entry_size)
-        cb->name_entry_size = namelen + IMM2_SIZE + 1;
+        cb->name_entry_size = (uint16_t)(namelen + IMM2_SIZE + 1);


       /* We have a valid name for this capturing group. */


@@ -3670,7 +3678,7 @@
       for (i = 0; i < cb->names_found; i++, ng++)
         {
         if (namelen == ng->length &&
-            PRIV(strncmp)(name, ng->name, namelen) == 0)
+            PRIV(strncmp)(name, ng->name, (size_t)namelen) == 0)
           {
           if (ng->number == cb->bracount) break;
           if ((options & PCRE2_DUPNAMES) == 0)
@@ -3694,7 +3702,7 @@


       if (cb->names_found >= cb->named_group_list_size)
         {
-        int newsize = cb->named_group_list_size * 2;
+        uint32_t newsize = cb->named_group_list_size * 2;
         named_group *newspace =
           cb->cx->memctl.malloc(newsize * sizeof(named_group),
           cb->cx->memctl.memory_data);
@@ -3716,9 +3724,9 @@
       /* Add this name to the list */


       cb->named_groups[cb->names_found].name = name;
-      cb->named_groups[cb->names_found].length = namelen;
+      cb->named_groups[cb->names_found].length = (uint16_t)namelen;
       cb->named_groups[cb->names_found].number = cb->bracount;
-      cb->named_groups[cb->names_found].isdup = isdupname;
+      cb->named_groups[cb->names_found].isdup = (uint16_t)isdupname;
       cb->names_found++;
       break;
       }        /* End of (? switch */
@@ -3731,7 +3739,7 @@
         (top_nest->flags & NSF_RESET) != 0)
       {
       if (cb->bracount > top_nest->max_group)
-        top_nest->max_group = cb->bracount;
+        top_nest->max_group = (uint16_t)cb->bracount;
       cb->bracount = top_nest->reset_group;
       }
     break;
@@ -3966,7 +3974,7 @@
       *errorcodeptr = ERR20;
       goto FAILED;
       }
-    *lengthptr += code - last_code;
+    *lengthptr += (size_t)(code - last_code);


     /* If "previous" is set and it is not at the start of the work space, move
     it back to there, in order to avoid filling up the work space. Otherwise,
@@ -3976,7 +3984,7 @@
       {
       if (previous > orig_code)
         {
-        memmove(orig_code, previous, CU2BYTES(code - previous));
+        memmove(orig_code, previous, (size_t)CU2BYTES(code - previous));
         code -= previous - orig_code;
         previous = orig_code;
         }
@@ -4137,7 +4145,7 @@
         *errorcodeptr = ERR20;
         goto FAILED;
         }
-      *lengthptr += code - last_code;   /* To include callout length */
+      *lengthptr += (size_t)(code - last_code);  /* To include callout length */
       }
     return TRUE;


@@ -4425,7 +4433,7 @@
             case PC_PUNCT:
             if (ptype == 0) ptype = PT_PXPUNCT;
             *class_uchardata++ = local_negate? XCL_NOTPROP : XCL_PROP;
-            *class_uchardata++ = ptype;
+            *class_uchardata++ = (PCRE2_UCHAR)ptype;
             *class_uchardata++ = 0;
             xclass_has_prop = TRUE;
             ptr = tempptr + 1;
@@ -4473,9 +4481,9 @@
         if (taboffset >= 0)
           {
           if (tabopt >= 0)
-            for (c = 0; c < 32; c++) pbits[c] |= cbits[c + taboffset];
+            for (c = 0; c < 32; c++) pbits[c] |= cbits[(int)c + taboffset];
           else
-            for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];
+            for (c = 0; c < 32; c++) pbits[c] &= ~cbits[(int)c + taboffset];
           }


         /* Now see if we need to remove any special characters. An option


Modified: code/trunk/src/pcre2_config.c
===================================================================
--- code/trunk/src/pcre2_config.c    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_config.c    2016-02-16 10:23:06 UTC (rev 492)
@@ -61,15 +61,16 @@
 * Return info about what features are configured *
 *************************************************/


-/*
+/* If where is NULL, the length of memory required is returned.
+
 Arguments:
   what             what information is required
   where            where to put the information


-Returns:           0 if data returned
-                   >= 0 if where is NULL, giving length required
+Returns:           0 if a numerical value is returned
+                   >= 0 if a string value 
                    PCRE2_ERROR_BADOPTION if "where" not recognized
-                   or JIT target requested when JIT not enabled
+                     or JIT target requested when JIT not enabled
 */


 PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
@@ -127,8 +128,8 @@
 #ifdef SUPPORT_JIT
     {
     const char *v = PRIV(jit_get_target)();
-    return 1 + ((where == NULL)?
-      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+    return (int)(1 + ((where == NULL)?
+      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)));
     }
 #else
   return PCRE2_ERROR_BADOPTION;
@@ -135,7 +136,7 @@
 #endif


case PCRE2_CONFIG_LINKSIZE:
- *((uint32_t *)where) = configured_link_size;
+ *((uint32_t *)where) = (uint32_t)configured_link_size;
break;

   case PCRE2_CONFIG_MATCHLIMIT:
@@ -169,8 +170,8 @@
 #else
     const char *v = "Unicode not supported";
 #endif
-    return 1 + ((where == NULL)?
-      strlen(v): PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+    return (int)(1 + ((where == NULL)?
+      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)));
    }
   break;


@@ -206,8 +207,8 @@
     const char *v = (XSTRING(Z PCRE2_PRERELEASE)[1] == 0)?
       XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
       XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
-    return 1 + ((where == NULL)?
-      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+    return (int)(1 + ((where == NULL)?
+      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)));
     }
   }



Modified: code/trunk/src/pcre2_dfa_match.c
===================================================================
--- code/trunk/src/pcre2_dfa_match.c    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_dfa_match.c    2016-02-16 10:23:06 UTC (rev 492)
@@ -401,7 +401,7 @@
 BOOL reset_could_continue = FALSE;


rlevel++;
-offsetcount &= (-2);
+offsetcount &= (uint32_t)(-2); /* Round down */

 wscount -= 2;
 wscount = (wscount - (wscount % (INTS_PER_STATEBLOCK * 2))) /
@@ -439,7 +439,7 @@
   end_code = this_start_code;
   do
     {
-    size_t back = GET(end_code, 2+LINK_SIZE);
+    size_t back = (size_t)GET(end_code, 2+LINK_SIZE);
     if (back > max_back) max_back = back;
     end_code += GET(end_code, 1);
     }
@@ -481,11 +481,11 @@
   end_code = this_start_code;
   do
     {
-    size_t back = GET(end_code, 2+LINK_SIZE);
+    size_t back = (size_t)GET(end_code, 2+LINK_SIZE);
     if (back <= gone_back)
       {
       int bstate = (int)(end_code - start_code + 2 + 2*LINK_SIZE);
-      ADD_NEW_DATA(-bstate, 0, gone_back - back);
+      ADD_NEW_DATA(-bstate, 0, (int)(gone_back - back));
       }
     end_code += GET(end_code, 1);
     }
@@ -509,7 +509,7 @@
     do { end_code += GET(end_code, 1); } while (*end_code == OP_ALT);
     new_count = workspace[1];
     if (!workspace[0])
-      memcpy(new_states, active_states, new_count * sizeof(stateblock));
+      memcpy(new_states, active_states, (size_t)new_count * sizeof(stateblock));
     }


   /* Not restarting */
@@ -593,8 +593,9 @@
     stateblock *current_state = active_states + i;
     BOOL caseless = FALSE;
     PCRE2_SPTR code;
+    uint32_t codevalue;
     int state_offset = current_state->offset;
-    int codevalue, rrc;
+    int rrc;
     int count;


     /* A negative offset is a special case meaning "hold off going to this
@@ -719,7 +720,7 @@
         ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);
         if (codevalue != OP_KET)
           {
-          ADD_ACTIVE(state_offset - GET(code, 1), 0);
+          ADD_ACTIVE(state_offset - (int)GET(code, 1), 0);
           }
         }
       else
@@ -733,11 +734,12 @@
             else if (match_count > 0 && ++match_count * 2 > (int)offsetcount)
               match_count = 0;
           count = ((match_count == 0)? (int)offsetcount : match_count * 2) - 2;
-          if (count > 0) memmove(offsets + 2, offsets, count * sizeof(PCRE2_SIZE));
+          if (count > 0) memmove(offsets + 2, offsets,
+            (size_t)count * sizeof(PCRE2_SIZE));
           if (offsetcount >= 2)
             {
-            offsets[0] = (int)(current_subject - start_subject);
-            offsets[1] = (int)(ptr - start_subject);
+            offsets[0] = (PCRE2_SIZE)(current_subject - start_subject);
+            offsets[1] = (PCRE2_SIZE)(ptr - start_subject);
             }
           if ((mb->moptions & PCRE2_DFA_SHORTEST) != 0) return match_count;
           }
@@ -959,7 +961,7 @@
             {
             if (d == '_') left_word = TRUE; else
               {
-              int cat = UCD_CATEGORY(d);
+              uint32_t cat = UCD_CATEGORY(d);
               left_word = (cat == ucp_L || cat == ucp_N);
               }
             }
@@ -984,7 +986,7 @@
             {
             if (c == '_') right_word = TRUE; else
               {
-              int cat = UCD_CATEGORY(c);
+              uint32_t cat = UCD_CATEGORY(c);
               right_word = (cat == ucp_L || cat == ucp_N);
               }
             }
@@ -1369,7 +1371,7 @@
       if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
       if (clen > 0)
         {
-        int lgb, rgb;
+        uint32_t lgb, rgb;
         PCRE2_SPTR nptr = ptr + clen;
         int ncount = 0;
         if (count > 0 && codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS)
@@ -1383,7 +1385,7 @@
           dlen = 1;
           if (!utf) d = *nptr; else { GETCHARLEN(d, nptr, dlen); }
           rgb = UCD_GRAPHBREAK(d);
-          if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+          if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break;
           ncount++;
           lgb = rgb;
           nptr += dlen;
@@ -1630,7 +1632,7 @@
       ADD_ACTIVE(state_offset + 2, 0);
       if (clen > 0)
         {
-        int lgb, rgb;
+        uint32_t lgb, rgb;
         PCRE2_SPTR nptr = ptr + clen;
         int ncount = 0;
         if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSSTAR ||
@@ -1645,7 +1647,7 @@
           dlen = 1;
           if (!utf) d = *nptr; else { GETCHARLEN(d, nptr, dlen); }
           rgb = UCD_GRAPHBREAK(d);
-          if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+          if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break;
           ncount++;
           lgb = rgb;
           nptr += dlen;
@@ -1902,7 +1904,7 @@
       count = current_state->count;  /* Number already matched */
       if (clen > 0)
         {
-        int lgb, rgb;
+        uint32_t lgb, rgb;
         PCRE2_SPTR nptr = ptr + clen;
         int ncount = 0;
         if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSUPTO)
@@ -1916,7 +1918,7 @@
           dlen = 1;
           if (!utf) d = *nptr; else { GETCHARLEN(d, nptr, dlen); }
           rgb = UCD_GRAPHBREAK(d);
-          if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+          if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break;
           ncount++;
           lgb = rgb;
           nptr += dlen;
@@ -2097,7 +2099,7 @@
       case OP_EXTUNI:
       if (clen > 0)
         {
-        int lgb, rgb;
+        uint32_t lgb, rgb;
         PCRE2_SPTR nptr = ptr + clen;
         int ncount = 0;
         lgb = UCD_GRAPHBREAK(c);
@@ -2106,7 +2108,7 @@
           dlen = 1;
           if (!utf) d = *nptr; else { GETCHARLEN(d, nptr, dlen); }
           rgb = UCD_GRAPHBREAK(d);
-          if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+          if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break;
           ncount++;
           lgb = rgb;
           nptr += dlen;
@@ -2582,7 +2584,7 @@
           mb,                                   /* static match data */
           code,                                 /* this subexpression's code */
           ptr,                                  /* where we currently are */
-          (int)(ptr - start_subject),           /* start offset */
+          (PCRE2_SIZE)(ptr - start_subject),    /* start offset */
           local_offsets,                        /* offset vector */
           sizeof(local_offsets)/sizeof(PCRE2_SIZE), /* size of same */
           local_workspace,                      /* workspace vector */
@@ -2601,8 +2603,8 @@
         {
         PCRE2_SIZE local_offsets[1000];
         int local_workspace[1000];
-        int codelink = GET(code, 1);
-        int condcode;
+        int codelink = (int)GET(code, 1);
+        PCRE2_UCHAR condcode;


         /* Because of the way auto-callout works during compile, a callout item
         is inserted between OP_COND and an assertion condition. This does not
@@ -2611,8 +2613,10 @@
         if (code[LINK_SIZE + 1] == OP_CALLOUT
             || code[LINK_SIZE + 1] == OP_CALLOUT_STR)
           {
-          unsigned int callout_length = (code[LINK_SIZE + 1] == OP_CALLOUT)
-              ? PRIV(OP_lengths)[OP_CALLOUT] : GET(code, 2 + 3*LINK_SIZE);
+          PCRE2_SIZE callout_length = (code[LINK_SIZE + 1] == OP_CALLOUT)?
+            (PCRE2_SIZE)PRIV(OP_lengths)[OP_CALLOUT] :
+            (PCRE2_SIZE)GET(code, 2 + 3*LINK_SIZE);
+
           rrc = 0;
           if (mb->callout != NULL)
             {
@@ -2678,7 +2682,7 @@


         else if (condcode == OP_RREF)
           {
-          int value = GET2(code, LINK_SIZE + 2);
+          unsigned int value = GET2(code, LINK_SIZE + 2);
           if (value != RREF_ANY) return PCRE2_ERROR_DFA_UCOND;
           if (mb->recursive != NULL)
             { ADD_ACTIVE(state_offset + LINK_SIZE + 2 + IMM2_SIZE, 0); }
@@ -2699,7 +2703,7 @@
             mb,                                   /* fixed match data */
             asscode,                              /* this subexpression's code */
             ptr,                                  /* where we currently are */
-            (int)(ptr - start_subject),           /* start offset */
+            (PCRE2_SIZE)(ptr - start_subject),    /* start offset */
             local_offsets,                        /* offset vector */
             sizeof(local_offsets)/sizeof(PCRE2_SIZE), /* size of same */
             local_workspace,                      /* workspace vector */
@@ -2747,7 +2751,7 @@
           mb,                                   /* fixed match data */
           callpat,                              /* this subexpression's code */
           ptr,                                  /* where we currently are */
-          (int)(ptr - start_subject),           /* start offset */
+          (PCRE2_SIZE)(ptr - start_subject),    /* start offset */
           local_offsets,                        /* offset vector */
           sizeof(local_offsets)/sizeof(PCRE2_SIZE), /* size of same */
           local_workspace,                      /* workspace vector */
@@ -2768,7 +2772,7 @@
           {
           for (rc = rc*2 - 2; rc >= 0; rc -= 2)
             {
-            int charcount = local_offsets[rc+1] - local_offsets[rc];
+            PCRE2_SIZE charcount = local_offsets[rc+1] - local_offsets[rc];
 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32
             if (utf)
               {
@@ -2779,7 +2783,8 @@
 #endif
             if (charcount > 0)
               {
-              ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, (charcount - 1));
+              ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, 
+                (int)(charcount - 1));
               }
             else
               {
@@ -2798,7 +2803,7 @@
       case OP_SCBRAPOS:
       case OP_BRAPOSZERO:
         {
-        int charcount, matched_count;
+        PCRE2_SIZE charcount, matched_count;
         PCRE2_SPTR local_ptr = ptr;
         BOOL allow_zero;


@@ -2821,7 +2826,7 @@
             mb,                                   /* fixed match data */
             code,                                 /* this subexpression's code */
             local_ptr,                            /* where we currently are */
-            (int)(ptr - start_subject),           /* start offset */
+            (PCRE2_SIZE)(ptr - start_subject),    /* start offset */
             local_offsets,                        /* offset vector */
             sizeof(local_offsets)/sizeof(PCRE2_SIZE), /* size of same */
             local_workspace,                      /* workspace vector */
@@ -2872,11 +2877,11 @@
             {
             PCRE2_SPTR p = ptr;
             PCRE2_SPTR pp = local_ptr;
-            charcount = (int)(pp - p);
+            charcount = (PCRE2_SIZE)(pp - p);
 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32
             if (utf) while (p < pp) if (NOT_FIRSTCU(*p++)) charcount--;
 #endif
-            ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));
+            ADD_NEW_DATA(-next_state_offset, 0, (int)(charcount - 1));
             }
           }
         }
@@ -2893,7 +2898,7 @@
           mb,                                   /* fixed match data */
           code,                                 /* this subexpression's code */
           ptr,                                  /* where we currently are */
-          (int)(ptr - start_subject),           /* start offset */
+          (PCRE2_SIZE)(ptr - start_subject),    /* start offset */
           local_offsets,                        /* offset vector */
           sizeof(local_offsets)/sizeof(PCRE2_SIZE), /* size of same */
           local_workspace,                      /* workspace vector */
@@ -2903,7 +2908,7 @@
         if (rc >= 0)
           {
           PCRE2_SPTR end_subpattern = code;
-          int charcount = local_offsets[1] - local_offsets[0];
+          PCRE2_SIZE charcount = local_offsets[1] - local_offsets[0];
           int next_state_offset, repeat_state_offset;


           do { end_subpattern += GET(end_subpattern, 1); }
@@ -2963,9 +2968,9 @@
               while (p < pp) if (NOT_FIRSTCU(*p++)) charcount--;
               }
 #endif
-            ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));
+            ADD_NEW_DATA(-next_state_offset, 0, (int)(charcount - 1));
             if (repeat_state_offset >= 0)
-              { ADD_NEW_DATA(-repeat_state_offset, 0, (charcount - 1)); }
+              { ADD_NEW_DATA(-repeat_state_offset, 0, (int)(charcount - 1)); }
             }
           }
         else if (rc != PCRE2_ERROR_NOMATCH) return rc;
@@ -3018,7 +3023,7 @@
             return rrc;   /* Abandon */
           }
         if (rrc == 0)
-          { ADD_ACTIVE(state_offset + callout_length, 0); }
+          { ADD_ACTIVE(state_offset + (int)callout_length, 0); }
         }
       break;


@@ -3307,10 +3312,10 @@
offset to be an absolute offset in the whole string. */

   match_data->rc = PRIV(valid_utf)(check_subject,
-    length - (check_subject - subject), &(match_data->startchar));
+    length - (PCRE2_SIZE)(check_subject - subject), &(match_data->startchar));
   if (match_data->rc != 0)
     {
-    match_data->startchar += check_subject - subject;
+    match_data->startchar += (PCRE2_SIZE)(check_subject - subject);
     return match_data->rc;
     }
   }
@@ -3332,7 +3337,8 @@
       {
       first_cu2 = TABLE_GET(first_cu, mb->tables + fcc_offset, first_cu);
 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 8
-      if (utf && first_cu > 127) first_cu2 = UCD_OTHERCASE(first_cu);
+      if (utf && first_cu > 127) 
+        first_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(first_cu);
 #endif
       }
     }
@@ -3352,7 +3358,7 @@
     {
     req_cu2 = TABLE_GET(req_cu, mb->tables + fcc_offset, req_cu);
 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 8
-    if (utf && req_cu > 127) req_cu2 = UCD_OTHERCASE(req_cu);
+    if (utf && req_cu > 127) req_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(req_cu);
 #endif
     }
   }
@@ -3560,9 +3566,9 @@
     start_match,                  /* where we currently are */
     start_offset,                 /* start offset in subject */
     match_data->ovector,          /* offset vector */
-    match_data->oveccount * 2,    /* actual size of same */
+    (uint32_t)match_data->oveccount * 2,  /* actual size of same */
     workspace,                    /* workspace vector */
-    wscount,                      /* size of same */
+    (int)wscount,                 /* size of same */
     0);                           /* function recurse level */


   /* Anything other than "no match" means we are done, always; otherwise, carry
@@ -3576,7 +3582,7 @@
       match_data->ovector[1] = (PCRE2_SIZE)(end_subject - subject);
       }
     match_data->leftchar = (PCRE2_SIZE)(mb->start_used_ptr - subject);
-    match_data->rightchar = mb->last_used_ptr - subject;
+    match_data->rightchar = (PCRE2_SIZE)( mb->last_used_ptr - subject);
     match_data->startchar = (PCRE2_SIZE)(start_match - subject);
     match_data->rc = rc;
     return rc;


Modified: code/trunk/src/pcre2_error.c
===================================================================
--- code/trunk/src/pcre2_error.c    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_error.c    2016-02-16 10:23:06 UTC (rev 492)
@@ -62,7 +62,7 @@
 substring, so that the whole string ends with \0\0, which can be detected when
 counting through. */


-static const char compile_error_texts[] =
+static const unsigned char compile_error_texts[] =
"no error\0"
"\\ at end of pattern\0"
"\\c at end of pattern\0"
@@ -177,7 +177,7 @@

/* Match-time and UTF error texts are in the same format. */

-static const char match_error_texts[] =
+static const unsigned char match_error_texts[] =
"no error\0"
"no match\0"
"partial match\0"
@@ -277,9 +277,9 @@
pcre2_get_error_message(int enumber, PCRE2_UCHAR *buffer, size_t size)
{
char xbuff[128];
-const char *message;
+const unsigned char *message;
size_t i;
-uint32_t n;
+int n;

if (size == 0) return PCRE2_ERROR_NOMEMORY;

@@ -315,7 +315,7 @@
}

buffer[i] = 0;
-return i;
+return (int)i;
}

/* End of pcre2_error.c */

Modified: code/trunk/src/pcre2_internal.h
===================================================================
--- code/trunk/src/pcre2_internal.h    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_internal.h    2016-02-16 10:23:06 UTC (rev 492)
@@ -269,21 +269,21 @@


 #define GETUTF8(c, eptr) \
     { \
-    if ((c & 0x20) == 0) \
-      c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
-    else if ((c & 0x10) == 0) \
-      c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
-    else if ((c & 0x08) == 0) \
-      c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
-      ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
-    else if ((c & 0x04) == 0) \
-      c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
-          ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
-          (eptr[4] & 0x3f); \
+    if ((c & 0x20u) == 0) \
+      c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \
+    else if ((c & 0x10u) == 0) \
+      c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
+    else if ((c & 0x08u) == 0) \
+      c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \
+      ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \
+    else if ((c & 0x04u) == 0) \
+      c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \
+          ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \
+          (eptr[4] & 0x3fu); \
     else \
-      c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
-          ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
-          ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
+      c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \
+          ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \
+          ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \
     }


/* Base macro to pick up the remaining bytes of a UTF-8 character, advancing
@@ -291,31 +291,31 @@

 #define GETUTF8INC(c, eptr) \
     { \
-    if ((c & 0x20) == 0) \
-      c = ((c & 0x1f) << 6) | (*eptr++ & 0x3f); \
-    else if ((c & 0x10) == 0) \
+    if ((c & 0x20u) == 0) \
+      c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \
+    else if ((c & 0x10u) == 0) \
       { \
-      c = ((c & 0x0f) << 12) | ((*eptr & 0x3f) << 6) | (eptr[1] & 0x3f); \
+      c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \
       eptr += 2; \
       } \
-    else if ((c & 0x08) == 0) \
+    else if ((c & 0x08u) == 0) \
       { \
-      c = ((c & 0x07) << 18) | ((*eptr & 0x3f) << 12) | \
-          ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
+      c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \
+          ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
       eptr += 3; \
       } \
-    else if ((c & 0x04) == 0) \
+    else if ((c & 0x04u) == 0) \
       { \
-      c = ((c & 0x03) << 24) | ((*eptr & 0x3f) << 18) | \
-          ((eptr[1] & 0x3f) << 12) | ((eptr[2] & 0x3f) << 6) | \
-          (eptr[3] & 0x3f); \
+      c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \
+          ((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \
+          (eptr[3] & 0x3fu); \
       eptr += 4; \
       } \
     else \
       { \
-      c = ((c & 0x01) << 30) | ((*eptr & 0x3f) << 24) | \
-          ((eptr[1] & 0x3f) << 18) | ((eptr[2] & 0x3f) << 12) | \
-          ((eptr[3] & 0x3f) << 6) | (eptr[4] & 0x3f); \
+      c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \
+          ((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \
+          ((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \
       eptr += 5; \
       } \
     }
@@ -325,34 +325,34 @@


 #define GETUTF8LEN(c, eptr, len) \
     { \
-    if ((c & 0x20) == 0) \
+    if ((c & 0x20u) == 0) \
       { \
-      c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
+      c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \
       len++; \
       } \
-    else if ((c & 0x10)  == 0) \
+    else if ((c & 0x10u)  == 0) \
       { \
-      c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
+      c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
       len += 2; \
       } \
-    else if ((c & 0x08)  == 0) \
+    else if ((c & 0x08u)  == 0) \
       {\
-      c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
-          ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
+      c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \
+          ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \
       len += 3; \
       } \
-    else if ((c & 0x04)  == 0) \
+    else if ((c & 0x04u)  == 0) \
       { \
-      c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
-          ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
-          (eptr[4] & 0x3f); \
+      c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \
+          ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \
+          (eptr[4] & 0x3fu); \
       len += 4; \
       } \
     else \
       {\
-      c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
-          ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
-          ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
+      c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \
+          ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \
+          ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \
       len += 5; \
       } \
     }


Modified: code/trunk/src/pcre2_intmodedep.h
===================================================================
--- code/trunk/src/pcre2_intmodedep.h    2016-02-15 09:15:49 UTC (rev 491)
+++ code/trunk/src/pcre2_intmodedep.h    2016-02-16 10:23:06 UTC (rev 492)
@@ -94,7 +94,7 @@
 unit string is now handled by the macros that are defined here.


The macros are controlled by the value of LINK_SIZE. This defaults to 2, but
-values of 2 or 4 are also supported. */
+values of 3 or 4 are also supported. */

/* ------------------- 8-bit support ------------------ */

@@ -102,29 +102,29 @@

#if LINK_SIZE == 2
#define PUT(a,n,d) \
- (a[n] = (d) >> 8), \
- (a[(n)+1] = (d) & 255)
+ (a[n] = (PCRE2_UCHAR)((d) >> 8)), \
+ (a[(n)+1] = (PCRE2_UCHAR)((d) & 255))
#define GET(a,n) \
- (((a)[n] << 8) | (a)[(n)+1])
+ (unsigned int)(((a)[n] << 8) | (a)[(n)+1])
#define MAX_PATTERN_SIZE (1 << 16)

 #elif LINK_SIZE == 3
 #define PUT(a,n,d)       \
-  (a[n] = (d) >> 16),    \
-  (a[(n)+1] = (d) >> 8), \
-  (a[(n)+2] = (d) & 255)
+  (a[n] = (PCRE2_UCHAR)((d) >> 16)),    \
+  (a[(n)+1] = (PCRE2_UCHAR)((d) >> 8)), \
+  (a[(n)+2] = (PCRE2_UCHAR)((d) & 255))
 #define GET(a,n) \
-  (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
+  (unsigned int)(((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
 #define MAX_PATTERN_SIZE (1 << 24)


 #elif LINK_SIZE == 4
 #define PUT(a,n,d)        \
-  (a[n] = (d) >> 24),     \
-  (a[(n)+1] = (d) >> 16), \
-  (a[(n)+2] = (d) >> 8),  \
-  (a[(n)+3] = (d) & 255)
+  (a[n] = (PCRE2_UCHAR)((d) >> 24)),     \
+  (a[(n)+1] = (PCRE2_UCHAR)((d) >> 16)), \
+  (a[(n)+2] = (PCRE2_UCHAR)((d) >> 8)),  \
+  (a[(n)+3] = (PCRE2_UCHAR)((d) & 255))
 #define GET(a,n) \
-  (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
+  (unsigned int)(((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
 #define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */


#else
@@ -149,10 +149,10 @@
#undef LINK_SIZE
#define LINK_SIZE 2
#define PUT(a,n,d) \
- (a[n] = (d) >> 16), \
- (a[(n)+1] = (d) & 65535)
+ (a[n] = (PCRE2_UCHAR)((d) >> 16)), \
+ (a[(n)+1] = (PCRE2_UCHAR)((d) & 65535))
#define GET(a,n) \
- (((a)[n] << 16) | (a)[(n)+1])
+ (unsigned int)(((a)[n] << 16) | (a)[(n)+1])
#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */

#else
@@ -283,12 +283,12 @@
/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
Otherwise it has an undefined behaviour. */

-#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3f])
+#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3fu])

/* Returns TRUE, if the given value is not the first code unit of a UTF
sequence. */

-#define NOT_FIRSTCU(c) (((c) & 0xc0) == 0x80)
+#define NOT_FIRSTCU(c) (((c) & 0xc0u) == 0x80u)

/* Get the next UTF-8 character, not advancing the pointer. This is called when
we know we are in UTF-8 mode. */
@@ -295,7 +295,7 @@

#define GETCHAR(c, eptr) \
c = *eptr; \
- if (c >= 0xc0) GETUTF8(c, eptr);
+ if (c >= 0xc0u) GETUTF8(c, eptr);

/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
pointer. */
@@ -302,7 +302,7 @@

#define GETCHARTEST(c, eptr) \
c = *eptr; \
- if (utf && c >= 0xc0) GETUTF8(c, eptr);
+ if (utf && c >= 0xc0u) GETUTF8(c, eptr);

/* Get the next UTF-8 character, advancing the pointer. This is called when we
know we are in UTF-8 mode. */
@@ -309,7 +309,7 @@

#define GETCHARINC(c, eptr) \
c = *eptr++; \
- if (c >= 0xc0) GETUTF8INC(c, eptr);
+ if (c >= 0xc0u) GETUTF8INC(c, eptr);

/* Get the next character, testing for UTF-8 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-8 mode. */
@@ -316,7 +316,7 @@

#define GETCHARINCTEST(c, eptr) \
c = *eptr++; \
- if (utf && c >= 0xc0) GETUTF8INC(c, eptr);
+ if (utf && c >= 0xc0u) GETUTF8INC(c, eptr);

/* Get the next UTF-8 character, not advancing the pointer, incrementing length
if there are extra bytes. This is called when we know we are in UTF-8 mode. */
@@ -323,7 +323,7 @@

#define GETCHARLEN(c, eptr, len) \
c = *eptr; \
- if (c >= 0xc0) GETUTF8LEN(c, eptr, len);
+ if (c >= 0xc0u) GETUTF8LEN(c, eptr, len);

/* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
pointer, incrementing length if there are extra bytes. This is called when we
@@ -331,21 +331,21 @@

#define GETCHARLENTEST(c, eptr, len) \
c = *eptr; \
- if (utf && c >= 0xc0) GETUTF8LEN(c, eptr, len);
+ if (utf && c >= 0xc0u) GETUTF8LEN(c, eptr, len);

/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-8 mode - we don't put a test within the macro
because almost all calls are already within a block of UTF-8 only code. */

-#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
+#define BACKCHAR(eptr) while((*eptr & 0xc0u) == 0x80u) eptr--

/* Same as above, just in the other direction. */
-#define FORWARDCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr++
-#define FORWARDCHARTEST(eptr,end) while(eptr < end && (*eptr & 0xc0) == 0x80) eptr++
+#define FORWARDCHAR(eptr) while((*eptr & 0xc0u) == 0x80u) eptr++
+#define FORWARDCHARTEST(eptr,end) while(eptr < end && (*eptr & 0xc0u) == 0x80u) eptr++

/* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \
- while((condition) && ((eptr) & 0xc0) == 0x80) action
+ while((condition) && ((eptr) & 0xc0u) == 0x80u) action

/* Deposit a character into memory, returning the number of code units. */

@@ -364,7 +364,7 @@

/* Tests whether the code point needs extra characters to decode. */

-#define HAS_EXTRALEN(c) (((c) & 0xfc00) == 0xd800)
+#define HAS_EXTRALEN(c) (((c) & 0xfc00u) == 0xd800u)

/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
Otherwise it has an undefined behaviour. */
@@ -374,13 +374,13 @@
/* Returns TRUE, if the given value is not the first code unit of a UTF
sequence. */

-#define NOT_FIRSTCU(c) (((c) & 0xfc00) == 0xdc00)
+#define NOT_FIRSTCU(c) (((c) & 0xfc00u) == 0xdc00u)

/* Base macro to pick up the low surrogate of a UTF-16 character, not
advancing the pointer. */

#define GETUTF16(c, eptr) \
- { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; }
+ { c = (((c & 0x3ffu) << 10) | (eptr[1] & 0x3ffu)) + 0x10000u; }

/* Get the next UTF-16 character, not advancing the pointer. This is called when
we know we are in UTF-16 mode. */
@@ -387,7 +387,7 @@

#define GETCHAR(c, eptr) \
c = *eptr; \
- if ((c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
+ if ((c & 0xfc00u) == 0xd800u) GETUTF16(c, eptr);

/* Get the next UTF-16 character, testing for UTF-16 mode, and not advancing the
pointer. */
@@ -394,13 +394,13 @@

#define GETCHARTEST(c, eptr) \
c = *eptr; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
+ if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16(c, eptr);

/* Base macro to pick up the low surrogate of a UTF-16 character, advancing
the pointer. */

#define GETUTF16INC(c, eptr) \
- { c = (((c & 0x3ff) << 10) | (*eptr++ & 0x3ff)) + 0x10000; }
+ { c = (((c & 0x3ffu) << 10) | (*eptr++ & 0x3ffu)) + 0x10000u; }

/* Get the next UTF-16 character, advancing the pointer. This is called when we
know we are in UTF-16 mode. */
@@ -407,7 +407,7 @@

#define GETCHARINC(c, eptr) \
c = *eptr++; \
- if ((c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
+ if ((c & 0xfc00u) == 0xd800u) GETUTF16INC(c, eptr);

/* Get the next character, testing for UTF-16 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-16 mode. */
@@ -414,13 +414,13 @@

#define GETCHARINCTEST(c, eptr) \
c = *eptr++; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
+ if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16INC(c, eptr);

/* Base macro to pick up the low surrogate of a UTF-16 character, not
advancing the pointer, incrementing the length. */

#define GETUTF16LEN(c, eptr, len) \
- { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; len++; }
+ { c = (((c & 0x3ffu) << 10) | (eptr[1] & 0x3ffu)) + 0x10000u; len++; }

/* Get the next UTF-16 character, not advancing the pointer, incrementing
length if there is a low surrogate. This is called when we know we are in
@@ -428,7 +428,7 @@

#define GETCHARLEN(c, eptr, len) \
c = *eptr; \
- if ((c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
+ if ((c & 0xfc00u) == 0xd800u) GETUTF16LEN(c, eptr, len);

/* Get the next UTF-816character, testing for UTF-16 mode, not advancing the
pointer, incrementing length if there is a low surrogate. This is called when
@@ -436,7 +436,7 @@

#define GETCHARLENTEST(c, eptr, len) \
c = *eptr; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
+ if (utf && (c & 0xfc00u) == 0xd800u) GETUTF16LEN(c, eptr, len);

/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-16 mode - we don't put a test within the
@@ -443,15 +443,15 @@
macro because almost all calls are already within a block of UTF-16 only
code. */

-#define BACKCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr--
+#define BACKCHAR(eptr) if ((*eptr & 0xfc00u) == 0xdc00u) eptr--

/* Same as above, just in the other direction. */
-#define FORWARDCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr++
-#define FORWARDCHARTEST(eptr,end) if (eptr < end && (*eptr & 0xfc00) == 0xdc00) eptr++
+#define FORWARDCHAR(eptr) if ((*eptr & 0xfc00u) == 0xdc00u) eptr++
+#define FORWARDCHARTEST(eptr,end) if (eptr < end && (*eptr & 0xfc00u) == 0xdc00u) eptr++

/* Same as above, but it allows a fully customizable form. */
#define ACROSSCHAR(condition, eptr, action) \
- if ((condition) && ((eptr) & 0xfc00) == 0xdc00) action
+ if ((condition) && ((eptr) & 0xfc00u) == 0xdc00u) action

/* Deposit a character into memory, returning the number of code units. */