]> jfr.im git - irc/quakenet/newserv.git/commitdiff
TRUSTS: various bug fixes I can't remember
authorChris Porter <redacted>
Fri, 2 Sep 2011 21:49:22 +0000 (22:49 +0100)
committerChris Porter <redacted>
Fri, 2 Sep 2011 21:49:22 +0000 (22:49 +0100)
trusts/data.c
trusts/trusts_commands.c

index 8ff3bc90f4c70bcac7356d2db70db31ca76f116c..f4c49a6a316894c446bf18f29ab9861b91882c9e 100644 (file)
@@ -273,26 +273,16 @@ trustgroup *tg_strtotg(char *name) {
 
   /* legacy format */
   if(name[0] == '#') {
-    id = strtoul(&name[1], NULL, 10);
-    if(!id)
+    char *endp;
+    id = strtoul(&name[1], &endp, 10);
+    if(!id || *endp)
       return NULL;
 
-    for(tg=tglist;tg;tg=tg->next)
-      if(tg->id == id)
-        return tg;
+    return tg_getbyid(id);
   }
 
   for(tg=tglist;tg;tg=tg->next)
-    if(!match(name, tg->name->content))
-      return tg;
-
-  id = strtoul(name, NULL, 10);
-  if(!id)
-    return NULL;
-
-  /* legacy format */
-  for(tg=tglist;tg;tg=tg->next)
-    if(tg->id == id)
+    if(!strcmp(name, tg->name->content))
       return tg;
 
   return NULL;
index 021973b26f7162884ff49d71fbd190420e169796..5620fab3491394e73f9f906a47e7107f3b07e3ff 100644 (file)
@@ -138,20 +138,16 @@ static void displaygroup(nick *sender, trustgroup *tg) {
 
 static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
   nick *sender = source;
-  char *name;
   trustgroup *tg = NULL;
-  int id, found = 0, remaining = 50;
+  int found = 0, remaining = 50;
+  char *name;
 
   if(cargc < 1)
     return CMD_USAGE;
 
   name = cargv[0];
 
-  if(name[0] == '#')
-    tg = tg_strtotg(name + 1);
-
-  if((id = strtol(name, NULL, 10)))
-    tg = tg_getbyid(id);
+  tg = tg_strtotg(name);
 
   if(tg) {
     displaygroup(sender, tg);