Revision: 2076 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2076&view=re... Author: codebrainz Date: 2011-05-23 08:28:39 +0000 (Mon, 23 May 2011)
Log Message: ----------- Use 'man' argument for section order.
Modified Paths: -------------- trunk/geany-plugins/devhelp/src/manpages.c
Modified: trunk/geany-plugins/devhelp/src/manpages.c =================================================================== --- trunk/geany-plugins/devhelp/src/manpages.c 2011-05-23 08:28:15 UTC (rev 2075) +++ trunk/geany-plugins/devhelp/src/manpages.c 2011-05-23 08:28:39 UTC (rev 2076) @@ -8,12 +8,9 @@
#ifdef HAVE_MAN
-#define DEVHELP_MANPAGE_NUM_SECTIONS 8 -/* In order of most likely sections */ -static gint sections[DEVHELP_MANPAGE_NUM_SECTIONS] = { 3, 2, 1, 8, 5, 4, 7, 6 }; - #define DEVHELP_MANPAGE_BUF_SIZE 4096
+ static GList *temp_files = NULL;
@@ -21,62 +18,26 @@ static gchar *find_manpage(const gchar *term, const gchar *section) { FILE *fp; - gint i, len, retcode=0; + gint len, retcode=0; gchar *cmd, buf[PATH_MAX];
g_return_val_if_fail(term != NULL, NULL);
- if (section != NULL) /* user-specified section */ - { + if (section == NULL) + cmd = g_strdup_printf("man -S 3:2:1:8:5:4:7:6 --where '%s'", term); + else cmd = g_strdup_printf("man --where %s '%s'", section, term); - if ((fp = popen(cmd, "r")) != NULL) - { - g_free(cmd);
- len = fread(buf, sizeof(gchar), PATH_MAX, fp); - retcode = pclose(fp); - } + if ((fp = popen(cmd, "r")) == NULL) + { g_free(cmd); + return NULL; } - else - {
- /* try in order of most-likely sections */ - for (i = 0; i < DEVHELP_MANPAGE_NUM_SECTIONS; i++) - { - cmd = g_strdup_printf("man --where %d '%s'", sections[i], term); - if ((fp = popen(cmd, "r")) == NULL) - { - g_free(cmd); - continue; - } + g_free(cmd); + len = fread(buf, sizeof(gchar), PATH_MAX, fp); + retcode = pclose(fp);
- g_free(cmd); - len = fread(buf, sizeof(gchar), PATH_MAX, fp); - retcode = pclose(fp); - - if (retcode != 0) - continue; - else - break; - } - - /* try without section if all else fails */ - if (retcode != 0) - { - cmd = g_strdup_printf("man --where '%s'", term); - if ((fp = popen(cmd, "r")) == NULL) - { - g_free(cmd); - return NULL; - } - - g_free(cmd); - len = fread(buf, sizeof(gchar), PATH_MAX, fp); - retcode = pclose(fp); - } - } - buf[PATH_MAX - 1] = '\0';
if (strlen(buf) == 0 || retcode != 0) @@ -96,7 +57,7 @@
g_return_val_if_fail(filename != NULL, NULL);
- cmd = g_strdup_printf("man "%s"", filename); + cmd = g_strdup_printf("man -S 3:2:1:8:5:4:7:6 -P"col -b" "%s"", filename);
fp = popen(cmd, "r"); g_free(cmd);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org