summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-01-19 20:04:06 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-01-19 20:04:06 +0000
commit58ff03a45757fbf883176977f2b04b7adb43b0a1 (patch)
tree01db6c699a78ae2c7132b0254265f418d3218939
parent2e577c23b2226b24b322e529a547fcfcff17c4da (diff)
downloadyelp-58ff03a45757fbf883176977f2b04b7adb43b0a1.tar.gz
rewrote to - accept NULL instead of scheme - return the new string instead
2002-01-19 Mikael Hallendal <micke@codefactory.se> * src/yelp-scrollkeeper.c: (ys_strip_scheme): rewrote to - accept NULL instead of scheme - return the new string instead of breaking down the one passed in. - use strstr instead of g_strstr_len with the entire string as len. (ys_parse_doc): - send NULL to ys_strip_scheme since we are not interested in the scheme for now. Also clean up that stuff a bit. - call xmlFree on the xml-strings instead of g_free. - don't free docsource before it's last use :)
-rw-r--r--ChangeLog15
-rw-r--r--src/.cvsignore3
-rw-r--r--src/yelp-scrollkeeper.c48
3 files changed, 42 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index bc1ad679..9eb0df56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-01-19 Mikael Hallendal <micke@codefactory.se>
+
+ * src/yelp-scrollkeeper.c:
+ (ys_strip_scheme): rewrote to
+ - accept NULL instead of scheme
+ - return the new string instead of breaking down the one passed
+ in.
+ - use strstr instead of g_strstr_len with the entire string as
+ len.
+ (ys_parse_doc):
+ - send NULL to ys_strip_scheme since we are not interested in the
+ scheme for now. Also clean up that stuff a bit.
+ - call xmlFree on the xml-strings instead of g_free.
+ - don't free docsource before it's last use :)
+
2002-01-19 Alexander Larsson <alla@lysator.liu.se>
* src/yelp-scrollkeeper.c (ys_strip_scheme):
diff --git a/src/.cvsignore b/src/.cvsignore
index fc6f62a7..e0911c4b 100644
--- a/src/.cvsignore
+++ b/src/.cvsignore
@@ -11,5 +11,6 @@ GNOME_Yelp-*
GNOME_Yelp.h
GNOME_Yelp.server
gnome_yelp_idl_stamp
-
+yelp-marshal.c
+yelp-marshal.h
diff --git a/src/yelp-scrollkeeper.c b/src/yelp-scrollkeeper.c
index 532ba817..5012efe7 100644
--- a/src/yelp-scrollkeeper.c
+++ b/src/yelp-scrollkeeper.c
@@ -57,7 +57,7 @@ static void ys_parse_toc_section (ParseData *data,
const gchar *base_uri);
static gchar * ys_get_xml_docpath (const gchar *command,
const gchar *argument);
-static void ys_strip_scheme (gchar **original_uri,
+static gchar * ys_strip_scheme (gchar *original_uri,
gchar **scheme);
static gboolean
@@ -207,33 +207,28 @@ ys_parse_doc (ParseData *data, GtkTreeIter *parent, xmlNode *xml_node)
gchar *format;
GtkTreeIter *iter;
gchar *docsource;
- gchar *scheme;
-/* gchar *index_location; */
for (cur = xml_node->xmlChildrenNode; cur; cur = cur->next) {
if (!g_strcasecmp (cur->name, "doctitle")) {
xml_str = xmlNodeGetContent (cur);
title = g_strdup (xml_str);
- g_free (xml_str);
+ xmlFree (xml_str);
}
else if (!g_strcasecmp (cur->name, "docomf")) {
xml_str = xmlNodeGetContent (cur);
omf = g_strdup (xml_str);
- g_free (xml_str);
+ xmlFree (xml_str);
}
else if (!g_strcasecmp (cur->name, "docsource")) {
xml_str = xmlNodeGetContent (cur);
- docsource = g_strdup (xml_str);
- ys_strip_scheme(&docsource, &scheme);
+ docsource = ys_strip_scheme (xml_str, NULL);
link = g_strconcat ("ghelp:", docsource, NULL);
- g_free (scheme);
- g_free (docsource);
- g_free (xml_str);
+ xmlFree (xml_str);
}
else if (!g_strcasecmp (cur->name, "docformat")) {
xml_str = xmlNodeGetContent (cur);
format = g_strdup (xml_str);
- g_free (xml_str);
+ xmlFree (xml_str);
}
}
@@ -255,7 +250,7 @@ ys_parse_doc (ParseData *data, GtkTreeIter *parent, xmlNode *xml_node)
g_free (omf);
g_free (link);
g_free (format);
- g_free (docsource);
+ g_free (docsource);
}
static void
@@ -375,22 +370,29 @@ ys_get_xml_docpath (const gchar *command, const gchar *argument)
return xml_location;
}
-static void
-ys_strip_scheme(gchar **original_uri, gchar **scheme)
+static gchar *
+ys_strip_scheme(gchar *original_uri, gchar **scheme)
{
gchar *new_uri;
gchar *point;
- point = g_strstr_len(*original_uri, strlen(*original_uri), ":");
- if (!point)
- {
- *scheme = NULL;
- return;
+ point = strstr (original_uri, ":");
+
+ if (!point) {
+ if (scheme) {
+ *scheme = NULL;
+ }
+
+ return g_strdup (original_uri);
+ }
+
+ if (scheme) {
+ *scheme = g_strndup(original_uri, point - original_uri);
}
- *scheme = g_strndup(*original_uri, point - *original_uri);
- new_uri = g_strdup(point + 1);
- g_free(*original_uri);
- *original_uri = new_uri;
+
+ new_uri = g_strdup (point + 1);
+
+ return new_uri;
}
gboolean