libmir / mir-algorithm

@@ -492,6 +492,34 @@
Loading
492 492
    assert(w.data == `\x03`);
493 493
}
494 494
495 +
///
496 +
void printReplaced(C, W)(scope ref W w, scope const(C)[] str, C c, scope const(C)[] to)
497 +
{
498 +
    import mir.string: scanLeftAny;
499 +
500 +
    while (str.length)
501 +
    {
502 +
        auto tailLen = str.scanLeftAny(c).length;
503 +
        print(w, str[0 .. $ - tailLen]);
504 +
        if (tailLen == 0)
505 +
            break;
506 +
        print(w, to);
507 +
        str = str[$ - tailLen + 1 .. $];
508 +
    }
509 +
}
510 +
511 +
///
512 +
@safe pure nothrow
513 +
unittest
514 +
{
515 +
    import mir.test: should;
516 +
    auto csv = stringBuf;
517 +
    csv.put('"');
518 +
    csv.printReplaced(`some string with " double quotes "!`, '"', `""`);
519 +
    csv.put('"');
520 +
    csv.data.should == `"some string with "" double quotes ""!"`;
521 +
}
522 +
495 523
/++
496 524
Decodes `char` `c` to the form `u00XX`, where `XX` is 2 hexadecimal characters.
497 525
+/

@@ -32,6 +32,7 @@
Loading
32 32
    version (LDC)
33 33
    static if (N <= 8)
34 34
    static if (is(__vector(U[N])))
35 +
    if (!__ctfe)
35 36
    {
36 37
        alias V = __vector(U[N]);
37 38
        pragma(msg, V);
@@ -102,6 +103,7 @@
Loading
102 103
        version (LDC)
103 104
        static if (N <= 8)
104 105
        static if (is(__vector(U[N])))
106 +
        if (!__ctfe)
105 107
        {
106 108
            import mir.bitop: cttz;
107 109
@@ -207,6 +209,7 @@
Loading
207 209
        version (LDC)
208 210
        static if (N <= 8)
209 211
        static if (is(__vector(U[N])))
212 +
        if (!__ctfe)
210 213
        {
211 214
            import mir.bitop: ctlz;
212 215
@@ -296,7 +299,7 @@
Loading
296 299
inout(C)[]
297 300
    strip(C, size_t L)
298 301
    (return scope inout(C)[] str, const C[L] chars...)
299 -
    @trusted pure nothrow @nogc
302 +
    @safe pure nothrow @nogc
300 303
    if (isSomeChar!C && L)
301 304
{
302 305
    return str.stripLeft(chars).stripRight(chars);
Files Coverage
source/mir 91.67%
Project Totals (79 files) 91.67%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading