[jruby-joni] 52/194: CClassNode.isOneChar

Hideki Yamane henrich at moszumanska.debian.org
Thu Feb 1 12:04:25 UTC 2018


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 82f8d1dbf5851a2c08e32c34469458ad44a11a79
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Sat Dec 30 00:30:03 2017 +0100

    CClassNode.isOneChar
---
 src/org/joni/ast/CClassNode.java | 28 ++++++++++++++++++++++++++++
 src/org/joni/ast/StringNode.java |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/org/joni/ast/CClassNode.java b/src/org/joni/ast/CClassNode.java
index 693151c..92fb469 100644
--- a/src/org/joni/ast/CClassNode.java
+++ b/src/org/joni/ast/CClassNode.java
@@ -98,6 +98,34 @@ public final class CClassNode extends Node {
         }
     }
 
+    public int isOneChar() {
+        if (isNot()) return -1;
+        int c = -1;
+        if (mbuf != null) {
+            int[]range = mbuf.getCodeRange();
+            c = range[1];
+            if (range[0] == 1 && c == range[2]) {
+                if (c < BitSet.SINGLE_BYTE_SIZE && bs.at(c)) {
+                    c = -1;
+                }
+            } else {
+                return -1;
+            }
+        }
+
+        for (int i = 0; i < BitSet.BITSET_SIZE; i++) {
+            int b1 = bs.getBits(i);
+            if (b1 != 0) {
+                if ((b1 & (b1 - 1)) == 0 && c == -1) {
+                    c = BitSet.BITS_IN_ROOM * i + Integer.bitCount(b1 - 1);
+                } else {
+                    return -1;
+                }
+            }
+        }
+        return c;
+    }
+
     // and_cclass
     public void and(CClassNode other, Encoding enc) {
         boolean not1 = isNot();
diff --git a/src/org/joni/ast/StringNode.java b/src/org/joni/ast/StringNode.java
index 15ed04c..dba1d11 100644
--- a/src/org/joni/ast/StringNode.java
+++ b/src/org/joni/ast/StringNode.java
@@ -54,7 +54,7 @@ public final class StringNode extends Node implements StringType {
     /* Ensure there is ahead bytes available in node's buffer
      * (assumes that the node is not shared)
      */
-    public void ensure(int ahead) {
+    private void ensure(int ahead) {
         int len = (end - p) + ahead;
         if (len >= bytes.length) {
             byte[]tmp = new byte[len + NODE_STR_MARGIN];

-- 
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