summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/regexp/RE.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/regexp/RE.java')
-rw-r--r--libjava/gnu/regexp/RE.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/libjava/gnu/regexp/RE.java b/libjava/gnu/regexp/RE.java
index fdc00feb3fb..d782975e9af 100644
--- a/libjava/gnu/regexp/RE.java
+++ b/libjava/gnu/regexp/RE.java
@@ -492,8 +492,25 @@ public class RE extends REToken {
else if ((unit.ch == '(') && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ unit.bk)) {
boolean pure = false;
boolean comment = false;
+ boolean lookAhead = false;
+ boolean negativelh = false;
if ((index+1 < pLength) && (pattern[index] == '?')) {
switch (pattern[index+1]) {
+ case '!':
+ if (syntax.get(RESyntax.RE_LOOKAHEAD)) {
+ pure = true;
+ negativelh = true;
+ lookAhead = true;
+ index += 2;
+ }
+ break;
+ case '=':
+ if (syntax.get(RESyntax.RE_LOOKAHEAD)) {
+ pure = true;
+ lookAhead = true;
+ index += 2;
+ }
+ break;
case ':':
if (syntax.get(RESyntax.RE_PURE_GROUPING)) {
pure = true;
@@ -539,10 +556,14 @@ public class RE extends REToken {
numSubs++;
}
- int useIndex = (pure) ? 0 : nextSub + numSubs;
+ int useIndex = (pure || lookAhead) ? 0 : nextSub + numSubs;
currentToken = new RE(String.valueOf(pattern,index,endIndex-index).toCharArray(),cflags,syntax,useIndex,nextSub + numSubs);
numSubs += ((RE) currentToken).getNumSubs();
+ if (lookAhead) {
+ currentToken = new RETokenLookAhead(currentToken,negativelh);
+ }
+
index = nextIndex;
} // not a comment
} // subexpression
OpenPOWER on IntegriCloud