summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-01-19 21:29:54 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-01-19 21:29:54 +0000
commitf080c058190a6af0618512e2bc45ad5e4549ddb6 (patch)
treee9f0524d7a4ba443f3cb66f2ae33c3b81a953c48
parentb3637df35f3486add4be0be27908419d6bd03684 (diff)
downloadyelp-f080c058190a6af0618512e2bc45ad5e4549ddb6.tar.gz
- Use g_spawn_command_line_sync instead of popen. - if 'manpath' command
2002-01-19 Mikael Hallendal <micke@codefactory.se> * src/yelp-man.c (yelp_man_init): - Use g_spawn_command_line_sync instead of popen. - if 'manpath' command is not found, look for MANPATH env. before using /usr/man and /usr/share/man - cleaned up a little to better fit into Yelp code.
-rw-r--r--ChangeLog10
-rw-r--r--src/yelp-man.c47
2 files changed, 32 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b6ef4ba..ecadbb81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2002-01-19 Mikael Hallendal <micke@codefactory.se>
+ * src/yelp-man.c (yelp_man_init):
+ - Use g_spawn_command_line_sync instead of popen.
+ - if 'manpath' command is not found, look for MANPATH env. before
+ using /usr/man and /usr/share/man
+ - cleaned up a little to better fit into Yelp code.
+
+2002-01-19 Mikael Hallendal <micke@codefactory.se>
+
* src/yelp-html.c (yelp_html_new): remove the temp printout. just
print Yelp for now.
@@ -7,6 +15,8 @@
check that /usr/man and /usr/share/man doesn't point to the same
place.
+2002-01-19 Mikael Hallendal <micke@codefactory.se>
+
* src/yelp-scrollkeeper.c:
(ys_strip_scheme): rewrote to
- accept NULL instead of scheme
diff --git a/src/yelp-man.c b/src/yelp-man.c
index 8b540cc7..022ff374 100644
--- a/src/yelp-man.c
+++ b/src/yelp-man.c
@@ -540,43 +540,40 @@ yelp_man_push_initial_tree (struct TreeNode *node, GtkTreeStore *store, GtkTreeI
gboolean
yelp_man_init (GtkTreeStore *store)
{
- FILE *fh;
- char aline[1024];
- char **manpath = NULL;
- int i;
- GHashTable *section_hash;
- struct TreeNode *root;
- struct stat stat_dir1;
- struct stat stat_dir2;
-
+ gchar *manpath = NULL;
+ char **manpathes = NULL;
+ GHashTable *section_hash;
+ struct TreeNode *root;
+ struct stat stat_dir1;
+ struct stat stat_dir2;
+ int i;
+
/* Go through all the man pages:
* 1. Determine the places to search (run 'manpath').
- * 2. Go through all subdirectories to find individual files.
- * 3. For each file, add it onto the tree at the right place.
+ * 2. If that is not found, use MANPATH environment variable.
+ * 3. Go through all subdirectories to find individual files.
+ * 4. For each file, add it onto the tree at the right place.
*/
section_hash = g_hash_table_new (g_str_hash, g_str_equal);
root = yelp_man_make_initial_tree (&root_data, section_hash);
- fh = popen ("manpath", "r");
- g_return_val_if_fail (fh, FALSE);
-
- if (fgets (aline, sizeof (aline), fh)) {
- g_strstrip (aline);
- manpath = g_strsplit (aline, ":", -1);
- } else {
- g_warning ("Couldn't get manpath");
+ if (!g_spawn_command_line_sync ("manpath", &manpath, NULL, NULL, NULL)) {
+ g_print ("manpath not found, looking for MANPATH env\n");
+ manpath = g_strdup (g_getenv ("MANPATH"));
}
- pclose (fh);
- i = 0;
if (manpath) {
- for (; manpath[i]; i++)
- yelp_man_populate_tree_for_dir (section_hash, manpath[i]);
- }
- if (!manpath || !manpath[0]) {
+ g_strstrip (manpath);
+ manpathes = g_strsplit (manpath, ":", -1);
+ g_free (manpath);
+ for (i = 0; manpathes[i]; i++) {
+ yelp_man_populate_tree_for_dir (section_hash,
+ manpathes[i]);
+ }
+ } else {
stat ("/usr/man", &stat_dir1);
stat ("/usr/share/man", &stat_dir2);