[jruby-joni] 80/194: dedup parse logic
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:29 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 9a4656e289bba33e30cc97035c2b0304b08ae0c3
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Sun Dec 31 15:20:06 2017 +0100
dedup parse logic
---
src/org/joni/Lexer.java | 2 +-
src/org/joni/Parser.java | 24 +++---------------------
2 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/src/org/joni/Lexer.java b/src/org/joni/Lexer.java
index 5766fd8..68fa49e 100644
--- a/src/org/joni/Lexer.java
+++ b/src/org/joni/Lexer.java
@@ -920,7 +920,7 @@ class Lexer extends ScannerSupport {
}
}
- private void fetchNamedBackrefToken() {
+ protected void fetchNamedBackrefToken() {
int last = p;
int backNum;
if (Config.USE_BACKREF_WITH_LEVEL) {
diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java
index cf35c76..8ec01f0 100644
--- a/src/org/joni/Parser.java
+++ b/src/org/joni/Parser.java
@@ -530,27 +530,9 @@ class Parser extends Lexer {
if (Config.USE_NAMED_GROUP) {
if (c == '<' || c == '\'') { /* (<name>), ('name') */
name = p;
- num = fetchName(c, false);
- int nameEnd = value;
- fetch();
- if (c != ')') newSyntaxException(ERR_UNDEFINED_GROUP_OPTION);
- NameEntry e = env.reg.nameToGroupNumbers(bytes, name, nameEnd);
- if (e == null) newValueException(ERR_UNDEFINED_NAME_REFERENCE, name, nameEnd);
- if (syntax.strictCheckBackref()) {
- if (e.backNum == 1) {
- if (e.backRef1 > env.numMem ||
- env.memNodes == null ||
- env.memNodes[e.backRef1] == null) newValueException(ERR_INVALID_BACKREF);
- } else {
- for (int i=0; i<e.backNum; i++) {
- if (e.backRefs[i] > env.numMem ||
- env.memNodes == null ||
- env.memNodes[e.backRefs[i]] == null) newValueException(ERR_INVALID_BACKREF);
- }
- }
- }
-
- num = e.backNum == 1 ? e.backRef1 : e.backRefs[0]; /* XXX: use left most named group as Perl */
+ fetchNamedBackrefToken();
+ inc();
+ num = token.getBackrefNum() > 1 ? token.getBackrefRefs()[0] : token.getBackrefRef1();
}
} else { // USE_NAMED_GROUP
newSyntaxException(ERR_INVALID_CONDITION_PATTERN);
--
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