]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/tools.c
found out from Kyle what b flag is.
[irc/evilnet/x3.git] / src / tools.c
index 85912a61c63caf9b554ec00eb3610686362b8a53..946f27a5175b297c4527781d9420ec5a4ddbc770 100644 (file)
@@ -1,7 +1,7 @@
 /* tools.c - miscellaneous utility functions
  * Copyright 2000-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -424,7 +424,9 @@ user_matches_glob_broken(struct userNode *user, const char *orig_glob, int inclu
         return 1;
     /* Check for a fakehost match. */
     if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
-            return 1;
+        return 1;
+    if (IsSetHost(user) && match_ircglob(sethostname, glob))
+        return 1;
     /* Check for an account match. */
     if (hidden_host_suffix && user->handle_info) {
         char hidden_host[HOSTLEN+1];
@@ -586,7 +588,7 @@ TypeLength(char type)
 {
     switch (type) {
     case 'y': return 365*24*60*60;
-    case 'M': return 31*24*60*60;
+    case 'M': return 30*24*60*60;
     case 'w': return 7*24*60*60;
     case 'd': return 24*60*60;
     case 'h': return 60*60;
@@ -596,6 +598,10 @@ TypeLength(char type)
     }
 }
 
+/* This function is not entirely accurate as it does not take into account leap units
+ * or varying months. TODO: use proper dateadd functions to calculate real seconds
+ * from now for the units (eg 1M should be give us seconds till todays date next month)
+ */
 unsigned long
 ParseInterval(const char *interval)
 {
@@ -765,13 +771,13 @@ intervalString(char *output, time_t interval, struct handle_info *hi)
 
         if (words++ == 1) {
             msg = language_find_message(lang, "MSG_AND");
-            pos += sprintf(output + pos, " %s ", msg);
+            pos += sprintf(output + pos, "%s ", msg);
         }
         if (count == 1)
             msg = language_find_message(lang, unit[type].msg_single);
         else
             msg = language_find_message(lang, unit[type].msg_plural);
-        pos += sprintf(output + pos, "%d %s", count, msg);
+        pos += sprintf(output + pos, "%d%s", count, msg);
     }
 
     output[pos] = 0;