[jruby-joni] 155/194: fix string expansion
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:37 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 a11c685c3b3cab2ca8f3bf231659afb097d5d259
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Thu Jan 11 20:20:33 2018 +0100
fix string expansion
---
src/org/joni/Analyser.java | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index f2485b6..5ce0238 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -1866,24 +1866,30 @@ final class Analyser extends Parser {
/* expand string */
if (target.getType() == NodeType.STR) {
- if (!isRepeatInfinite(qn.lower) && qn.lower == qn.upper &&
- qn.lower > 1 && qn.lower <= EXPAND_STRING_MAX_LENGTH) {
- StringNode sn = (StringNode)target;
+ StringNode sn = (StringNode)target;
+ if (qn.lower > 1) {
+ StringNode str = new StringNode(sn.bytes, sn.p, sn.end);
+ str.flag = sn.flag;
+
+ int i;
+ int n = qn.lower;
int len = sn.length();
+ for (i = 1; i < n && (i + 1) * len <= EXPAND_STRING_MAX_LENGTH; i++) {
+ str.catBytes(sn.bytes, sn.p, sn.end);
+ }
- if (len * qn.lower <= EXPAND_STRING_MAX_LENGTH) {
- StringNode str = new StringNode();
- str.flag = sn.flag;
+ if (i < qn.upper || isRepeatInfinite(qn.upper)) {
+ qn.lower -= i;
+ if (!isRepeatInfinite(qn.upper)) qn.upper -= i;
+ ListNode list = ListNode.newList(str, null);
+ qn.swap(list);
+ ListNode.listAdd(list, qn);
+ } else {
qn.swap(str);
- int n = qn.lower;
- for (int i = 0; i < n; i++) {
- str.catBytes(sn.bytes, sn.p, sn.end);
- }
- break; /* break case NT_QTFR: */
}
-
}
}
+
if (Config.USE_OP_PUSH_OR_JUMP_EXACT) {
if (qn.greedy && qn.targetEmptyInfo != 0) {
if (target.getType() == NodeType.QTFR) {
--
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