fix another crash in the info parser

This commit is contained in:
Matthias Clasen 2007-04-19 02:54:20 +00:00
parent fb9904313d
commit 1715b1ed06
4 changed files with 146 additions and 1 deletions

View File

@ -0,0 +1,20 @@
--- yelp-2.18.1/src/yelp-info-parser.c.info-gnutls 2007-04-18 22:38:23.000000000 -0400
+++ yelp-2.18.1/src/yelp-info-parser.c 2007-04-18 22:38:30.000000000 -0400
@@ -184,10 +184,16 @@
filename = find_info_part (items[0], file);
str = open_info_file (filename);
if (!str) {
- return NULL;
+ g_strfreev (items);
+ continue;
}
pages = g_strsplit (str, "", 2);
g_free (str);
+ if (!pages[1]) {
+ g_strfreev (items);
+ g_strfreev (pages);
+ continue;
+ }
offset = atoi(items[1]);
plength = strlen(pages[1]);

View File

@ -0,0 +1,96 @@
--- yelp-2.18.1/src/yelp-man-parser.c.man-xrefs 2007-04-18 13:33:14.000000000 -0400
+++ yelp-2.18.1/src/yelp-man-parser.c 2007-04-18 13:33:19.000000000 -0400
@@ -339,6 +339,20 @@
else
parser->ins = parser_append_node (parser, b);
+ if (ptr->next) {
+ gchar *tmp = ptr->next->data;
+
+ if (tmp[0] == '(' && g_ascii_isdigit (tmp[1]) &&
+ (tmp[2] == ')' || (g_ascii_isalpha (tmp[2]) && tmp[3] == ')'))) {
+ tmp = g_strconcat (ptr->data, " ", tmp, NULL);
+ parser_append_given_text_handle_escapes (parser, tmp, TRUE);
+ g_free (tmp);
+ parser->ins = parser->ins->parent;
+ ptr = ptr->next->next;
+ continue;
+ }
+ }
+
parser_append_given_text_handle_escapes (parser, ptr->data, TRUE);
parser->ins = parser->ins->parent;
@@ -1554,15 +1568,18 @@
}
else if ((make_links) && (*ptr == '(')) {
gchar *space_pos;
- gchar *tmp_cur;
gchar *url;
gchar c;
+ gchar *name_end;
+ gchar *num_start;
+ gchar *num_end;
space_pos = ptr;
while (space_pos != anc && *(space_pos - 1) == ' ') {
space_pos--;
}
+ name_end = space_pos;
while (space_pos != anc && *(space_pos - 1) != ' ') {
space_pos--;
@@ -1570,13 +1587,18 @@
if (space_pos != ptr &&
g_ascii_isdigit(*(ptr+1)) &&
- *(ptr+2) == ')') {
-
+ (*(ptr+2) == ')' || (g_ascii_isalpha (*(ptr+2)) && *(ptr+3) == ')'))) {
+ num_start = ptr;
+ if (*(ptr+2) == ')')
+ num_end = ptr + 2;
+ else
+ num_end = ptr + 3;
+
+ g_print ("text %s\n", anc);
ptr+=3;
parser_ensure_P (parser);
- tmp_cur = ptr;
ptr = space_pos;
c = (*ptr);
@@ -1584,13 +1606,15 @@
parser_append_given_text (parser, anc);
*ptr = c;
anc = ptr;
+ ptr = num_start;
- ptr = tmp_cur;
-
- c = *(ptr);
- *(ptr) = '\0';
- url = g_strdup_printf ("man:%s(%c)", anc, *(ptr - 1));
+ c = *name_end;
+ *name_end = '\0';
+ *num_end = '\0';
+ g_print ("name part %s, num %s\n", anc, num_start + 1);
+ url = g_strdup_printf ("man:%s(%s)", anc, num_start + 1);
+ g_print ("link %s\n", url);
parser->ins = parser_append_node (parser, "UR");
parser->ins = parser_append_node (parser, "URI");
@@ -1600,7 +1624,8 @@
parser_append_given_text (parser, anc);
parser->ins = parser->ins->parent;
- *(ptr) = c;
+ *name_end = c;
+ *num_end = ')';
anc = ptr;
g_free (url);

View File

@ -0,0 +1,16 @@
--- yelp-2.18.1/src/yelp-utils.c.posix-man 2007-04-18 12:51:28.000000000 -0400
+++ yelp-2.18.1/src/yelp-utils.c 2007-04-18 12:51:32.000000000 -0400
@@ -807,8 +807,11 @@
if ((cur = strchr (path, ')')))
man_num = g_strndup (path, cur - path);
if (man_num[0]) {
- man_dir = g_new (gchar, 5);
- g_snprintf (man_dir, 5, "man%c", man_num[0]);
+ man_dir = g_new (gchar, 6);
+ if (man_num[1] == 'p')
+ g_snprintf (man_dir, 6, "man%cp", man_num[0]);
+ else
+ g_snprintf (man_dir, 5, "man%c", man_num[0]);
}
} else {
man_name = g_strdup (path);

View File

@ -19,7 +19,7 @@
Summary: A system documentation reader from the Gnome project
Name: yelp
Version: 2.18.1
Release: 2%{?dist}
Release: 3%{?dist}
Source: http://ftp.gnome.org/pub/GNOME/sources/yelp/2.18/%{name}-%{version}.tar.bz2
URL: http://live.gnome.org/Yelp
# http://bugzilla.gnome.org/show_bug.cgi?id=319096
@ -30,6 +30,12 @@ Patch3: yelp-2.15.91-use-pango.patch
Patch5: yelp-2.16.0-apropos.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=430365
Patch6: yelp-2.18.1-info-bc-crash.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=431077
Patch7: yelp-2.18.1-posix-man.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=431078
Patch8: yelp-2.18.1-man-xrefs.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=430365
Patch9: yelp-2.18.1-info-gnutls.patch
License: GPL
Group: Applications/System
@ -88,6 +94,9 @@ one central tool.
%patch3 -p1 -b .use-pango
%patch5 -p1 -b .apropos
%patch6 -p1 -b .info-bc-crash
%patch7 -p1 -b .posix-man
%patch8 -p1 -b .man-xrefs
%patch9 -p1 -b .info-gnutls
%build
%configure \
@ -152,6 +161,10 @@ update-desktop-database &> /dev/null ||:
%{_datadir}/yelp
%changelog
* Wed Apr 18 2007 Matthias Clasen <mclasen@redhat.com> - 2.18.1-3
- Improve the man parser a bit
- Fix another crash in the info parser
* Tue Apr 17 2007 Matthias Clasen <mclasen@redhat.com> - 2.18.1-2
- Fix a crash in the info parser (#216308)