GNOME Bugzilla – Bug 331828
off-by-one when parsing 'apropos' output in yelp-search-pager.c
Last modified: 2010-04-29 22:38:25 UTC
Please describe the problem: [This could be freebsd specific, as the format of apropos output is different) When searching for a manpage in yelp 2.13.x (2.13.4 and 2.13.5 tested), the search result page truncates the manpage name by one character. For example, instead of man:audit, it lists man:audi. This is because apropos on FreeBSD creates output like this: name(section)[,name(section)...] - description Linux (RH9 tested) looks like this: name (section) - description name (section) - description (never saw more than one name on the same line, but can't say for sure) Steps to reproduce: 1. [use FreeBSD, or !linux probably] 2. search for anything in yelp which has a manpage, and more than one result (so that the search results page is displayed) 3. try to click on a manpage link, observe truncated link captions. Actual results: Error message, that the manpage could not be found. The name of the manpage is truncated. Expected results: Manpage opens. Does this happen every time? Yes. Other information: The patch fixes the issue for me: --- src/yelp-search-pager.c.orig Sun Feb 19 18:30:31 2006 +++ src/yelp-search-pager.c Sun Feb 19 18:32:18 2006 @@ -1389,7 +1389,6 @@ before = g_strdup (g_strchomp (line[0])); after = strstr (before, "("); tmp = after; - tmp--; title = g_strndup (before, tmp-before); --
OK, I've fixed this in a slightly different way (a more general way): - tmp = after; - tmp--; + tmp = after; + + while (!g_ascii_isspace(*tmp)) + tmp--; This should work under both linux and *BSD. Closing. 2006-02-27 Don Scorgie <dscorgie@cvs.gnome.org> * src/yelp-search-pager.c: Look for spaces when processing man page search results This stops (at least) FreeBSD off-by-1 errors (bug #331828)
I believe the logic of this fix is inverted. The way it is now, it causes tmp to decrement all the way, making tmp - before negative, and causes yelp to allocate 4 GB of memory to hold the title. I think what you want is: while (g_ascii_isspace(*tmp)) tmp--; Because on FreeBSD, the format looks like: ls(1) BUS_CONFIG_INTR(9) ... Once I remove the '!' searching seems to work as expected.