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 064fef01753696b555257a7b179297d69cbb3f01
Author: Marcin Mielzynski <l...@gazeta.pl>
Date:   Wed Jan 17 20:24:59 2018 +0100

    enable bitset duplication warnings
---
 src/org/joni/BitSet.java         | 12 ++++++++++--
 src/org/joni/Parser.java         |  4 ++--
 src/org/joni/ast/CClassNode.java | 32 ++++++++++++++++----------------
 3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/src/org/joni/BitSet.java b/src/org/joni/BitSet.java
index 96aea02..d3108f6 100644
--- a/src/org/joni/BitSet.java
+++ b/src/org/joni/BitSet.java
@@ -32,6 +32,11 @@ public final class BitSet {
         return (bits[pos >>> ROOM_SHIFT] & bit(pos)) != 0;
     }
 
+    public void set(ScanEnvironment env, int pos) {
+        if (at(pos)) env.ccDuplicateWarn();
+        set(pos);
+    }
+
     public void set(int pos) {
         bits[pos >>> ROOM_SHIFT] |= bit(pos);
     }
@@ -55,8 +60,11 @@ public final class BitSet {
         return true;
     }
 
-    public void setRange(int from, int to) {
-        for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) set(i);
+    public void setRange(ScanEnvironment env, int from, int to) {
+        for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) {
+            if (env != null && at(i)) env.ccDuplicateWarn();
+            set(i);
+        }
     }
 
     public void setAll() {
diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java
index 6edf81a..f21ee3b 100644
--- a/src/org/joni/Parser.java
+++ b/src/org/joni/Parser.java
@@ -384,7 +384,7 @@ class Parser extends Lexer {
                 final int NEW_LINE = 0x0a;
                 if (enc.isNewLine(NEW_LINE)) {
                     if (enc.codeToMbcLength(NEW_LINE) == 1) {
-                        cc.bs.set(NEW_LINE);
+                        cc.bs.set(env, NEW_LINE);
                     } else {
                         cc.addCodeRange(env, NEW_LINE, NEW_LINE);
                     }
@@ -885,7 +885,7 @@ class Parser extends Lexer {
         if (enc.minLength() > 1) {
             right.addCodeRange(env, 0x0A, 0x0D);
         } else {
-            right.bs.setRange(0x0A, 0x0D);
+            right.bs.setRange(env, 0x0A, 0x0D);
         }
 
         if (enc.isUnicode()) {
diff --git a/src/org/joni/ast/CClassNode.java b/src/org/joni/ast/CClassNode.java
index 7061f0a..9c72449 100644
--- a/src/org/joni/ast/CClassNode.java
+++ b/src/org/joni/ast/CClassNode.java
@@ -246,7 +246,7 @@ public final class CClassNode extends Node {
                         }
                         return;
                     }
-                    bs.set(j);
+                    bs.set(env, j);
                 }
             }
             // !sb_end:!
@@ -269,13 +269,13 @@ public final class CClassNode extends Node {
                         if (prev < 0x7fffffff/*!!!*/) addCodeRangeToBuf(env, 
prev, 0x7fffffff);
                         return;
                     }
-                    bs.set(j);
+                    bs.set(env, j);
                 }
                 prev = CR_TO(mbr, i) + 1;
             }
 
             for (int j=prev; j<sbOut; j++) {
-                bs.set(j);
+                bs.set(env, j);
             }
 
             // !sb_end2:!
@@ -311,7 +311,7 @@ public final class CClassNode extends Node {
                     if (enc.minLength() > 1) {
                         ccAscii.addCodeRangeToBuf(env, 0x00, 0x7F);
                     } else {
-                        ccAscii.bs.setRange(0x00, 0x7F);
+                        ccAscii.bs.setRange(env, 0x00, 0x7F);
                     }
                     ccWork.and(ccAscii, env);
                 }
@@ -337,12 +337,12 @@ public final class CClassNode extends Node {
         case CharacterType.ALNUM:
             if (not) {
                 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) {
-                    if (!enc.isCodeCType(c, ctype)) bs.set(c);
+                    if (!enc.isCodeCType(c, ctype)) bs.set(env, c);
                 }
                 addAllMultiByteRange(env);
             } else {
                 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) {
-                    if (enc.isCodeCType(c, ctype)) bs.set(c);
+                    if (enc.isCodeCType(c, ctype)) bs.set(env, c);
                 }
             }
             break;
@@ -351,12 +351,12 @@ public final class CClassNode extends Node {
         case CharacterType.PRINT:
             if (not) {
                 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) {
-                    if (!enc.isCodeCType(c, ctype) || c >= maxCode) bs.set(c);
+                    if (!enc.isCodeCType(c, ctype) || c >= maxCode) 
bs.set(env, c);
                 }
                 if (asciiRange) addAllMultiByteRange(env);
             } else {
                 for (int c=0; c<maxCode; c++) {
-                    if (enc.isCodeCType(c, ctype)) bs.set(c);
+                    if (enc.isCodeCType(c, ctype)) bs.set(env, c);
                 }
                 if (!asciiRange) addAllMultiByteRange(env);
             }
@@ -365,13 +365,13 @@ public final class CClassNode extends Node {
         case CharacterType.WORD:
             if (!not) {
                 for (int c=0; c<maxCode; c++) {
-                    if (enc.isSbWord(c)) bs.set(c);
+                    if (enc.isSbWord(c)) bs.set(env, c);
                 }
                 if (!asciiRange) addAllMultiByteRange(env);
             } else {
                 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) {
                     if (enc.codeToMbcLength(c) > 0 && /* check invalid code 
point */
-                            !(enc.isWord(c) || c >= maxCode)) bs.set(c);
+                            !(enc.isWord(c) || c >= maxCode)) bs.set(env, c);
                 }
                 if (asciiRange) addAllMultiByteRange(env);
             }
@@ -410,7 +410,7 @@ public final class CClassNode extends Node {
 
         if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) {
             if (arg.type == CCVALTYPE.SB) {
-                bs.set(arg.from);
+                bs.set(env, arg.from);
                 if (ascCC != null) ascCC.bs.set(arg.from);
             } else if (arg.type == CCVALTYPE.CODE_POINT) {
                 addCodeRange(env, arg.from, arg.from);
@@ -425,7 +425,7 @@ public final class CClassNode extends Node {
         switch(arg.state) {
         case VALUE:
             if (arg.type == CCVALTYPE.SB) {
-                bs.set(arg.from);
+                bs.set(env, arg.from);
                 if (ascCc != null) ascCc.bs.set(arg.from);
             } else if (arg.type == CCVALTYPE.CODE_POINT) {
                 addCodeRange(env, arg.from, arg.from);
@@ -447,8 +447,8 @@ public final class CClassNode extends Node {
                             throw new 
ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS);
                         }
                     }
-                    bs.setRange(arg.from, arg.to);
-                    if (ascCc != null) ascCc.bs.setRange(arg.from, arg.to);
+                    bs.setRange(env, arg.from, arg.to);
+                    if (ascCc != null) ascCc.bs.setRange(null, arg.from, 
arg.to);
                 } else {
                     addCodeRange(env, arg.from, arg.to);
                     if (ascCc != null) ascCc.addCodeRange(env, arg.from, 
arg.to, false);
@@ -463,10 +463,10 @@ public final class CClassNode extends Node {
                         throw new 
ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS);
                     }
                 }
-                bs.setRange(arg.from, arg.to < 0xff ? arg.to : 0xff);
+                bs.setRange(env, arg.from, arg.to < 0xff ? arg.to : 0xff);
                 addCodeRange(env, arg.from, arg.to);
                 if (ascCc != null) {
-                    ascCc.bs.setRange(arg.from, arg.to < 0xff ? arg.to : 0xff);
+                    ascCc.bs.setRange(null, arg.from, arg.to < 0xff ? arg.to : 
0xff);
                     ascCc.addCodeRange(env, arg.from, arg.to, false);
                 }
             }

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

_______________________________________________
pkg-java-commits mailing list
pkg-java-comm...@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to