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

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 10952
Merged at revision: 10949
Proposed branch: lp:~paul-lucas/zorba/bug-1026379
Merge into: lp:zorba
Diff against target: 107 lines (+19/-12)
4 files modified
ChangeLog (+1/-0)
src/runtime/strings/strings_impl.cpp (+16/-12)
test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res (+1/-0)
test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq (+1/-0)
To merge this branch: bzr merge lp:~paul-lucas/zorba/bug-1026379
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+115877@code.launchpad.net

Commit message

No longer checking captured subgroups in replacement string when 'q' flag is given.

Description of the change

No longer checking captured subgroups in replacement string when 'q' flag is given.

To post a comment you must log in.
lp:~paul-lucas/zorba/bug-1026379 updated
10952. By Paul J. Lucas

Cosmetic change.

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
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1026379-2012-07-20T03-02-57.672Z 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 2012-07-19 13:47:33 +0000
3+++ ChangeLog 2012-07-20 02:59:21 +0000
4@@ -38,6 +38,7 @@
5 for calling TypeOps::get_atomic_type_code() from
6 SchemaValidatorImpl::isPossibleSimpleContentRevalImpl())
7 * Fixed bug #867357 (Improved parser error messages)
8+ * Fixed bug #1026379 ("q" flag for fn:replace() is ignored)
9 * Fixed bug #932314 (non-comparable values must be treated as distinct by
10 fn:distinct-values)
11 * Fixed bug #1015580 (Add base64_streambuf / replace inefficient base64 code)
12
13=== modified file 'src/runtime/strings/strings_impl.cpp'
14--- src/runtime/strings/strings_impl.cpp 2012-07-12 17:29:55 +0000
15+++ src/runtime/strings/strings_impl.cpp 2012-07-20 02:59:21 +0000
16@@ -1541,7 +1541,7 @@
17 zstring input;
18 zstring flags;
19 zstring pattern;
20- zstring replacement, replacement2;
21+ zstring replacement;
22 zstring resStr;
23 store::Item_t item;
24 bool tmp;
25@@ -1585,24 +1585,27 @@
26 err::FORX0003, ERROR_PARAMS( pattern ), ERROR_LOC( loc )
27 );
28
29- { // local scope
30+ if ( flags.find( 'q' ) == zstring::npos ) {
31+
32+ // count the number of capturing groups
33+ bool got_paren = false;
34 int num_capturing_groups = 0;
35-
36- bool got_paren = false;
37 FOR_EACH( zstring, c, pattern ) {
38 if ( got_paren && *c != '?' )
39 ++num_capturing_groups;
40 got_paren = *c == '(';
41 }
42
43- bool got_backslash = false, got_dollar = false;
44+ bool got_backslash = false;
45+ bool got_dollar = false;
46+ zstring temp_replacement;
47 FOR_EACH( zstring, c, replacement ) {
48 if ( got_backslash ) {
49 switch ( *c ) {
50 case '\\':
51 case '$':
52- replacement2 += '\\';
53- replacement2 += *c;
54+ temp_replacement += '\\';
55+ temp_replacement += *c;
56 got_backslash = false;
57 continue;
58 default:
59@@ -1621,8 +1624,8 @@
60 ERROR_LOC( loc )
61 );
62 if ( *c - '0' <= num_capturing_groups ) {
63- replacement2 += '$';
64- replacement2 += *c;
65+ temp_replacement += '$';
66+ temp_replacement += *c;
67 }
68 got_dollar = false;
69 continue;
70@@ -1635,7 +1638,7 @@
71 got_dollar = true;
72 break;
73 default:
74- replacement2 += *c;
75+ temp_replacement += *c;
76 break;
77 }
78 } // FOR_EACH
79@@ -1651,13 +1654,14 @@
80 ERROR_PARAMS( replacement, ZED( TrailingChar_3 ), '$' ),
81 ERROR_LOC( loc )
82 );
83- } // local scope
84+ replacement = temp_replacement;
85+ }
86
87 try
88 {
89 zstring lib_pattern;
90 convert_xquery_re( pattern, &lib_pattern, flags.c_str() );
91- utf8::replace_all(input, lib_pattern, flags.c_str(), replacement2, &resStr);
92+ utf8::replace_all(input, lib_pattern, flags.c_str(), replacement, &resStr);
93 }
94 catch(XQueryException& ex)
95 {
96
97=== added file 'test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res'
98--- test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res 1970-01-01 00:00:00 +0000
99+++ test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res 2012-07-20 02:59:21 +0000
100@@ -0,0 +1,1 @@
101+$oo
102
103=== added file 'test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq'
104--- test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq 1970-01-01 00:00:00 +0000
105+++ test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq 2012-07-20 02:59:21 +0000
106@@ -0,0 +1,1 @@
107+fn:replace("foo", "f", "$", "q")

Subscribers

People subscribed via source and target branches