* strlen(); strcpy -> single strlen + memmove
[citadel.git] / webcit / tools.c
index ff11a586b332d6d2e4df93bff7c2b2f8848b3d02..98c3bb584a8405d8fe61024223d03bfa6926326b 100644 (file)
@@ -249,12 +249,19 @@ int pattern2(char *search, char *patn)
  */
 void striplt(char *buf)
 {
-       if (strlen(buf) == 0) return;
-       while ((strlen(buf) > 0) && (isspace(buf[0])))
-               strcpy(buf, &buf[1]);
-       if (strlen(buf) == 0) return;
-       while (isspace(buf[strlen(buf) - 1]))
-               buf[strlen(buf) - 1] = 0;
+       long len;
+
+       len = strlen(buf);
+       if (len == 0) return;
+       while ((len > 0) && (isspace(buf[0]))){
+               memmove (buf, &buf[1], len);
+               len --;
+       }
+       if (len == 0) return;
+       while (isspace(buf[len - 1])){
+               buf[len - 1] = 0;
+               len --;
+       }
 }