aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/regexp/RE.java
diff options
context:
space:
mode:
authorBernd Schmidt <bernd.schmidt@analog.com>2006-02-06 16:36:35 +0000
committerBernd Schmidt <bernd.schmidt@analog.com>2006-02-06 16:36:35 +0000
commitb3d13cd7ae392041004db6b9bf5098372048c00e (patch)
tree2adf45987dc9f88c26eeb95b0071647ebb5c87ec /libjava/gnu/regexp/RE.java
parent337db89251de80f8ff7a00b2d71bc333c630b6e4 (diff)
Merge reload-branch up to revision 101000reload-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/reload-branch@110651 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/regexp/RE.java')
-rw-r--r--libjava/gnu/regexp/RE.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/libjava/gnu/regexp/RE.java b/libjava/gnu/regexp/RE.java
index c8c8a3eb9ff..541e8cb950f 100644
--- a/libjava/gnu/regexp/RE.java
+++ b/libjava/gnu/regexp/RE.java
@@ -629,20 +629,29 @@ public class RE extends REToken {
currentToken = setRepeated(currentToken,0,Integer.MAX_VALUE,index);
}
- // ONE-OR-MORE REPEAT OPERATOR
+ // ONE-OR-MORE REPEAT OPERATOR / POSSESSIVE MATCHING OPERATOR
// + | \+ depending on RE_BK_PLUS_QM
// not available if RE_LIMITED_OPS is set
else if ((unit.ch == '+') && !syntax.get(RESyntax.RE_LIMITED_OPS) && (!syntax.get(RESyntax.RE_BK_PLUS_QM) ^ (unit.bk || quot))) {
if (currentToken == null)
throw new REException(getLocalizedMessage("repeat.no.token"),REException.REG_BADRPT,index);
- if (currentToken instanceof RETokenRepeated)
- throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,index);
- if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
+
+ // Check for possessive matching on RETokenRepeated
+ if (currentToken instanceof RETokenRepeated) {
+ RETokenRepeated tokenRep = (RETokenRepeated)currentToken;
+ if (syntax.get(RESyntax.RE_POSSESSIVE_OPS) && !tokenRep.isPossessive() && !tokenRep.isStingy())
+ tokenRep.makePossessive();
+ else
+ throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,index);
+
+ }
+ else if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,index);
- if (currentToken.getMinimumLength() == 0)
+ else if (currentToken.getMinimumLength() == 0)
throw new REException(getLocalizedMessage("repeat.empty.token"),REException.REG_BADRPT,index);
- currentToken = setRepeated(currentToken,1,Integer.MAX_VALUE,index);
+ else
+ currentToken = setRepeated(currentToken,1,Integer.MAX_VALUE,index);
}
// ZERO-OR-ONE REPEAT OPERATOR / STINGY MATCHING OPERATOR
@@ -655,13 +664,14 @@ public class RE extends REToken {
// Check for stingy matching on RETokenRepeated
if (currentToken instanceof RETokenRepeated) {
- if (syntax.get(RESyntax.RE_STINGY_OPS) && !((RETokenRepeated)currentToken).isStingy())
- ((RETokenRepeated)currentToken).makeStingy();
- else
- throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,index);
- }
- else if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
- throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,index);
+ RETokenRepeated tokenRep = (RETokenRepeated)currentToken;
+ if (syntax.get(RESyntax.RE_STINGY_OPS) && !tokenRep.isStingy() && !tokenRep.isPossessive())
+ tokenRep.makeStingy();
+ else
+ throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,index);
+ }
+ else if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
+ throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,index);
else
currentToken = setRepeated(currentToken,0,1,index);
}