<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tests/test_jjrb_offsets.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,2 @@
 #! /bin/sh
-jruby -v -I lib tests/runner.rb
+exec jruby -v -I lib tests/runner.rb</diff>
      <filename>run-tests</filename>
    </modified>
    <modified>
      <diff>@@ -508,7 +508,7 @@ case 1:
 // line 296 &quot;src/json/ext/Parser.rl&quot;
 	{
                 if (pe &gt; p + 9 &amp;&amp;
-                    byteList.subSequence(p, p + 9).toString().equals(JSON_MINUS_INFINITY)) {
+                    absSubSequence(p, p + 9).toString().equals(JSON_MINUS_INFINITY)) {
 
                     if (parser.allowNaN) {
                         result = getConstant(CONST_MINUS_INFINITY);
@@ -838,7 +838,7 @@ case 5:
                 return null;
             }
 
-            ByteList num = (ByteList)byteList.subSequence(memo, p);
+            ByteList num = absSubSequence(memo, p);
             // note: this is actually a shared string, but since it is temporary and
             //       read-only, it doesn't really matter
             RubyString expr = RubyString.newStringLight(runtime, num);
@@ -1077,7 +1077,7 @@ case 5:
                 return null;
             }
 
-            ByteList num = (ByteList)byteList.subSequence(memo, p);
+            ByteList num = absSubSequence(memo, p);
             // note: this is actually a shared string, but since it is temporary and
             //       read-only, it doesn't really matter
             RubyString expr = RubyString.newStringLight(runtime, num);
@@ -2314,6 +2314,18 @@ case 5:
         }
 
         /**
+         * Returns a subsequence of the source ByteList, based on source
+         * array byte offsets (i.e., the ByteList's own begin offset is not
+         * automatically added).
+         * @param start
+         * @param end
+         */
+        private ByteList absSubSequence(int absStart, int absEnd) {
+            int offset = byteList.begin();
+            return (ByteList)byteList.subSequence(absStart - offset, absEnd - offset);
+        }
+
+        /**
          * Retrieves a constant directly descended from the &lt;code&gt;JSON&lt;/code&gt; module.
          * @param name The constant name
          */</diff>
      <filename>src/json/ext/Parser.java</filename>
    </modified>
    <modified>
      <diff>@@ -295,7 +295,7 @@ public class Parser extends RubyObject {
             }
             action parse_number {
                 if (pe &gt; fpc + 9 &amp;&amp;
-                    byteList.subSequence(fpc, fpc + 9).toString().equals(JSON_MINUS_INFINITY)) {
+                    absSubSequence(fpc, fpc + 9).toString().equals(JSON_MINUS_INFINITY)) {
 
                     if (parser.allowNaN) {
                         result = getConstant(CONST_MINUS_INFINITY);
@@ -413,7 +413,7 @@ public class Parser extends RubyObject {
                 return null;
             }
 
-            ByteList num = (ByteList)byteList.subSequence(memo, p);
+            ByteList num = absSubSequence(memo, p);
             // note: this is actually a shared string, but since it is temporary and
             //       read-only, it doesn't really matter
             RubyString expr = RubyString.newStringLight(runtime, num);
@@ -449,7 +449,7 @@ public class Parser extends RubyObject {
                 return null;
             }
 
-            ByteList num = (ByteList)byteList.subSequence(memo, p);
+            ByteList num = absSubSequence(memo, p);
             // note: this is actually a shared string, but since it is temporary and
             //       read-only, it doesn't really matter
             RubyString expr = RubyString.newStringLight(runtime, num);
@@ -844,6 +844,18 @@ public class Parser extends RubyObject {
         }
 
         /**
+         * Returns a subsequence of the source ByteList, based on source
+         * array byte offsets (i.e., the ByteList's own begin offset is not
+         * automatically added).
+         * @param start
+         * @param end
+         */
+        private ByteList absSubSequence(int absStart, int absEnd) {
+            int offset = byteList.begin();
+            return (ByteList)byteList.subSequence(absStart - offset, absEnd - offset);
+        }
+
+        /**
          * Retrieves a constant directly descended from the &lt;code&gt;JSON&lt;/code&gt; module.
          * @param name The constant name
          */</diff>
      <filename>src/json/ext/Parser.rl</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,7 @@ require 'test_json_unicode'
 require 'test_json_addition'
 require 'test_json_rails'
 require 'test_json_fixtures'
+require 'test_jjrb_offsets'
 
 class TS_AllTests
   def self.suite
@@ -20,6 +21,7 @@ class TS_AllTests
     suite &lt;&lt; TC_JSONAddition.suite
     suite &lt;&lt; TC_JSONRails.suite
     suite &lt;&lt; TC_JSONFixtures.suite
+    suite &lt;&lt; TestJjrbOffsets.suite
   end
 end
 Test::Unit::UI::Console::TestRunner.run(TS_AllTests)</diff>
      <filename>tests/runner.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>32b5a3a525fe95f4e149d9b67a27f61804310914</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Luz</name>
    <email>dev@mernen.com</email>
  </author>
  <url>http://github.com/mernen/json-jruby/commit/62cec7eef11c380b9691d23e8be0000eabf68b1f</url>
  <id>62cec7eef11c380b9691d23e8be0000eabf68b1f</id>
  <committed-date>2009-05-12T14:00:45-07:00</committed-date>
  <authored-date>2009-05-12T13:40:57-07:00</authored-date>
  <message>Fixed the calculation of ranges when dealing with non-zero ByteList offsets.

Thanks to Julio Castillo for the report.</message>
  <tree>2587a0ce3ad0af2dfe18dbe70747a540c50627c4</tree>
  <committer>
    <name>Daniel Luz</name>
    <email>dev@mernen.com</email>
  </committer>
</commit>
