mirror of
https://git.checksum.fail/alec/slon.git
synced 2025-12-08 12:09:55 +02:00
System/Libraries/String: Use mode instead of always trimming both ends in String.Trim()
This commit is contained in:
@@ -132,14 +132,14 @@ Bool @string_trim_ch(U8 s_ch, U8 trim_ch)
|
|||||||
U0 @string_trim(U8* s, U8 ch = NULL, I64 mode = TRIM_BOTH)
|
U0 @string_trim(U8* s, U8 ch = NULL, I64 mode = TRIM_BOTH)
|
||||||
{
|
{
|
||||||
Bool trim_ch = @string_trim_ch(*s, ch);
|
Bool trim_ch = @string_trim_ch(*s, ch);
|
||||||
if (TRIM_BOTH || TRIM_LEFT) {
|
if (mode == TRIM_BOTH || mode == TRIM_LEFT) {
|
||||||
while (trim_ch) {
|
while (trim_ch) {
|
||||||
StrCpy(s, s + 1);
|
StrCpy(s, s + 1);
|
||||||
trim_ch = @string_trim_ch(*s, ch);
|
trim_ch = @string_trim_ch(*s, ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trim_ch = @string_trim_ch(s[StrLen(s) - 1], ch);
|
trim_ch = @string_trim_ch(s[StrLen(s) - 1], ch);
|
||||||
if (TRIM_BOTH || TRIM_RIGHT) {
|
if (mode == TRIM_BOTH || mode == TRIM_RIGHT) {
|
||||||
while (trim_ch) {
|
while (trim_ch) {
|
||||||
s[StrLen(s) - 1] = NULL;
|
s[StrLen(s) - 1] = NULL;
|
||||||
trim_ch = @string_trim_ch(s[StrLen(s) - 1], ch);
|
trim_ch = @string_trim_ch(s[StrLen(s) - 1], ch);
|
||||||
|
|||||||
Reference in New Issue
Block a user