[jruby-joni] 36/223: Sync joni up with jcodings changes and fix opEndLine and opSemiEndLine as well.
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:21:43 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 ad7a724536a02be61de89e4348be048ce0e118fa
Author: Marcin Mielżyński <lopx at gazeta.pl>
Date: Sun Sep 14 17:39:07 2008 +0000
Sync joni up with jcodings changes and fix opEndLine and opSemiEndLine as well.
git-svn-id: http://svn.codehaus.org/jruby/joni/trunk@7703 961051c9-f516-0410-bf72-c9f7e237a7b7
---
src/org/joni/ByteCodeMachine.java | 28 ++++++++---------
src/org/joni/Matcher.java | 63 +++++++++++++++++++--------------------
src/org/joni/Regex.java | 4 +--
src/org/joni/SearchAlgorithm.java | 14 ++++-----
src/org/joni/ast/StringNode.java | 2 +-
5 files changed, 55 insertions(+), 56 deletions(-)
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index 5d74a15..3620d34 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -1046,17 +1046,16 @@ class ByteCodeMachine extends StackMachine {
private void opEndLine() {
if (s == end) {
- if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE &&
- str == end || !enc.isNewLine(bytes, sprev, end)) {
- if (isNotEol(msaOptions)) opFail();
+ if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
+ if (str == end || !enc.isNewLine(bytes, sprev, end)) {
+ if (isNotEol(msaOptions)) opFail();
+ }
return;
} else {
- if (isNotEol(msaOptions)) opFail();
+ if (isNotEol(msaOptions)) opFail();
return;
}
- } else if (enc.isNewLine(bytes, s, end)) {
- return;
- } else if (Config.USE_CRNL_AS_LINE_TERMINATOR && enc.isMbcCrnl(bytes, s, end)) {
+ } else if (enc.isNewLine(bytes, s, end) || (Config.USE_CRNL_AS_LINE_TERMINATOR && enc.isMbcCrnl(bytes, s, end))) {
return;
}
opFail();
@@ -1064,9 +1063,10 @@ class ByteCodeMachine extends StackMachine {
private void opSemiEndBuf() {
if (s == end) {
- if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE &&
- str == end || !enc.isNewLine(bytes, sprev, end)) {
- if (isNotEol(msaOptions)) opFail();
+ if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
+ if (str == end || !enc.isNewLine(bytes, sprev, end)) {
+ if (isNotEol(msaOptions)) opFail();
+ }
return;
} else {
if (isNotEol(msaOptions)) opFail();
@@ -1596,9 +1596,9 @@ class ByteCodeMachine extends StackMachine {
private void opLookBehind() {
int tlen = code[ip++];
- s = enc.stepBack(bytes, str, s, tlen);
+ s = enc.stepBack(bytes, str, s, end, tlen);
if (s == -1) {opFail(); return;}
- sprev = enc.prevCharHead(bytes, str, s);
+ sprev = enc.prevCharHead(bytes, str, s, end);
}
private void opLookBehindSb() {
@@ -1611,7 +1611,7 @@ class ByteCodeMachine extends StackMachine {
private void opPushLookBehindNot() {
int addr = code[ip++];
int tlen = code[ip++];
- int q = enc.stepBack(bytes, str, s, tlen);
+ int q = enc.stepBack(bytes, str, s, end, tlen);
if (q == -1) {
/* too short case -> success. ex. /(?<!XXX)a/.match("a")
If you want to change to fail, replace following line. */
@@ -1620,7 +1620,7 @@ class ByteCodeMachine extends StackMachine {
} else {
pushLookBehindNot(ip + addr, s, sprev);
s = q;
- sprev = enc.prevCharHead(bytes, str, s);
+ sprev = enc.prevCharHead(bytes, str, s, end);
}
}
diff --git a/src/org/joni/Matcher.java b/src/org/joni/Matcher.java
index 354622c..215f0da 100644
--- a/src/org/joni/Matcher.java
+++ b/src/org/joni/Matcher.java
@@ -101,7 +101,7 @@ public abstract class Matcher extends IntHolder {
stateCheckBuffInit(end - str, offset, regex.numCombExpCheck); // move it to construction?
} // USE_COMBINATION_EXPLOSION_CHECK
- int prev = enc.prevCharHead(bytes, str, at);
+ int prev = enc.prevCharHead(bytes, str, at, end);
if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) {
return matchAt(end /*range*/, at, prev);
@@ -147,7 +147,7 @@ public abstract class Matcher extends IntHolder {
switch (regex.subAnchor) {
case AnchorType.BEGIN_LINE:
if (p != str) {
- int prev = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p);
+ int prev = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p, end);
if (!enc.isNewLine(bytes, prev, end)) {
// goto retry_gate;
pprev = p;
@@ -159,21 +159,21 @@ public abstract class Matcher extends IntHolder {
case AnchorType.END_LINE:
if (p == end) {
- if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
- int prev = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p);
+ if (!Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
+ int prev = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p, end);
if (prev != -1 && enc.isNewLine(bytes, prev, end)) {
// goto retry_gate;
pprev = p;
p += enc.length(bytes, p, end);
continue retry;
}
- } else if (!enc.isNewLine(bytes, p, end)) {
- if (Config.USE_CRNL_AS_LINE_TERMINATOR && enc.isMbcCrnl(bytes, p, end)) break;
- // goto retry_gate;
- pprev = p;
- p += enc.length(bytes, p, end);
- continue retry;
}
+ } else if (!enc.isNewLine(bytes, p, end) && (!Config.USE_CRNL_AS_LINE_TERMINATOR || !enc.isMbcCrnl(bytes, p, end))) {
+ //if () break;
+ // goto retry_gate;
+ pprev = p;
+ p += enc.length(bytes, p, end);
+ continue retry;
}
break;
} // switch
@@ -183,9 +183,9 @@ public abstract class Matcher extends IntHolder {
low = p;
if (lowPrev != null) { // ??? // remove null checks
if (low > s) {
- lowPrev.value = enc.prevCharHead(bytes, s, p);
+ lowPrev.value = enc.prevCharHead(bytes, s, p, end);
} else {
- lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p);
+ lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, p, end);
}
}
} else {
@@ -193,13 +193,13 @@ public abstract class Matcher extends IntHolder {
low = p - regex.dMax;
if (low > s) {
- low = enc.rightAdjustCharHeadWithPrev(bytes, s, low, lowPrev);
+ low = enc.rightAdjustCharHeadWithPrev(bytes, s, low, end, lowPrev);
if (lowPrev != null && lowPrev.value == -1) {
- lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : s, low);
+ lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : s, low, end);
}
} else {
if (lowPrev != null) {
- lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, low);
+ lowPrev.value = enc.prevCharHead(bytes, (pprev != -1) ? pprev : str, low, end);
}
}
}
@@ -235,7 +235,7 @@ public abstract class Matcher extends IntHolder {
switch (regex.subAnchor) {
case AnchorType.BEGIN_LINE:
if (p != str) {
- int prev = enc.prevCharHead(bytes, str, p);
+ int prev = enc.prevCharHead(bytes, str, p, end);
if (!enc.isNewLine(bytes, prev, end)) {
p = prev;
continue retry;
@@ -245,17 +245,16 @@ public abstract class Matcher extends IntHolder {
case AnchorType.END_LINE:
if (p == end) {
- if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
- int prev = enc.prevCharHead(bytes, adjrange, p);
+ if (!Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) {
+ int prev = enc.prevCharHead(bytes, adjrange, p, end);
if (prev == -1) return false;
if (enc.isNewLine(bytes, prev, end)) {
p = prev;
continue retry;
}
}
- } else if (!enc.isNewLine(bytes, p, end)) {
- if (Config.USE_CRNL_AS_LINE_TERMINATOR && enc.isMbcCrnl(bytes, p, end)) break;
- p = enc.prevCharHead(bytes, adjrange, p);
+ } else if (!enc.isNewLine(bytes, p, end) && (!Config.USE_CRNL_AS_LINE_TERMINATOR || !enc.isMbcCrnl(bytes, p, end))) {
+ p = enc.prevCharHead(bytes, adjrange, p, end);
if (p == -1) return false;
continue retry;
}
@@ -267,7 +266,7 @@ public abstract class Matcher extends IntHolder {
if (regex.dMax != MinMaxLen.INFINITE_DISTANCE) {
low = p - regex.dMax;
high = p - regex.dMin;
- high = enc.rightAdjustCharHead(bytes, adjrange, high);
+ high = enc.rightAdjustCharHead(bytes, adjrange, high, end);
}
if (Config.DEBUG_SEARCH) {
@@ -355,12 +354,12 @@ public abstract class Matcher extends IntHolder {
// !end_buf:!
if (endBuf(start, range, minSemiEnd, maxSemiEnd)) return -1; // mismatch_no_msa;
} else if ((regex.anchor & AnchorType.SEMI_END_BUF) != 0) {
- int preEnd = enc.stepBack(bytes, str, end, 1);
+ int preEnd = enc.stepBack(bytes, str, end, end, 1);
maxSemiEnd = end;
if (enc.isNewLine(bytes, preEnd, end)) {
minSemiEnd = preEnd;
if (Config.USE_CRNL_AS_LINE_TERMINATOR) {
- preEnd = enc.stepBack(bytes, str, preEnd, 1);
+ preEnd = enc.stepBack(bytes, str, preEnd, end, 1);
if (preEnd != -1 && enc.isMbcCrnl(bytes, preEnd, end)) {
minSemiEnd = preEnd;
}
@@ -418,7 +417,7 @@ public abstract class Matcher extends IntHolder {
s = start;
if (range > start) { /* forward search */
if (s > str) {
- prev = enc.prevCharHead(bytes, str, s);
+ prev = enc.prevCharHead(bytes, str, s, end);
} else {
prev = 0; // -1
}
@@ -489,7 +488,7 @@ public abstract class Matcher extends IntHolder {
if (regex.searchAlgorithm != SearchAlgorithm.NONE) {
int adjrange;
if (range < end) {
- adjrange = enc.leftAdjustCharHead(bytes, str, range);
+ adjrange = enc.leftAdjustCharHead(bytes, str, range, end);
} else {
adjrange = end;
}
@@ -500,7 +499,7 @@ public abstract class Matcher extends IntHolder {
if (!backwardSearchRange(bytes, str, end, schStart, range, adjrange)) return mismatch(); // low, high
if (s > high) s = high;
while (s >= low) {
- prev = enc.prevCharHead(bytes, str, s);
+ prev = enc.prevCharHead(bytes, str, s, end);
if (matchCheck(origStart, s, prev)) return match(s);
s = prev;
}
@@ -518,7 +517,7 @@ public abstract class Matcher extends IntHolder {
if (schStart > end) {
schStart = end;
} else {
- schStart = enc.leftAdjustCharHead(bytes, start, schStart);
+ schStart = enc.leftAdjustCharHead(bytes, start, schStart, end);
}
}
}
@@ -527,7 +526,7 @@ public abstract class Matcher extends IntHolder {
}
do {
- prev = enc.prevCharHead(bytes, str, s);
+ prev = enc.prevCharHead(bytes, str, s, end);
if (matchCheck(origStart, s, prev)) return match(s);
s = prev;
} while (s >= range);
@@ -543,9 +542,9 @@ public abstract class Matcher extends IntHolder {
if ((minSemiEnd - start) > regex.anchorDmax) {
start = minSemiEnd - regex.anchorDmax;
if (start < end) {
- start = enc.rightAdjustCharHead(bytes, str, start);
+ start = enc.rightAdjustCharHead(bytes, str, start, end);
} else { /* match with empty at end */
- start = enc.prevCharHead(bytes, str, end);
+ start = enc.prevCharHead(bytes, str, end, end);
}
}
if ((maxSemiEnd - (range - 1)) < regex.anchorDmin) {
@@ -558,7 +557,7 @@ public abstract class Matcher extends IntHolder {
}
if ((maxSemiEnd - start) < regex.anchorDmin) {
start = maxSemiEnd - regex.anchorDmin;
- start = enc.leftAdjustCharHead(bytes, str, start);
+ start = enc.leftAdjustCharHead(bytes, str, start, end);
}
if (range > start) return true; // mismatch_no_msa;
}
diff --git a/src/org/joni/Regex.java b/src/org/joni/Regex.java
index 4cb5cb7..41820df 100644
--- a/src/org/joni/Regex.java
+++ b/src/org/joni/Regex.java
@@ -434,9 +434,9 @@ public final class Regex implements RegexState {
if(pos > 0 && enc.maxLength() != 1 && pos < len) {
int p;
if(range > 0) {
- p = enc.rightAdjustCharHead(str, start, start + pos);
+ p = enc.rightAdjustCharHead(str, start, start + pos, start + len);
} else {
- p = enc.leftAdjustCharHead(str, start, start + pos);
+ p = enc.leftAdjustCharHead(str, start, start + pos, start + len);
}
return p - start;
}
diff --git a/src/org/joni/SearchAlgorithm.java b/src/org/joni/SearchAlgorithm.java
index c19591a..2078096 100644
--- a/src/org/joni/SearchAlgorithm.java
+++ b/src/org/joni/SearchAlgorithm.java
@@ -75,7 +75,7 @@ public abstract class SearchAlgorithm {
if (s > textStart) {
s = textStart;
} else {
- s = enc.leftAdjustCharHead(text, adjustText, s);
+ s = enc.leftAdjustCharHead(text, adjustText, s, textEnd);
}
while (s >= textP) {
@@ -88,7 +88,7 @@ public abstract class SearchAlgorithm {
}
if (t == targetEnd) return s;
}
- s = enc.prevCharHead(text, adjustText, s);
+ s = enc.prevCharHead(text, adjustText, s, textEnd);
}
return -1;
}
@@ -201,12 +201,12 @@ public abstract class SearchAlgorithm {
if (s > textStart) {
s = textStart;
} else {
- s = enc.leftAdjustCharHead(text, adjustText, s);
+ s = enc.leftAdjustCharHead(text, adjustText, s, textEnd);
}
while (s >= textP) {
if (lowerCaseMatch(target, targetP, targetEnd, text, s, textEnd)) return s;
- s = enc.prevCharHead(text, adjustText, s);
+ s = enc.prevCharHead(text, adjustText, s, textEnd);
}
return -1;
}
@@ -356,7 +356,7 @@ public abstract class SearchAlgorithm {
if (textStart < s) {
s = textStart;
} else {
- s = enc.leftAdjustCharHead(text, adjustText, s);
+ s = enc.leftAdjustCharHead(text, adjustText, s, textEnd);
}
while (s >= textP) {
@@ -368,7 +368,7 @@ public abstract class SearchAlgorithm {
if (t == targetEnd) return s;
s -= regex.intMapBackward[text[s] & 0xff];
- s = enc.leftAdjustCharHead(text, adjustText, s);
+ s = enc.leftAdjustCharHead(text, adjustText, s, textEnd);
}
return -1;
}
@@ -488,7 +488,7 @@ public abstract class SearchAlgorithm {
if (s >= textEnd) s = textEnd - 1; // multibyte safe ?
while (s >= textP) {
if (map[text[s] & 0xff] != 0) return s;
- s = enc.prevCharHead(text, adjustText, s);
+ s = enc.prevCharHead(text, adjustText, s, textEnd);
}
return -1;
}
diff --git a/src/org/joni/ast/StringNode.java b/src/org/joni/ast/StringNode.java
index 7d25349..bf8217e 100644
--- a/src/org/joni/ast/StringNode.java
+++ b/src/org/joni/ast/StringNode.java
@@ -117,7 +117,7 @@ public final class StringNode extends Node implements StringType {
StringNode n = null;
if (end > p) {
- int prev = enc.prevCharHead(bytes, p, end);
+ int prev = enc.prevCharHead(bytes, p, end, end);
if (prev != -1 && prev > p) { /* can be splitted. */
n = new StringNode(bytes, prev, end);
if (isRaw()) n.setRaw();
--
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