Skip to content

Commit

Permalink
fix 'x' flag parsing (#1188)
Browse files Browse the repository at this point in the history
* fix 'x' flag parsing

as seen in FunMatches.java#L528, an 'x' flag in regular expressions should be interpreted as Pattern.COMMENTS

* typo fix

* add analyze-string#3 'x' flag test
  • Loading branch information
telic authored and adamretter committed Nov 29, 2016
1 parent 47325cf commit 605c4e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/org/exist/xquery/functions/fn/FunAnalyzeString.java
Expand Up @@ -195,7 +195,7 @@ private int parseStringFlags(final String flags) {
break;

case 'x' :
iFlags |= Pattern.CANON_EQ;
iFlags |= Pattern.COMMENTS;
break;

case 'q' :
Expand All @@ -205,4 +205,4 @@ private int parseStringFlags(final String flags) {
}
return iFlags;
}
}
}
7 changes: 7 additions & 0 deletions test/src/xquery/xquery3/fn.xql
Expand Up @@ -3,6 +3,7 @@ xquery version "3.0";
module namespace fn="http://exist-db.org/xquery/test/fnfunctions";

declare namespace test="http://exist-db.org/xquery/xqsuite";
declare namespace xpf = "http://www.w3.org/2005/xpath-functions";

declare
%test:assertEquals(0, 4, 3, 2, 1)
Expand All @@ -14,3 +15,9 @@ return
})
};

declare
%test:args('test', 't e s t', '') %test:assertFalse
%test:args('test', 't e s t', 'x') %test:assertTrue
function fn:analyze-matches($str, $pat, $flags) {
exists(analyze-string($str, $pat, $flags)/xpf:match)
};

0 comments on commit 605c4e3

Please sign in to comment.