<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>16217</bug_id>
          
          <creation_ts>2007-11-30 18:32:33 -0800</creation_ts>
          <short_desc>PCRE offset vector handling need to be re-written</short_desc>
          <delta_ts>2011-07-21 19:08:40 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>barraclough</cc>
    
    <cc>darin</cc>
    
    <cc>ggaren</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>62845</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-11-30 18:32:33 -0800</bug_when>
    <thetext>PCRE offset vector handling need to be re-written

PCRE has this *awful* concept of an &quot;offset_vector&quot; which is set on the match_data and passed in to jsRegExpExec.  We&apos;ve already partially disabled the code in jsRegExpExec to second-guess the caller who might pass in a too-small offsets vector.  Now we need to change how the offsets vector is constructed and used.

First, how it&apos;s used:

offsets_vector is an int array of length 3n where n is the expected number of sub-string matches.

The first 2n ints are used to store start/stop offsets into the string for any matched sub-strings.  The last 1n ints are &quot;private&quot; and I&apos;m not entirely sure what they&apos;re always used for, I believe they mostly store offset lengths during exec.

This should be replaced by an array of SubstringMatch { int startOffset; int endOffset; } structs an some auxiliary data store for the extra temporary offset data.  I assume that the current solution came into being to try and have the best data locality, and to try and reduce the number of mallocs, but having 1 fewer mallocs per call is totally not worth this compexity.  If we decide it is, we can hide this hack behind some sort of OffsetsStorage structure.

i suggest that we continue to pass in the SubstringMatch array by pointer (SubstringMatch* matches) even if the callers use a vector.  The reason being that that allows the callers to use inline capacity vectors w/o needing to copy to a generic Vector&lt;T&gt; for the call,  or have the SPI have some fixed size vector in it&apos;s argument lists, ick.  The offset support information can be allocated internally.  Alternaitvely all this allocation could be abstracted into a single class which the caller is required to create and pass in (or delete when it&apos;s passed out).  Example: OffsetsStorage* offsets = OffsetsStorage(number); would create the right allocation, and then internally we can access things using methods like setSubstringStart(number, offset).

I&apos;d be curious if other PCRE hackers have other suggestions.  I think one of the above mentioned options should work and would be a huge cleanup from what we currently have.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>440791</commentid>
    <comment_count>1</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-07-21 19:08:40 -0700</bug_when>
    <thetext>PCRE has been removed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>