[jruby-joni] 85/223: Better warnings.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:21:52 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 ff9f142ddafb5bfc1ec395d588b9044d809e1b47
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Fri Feb 17 01:01:46 2012 +0100

    Better warnings.
---
 src/org/joni/Lexer.java           | 22 ++++++++++++++++++----
 src/org/joni/ScanEnvironment.java |  6 ------
 src/org/joni/Warnings.java        | 26 ++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/org/joni/Lexer.java b/src/org/joni/Lexer.java
index 311ff17..262ec71 100644
--- a/src/org/joni/Lexer.java
+++ b/src/org/joni/Lexer.java
@@ -606,6 +606,8 @@ class Lexer extends ScannerSupport {
                             unfetch();
                         }
                     }
+                } else {
+                    syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c);
                 }
                 break;
 
@@ -1098,10 +1100,10 @@ class Lexer extends ScannerSupport {
                                 }
                             } else {
                                 unfetch();
-                                env.syntaxWarn("invalid back reference");
+                                syntaxWarn(Warnings.INVALID_BACKREFERENCE);
                             }
                         } else {
-                            env.syntaxWarn("invalid back reference");
+                            syntaxWarn(Warnings.INVALID_BACKREFERENCE);
                         }
                     }
 
@@ -1124,10 +1126,10 @@ class Lexer extends ScannerSupport {
                                 token.setCallGNum(gNum);
                             } else {
                                 unfetch();
-                                env.syntaxWarn("invalid subexp call");
+                                syntaxWarn(Warnings.INVALID_SUBEXP_CALL);
                             }
                         } else {
-                            env.syntaxWarn("invalid subexp call");
+                            syntaxWarn(Warnings.INVALID_SUBEXP_CALL);
                         }
                     }
                     break;
@@ -1155,6 +1157,8 @@ class Lexer extends ScannerSupport {
                             unfetch();
                         }
                     }
+                } else {
+                    syntaxWarn(Warnings.INVALID_UNICODE_PROPERTY, (char)c);
                 }
                 break;
 
@@ -1392,4 +1396,14 @@ class Lexer extends ScannerSupport {
         newInternalException(ERR_PARSER_BUG);
         return 0; // not reached
     }
+
+    protected final void syntaxWarn(String message, char c) {
+        syntaxWarn(message.replace("<%n>", Character.toString(c)));
+    }
+
+    protected final void syntaxWarn(String message) {
+        if (Config.USE_WARN) {
+            env.reg.warnings.warn(message + ": /" + new String(bytes, getBegin(), getEnd()) + "/");
+        }
+    }
 }
diff --git a/src/org/joni/ScanEnvironment.java b/src/org/joni/ScanEnvironment.java
index 53543a5..02a1ad7 100644
--- a/src/org/joni/ScanEnvironment.java
+++ b/src/org/joni/ScanEnvironment.java
@@ -137,10 +137,4 @@ public final class ScanEnvironment {
             }
         }
     }
-
-    void syntaxWarn(String message) {
-        if (Config.USE_WARN) {
-            reg.warnings.warn(message);
-        }
-    }
 }
diff --git a/src/org/joni/Warnings.java b/src/org/joni/Warnings.java
new file mode 100644
index 0000000..80e1519
--- /dev/null
+++ b/src/org/joni/Warnings.java
@@ -0,0 +1,26 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.joni;
+
+public interface Warnings {
+    final String INVALID_BACKREFERENCE =            "invalid back reference";
+    final String INVALID_SUBEXP_CALL =              "invalid subexp call";
+    final String INVALID_UNICODE_PROPERTY =         "invalid Unicode Property \\<%n>";
+}

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