Second Extended Filesystem (ext2) and other improvements (#33)
[lunaix-os.git] / lunaix-os / libs / klibc / string / trim.c
index fb907fa5673585413ac99c421b971d336414e585..3c3d11a7fc2f029998bfe2eca2716636f93c98fe 100644 (file)
@@ -1,13 +1,14 @@
 #include <klibc/string.h>
+#include <lunaix/compiler.h>
 
 #define WS_CHAR(c)                                                             \
     (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\v' || c == '\r')
 
-void
+void weak
 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,16 +19,16 @@ strrtrim(char* str)
     str[l + 1] = '\0';
 }
 
-char*
+char* weak
 strltrim_safe(char* str)
 {
-    size_t l = 0;
+    unsigned long l = 0;
     char c = 0;
     while ((c = str[l]) && WS_CHAR(c)) {
         l++;
     }
 
-    if (!l)
-        return str;
-    return strcpy(str, str + l);
+    if (l)
+        strcpy(str, str + l);
+    return str;
 }
\ No newline at end of file