Ignore:
Timestamp:
Aug 31, 2006, 2:28:29 PM (19 years ago)
Author:
thatcher
Message:

Reviewed by Geoff.

Band-aid fix for PCRE to compile for ppc64 and x86_64 now that
we use -Wshorten-64-to-32. Adds an INT_CAST macro that ASSERTs
the value <= INT_MAX.

I filed <rdar://problem/4712064> to track the need to verify
PCRE's 64-bit compliance.

  • pcre/pcre_compile.c: (complete_callout): (compile_branch): (compile_regex): (pcre_compile2):
  • pcre/pcre_exec.c: (match): (pcre_exec):
  • pcre/pcre_get.c: (pcre_get_substring_list):
  • pcre/pcre_internal.h:
  • pcre/pcre_tables.c:
  • pcre/pcre_try_flipped.c: (_pcre_try_flipped):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre_compile.c

    r15455 r16155  
    14891489complete_callout(uschar *previous_callout, const pcre_uchar *ptr, compile_data *cd)
    14901490{
    1491 int length = ptr - cd->start_pattern - GET(previous_callout, 2);
     1491int length = INT_CAST(ptr - cd->start_pattern - GET(previous_callout, 2));
    14921492PUT(previous_callout, 2 + LINK_SIZE, length);
    14931493}
     
    18461846        {
    18471847        BOOL local_negate = FALSE;
    1848         int posix_class, i;
     1848        int posix_class, i, namelen;
    18491849        register const uschar *cbits = cd->cbits;
    18501850
     
    18621862          }
    18631863
    1864         posix_class = check_posix_name(ptr, tempptr - ptr);
     1864        namelen = INT_CAST(tempptr - ptr);
     1865        posix_class = check_posix_name(ptr, namelen);
    18651866        if (posix_class < 0)
    18661867          {
     
    22762277      else
    22772278        {
    2278         int len = class_utf8data - (code + 33);
     2279        int len = INT_CAST(class_utf8data - (code + 33));
    22792280        memmove(code + 1, code + 33, len);
    22802281        code += len + 1;
     
    24052406        uschar *lastchar = code - 1;
    24062407        while((*lastchar & 0xc0) == 0x80) lastchar--;
    2407         c = code - lastchar;            /* Length of UTF-8 character */
     2408        c = INT_CAST(code - lastchar);            /* Length of UTF-8 character */
    24082409        memcpy(utf8_char, lastchar, c); /* Save the char */
    24092410        c |= 0x80;                      /* Flag c as a length */
     
    26182619      register int i;
    26192620      int ketoffset = 0;
    2620       int len = code - previous;
     2621      int len = INT_CAST(code - previous);
    26212622      uschar *bralink = NULL;
    26222623
     
    26312632        register uschar *ket = previous;
    26322633        do ket += GET(ket, 1); while (*ket != OP_KET);
    2633         ketoffset = code - ket;
     2634        ketoffset = INT_CAST(code - ket);
    26342635        }
    26352636
     
    26772678        else
    26782679          {
    2679           int offset;
     2680          int offset, tmpoffset;
    26802681          *code = OP_END;
    26812682          adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd);
     
    26882689          filled in later when the ends of the brackets are reached. */
    26892690
    2690           offset = (bralink == NULL)? 0 : previous - bralink;
     2691          tmpoffset = INT_CAST(previous - bralink);
     2692          offset = (bralink == NULL)? 0 : tmpoffset;
    26912693          bralink = previous;
    26922694          PUTINC(previous, 0, offset);
     
    27322734          if (i != 0)
    27332735            {
    2734             int offset;
     2736            int offset, tmpoffset;
    27352737            *code++ = OP_BRA;
    2736             offset = (bralink == NULL)? 0 : code - bralink;
     2738            tmpoffset = INT_CAST(code - bralink);
     2739            offset = (bralink == NULL)? 0 : tmpoffset;
    27372740            bralink = code;
    27382741            PUTINC(code, 0, offset);
     
    27492752          {
    27502753          int oldlinkoffset;
    2751           int offset = code - bralink + 1;
     2754          int offset = INT_CAST(code - bralink + 1);
    27522755          uschar *bra = code - offset;
    27532756          oldlinkoffset = GET(bra, 1);
     
    27832786    if (possessive_quantifier)
    27842787      {
    2785       int len = code - tempcode;
     2788      int len = INT_CAST(code - tempcode);
    27862789      memmove(tempcode + 1+LINK_SIZE, tempcode, len);
    27872790      code += 1 + LINK_SIZE;
     
    29312934
    29322935          while (*ptr++ != '>');
    2933           namelen = ptr - name - 1;
     2936          namelen = INT_CAST(ptr - name - 1);
    29342937
    29352938          /* FIXME: This won't work for UTF-16. */
     
    29702973
    29712974          while (*ptr != ')') ptr++;
    2972           namelen = ptr - name;
     2975          namelen = INT_CAST(ptr - name);
    29732976
    29742977          for (i = 0; i < cd->names_found; i++)
     
    35873590  if (*ptr != '|')
    35883591    {
    3589     int length = code - last_branch;
     3592    int length = INT_CAST(code - last_branch);
    35903593    do
    35913594      {
     
    45804583            }
    45814584          name_count++;
    4582           if (ptr - p > max_name_size) max_name_size = (ptr - p);
     4585          if (ptr - p > max_name_size) max_name_size = INT_CAST(ptr - p);
    45834586          break;
    45844587          }
     
    495549584-byte pointers is run on another with 8-byte pointers. */
    49564959
    4957 re->magic_number = MAGIC_NUMBER;
    4958 re->size = size;
     4960re->magic_number = (pcre_uint32)MAGIC_NUMBER;
     4961re->size = (pcre_uint32)size;
    49594962re->options = options;
    49604963re->dummy1 = 0;
     
    50175020  (pcre_free)(re);
    50185021  PCRE_ERROR_RETURN:
    5019   *erroroffset = ptr - (const pcre_uchar *)pattern;
     5022  *erroroffset = INT_CAST(ptr - (const pcre_uchar *)pattern);
    50205023  PCRE_EARLY_ERROR_RETURN:
    50215024  *errorptr = error_texts[errorcode];
Note: See TracChangeset for help on using the changeset viewer.