X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/c4d08ac5260bb26db10bcfd9dc6fd2db60efebe9..b3b42765712afed5a35c9be5c832f4a06bd85e7a:/lunaix-os/libs/klibc/string/trim.c diff --git a/lunaix-os/libs/klibc/string/trim.c b/lunaix-os/libs/klibc/string/trim.c index 82f29bd..fb907fa 100644 --- a/lunaix-os/libs/klibc/string/trim.c +++ b/lunaix-os/libs/klibc/string/trim.c @@ -18,12 +18,16 @@ strrtrim(char* str) str[l + 1] = '\0'; } -void* +char* strltrim_safe(char* str) { size_t l = 0; char c = 0; - while ((c = str[l++]) && WS_CHAR(c)) - ; + while ((c = str[l]) && WS_CHAR(c)) { + l++; + } + + if (!l) + return str; return strcpy(str, str + l); } \ No newline at end of file