[Issue 5712] [patch] std.regex.replace disallows w/dstring

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 6 11:01:53 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5712



--- Comment #1 from Haruki Shigemori <rayerd.wiz at gmail.com> 2011-03-06 10:58:54 PST ---
(From update of attachment 930)
>From 22abb3531c34705395bee0c87b4c50ad9104adbe Mon Sep 17 00:00:00 2001
From: haru-s <rayerd.wiz at gmail.com>
Date: Mon, 7 Mar 2011 03:56:41 +0900
Subject: [PATCH] std.regex.replace came to accept w/dstring.

---
 std/regex.d |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/std/regex.d b/std/regex.d
index 683148f..9c00a0a 100644
--- a/std/regex.d
+++ b/std/regex.d
@@ -2576,8 +2576,8 @@ and, using the format string, generate and return a new
string.
     private static Range replace3(String)(String format, Range input,
             regmatch_t[] pmatch)
     {
-        string result;
-        uint c2;
+        Range result;
+        Unqual!(ElementType!String) c2;
         sizediff_t startIdx;
         sizediff_t endIdx;
         int i;
@@ -2586,7 +2586,7 @@ and, using the format string, generate and return a new
string.
         result.length = 0;
         for (size_t f = 0; f < format.length; f++)
         {
-            char c = format[f];
+            Unqual!(ElementType!String) c = format[f];
           L1:
             if (c != '$')
             {
@@ -2640,7 +2640,7 @@ and, using the format string, generate and return a new
string.
                     {
                         result ~= '$';
                         result ~= c;
-                        c = cast(char)c2;
+                        c = c2;
                         goto L1;
                     }
                 }
@@ -2665,7 +2665,7 @@ and, using the format string, generate and return a new
string.
         }
         return result;
     }
-
+    
 /* ***********************************
  * Like replace(char[] format), but uses old style formatting:
                 <table border=1 cellspacing=0 cellpadding=5>
@@ -2755,6 +2755,13 @@ unittest
     assert(match("abc", regex(".b..")).empty);
 }

+unittest
+{
+    replace("a", regex("a"), "b");
+    replace("a"w, regex("a"w), "b"w);
+    replace("a"d, regex("a"d), "b"d);
+}
+

//------------------------------------------------------------------------------

 /**
-- 
1.7.3.1.msysgit.0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list