[jruby-joni] 208/279: Imported Upstream version 2.1.2

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:27:35 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 515453ea5384f62c97d9173c202c5f57c1b00206
Author: Hideki Yamane <henrich at debian.org>
Date:   Sat Sep 13 00:14:47 2014 +0900

    Imported Upstream version 2.1.2
---
 pom.xml                                |  2 +-
 src/org/joni/Analyser.java             |  4 ++--
 src/org/joni/StackMachine.java         | 20 ++++++++++----------
 src/org/joni/constants/AnchorType.java | 27 +++++++++++++++++----------
 test/org/joni/test/TestA.java          |  3 +++
 test/org/joni/test/TestU.java          | 31 +++++++++++++++++++++++++++++++
 6 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3d4352d..2b91583 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
   <groupId>org.jruby.joni</groupId>
   <artifactId>joni</artifactId>
   <packaging>jar</packaging>
-  <version>2.1.0</version>
+  <version>2.1.2</version>
   <name>Joni</name>
   <description>
     Java port of Oniguruma: http://www.geocities.jp/kosako3/oniguruma
diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 9665ba6..9aa9acc 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -1461,8 +1461,8 @@ final class Analyser extends Parser {
                     sn.set(sbuf, 0, sp);
                     return;
                 }
-                sp++;
             }
+            sp += len;
         }
     }
 
@@ -1912,7 +1912,7 @@ final class Analyser extends Parser {
                 break;
 
             case AnchorType.LOOK_BEHIND_NOT:
-                if (checkTypeTree(an.target, NodeType.ALLOWED_IN_LB, EncloseType.ALLOWED_IN_LB, AnchorType.ALLOWED_IN_LB)) newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
+                if (checkTypeTree(an.target, NodeType.ALLOWED_IN_LB, EncloseType.ALLOWED_IN_LB_NOT, AnchorType.ALLOWED_IN_LB_NOT)) newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN);
                 node = setupLookBehind(node);
                 if (node.getType() != NodeType.ANCHOR) continue restart;
                 setupTree(((AnchorNode)node).target, (state | IN_NOT));
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index a5e51a4..7b16780 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -66,19 +66,19 @@ abstract class StackMachine extends Matcher implements StackType {
     }
 
     static final ThreadLocal<WeakReference<StackEntry[]>> stacks
-            = new ThreadLocal<WeakReference<StackEntry[]>>() {
-        @Override
-        protected WeakReference<StackEntry[]> initialValue() {
-            return new WeakReference<StackEntry[]>(allocateStack());
-        }
-    };
+            = new ThreadLocal<WeakReference<StackEntry[]>>();
 
     private static StackEntry[] fetchStack() {
         WeakReference<StackEntry[]> ref = stacks.get();
-        StackEntry[] stack = ref.get();
-        if (stack == null) {
-            ref = new WeakReference<StackEntry[]>(stack = allocateStack());
-            stacks.set(ref);
+        StackEntry[] stack;
+        if (ref == null) {
+            stacks.set( new WeakReference<StackEntry[]>(stack = allocateStack()) );
+        }
+        else {
+            stack = ref.get();
+            if (stack == null) {
+                stacks.set( new WeakReference<StackEntry[]>(stack = allocateStack()) );
+            }
         }
         return stack;
     }
diff --git a/src/org/joni/constants/AnchorType.java b/src/org/joni/constants/AnchorType.java
index 5d7336d..f297577 100644
--- a/src/org/joni/constants/AnchorType.java
+++ b/src/org/joni/constants/AnchorType.java
@@ -42,17 +42,24 @@ public interface AnchorType {
     final int ANYCHAR_STAR_MASK = (ANYCHAR_STAR | ANYCHAR_STAR_ML);
     final int END_BUF_MASK      = (END_BUF | SEMI_END_BUF);
 
-    final int ALLOWED_IN_LB =     ( LOOK_BEHIND |
-                                    BEGIN_LINE |
-                                    END_LINE |
-                                    BEGIN_BUF |
-                                    BEGIN_POSITION );
+    final int KEEP              = (1<<16);
 
-    final int ALLOWED_IN_LB_NOT = ( LOOK_BEHIND |
-                                    LOOK_BEHIND_NOT |
-                                    BEGIN_LINE |
-                                    END_LINE |
+    final int ALLOWED_IN_LB =     ( END_LINE |
                                     BEGIN_BUF |
-                                    BEGIN_POSITION );
+                                    BEGIN_POSITION |
+                                    KEEP |
+                                    WORD_BOUND |
+                                    NOT_WORD_BOUND |
+                                    WORD_BEGIN |
+                                    WORD_END );
+
 
+    final int ALLOWED_IN_LB_NOT = ( END_LINE |
+                                    BEGIN_BUF |
+                                    BEGIN_POSITION |
+                                    KEEP |
+                                    WORD_BOUND |
+                                    NOT_WORD_BOUND |
+                                    WORD_BEGIN |
+                                    WORD_END );
 }
diff --git a/test/org/joni/test/TestA.java b/test/org/joni/test/TestA.java
index aee59ae..d9403da 100644
--- a/test/org/joni/test/TestA.java
+++ b/test/org/joni/test/TestA.java
@@ -497,6 +497,9 @@ public class TestA extends Test {
         x2s("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAA", 0, 35, Option.IGNORECASE);
 
         x2s("(?mix)", "", 0, 0);
+
+        x2s("(?<=\\babc)d", " abcd", 4, 5);
+        x2s("(?<=\\Babc)d", "aabcd", 4, 5);
     }
 
     public static void main(String[] args) throws Throwable{
diff --git a/test/org/joni/test/TestU.java b/test/org/joni/test/TestU.java
index ee1ed76..332de05 100644
--- a/test/org/joni/test/TestU.java
+++ b/test/org/joni/test/TestU.java
@@ -762,6 +762,37 @@ public class TestU extends Test {
         ns("\000[\000^\000[\000^\000a\000-\000z0B0D0F\000]\000&\000&\000[\000^\000b\000c\000d\000e\000f\000g0F0H0J\000]\000g\000-\000w\000]\000\000", "\0002\000\000");
         x2s("\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000\134\000/\000b\000>\000\000", "\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000/\000b\000>\000\000", 0, 40);
         x2s("\000.\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000\134\000/\000b\000>\000\000", "\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000/\000b\000>\000\000", 0, 40);
+
+        // Unicode case folding tests
+        // common case folding: u+0041 and u+0061
+        x2s("\u0000\u0041\000\000", "\u0000\u0061\000\000", 0, 2, Option.IGNORECASE);
+        x2s("\u0000\u0061\000\000", "\u0000\u0041\000\000", 0, 2, Option.IGNORECASE);
+        // common case folding: u+00C0 and u+00E0
+        x2s("\u0000\u00C0\000\000", "\u0000\u00E0\000\000", 0, 2, Option.IGNORECASE);
+        x2s("\u0000\u00E0\000\000", "\u0000\u00C0\000\000", 0, 2, Option.IGNORECASE);
+        // common case folding: u+00B5 and u+03BC
+        x2s("\u0000\u00B5\000\000", "\u0003\u00BC\000\000", 0, 2, Option.IGNORECASE);
+        x2s("\u0003\u00BC\000\000", "\u0000\u00B5\000\000", 0, 2, Option.IGNORECASE);
+        // common case folding: u+0073 and u+017F
+        x2s("\u0000\u0073\000\000", "\u0001\u007F\000\000", 0, 2, Option.IGNORECASE);
+        x2s("\u0001\u007F\000\000", "\u0000\u0073\000\000", 0, 2, Option.IGNORECASE);
+        // full case folding: u+1FA0 and u+1F60 u+03B9
+        x2s("\u001F\u00A0\000\000", "\u001F\u0060\u0003\u00B9\000\000", 0, 4, Option.IGNORECASE);
+        x2s("\u001F\u0060\u0003\u00B9\000\000", "\u001F\u00A0\000\000", 0, 2, Option.IGNORECASE);
+        // full case folding: u+1FA8 and u+1F60 u+03B9
+        x2s("\u001F\u00A8\000\000", "\u001F\u0060\u0003\u00B9\000\000", 0, 4, Option.IGNORECASE);
+        x2s("\u001F\u0060\u0003\u00B9\000\000", "\u001F\u00A8\000\000", 0, 2, Option.IGNORECASE);
+        // simple case folding: u+1FA8 and u+1FA0
+        x2s("\u001F\u00A8\000\000", "\u001F\u00A0\000\000", 0, 2, Option.IGNORECASE);
+        x2s("\u001F\u00A0\000\000", "\u001F\u00A8\000\000", 0, 2, Option.IGNORECASE);
+        // FIXME: Case folding for 'LATIN CAPITAL LETTER SHARP S' not supported
+        // full case folding: u+1E9E and u+0073 u+0073
+        // x2s("\u001E\u009E\000\000", "\u0000\u0073\u0000\u0073\000\000", 0, 4, Option.IGNORECASE);
+        // simple case folding: u+1E9E and u+00DF
+        // x2s("\u001E\u009E\000\000", "\u0000\u00DF\000\000", 0, 2, Option.IGNORECASE);
+
+        // Case fold exceeding Analyser#THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION (= 8)
+        x2s("\u0000\u0041\u0000\u0041\u0000\u0041\u0000\u0041\000\000", "\u0000\u0061\u0000\u0061\u0000\u0061\u0000\u0061\000\000", 0, 8, 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