changed Makefile; build all commands as an own file
[NeonServV5.git] / tools.c
diff --git a/tools.c b/tools.c
index 1fc4be91715427259db63ae895494156ccdd675c..097684855d8230a66cb21819ceb9240dce68a5cb 100644 (file)
--- a/tools.c
+++ b/tools.c
@@ -5,8 +5,8 @@
 #include "ClientSocket.h"
 
 static const struct default_language_entry msgtab[] = {
-    {"TIME_MASK_2_ITEMS", "%s and %s"},
-    {"TIME_MASK_3_ITEMS", "%s, %s and %s"},
+    {"TIME_MASK_2_ITEMS", "%s and %s"}, /* {ARGS: "2 days", "1 hour"} */
+    {"TIME_MASK_3_ITEMS", "%s, %s and %s"}, /* {ARGS: "2 days", "1 hour", "20 minutes"} */
     {"TIME_YEAR", "year"},
     {"TIME_YEARS", "years"},
     {"TIME_MONTH", "month"},
@@ -259,7 +259,7 @@ char* timeToStr(struct UserNode *user, int seconds, int items, char *buf) {
             }
             buf[p++] = ' ';
         }
-        buf[p-1] = '\0';
+        buf[(p ? p-1 : 0)] = '\0';
     }
     return buf;
 }
@@ -279,12 +279,17 @@ int strToTime(struct UserNode *user, char *str) {
     int unit_multiplikator;
     while(*str) {
         p = str;
+        while(*p && !isdigit(*p)) //skip leading chars
+            p++;
+        str = p;
         while(*p && isdigit(*p)) //get the value
             p++;
         tmpchar = *p;
         *p = '\0';
         cvalue = isdigit(*str) ? atoi(str) : 0;
         *p = tmpchar;
+        while(*p == ' ') //skip spaces
+            p++;
         str = p;
         while(*p && !isdigit(*p)) //get the unit
             p++;