Merge lp:~paul-lucas/zorba/bug-1131984 into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11393
Merged at revision: 11393
Proposed branch: lp:~paul-lucas/zorba/bug-1131984
Merge into: lp:zorba
Diff against target: 111 lines (+30/-10)
3 files modified
ChangeLog (+1/-0)
src/util/icu_regex.cpp (+29/-8)
test/fots/CMakeLists.txt (+0/-2)
To merge this branch: bzr merge lp:~paul-lucas/zorba/bug-1131984
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+159750@code.launchpad.net

Commit message

Description of the change

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1131984-2013-04-19T04-14-42.072Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1131984-2013-04-19T20-05-42.554Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-04-18 04:19:56 +0000
3+++ ChangeLog 2013-04-19 04:11:29 +0000
4@@ -48,6 +48,7 @@
5 * Fixed bug #1085408 (xs:date(): casting large year values)
6 * Fixed bug #867027 (XQST0059 error messages inconsistent)
7 * Fixed bug #1095889 (Improve error message for xml-parsing error).
8+ * Fixed bug #1131984 (apparently invalid regex in queries)
9 * Fixed bug #1123163 (fn:format-integer failures)
10 * Fixed bug in index join rule (no index join if inner clause has positional var).
11 * Fixed bug in index join rule (copy var ids after cloning index domain expr).
12
13=== modified file 'src/util/icu_regex.cpp'
14--- src/util/icu_regex.cpp 2013-04-18 03:26:36 +0000
15+++ src/util/icu_regex.cpp 2013-04-19 04:11:29 +0000
16@@ -57,12 +57,20 @@
17 #define bs_i "\\p{L}_:" /* \i equivalent contents */
18 #define bs_W "\\p{P}\\p{Z}\\p{C}" /* \W equivalent contents */
19
20+/**
21+ * Decremements an integer, but no lower that a certain limit (usually zero).
22+ *
23+ * @tparam IntegralType The integral type.
24+ * @param i A pointer to the integer to decrement.
25+ * @param limit The limit not to go lower than.
26+ * @return Returns \c true only when the limit has been reached for the first
27+ * time.
28+ */
29 template<typename IntegralType> inline
30 typename std::enable_if<ZORBA_TR1_NS::is_integral<IntegralType>::value,
31- void>::type
32+ bool>::type
33 dec_limit( IntegralType *i, IntegralType limit = 0 ) {
34- if ( *i > limit )
35- --*i;
36+ return *i > limit && --*i == limit;
37 }
38
39 static unsigned digits( long n ) {
40@@ -108,13 +116,21 @@
41 return icu_flags;
42 }
43
44+/**
45+ * Checks whether the given iterator is positioned at the first character in a
46+ * character range, e.g, the 'a' in "[a-z]" (assuming we're already within a
47+ * character class [...]).
48+ *
49+ * @param s The string on which \a i is iterating.
50+ * @param i The iterator marking the position of the character to check.
51+ */
52 inline bool is_char_range_begin( zstring const &s,
53- zstring::const_iterator i ) {
54+ /* intentionally not const& */ zstring::const_iterator i ) {
55 return ztd::peek( s, &i ) == '-' && ztd::peek( s, &i ) != '[';
56 }
57
58 inline bool is_non_capturing_begin( zstring const &s,
59- zstring::const_iterator i ) {
60+ /* intentionally not const& */ zstring::const_iterator i ) {
61 return ztd::peek_behind( s, &i ) == '?' && ztd::peek_behind( s, &i ) == '(';
62 }
63
64@@ -138,6 +154,7 @@
65 char c_cooked; // current cooked XQuery char
66 char prev_c_cooked = 0; // previous c_cooked
67 char char_range_begin_cooked = 0; // the 'a' in [a-b]
68+ bool char_range_possible = true; // handles case like [a-h-o-z]
69
70 bool got_backslash = false;
71 int got_quantifier = 0;
72@@ -437,11 +454,15 @@
73 // XQuery [A-Z-[OI]] becomes ICU [A-Z--[OI]].
74 //
75 *icu_re += '-';
76- } else if ( prev_c_cooked != '[' && next_c != ']' ) {
77+ } else if ( char_range_possible &&
78+ prev_c_cooked != '[' && next_c != ']' ) {
79 //
80 // The '-' is neither the first or last character within a
81 // character range (i.e., a literal '-') so therefore it's
82- // indicating a character range.
83+ // indicating a character range -- except if we just completed a
84+ // character range. For example, in "[a-h-o-z]", there are two
85+ // ranges: a-h and o-z. The '-' between the 'h' and the 'o' is a
86+ // literal '-' and NOT a range h-o.
87 //
88 char_range_begin_cooked = prev_c_cooked;
89 in_char_range = 2;
90@@ -536,7 +557,7 @@
91 *icu_re += c;
92
93 next:
94- dec_limit( &in_char_range );
95+ char_range_possible = !dec_limit( &in_char_range );
96 dec_limit( &got_quantifier );
97 dec_limit( &is_first_char );
98 prev_c_cooked = c_cooked;
99
100=== modified file 'test/fots/CMakeLists.txt'
101--- test/fots/CMakeLists.txt 2013-04-19 00:21:18 +0000
102+++ test/fots/CMakeLists.txt 2013-04-19 04:11:29 +0000
103@@ -125,8 +125,6 @@
104 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-date format-date-en132 21423)
105 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-date format-date-en133 21423)
106 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-date format-date-en134 21423)
107-EXPECTED_FOTS_FAILURE (DISPUTED fn-matches.re re00056 21425)
108-EXPECTED_FOTS_FAILURE (DISPUTED fn-matches.re re00086 21425)
109 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-integer format-integer-044 21448)
110 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-date format-date-en152 21558)
111 EXPECTED_FOTS_FAILURE (DISPUTED fn-format-dateTime format-dateTime-en152 21558)

Subscribers

People subscribed via source and target branches