Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-common / core / fe-help.c
index fa90473d308bcf7efc7358d09d5766e5674b99e2..c093b84b296547e249e4258f30d0c04a21231c9e 100644 (file)
 
 static int commands_equal(COMMAND_REC *rec, COMMAND_REC *rec2)
 {
+       int i;
+
        if (rec->category == NULL && rec2->category != NULL)
                return -1;
        if (rec2->category == NULL && rec->category != NULL)
                return 1;
+       if (rec->category != NULL && rec2->category != NULL) {
+               i = strcmp(rec->category, rec2->category);
+               if (i != 0)
+                       return i;
+       }
 
        return strcmp(rec->cmd, rec2->cmd);
 }
@@ -110,16 +117,27 @@ static void help_category(GSList *cmdlist, int items)
 static int show_help_file(const char *file)
 {
         const char *helppath;
-       char tmpbuf[1024], *str, *path;
+       char tmpbuf[1024], *str, *path, **paths, **tmp;
        LINEBUF_REC *buffer = NULL;
        int f, ret, recvlen;
 
         helppath = settings_get_str("help_path");
 
-       /* helpdir/command or helpdir/category/command */
-       path = g_strdup_printf("%s/%s", helppath, file);
-       f = open(path, O_RDONLY);
-       g_free(path);
+       paths = g_strsplit(helppath, ":", -1);
+
+       f = -1;
+       for (tmp = paths; *tmp != NULL; tmp++) {
+               /* helpdir/command or helpdir/category/command */
+               path = g_strdup_printf("%s/%s", *tmp, file);
+               f = open(path, O_RDONLY);
+               g_free(path);
+
+               if (f != -1)
+                       break;
+
+       }
+
+       g_strfreev(paths);
 
        if (f == -1)
                return FALSE;
@@ -240,6 +258,7 @@ static void cmd_help(const char *data)
        ptr = cmd+strlen(cmd);
        while (ptr[-1] == ' ') ptr--; *ptr = '\0';
 
+       g_strdown(cmd);
        show_help(cmd);
         g_free(cmd);
 }