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
=== modified file 'ChangeLog'
--- ChangeLog 2012-07-19 13:47:33 +0000
+++ ChangeLog 2012-07-20 02:59:21 +0000
@@ -38,6 +38,7 @@
38 for calling TypeOps::get_atomic_type_code() from38 for calling TypeOps::get_atomic_type_code() from
39 SchemaValidatorImpl::isPossibleSimpleContentRevalImpl())39 SchemaValidatorImpl::isPossibleSimpleContentRevalImpl())
40 * Fixed bug #867357 (Improved parser error messages)40 * Fixed bug #867357 (Improved parser error messages)
41 * Fixed bug #1026379 ("q" flag for fn:replace() is ignored)
41 * Fixed bug #932314 (non-comparable values must be treated as distinct by42 * Fixed bug #932314 (non-comparable values must be treated as distinct by
42 fn:distinct-values)43 fn:distinct-values)
43 * Fixed bug #1015580 (Add base64_streambuf / replace inefficient base64 code)44 * Fixed bug #1015580 (Add base64_streambuf / replace inefficient base64 code)
4445
=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp 2012-07-12 17:29:55 +0000
+++ src/runtime/strings/strings_impl.cpp 2012-07-20 02:59:21 +0000
@@ -1541,7 +1541,7 @@
1541 zstring input;1541 zstring input;
1542 zstring flags;1542 zstring flags;
1543 zstring pattern;1543 zstring pattern;
1544 zstring replacement, replacement2;1544 zstring replacement;
1545 zstring resStr;1545 zstring resStr;
1546 store::Item_t item;1546 store::Item_t item;
1547 bool tmp;1547 bool tmp;
@@ -1585,24 +1585,27 @@
1585 err::FORX0003, ERROR_PARAMS( pattern ), ERROR_LOC( loc )1585 err::FORX0003, ERROR_PARAMS( pattern ), ERROR_LOC( loc )
1586 );1586 );
15871587
1588 { // local scope1588 if ( flags.find( 'q' ) == zstring::npos ) {
1589
1590 // count the number of capturing groups
1591 bool got_paren = false;
1589 int num_capturing_groups = 0;1592 int num_capturing_groups = 0;
1590
1591 bool got_paren = false;
1592 FOR_EACH( zstring, c, pattern ) {1593 FOR_EACH( zstring, c, pattern ) {
1593 if ( got_paren && *c != '?' )1594 if ( got_paren && *c != '?' )
1594 ++num_capturing_groups;1595 ++num_capturing_groups;
1595 got_paren = *c == '(';1596 got_paren = *c == '(';
1596 }1597 }
15971598
1598 bool got_backslash = false, got_dollar = false;1599 bool got_backslash = false;
1600 bool got_dollar = false;
1601 zstring temp_replacement;
1599 FOR_EACH( zstring, c, replacement ) {1602 FOR_EACH( zstring, c, replacement ) {
1600 if ( got_backslash ) {1603 if ( got_backslash ) {
1601 switch ( *c ) {1604 switch ( *c ) {
1602 case '\\':1605 case '\\':
1603 case '$':1606 case '$':
1604 replacement2 += '\\';1607 temp_replacement += '\\';
1605 replacement2 += *c;1608 temp_replacement += *c;
1606 got_backslash = false;1609 got_backslash = false;
1607 continue;1610 continue;
1608 default:1611 default:
@@ -1621,8 +1624,8 @@
1621 ERROR_LOC( loc )1624 ERROR_LOC( loc )
1622 );1625 );
1623 if ( *c - '0' <= num_capturing_groups ) {1626 if ( *c - '0' <= num_capturing_groups ) {
1624 replacement2 += '$';1627 temp_replacement += '$';
1625 replacement2 += *c;1628 temp_replacement += *c;
1626 }1629 }
1627 got_dollar = false;1630 got_dollar = false;
1628 continue;1631 continue;
@@ -1635,7 +1638,7 @@
1635 got_dollar = true;1638 got_dollar = true;
1636 break;1639 break;
1637 default:1640 default:
1638 replacement2 += *c;1641 temp_replacement += *c;
1639 break;1642 break;
1640 }1643 }
1641 } // FOR_EACH1644 } // FOR_EACH
@@ -1651,13 +1654,14 @@
1651 ERROR_PARAMS( replacement, ZED( TrailingChar_3 ), '$' ),1654 ERROR_PARAMS( replacement, ZED( TrailingChar_3 ), '$' ),
1652 ERROR_LOC( loc )1655 ERROR_LOC( loc )
1653 );1656 );
1654 } // local scope1657 replacement = temp_replacement;
1658 }
16551659
1656 try1660 try
1657 {1661 {
1658 zstring lib_pattern;1662 zstring lib_pattern;
1659 convert_xquery_re( pattern, &lib_pattern, flags.c_str() );1663 convert_xquery_re( pattern, &lib_pattern, flags.c_str() );
1660 utf8::replace_all(input, lib_pattern, flags.c_str(), replacement2, &resStr);1664 utf8::replace_all(input, lib_pattern, flags.c_str(), replacement, &resStr);
1661 }1665 }
1662 catch(XQueryException& ex)1666 catch(XQueryException& ex)
1663 {1667 {
16641668
=== added file 'test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res'
--- test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/string/ReplaceFunc/replace20.xml.res 2012-07-20 02:59:21 +0000
@@ -0,0 +1,1 @@
1$oo
02
=== added file 'test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq'
--- test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/string/ReplaceFunc/replace20.xq 2012-07-20 02:59:21 +0000
@@ -0,0 +1,1 @@
1fn:replace("foo", "f", "$", "q")

Subscribers

People subscribed via source and target branches