Bug 471784 - Problem with makewhatis dans command name with dash
Summary: Problem with makewhatis dans command name with dash
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: man
Version: 9
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-11-16 09:11 UTC by pmarion
Modified: 2010-06-22 12:27 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-11-19 10:35:51 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description pmarion 2008-11-16 09:11:15 UTC
Description of problem:

When makewhatis constructs its database, there is a problem if the command name contain a dash.
Exemple

with the command ssh-agent the result in /var/cache/man/whatis is 

ssh [] (1) - agent - xxxxxxxxxxxxxxxx
instead of
ssh-agent (1) - xxxxxxxxxxxxxxxx

And when we use a command like 'apropos agent' we get 
ssh [] (1) - agent - xxxxxxxxxxxxxxxx

Comment 1 pmarion 2008-11-16 09:29:34 UTC
In the script makewhatis the problem seems to be located there
if ($0 ~ progname"-") {  # Fix old cat pages
  sub(progname"-", progname" - ");
}

I tried to replace 
sub(progname"-", progname"---");
I get
ssh---agent []       (1)  - authentication agent

It's not the real fix, but a way to locate where could be the solution.

Comment 2 Ivana Varekova 2008-11-19 10:35:51 UTC
Thanks, fixed in man-1.6f-12.fc11.

Comment 3 Philip Spencer 2009-02-05 17:50:07 UTC
This is actually the wrong fix. The problem is not in the lines of code

if ($0 ~ progname"-") {  # Fix old cat pages
  sub(progname"-", progname" - ");
}

-- those lines of code are fine and can be uncommented again.

The actual cause of the problem is that "progname" is set to be the EMPTY STRING.

If it were correctly set to the program name, the above code would be fine and would change things like "ssh-agent-description here" to
"ssh-agent - description here".

However, because it is empty, it causes the observed problem.

That is also why running "whatis man" (for example) gives

man []               (1)  - format and display the on-line manual pages

with the empty string in square brackets -- which should not be there!

The real cause of both these problems is earlier:

              use_zcat = match(filename,"\\.Z$") ||
               match(filename,"\\.z$") || match(filename,"\\.gz$");
              if (!use_zcat)
                use_bzcat = match(filename,"\\.bz2");
  ****===>    if(!use_bzcat)
                use_lzcat = match(filename,"\\.lzma");
              if (use_zcat || use_bzcat || use_lzcat ) {
                filename_no_gz = substr(filename, 0, RSTART - 1);
              } else {
                filename_no_gz = filename;
              }
              match(filename_no_gz, "/[^/]+$");
              progname = substr(filename, RSTART + 1, RLENGTH - 1);

The line marked ***====> is the problem. It should be replaced with

    if (!use_zcat && ! use_bzcat)

As it stands, with gzipped manpages, z_cat is set to true by the first line, which also sets RSTART to the beginning of the .gz suffix. Then the use_bzcat assignment is (correctly) skipped, leaving use_bzcat false. 

Then the problem line sees that use_bzcat is false and tries to assign use_lzcat. In so doing it runs another match command, which fails, and which overwrites RSTART and RLENGTH to zero. The final line then sets progname to the empty string.

In summary:

The fix is to put back in the lines that were commented out in the first fix attempt, and instead to alter the single line marked with ***====> above.

Can somebody with write-access to this bug please reopen it?

Thanks!

Comment 4 Tim Landscheidt 2010-06-22 12:27:06 UTC
For anyone who stumbles here like me: It wasn't fixed until Fedora 11's man-1.6f-21.fc11 (including) at least, Fedora 13's seems to incorporate Philip's patch.


Note You need to log in before you can comment on or make changes to this bug.