refactor: add a async read/write variant to device ops, with allow async io to be...
[lunaix-os.git] / lunaix-os / libs / klibc / string / trim.c
index 82f29bd717ead44bcaddd5dd4c9fc6927a211a4c..c15e159a94b9c6809c4d58926f990a03417a02d6 100644 (file)
@@ -6,8 +6,8 @@
 void
 strrtrim(char* str)
 {
-    size_t l = strlen(str);
-    while (l < (size_t)-1) {
+    unsigned long l = strlen(str);
+    while (l < (unsigned long)-1) {
         char c = str[l];
         if (!c || WS_CHAR(c)) {
             l--;
@@ -18,12 +18,16 @@ strrtrim(char* str)
     str[l + 1] = '\0';
 }
 
-void*
+char*
 strltrim_safe(char* str)
 {
-    size_t l = 0;
+    unsigned long 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