summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-08-12 22:44:01 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-08-12 22:44:01 +0000
commitd2a123fefb535cf226dca2ad0784b5281b09cde2 (patch)
treef65c90f8f88e403b347f8787e5d0a6e694860ddb
parenta3ba82643911c168197e04ac35485c88acca9337 (diff)
downloadyelp-d2a123fefb535cf226dca2ad0784b5281b09cde2.tar.gz
- return a GSList instead - Hopefully fixed #90385 (yelp_man_init): using
2002-08-13 Mikael Hallendal <micke@codefactory.se> * src/yelp-man.c: (yelp_man_remove_duplicates_from_manpath): - return a GSList instead - Hopefully fixed #90385 (yelp_man_init): using a GSList for manpathes instead of gchar **.
-rw-r--r--ChangeLog13
-rw-r--r--src/yelp-html-gtkhtml2.c2
-rw-r--r--src/yelp-man.c90
-rw-r--r--src/yelp-reader.c17
4 files changed, 75 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d7eca56..e68a76b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-08-13 Mikael Hallendal <micke@codefactory.se>
+
+ * src/yelp-man.c:
+ (yelp_man_remove_duplicates_from_manpath):
+ - return a GSList instead
+ - Hopefully fixed #90385
+ (yelp_man_init): using a GSList for manpathes instead of gchar **.
+
2002-08-07 Mikael Hallendal <micke@codefactory.se>
* src/yelp-view-toc.c:
@@ -38,7 +46,8 @@
- include quotes around stylesheet path so its correctly passed in
* stylesheets/yelp-custom.xsl:
- - move parameterisation of admonition graphics to yelp-customization.xsl
+ - move parameterisation of admonition graphics to
+ yelp-customization.xsl
* stylesheets/yelp-customization.xsl:
- make <b> create a consistent result
@@ -75,7 +84,7 @@
2002-08-04 Yogeesh MB <yogeeshappa.mathighatta@wipro.com>
* src/yelp-man.c: added function which removes multiple
- man pathes, fixes bug#75728
+ man pathes, fixes bug #75728
2002-08-02 Sander Vesik <sander.vesik@sun.com>
* stylesheets/yelp-customization.xsl:
diff --git a/src/yelp-html-gtkhtml2.c b/src/yelp-html-gtkhtml2.c
index 5eb11806..7b08ae09 100644
--- a/src/yelp-html-gtkhtml2.c
+++ b/src/yelp-html-gtkhtml2.c
@@ -36,7 +36,6 @@
#include "yelp-marshal.h"
#include "yelp-error.h"
#include "yelp-uri.h"
-#include "yelp-reader.h"
#include "yelp-html.h"
#define d(x)
@@ -46,7 +45,6 @@ struct _YelpHtmlPriv {
HtmlDocument *doc;
YelpURI *base_uri;
- YelpReader *reader;
};
diff --git a/src/yelp-man.c b/src/yelp-man.c
index d23a793f..b232fa8e 100644
--- a/src/yelp-man.c
+++ b/src/yelp-man.c
@@ -3,7 +3,7 @@
* Copyright (C) 2002 Red Hat Inc.
* Copyright (C) 2000 Sun Microsystems, Inc.
* Copyright (C) 2001 Eazel, Inc.
- * Copyright (C) 2002 Mikael Hallendal <micke@codefactory.se>
+ * Copyright (C) 2002 CodeFactory AB
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -203,6 +203,8 @@ yelp_man_populate_tree_for_dir (GHashTable *section_hash,
{
char cbuf[1024];
+ g_return_if_fail (basedir != NULL);
+
g_snprintf (cbuf, sizeof (cbuf), "%s/man1", basedir);
yelp_man_populate_tree_for_subdir (section_hash, cbuf, '1');
@@ -564,53 +566,59 @@ yelp_man_push_initial_tree (struct TreeNode *node, GNode *parent)
}
}
-static gchar**
+static GSList *
yelp_man_remove_duplicates_from_manpath (gchar *manpath)
{
- gchar **manpathes = NULL;
- gchar **tmppathes = NULL;
- gint i, j;
-
- if (manpath == NULL)
+ GSList *ret_val = NULL;
+ gchar **tmppathes = NULL;
+ gint i;
+
+ if (manpath == NULL) {
return NULL;
+ }
g_strstrip (manpath);
- if (manpath[0] == '\0')
+
+ if (manpath[0] == '\0') {
return NULL;
+ }
tmppathes = g_strsplit (manpath, ":", -1);
- for (i = 1; tmppathes[i]; i++);
- manpathes = (char **) g_malloc0(i * sizeof(char **));
+ ret_val = g_slist_prepend (ret_val, g_strdup (tmppathes[0]));
- 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])))
+ for (i = 1; tmppathes[i]; i++) {
+ GSList *l;
+ gboolean found = FALSE;
+
+ for (l = ret_val; l; l = l->next) {
+ if (g_ascii_strcasecmp ((gchar *) l->data,
+ tmppathes[i]) == 0) {
+ found = TRUE;
break;
+ }
}
- if (manpathes[j] == NULL) {
- manpathes[j] = g_strdup (tmppathes[i]);
- manpathes[j + 1] = NULL;
- }
+
+ if (!found) {
+ ret_val = g_slist_prepend (ret_val,
+ g_strdup (tmppathes[i]));
+ }
}
g_strfreev (tmppathes);
- return manpathes;
+ return ret_val;
}
gboolean
yelp_man_init (GNode *tree, GList **index)
{
- gchar *manpath = NULL;
- gchar **manpathes = NULL;
- GHashTable *section_hash;
- struct TreeNode *root;
- struct stat stat_dir1;
- struct stat stat_dir2;
- int i;
+ gchar *manpath = NULL;
+ GSList *manpathes = NULL;
+ GHashTable *section_hash;
+ struct TreeNode *root;
+ struct stat stat_dir1;
+ struct stat stat_dir2;
/* Go through all the man pages:
* 1. Determine the places to search (run 'manpath').
@@ -622,22 +630,36 @@ yelp_man_init (GNode *tree, GList **index)
section_hash = g_hash_table_new (g_str_hash, g_str_equal);
root = yelp_man_make_initial_tree (&root_data, section_hash);
-
+
if (g_spawn_command_line_sync ("manpath", &manpath, NULL, NULL, NULL)) {
+ gint i;
+ gchar **tmppathes;
+
g_strstrip (manpath);
- manpathes = g_strsplit (manpath, ":", -1);
+ tmppathes = g_strsplit (manpath, ":", -1);
+
+ for (i = 0; tmppathes[i]; ++i) {
+ manpathes = g_slist_prepend (manpathes, tmppathes[i]);
+ }
+
+ g_free (tmppathes);
} 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);
}
+
g_free (manpath);
if (manpathes != NULL) {
- for (i = 0; manpathes[i]; i++) {
- yelp_man_populate_tree_for_dir (section_hash,
- manpathes[i]);
+ GSList *l;
+
+ for (l = manpathes; l; l = l->next) {
+ yelp_man_populate_tree_for_dir (section_hash,
+ (gchar *) l->data);
}
+
+ g_slist_foreach (manpathes, (GFunc) g_free, NULL);
+ g_slist_free (manpathes);
} else {
stat ("/usr/man", &stat_dir1);
stat ("/usr/share/man", &stat_dir2);
@@ -663,7 +685,5 @@ yelp_man_init (GNode *tree, GList **index)
*index = g_list_concat (*index, man_index);
- g_strfreev (manpathes);
-
return TRUE;
}
diff --git a/src/yelp-reader.c b/src/yelp-reader.c
index 6e19e8d6..f87ab6b9 100644
--- a/src/yelp-reader.c
+++ b/src/yelp-reader.c
@@ -761,19 +761,18 @@ yelp_reader_start (YelpReader *reader, YelpURI *uri)
if (str_uri && *str_uri) {
str_uri = look_for_html_help_file (str_uri);
new_uri = yelp_uri_new (str_uri);
- }
- else
+ } else {
new_uri = yelp_uri_copy (uri);
+ }
g_free (str_uri);
if (yelp_uri_get_type (new_uri) == YELP_URI_TYPE_DOCBOOK_XML ||
yelp_uri_get_type (new_uri) == YELP_URI_TYPE_DOCBOOK_SGML) {
+ /* check if there is HTML cache. If found, use the HTML cache. */
document = yelp_cache_lookup (yelp_uri_get_path (new_uri));
}
-
- /* check if there is HTML cache. If found, use the HTML cache. */
else if (yelp_uri_get_type (new_uri) == YELP_URI_TYPE_HTML) {
GnomeVFSHandle *handle;
GnomeVFSResult result;
@@ -801,14 +800,16 @@ yelp_reader_start (YelpReader *reader, YelpURI *uri)
break;
}
- if (html_buffer == NULL)
+ if (html_buffer == NULL) {
html_buffer = g_string_new (g_strndup (buffer,
- n));
- else
+ n));
+ } else {
html_buffer = g_string_append (html_buffer,
g_strndup (buffer,
- n));
+ n));
+ }
}
+
document = html_buffer->str;
g_string_free (html_buffer, FALSE);
}