[jruby-joni] 115/223: Fix StringNode only casing and add a test case.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:21:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit f3006cd20ca30dc2ee0f49c1cc3ef60aa352f340
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Sat Mar 10 23:18:15 2012 +0100

    Fix StringNode only casing and add a test case.
---
 src/org/joni/Analyser.java       | 7 ++++++-
 src/org/joni/ast/StringNode.java | 7 +++++++
 test/org/joni/test/Test.java     | 4 ++++
 test/org/joni/test/TestU8.java   | 6 ++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 6f1732f..d166bc3 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -1607,7 +1607,12 @@ final class Analyser extends Parser {
         }
         /* ending */
         Node xnode = topRoot != null ? topRoot : prevNode[0];
-        swap(node, xnode);
+
+        if (xnode instanceof StringNode) {
+            sn.assign((StringNode)xnode);
+        } else {
+            swap(node, xnode);
+        }
     }
 
     private static final int CEC_THRES_NUM_BIG_REPEAT       = 512;
diff --git a/src/org/joni/ast/StringNode.java b/src/org/joni/ast/StringNode.java
index 2857c94..318eec1 100644
--- a/src/org/joni/ast/StringNode.java
+++ b/src/org/joni/ast/StringNode.java
@@ -81,6 +81,13 @@ public final class StringNode extends Node implements StringType {
         }
     }
 
+    public void assign(StringNode from) {
+        bytes = from.bytes;
+        p = from.p;
+        end = from.end;
+        flag = from.flag;
+    }
+
     @Override
     public int getType() {
         return STR;
diff --git a/test/org/joni/test/Test.java b/test/org/joni/test/Test.java
index a70f191..dda5c3e 100644
--- a/test/org/joni/test/Test.java
+++ b/test/org/joni/test/Test.java
@@ -124,6 +124,10 @@ public abstract class Test {
         xx(pattern, str, from, to, 0, false);
     }
 
+    protected void x2(byte[]pattern, byte[]str, int from, int to, int option) {
+        xx(pattern, str, from, to, 0, false, option);
+    }
+
     protected void x3(byte[]pattern, byte[]str, int from, int to, int mem) {
         xx(pattern, str, from, to, mem, false);
     }
diff --git a/test/org/joni/test/TestU8.java b/test/org/joni/test/TestU8.java
index e3d5b11..3c5ef1a 100644
--- a/test/org/joni/test/TestU8.java
+++ b/test/org/joni/test/TestU8.java
@@ -63,6 +63,12 @@ public class TestU8 extends Test {
         str = new byte[]{(byte)239, (byte)188, (byte)161, 65};
 
         n(pat, str, Option.IGNORECASE);
+
+        pat = new byte[]{94, (byte)195, (byte)159, 123, 50, 125, 36};
+        str = new byte[]{(byte)195, (byte)159, 115, 115};
+
+        x2(pat, str, 0, 4, Option.IGNORECASE);
+
     }
 
     public static void main(String[] args) throws Throwable {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list