[jruby-joni] 158/223: Modify Analyser to respect the STRICT_CHECK_BACKREF syntax option
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:22:04 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 59fd64bca303e33958cfeeee1262401bcbe61ba8
Author: Ben Browning <bbrownin at redhat.com>
Date: Thu Sep 5 22:35:30 2013 -0400
Modify Analyser to respect the STRICT_CHECK_BACKREF syntax option
---
src/org/joni/Analyser.java | 65 ++++++++++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 23 deletions(-)
diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 815a7dd..59063ff 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -412,13 +412,19 @@ final class Analyser extends Parser {
BackRefNode br = (BackRefNode)node;
if (br.isRecursion()) break;
- if (br.back[0] > env.numMem) newValueException(ERR_INVALID_BACKREF);
- min = getMinMatchLength(env.memNodes[br.back[0]]);
+ if (br.back[0] > env.numMem) {
+ if (syntax.strictCheckBackref()) newValueException(ERR_INVALID_BACKREF);
+ } else {
+ min = getMinMatchLength(env.memNodes[br.back[0]]);
+ }
for (int i=1; i<br.backNum; i++) {
- if (br.back[i] > env.numMem) newValueException(ERR_INVALID_BACKREF);
- int tmin = getMinMatchLength(env.memNodes[br.back[i]]);
- if (min > tmin) min = tmin;
+ if (br.back[i] > env.numMem) {
+ if (syntax.strictCheckBackref()) newValueException(ERR_INVALID_BACKREF);
+ } else {
+ int tmin = getMinMatchLength(env.memNodes[br.back[i]]);
+ if (min > tmin) min = tmin;
+ }
}
break;
@@ -546,9 +552,12 @@ final class Analyser extends Parser {
}
for (int i=0; i<br.backNum; i++) {
- if (br.back[i] > env.numMem) newValueException(ERR_INVALID_BACKREF);
- int tmax = getMaxMatchLength(env.memNodes[br.back[i]]);
- if (max < tmax) max = tmax;
+ if (br.back[i] > env.numMem) {
+ if(syntax.strictCheckBackref()) newValueException(ERR_INVALID_BACKREF);
+ } else {
+ int tmax = getMaxMatchLength(env.memNodes[br.back[i]]);
+ if (max < tmax) max = tmax;
+ }
}
break;
@@ -1780,15 +1789,18 @@ final class Analyser extends Parser {
case NodeType.BREF:
BackRefNode br = (BackRefNode)node;
for (int i=0; i<br.backNum; i++) {
- if (br.back[i] > env.numMem) newValueException(ERR_INVALID_BACKREF);
- env.backrefedMem = bsOnAt(env.backrefedMem, br.back[i]);
- env.btMemStart = bsOnAt(env.btMemStart, br.back[i]);
- if (Config.USE_BACKREF_WITH_LEVEL) {
- if (br.isNestLevel()) {
- env.btMemEnd = bsOnAt(env.btMemEnd, br.back[i]);
- }
- } // USE_BACKREF_AT_LEVEL
- ((EncloseNode)env.memNodes[br.back[i]]).setMemBackrefed();
+ if (br.back[i] > env.numMem) {
+ if (syntax.strictCheckBackref()) newValueException(ERR_INVALID_BACKREF);
+ } else {
+ env.backrefedMem = bsOnAt(env.backrefedMem, br.back[i]);
+ env.btMemStart = bsOnAt(env.btMemStart, br.back[i]);
+ if (Config.USE_BACKREF_WITH_LEVEL) {
+ if (br.isNestLevel()) {
+ env.btMemEnd = bsOnAt(env.btMemEnd, br.back[i]);
+ }
+ } // USE_BACKREF_AT_LEVEL
+ ((EncloseNode)env.memNodes[br.back[i]]).setMemBackrefed();
+ }
}
break;
@@ -2081,14 +2093,21 @@ final class Analyser extends Parser {
Node[]nodes = oenv.scanEnv.memNodes;
- int min = getMinMatchLength(nodes[br.back[0]]);
- int max = getMaxMatchLength(nodes[br.back[0]]);
+ int min = 0;
+ int max = 0;
+
+ if (nodes != null && nodes[br.back[0]] != null) {
+ min = getMinMatchLength(nodes[br.back[0]]);
+ max = getMaxMatchLength(nodes[br.back[0]]);
+ }
for (int i=1; i<br.backNum; i++) {
- int tmin = getMinMatchLength(nodes[br.back[i]]);
- int tmax = getMaxMatchLength(nodes[br.back[i]]);
- if (min > tmin) min = tmin;
- if (max < tmax) max = tmax;
+ if (nodes[br.back[i]] != null) {
+ int tmin = getMinMatchLength(nodes[br.back[i]]);
+ int tmax = getMaxMatchLength(nodes[br.back[i]]);
+ if (min > tmin) min = tmin;
+ if (max < tmax) max = tmax;
+ }
}
opt.length.set(min, max);
break;
--
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