summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogeesh MB <yogeeshappa.mathighatta@wipro.com>2002-08-03 22:09:12 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-08-03 22:09:12 +0000
commite858461c643e148f1eacd85ed811b1cf17213a9b (patch)
tree82d315565708fae6d6172664537365a00fde0d54
parent581d250ad85889c8dbfe82d3e520caaf15cc091e (diff)
downloadyelp-e858461c643e148f1eacd85ed811b1cf17213a9b.tar.gz
added function which removes multiple man pathes, fixes bug#75728
2002-08-04 Yogeesh MB <yogeeshappa.mathighatta@wipro.com> * src/yelp-man.c: added function which removes multiple man pathes, fixes bug#75728
-rw-r--r--ChangeLog5
-rw-r--r--src/yelp-man.c54
2 files changed, 51 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 56886728..6e02db4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-08-04 Yogeesh MB <yogeeshappa.mathighatta@wipro.com>
+
+ * src/yelp-man.c: added function which removes multiple
+ man pathes, fixes bug#75728
+
2002-08-02 Sander Vesik <sander.vesik@sun.com>
* stylesheets/yelp-customization.xsl:
- make list items have some space around them
diff --git a/src/yelp-man.c b/src/yelp-man.c
index 3e4b7a16..d23a793f 100644
--- a/src/yelp-man.c
+++ b/src/yelp-man.c
@@ -564,11 +564,48 @@ yelp_man_push_initial_tree (struct TreeNode *node, GNode *parent)
}
}
+static gchar**
+yelp_man_remove_duplicates_from_manpath (gchar *manpath)
+{
+ gchar **manpathes = NULL;
+ gchar **tmppathes = NULL;
+ gint i, j;
+
+ if (manpath == NULL)
+ return NULL;
+
+ g_strstrip (manpath);
+ if (manpath[0] == '\0')
+ return NULL;
+
+ tmppathes = g_strsplit (manpath, ":", -1);
+
+ for (i = 1; tmppathes[i]; i++);
+ manpathes = (char **) g_malloc0(i * sizeof(char **));
+
+ manpathes[0] = g_strdup (tmppathes[0]);
+ manpathes[1] = NULL;
+ for ( i = 1; tmppathes[i]; i++){
+ for (j = 0; manpathes[j]; j++) {
+ if(!(strcmp(tmppathes[i], manpathes[j])))
+ break;
+ }
+ if (manpathes[j] == NULL) {
+ manpathes[j] = g_strdup (tmppathes[i]);
+ manpathes[j + 1] = NULL;
+ }
+ }
+
+ g_strfreev (tmppathes);
+
+ return manpathes;
+}
+
gboolean
yelp_man_init (GNode *tree, GList **index)
{
gchar *manpath = NULL;
- char **manpathes = NULL;
+ gchar **manpathes = NULL;
GHashTable *section_hash;
struct TreeNode *root;
struct stat stat_dir1;
@@ -586,16 +623,17 @@ yelp_man_init (GNode *tree, GList **index)
root = yelp_man_make_initial_tree (&root_data, section_hash);
- if (!g_spawn_command_line_sync ("manpath", &manpath, NULL, NULL, NULL)) {
+ if (g_spawn_command_line_sync ("manpath", &manpath, NULL, NULL, NULL)) {
+ g_strstrip (manpath);
+ manpathes = g_strsplit (manpath, ":", -1);
+ } else {
g_print ("manpath not found, looking for MANPATH env\n");
manpath = g_strdup (g_getenv ("MANPATH"));
+ manpathes = yelp_man_remove_duplicates_from_manpath (manpath);
}
-
- if (manpath) {
- g_strstrip (manpath);
- manpathes = g_strsplit (manpath, ":", -1);
- g_free (manpath);
-
+ g_free (manpath);
+
+ if (manpathes != NULL) {
for (i = 0; manpathes[i]; i++) {
yelp_man_populate_tree_for_dir (section_hash,
manpathes[i]);