(*** This bug was imported into bugs.kde.org ***) Package:kio-man Version:KDE 3.0.1 Severity:normal Manual pages on those systems can have not only nonstandard but also very long section names (sysevent_free(3SYSEVENT) or libpicltree(3PICLTREE) anyone?). Problem is that the ioslave only recognises 1-digit or 1-digit+1-letter section names for highlighting and indexing (and even then only a limited set of 1-letter suffixes) so pages in other sections are inaccessible. The keyword index on these systems is also in a different file ("windex") with a slightly different format. The patch below attempts to fix manpage handling on these systems by doing: 1. Look for the keyword index in "windex" as a last resort and if that file is used convert the lines read from it into the "whatis" format before processing. 2. Lowercase section names to ensure that they are in the correct case for the filesystem even if the URL says uppercase. 3. Get the list of valid sections by enumerating the subdirectories under each manpage directory rather than having a built-in list (only if MANSECTS is not set in the user's environment). 4. Canonicalise the path for each manpage directory before adding it to the internal path list to avoid spurious duplicates (e.g. offering 2 choices /usr/share/man/manS/page(S) and /usr/man/manS/page(S) if /usr/man is a symlink to /usr/share/man). 5. Recognise long section names in the HTML converter also incorporating bugfix for 44758. Apologies for the patch bring so long and involved but there were lots of things that needed fixing in this ioslave and hopefully it was easier to do them all together... ----------------------------------------------------------------- --- kdebase/kioslave/man/kio_man.cpp.origMon Jul 8 10:37:51 2002 +++ kdebase/kioslave/man/kio_man.cppTue Jul 9 08:54:47 2002 @@ -1328 +13220 @@ QString l; while (!t.eof()) { - l = t.readLine(); - int pos = l.find(mark); + l = t.readLine(); + int pos; + + if (name.right(7) == "/windex")// special for SunOS/SVR4 + { + l = l.simplifyWhiteSpace(); + pos = l.find(" ("); + if (pos != -1) + { + l = l.left(pos).replace(QRegExp(" ")"") + l.mid(pos); + } + } + + pos = l.find(mark); if (pos != -1) { QString names = l.left(pos); @@ -1587 +1707 @@ // Supplementary places for whatis databases man_dirs << "/var/cache/man"; QStringList names; - names << "whatis.db" << "whatis"; + names << "whatis.db" << "whatis" << "windex"; QString mark = " (" + section + ") - "; for ( QStringList::ConstIterator it_dir = man_dirs.begin(); @@ -2457 +2577 @@ // // Section given as argument // - sect_list += section; + sect_list += section.lower(); } else { // @@ -2637 +2757 @@ while ( (ep = ::readdir( dp )) != 0L ) { QString file = QFile::decodeName( ep->d_name ); if ( file.startsWith( man ) ) - sect_list += file.mid(3); + sect_list += file.mid(3).lower(); } ::closedir( dp ); @@ -59320 +60533 @@ { QStringList l; - for (QStringList::ConstIterator it = section_names.begin(); - it != section_names.end(); ++it) + for (QStringList::ConstIterator dir = dirs.begin(); + dir != dirs.end(); ++dir) { - for (QStringList::ConstIterator dir = dirs.begin(); - dir != dirs.end(); ++dir) +DIR *dp = ::opendir( QFile::encodeName( *dir ) ); +if ( !dp ) continue; + +struct dirent *ep; +QString man = QString("man"); + +while ( (ep = ::readdir( dp )) != 0L ) +{ + QString file = QFile::decodeName( ep->d_name ); + if ( file.startsWith( man ) ) { -QDir d((*dir)+"/man"+(*it)); -if (d.exists()) +QString sect = file.mid(3).lower(); +QChar ch = sect.at(0); +if ( ch.isDigit() && ch != '0' ) { - l << *it; - break; +if ( l.findIndex( sect ) == -1 ) l << sect; } } +} + +::closedir( dp ); } + + l.sort(); return l; } @@ -6456 +67025 @@ } +static void add_dir(const QString &dirQStringList &mp) +{ + struct stat sbuf; + + if ( dir.isEmpty() ) return; + + QDir d = dir; + QString rp = d.canonicalPath(); + if ( rp.isEmpty() ) return; +// Add dir to the man path if... + if ( mp.findIndex( rp ) == -1 &&// not already in path + ::stat( QFile::encodeName( rp ) &sbuf ) == 0// and exists + && S_ISDIR( sbuf.st_mode ) )// and is a directory + { +mp += rp; + } +} + + void MANProtocol::checkManPaths() { static bool inited = false; @@ -82919 +87310 @@ it != path_list_env.end(); it++ ) { - struct stat sbuf; - QString dir = (*it); - - if ( !dir.isEmpty() ) { - // Add dir to the man path if it exists - if ( m_manpath.findIndex( dir ) == -1 ) { - if ( ::stat( QFile::encodeName( dir ) &sbuf ) == 0 - && S_ISDIR( sbuf.st_mode ) ) - { - m_manpath += dir; - } - } + if ( !dir.isEmpty() ) +{ + add_dir( dir m_manpath ); } else { // Insert constructed path ($MANPATH was empty or @@ -85219 +88712 @@ it2++ ) { dir = (*it2); - - if ( !dir.isEmpty() ) { - if ( m_manpath.findIndex( dir ) == -1 ) { - if ( ::stat( QFile::encodeName( dir ) &sbuf ) == 0 - && S_ISDIR( sbuf.st_mode ) ) - { - m_manpath += dir; - } - } - } +add_dir( dir m_manpath ); } } } + + kdDebug(7107) << "final m_manpath = " << m_manpath.join(":") << endl; /* sections are not used // Sections --- kdebase/kioslave/man/man2html.cpp.cvsFri Jul 5 13:50:32 2002 +++ kdebase/kioslave/man/man2html.cppMon Jul 8 12:57:04 2002 @@ -4396 +4397 @@ int ijnr; char *f *g*h; char *idtest[6]; /* url mailto www ftp manpage */ + bool ok; out_length+=strlen(c); /* search for (section) */ nr=0; @@ -50210 +50324 @@ f=idtest[j]; /* check section */ g=strchr(f')'); - if (g && f-g<6 && (isalnum(f[-1]) || f[-1]=='>') && -((isdigit(f[1]) && f[1]!='0' && - (f[2]==')' || (isalpha(f[2]) && f[3]==')') || f[2]=='X')) || - (f[2]==')' && (f[1]=='n' || f[1]=='l')))) { + if (g!=NULL && (g-f)<12 && (isalnum(f[-1]) || f[-1]=='>') && + isdigit(f[1]) && f[1]!='0') + { +ok = TRUE; +h = f+2; +while (h<g) +{ + if (!isalpha(*h++)) + { +ok = FALSE; +break; + } +} + } + else ok = FALSE; + + if (ok) + { /* this might be a link */ h=f-1; /* skip html makeup */ @@ -51411 +52913 @@ if (h!=c) h--; } if (isalnum(*h)) { - char tsecsubsec *e; - e=h+1; + char tsec; + char *e=h+1; sec=f[1]; - subsec=f[2]; - if ((subsec=='X' && f[3]!=')')|| subsec==')') subsec='\0'; + t = *g; + *g = '\0'; + QCString subsec = f+2; + *g = t; while (h>c && (isalnum(h[-1]) || h[-1]=='_' || h[-1]==':' || h[-1]=='-' || h[-1]=='.')) h--; @@ -52910 +5467 @@ t=*e; *e='\0'; QCString str; - if (subsec) - str.sprintf("<A HREF=\"man:/%s(%c%c))\">%s</A>" h sec tolower(subsec) h); - else - str.sprintf("<A HREF=\"man:/%s(%c)\">%s</A>" h sec h); + str.sprintf("<A HREF=\"man:/%s(%c%s)\">%s</A>" h sec subsec.lower().data() h); output_real(str.data()); *e=t; c=e; ----------------------------------------------------------------- -- Jonathan Marten SCM Team Engineer VSP Bracknell UK jonathan.marten@uk.sun.com Sun Microsystems "Progress is not expedited by frequent requests for progress reports"
looks good, will check that later.
Coolo? Do you approve of that patch? :)
Subject: Re: handle Solaris/SVR4 manpages (with long section names) and keyword index On Samstag, 22. Februar 2003 10:07, you wrote: > ------- You are receiving this mail because: ------- > You are the assignee for the bug, or are watching the assignee. > > http://bugs.kde.org/show_bug.cgi?id=45309 > > > > > ------- Additional Comments From staikos@kde.org 2003-02-22 10:07 ------- > Coolo? Do you approve of that patch? :) Well, if you check the patch, you'll notice that it misses commas. And the code has changed too much so it's real work. But the bug is still ASSIGNED Greetings, Stephan
We did discuss the patch on kde-devel some time ago. The consensus was that since it was a complex change, the patch had been badly mangled by the bug database, and also someone else had submitted some other changes to the same area, this bug would be put aside and I'd look at reimplementing the fixes if necessary once KDE3.1 was out (I suppose that means now). So I'd be happy if this bug was closed as will-not-fix.
Subject: Re: handle Solaris/SVR4 manpages (with long section names) and keyword index Am Monday 24 February 2003 10:28 schrieben Sie: > ------- You are receiving this mail because: ------- > You are the assignee for the bug, or are watching the assignee. > > http://bugs.kde.org/show_bug.cgi?id=45309 > > > > > ------- Additional Comments From jonathan.marten@uk.sun.com 2003-02-24 10:28 ------- > We did discuss the patch on kde-devel some time ago. The consensus was that since it was a > complex change, the patch had been badly mangled by the bug database, and also someone else > had submitted some other changes to the same area, this bug would be put aside and I'd look at > reimplementing the fixes if necessary once KDE3.1 was out (I suppose that means now). > > So I'd be happy if this bug was closed as will-not-fix. > I leave it open as reminder :) Gruss, Stephan
Jonathan, any news? I don't remember any.
Updated long section names patch provided in bug 74925. Other fixes in this patch are either already implemented or would be impossible to patch into current sources. Suggest this bug is closed as WONTFIX.
*** Bug 74925 has been marked as a duplicate of this bug. ***
CVS commit by coolo: applying fix for 74925 CCMAIL: 45309-done@bugs.kde.org M +19 -4 man2html.cpp 1.41.2.1 --- kdebase/kioslave/man/man2html.cpp #1.41:1.41.2.1 @@ -620,4 +620,5 @@ static void add_links(char *c) char *f, *g,*h; char *idtest[6]; /* url, mailto, www, ftp, manpage */ + bool ok; out_length+=strlen(c); /* search for (section) */ @@ -683,8 +684,22 @@ static void add_links(char *c) /* check section */ g=strchr(f,')'); - if (g && f-g<6 && (isalnum(f[-1]) || f[-1]=='>') && - ((isdigit(f[1]) && f[1]!='0' && - (f[2]==')' || (isalpha(f[2]) && f[3]==')') || f[2]=='X')) || - (f[2]==')' && (f[1]=='n' || f[1]=='l')))) { + if (g!=NULL && (g-f)<12 && (isalnum(f[-1]) || f[-1]=='>') && + isdigit(f[1]) && f[1]!='0') + { + ok = TRUE; + h = f+2; + while (h<g) + { + if (!isalpha(*h++)) + { + ok = FALSE; + break; + } + } + } + else ok = FALSE; + + if (ok) + { /* this might be a link */ h=f-1;