mirror of https://github.com/adamdruppe/arsd.git
whitespace fixes
This commit is contained in:
parent
4dd75f7ee6
commit
99b168bf95
14
core.d
14
core.d
|
@ -900,11 +900,17 @@ unittest {
|
||||||
+/
|
+/
|
||||||
nothrow @safe @nogc pure
|
nothrow @safe @nogc pure
|
||||||
inout(char)[] stripInternal(return inout(char)[] s) {
|
inout(char)[] stripInternal(return inout(char)[] s) {
|
||||||
|
bool isAllWhitespace = true;
|
||||||
foreach(i, char c; s)
|
foreach(i, char c; s)
|
||||||
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
||||||
s = s[i .. $];
|
s = s[i .. $];
|
||||||
|
isAllWhitespace = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isAllWhitespace)
|
||||||
|
return s[$..$];
|
||||||
|
|
||||||
for(int a = cast(int)(s.length - 1); a > 0; a--) {
|
for(int a = cast(int)(s.length - 1); a > 0; a--) {
|
||||||
char c = s[a];
|
char c = s[a];
|
||||||
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
||||||
|
@ -916,15 +922,19 @@ inout(char)[] stripInternal(return inout(char)[] s) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
nothrow @safe @nogc pure
|
nothrow @safe @nogc pure
|
||||||
inout(char)[] stripRightInternal(return inout(char)[] s) {
|
inout(char)[] stripRightInternal(return inout(char)[] s) {
|
||||||
for(int a = cast(int)(s.length - 1); a > 0; a--) {
|
bool isAllWhitespace = true;
|
||||||
char c = s[a];
|
foreach_reverse(a, c; s) {
|
||||||
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
if(c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
||||||
s = s[0 .. a + 1];
|
s = s[0 .. a + 1];
|
||||||
|
isAllWhitespace = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(isAllWhitespace)
|
||||||
|
s = s[0..0];
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue