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_exec.c

    r15455 r16155  
    591591
    592592      DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
    593       md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
     593      md->offset_vector[md->offset_end - number] = INT_CAST(eptr - md->start_subject);
    594594
    595595      do
     
    810810      cb.offset_vector    = md->offset_vector;
    811811      cb.subject          = (const pcre_char *)md->start_subject;
    812       cb.subject_length   = md->end_subject - md->start_subject;
    813       cb.start_match      = md->start_match - md->start_subject;
    814       cb.current_position = eptr - md->start_subject;
     812      cb.subject_length   = INT_CAST(md->end_subject - md->start_subject);
     813      cb.start_match      = INT_CAST(md->start_match - md->start_subject);
     814      cb.current_position = INT_CAST(eptr - md->start_subject);
    815815      cb.pattern_position = GET(ecode, 2);
    816816      cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
     
    10771077            md->offset_vector[offset] =
    10781078              md->offset_vector[md->offset_end - number];
    1079             md->offset_vector[offset+1] = eptr - md->start_subject;
     1079            md->offset_vector[offset+1] = INT_CAST(eptr - md->start_subject);
    10801080            if (offset_top <= offset) offset_top = offset + 2;
    10811081            }
     
    14191419    case OP_REF:
    14201420      {
     1421      int tmplen;
    14211422      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
    14221423      ecode += 3;                                 /* Advance past item */
     
    14271428      minima. */
    14281429
     1430      tmplen = INT_CAST(md->end_subject - eptr + 1);
    14291431      length = (offset >= offset_top || md->offset_vector[offset] < 0)?
    1430         md->end_subject - eptr + 1 :
     1432        tmplen :
    14311433        md->offset_vector[offset+1] - md->offset_vector[offset];
    14321434
     
    30703072              {
    30713073              c = max - min;
    3072               if (c > md->end_subject - eptr) c = md->end_subject - eptr;
     3074              if (c > md->end_subject - eptr) c = INT_CAST(md->end_subject - eptr);
    30733075              eptr += c;
    30743076              }
     
    30803082          case OP_ANYBYTE:
    30813083          c = max - min;
    3082           if (c > md->end_subject - eptr) c = md->end_subject - eptr;
     3084          if (c > md->end_subject - eptr) c = INT_CAST(md->end_subject - eptr);
    30833085          eptr += c;
    30843086          break;
     
    31853187          case OP_ANYBYTE:
    31863188          c = max - min;
    3187           if (c > md->end_subject - eptr) c = md->end_subject - eptr;
     3189          if (c > md->end_subject - eptr) c = INT_CAST(md->end_subject - eptr);
    31883190          eptr += c;
    31893191          break;
     
    34143416if (extra_data != NULL)
    34153417  {
    3416   register unsigned int flags = extra_data->flags;
     3418  register unsigned long flags = extra_data->flags;
    34173419  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)
    34183420    study = (const pcre_study_data *)extra_data->study_data;
     
    37733775  if (offsetcount < 2) rc = 0; else
    37743776    {
    3775     offsets[0] = start_match - match_block.start_subject;
    3776     offsets[1] = match_block.end_match_ptr - match_block.start_subject;
     3777    offsets[0] = INT_CAST(start_match - match_block.start_subject);
     3778    offsets[1] = INT_CAST(match_block.end_match_ptr - match_block.start_subject);
    37773779    }
    37783780
Note: See TracChangeset for help on using the changeset viewer.