Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-1188084 into 
lp:zorba.

Commit message:
Fixed fn:replace() replacement string that has > 9 $ substitutions.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1188084 in Zorba: "fn-replace-42 failing"
  https://bugs.launchpad.net/zorba/+bug/1188084

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/bug-1188084/+merge/168556

Fixed fn:replace() replacement string that has > 9 $ substitutions.
-- 
https://code.launchpad.net/~paul-lucas/zorba/bug-1188084/+merge/168556
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp	2013-06-06 18:33:17 +0000
+++ src/runtime/strings/strings_impl.cpp	2013-06-10 22:18:30 +0000
@@ -1609,10 +1609,17 @@
             ERROR_PARAMS( replacement, ZED( BadCharAfter_34 ), *c, '$' ),
             ERROR_LOC( loc )
           );
-        if ( *c - '0' <= num_capturing_groups ) {
-          temp_replacement += '$';
-          temp_replacement += *c;
+
+        temp_replacement += '$';
+        temp_replacement += *c;
+
+        char const c2 = ztd::peek( replacement, c );
+        if ( ascii::is_digit( c2 ) ) {
+          int const group = 10 + c2 - '0';
+          if ( group > num_capturing_groups )
+            temp_replacement += '\\';
         }
+
         got_dollar = false;
         continue;
       }

=== modified file 'src/util/icu_regex.cpp'
--- src/util/icu_regex.cpp	2013-04-19 04:07:25 +0000
+++ src/util/icu_regex.cpp	2013-06-10 22:18:30 +0000
@@ -616,11 +616,11 @@
   return;
 
 not_single_char_esc:
-    throw INVALID_RE_EXCEPTION( xq_re, ZED( NotSingleCharEsc_3 ), c );
+  throw INVALID_RE_EXCEPTION( xq_re, ZED( NotSingleCharEsc_3 ), c );
 unbalanced_char:
-    throw INVALID_RE_EXCEPTION( xq_re, ZED( UnbalancedChar_3 ), c );
+  throw INVALID_RE_EXCEPTION( xq_re, ZED( UnbalancedChar_3 ), c );
 unescaped_char:
-    throw INVALID_RE_EXCEPTION( xq_re, ZED( UnescapedChar_3 ), c );
+  throw INVALID_RE_EXCEPTION( xq_re, ZED( UnescapedChar_3 ), c );
 }
 
 ///////////////////////////////////////////////////////////////////////////////

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to