After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 331828 - off-by-one when parsing 'apropos' output in yelp-search-pager.c
off-by-one when parsing 'apropos' output in yelp-search-pager.c
Status: RESOLVED FIXED
Product: yelp
Classification: Applications
Component: XSLT
2.13.x
Other All
: Normal major
: ---
Assigned To: Yelp maintainers
Yelp maintainers
Depends on:
Blocks:
 
 
Reported: 2006-02-20 00:01 UTC by Andreas Kohn
Modified: 2010-04-29 22:38 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14



Description Andreas Kohn 2006-02-20 00:01:24 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);

--
Comment 1 Don Scorgie 2006-02-27 19:02:17 UTC
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)
Comment 2 Joe Marcus Clarke 2006-05-02 23:10:33 UTC
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.