diet.internal.string 0/44(0%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
module diet.internal.string; import std.ascii : isWhite; pure @safe nothrow: string ctstrip(string s) { size_t strt = 0, end = s.length; while (strt < s.length && s[strt].isWhite) strt++; while (end > 0 && s[end-1].isWhite) end--; return strt < end ? s[strt .. end] : null; } string ctstripLeft(string s) { size_t i = 0; while (i < s.length && s[i].isWhite) i++; return s[i .. $]; } string ctstripRight(string s) { size_t i = s.length; while (i > 0 && s[i-1].isWhite) i--; return s[0 .. i]; } string dstringEscape(char ch) { switch (ch) { default: return ""~ch; case '\\': return "\\\\"; case '\r': return "\\r"; case '\n': return "\\n"; case '\t': return "\\t"; case '\"': return "\\\""; } } string dstringEscape(in ref string str) { string ret; foreach( ch; str ) ret ~= dstringEscape(ch); return ret; } string dstringUnescape(in string str) { string ret; size_t i, start = 0; for( i = 0; i < str.length; i++ ) if( str[i] == '\\' ){ if( i > start ){ if( start > 0 ) ret ~= str[start .. i]; else ret = str[0 .. i]; } assert(i+1 < str.length, "The string ends with the escape char: " ~ str); switch(str[i+1]){ default: ret ~= str[i+1]; break; case 'r': ret ~= '\r'; break; case 'n': ret ~= '\n'; break; case 't': ret ~= '\t'; break; } i++; start = i+1; } if( i > start ){ if( start == 0 ) return str; else ret ~= str[start .. i]; } return ret; } string sanitizeEscaping(string str) { str = dstringUnescape(str); return dstringEscape(str); } string stripUTF8BOM(string input) { if (input.length >= 3 && input[0 .. 3] == [0xEF, 0xBB, 0xBF]) return input[3 .. $]; return input; }