[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: kio-man on Solaris SPARC
From: Markus Keidl <keidl () web ! de>
Date: 2002-10-23 12:37:13
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Hi,
On Mon, 21 Oct 2002, Stephan Kulow wrote:
> .so is supported. Is /usr/man/sman1b/mail.1b a roff page or a docbook page?
> If later, you have a bug there - check read_man_page in kio_man.cpp
attached is a patch (kio-man.patch) that fixes this bug. The check for SGML
pages is now in readManPage. The check is now - again - done by scanning the man
page path for "sman". The detection of the MIME type with KMimeType worked for
some man pages, but not for all. E.g. /usr/man/sman7fs/pcfs.7fs is reported as
text/x-csrc which is wrong.
I attached a second patch (kio-man-man2html.patch) which fixes a problem in
man2html. man2html creates wrong links for sections with more than 2 characters
(it truncates the section after one char), so they didn't work here. In
man:/usr/man/sman3xc/filter.3xc, e.g., there is a link to the newterm man page
which is in section 3XC. The HTML text is "newterm(3XC), but the link goes to
man:/newterm(3), i.e. section 3, and does not work.
The problem with the second patch is that I don't know why the code in man2html
does what it does. Some examples:
(1X) generates a link to section 1 which is OK.
(1XS) generates a link to section 1 which is wrong.
(7FS) generates a link to section 7f which is probably wrong, too Now, all
links I tested work. But why was it that complicated in the first place? Maybe
there was a reason for that, but I don't know. There is actually code in
man2html which sets the section to "\0" if the section name is "XS"!
Regards,
Markus Keidl
["kio-man.patch" (text/plain)]
Index: kio_man.cpp
===================================================================
RCS file: /home2/webcvs/mirror/kdebase/kioslave/man/kio_man.cpp,v
retrieving revision 1.56
diff -u -3 -p -b -u -p -r1.56 kio_man.cpp
--- kio_man.cpp 21 Oct 2002 14:31:34 -0000 1.56
+++ kio_man.cpp 22 Oct 2002 15:37:46 -0000
@@ -402,30 +402,7 @@ void MANProtocol::get(const KURL& url )
else
{
QCString filename=QFile::encodeName(foundPages[0]);
- const char *buf = NULL;
-
- /* Determine mime type of file. If type is text/html, assume that it's
- * SGML and convert it to roff format (used on Solaris). Other
- * possibility: filename.contains("sman", false) */
- QString file_mimetype = KMimeType::findByPath(QString(filename), 0, false)->name();
- if (file_mimetype == "text/html")
- {
- *myStdStream="";
- KProcess proc;
-
- /* Determine path to sgml2roff, if not already done. */
- getProgramPath();
- proc << mySgml2RoffPath << filename;
-
- QApplication::connect(&proc, SIGNAL(receivedStdout (KProcess *, char *, int)),
- this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
- proc.start(KProcess::Block, KProcess::All);
-
- buf = myStdStream->latin1();
- // Does not work (return string is empty): buf = QCString(myStdStream->local8Bit());
- }
- else
- buf = readManPage(filename);
+ char *buf = readManPage(filename);
if (!buf)
{
@@ -454,6 +431,32 @@ char *MANProtocol::readManPage(const cha
{
QCString filename = _filename;
+ char *buf = NULL;
+
+ /* Determine type of man page file by checking its path. Determination by
+ * MIME type with KMimeType doesn't work reliablely. E.g., Solaris 7:
+ * /usr/man/sman7fs/pcfs.7fs -> text/x-csrc : WRONG
+ * If the path name constains the string sman, assume that it's SGML and
+ * convert it to roff format (used on Solaris). */
+ //QString file_mimetype = KMimeType::findByPath(QString(filename), 0, false)->name();
+ if (filename.contains("sman", false)) //file_mimetype == "text/html" || )
+ {
+ *myStdStream="";
+ KProcess proc;
+
+ /* Determine path to sgml2roff, if not already done. */
+ getProgramPath();
+ proc << mySgml2RoffPath << filename;
+
+ QApplication::connect(&proc, SIGNAL(receivedStdout (KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+ proc.start(KProcess::Block, KProcess::All);
+
+ buf = (char*)myStdStream->latin1();
+ // Does not work (return string is empty): buf = QCString(myStdStream->local8Bit());
+ }
+ else
+ {
if (QDir::isRelativePath(filename)) {
kdDebug(7107) << "relative " << filename << endl;
filename = QDir::cleanDirPath(lastdir + "/" + filename).utf8();
@@ -488,10 +491,11 @@ char *MANProtocol::readManPage(const cha
delete fd;
int l = text.length();
- char *buf = new char[l + 4];
+ buf = new char[l + 4];
memcpy(buf + 1, text.data(), l);
buf[0]=buf[l]='\n';
buf[l+1]=buf[l+2]='\0';
+ }
return buf;
}
["kio-man-man2html.patch" (text/plain)]
Index: man2html.cpp
===================================================================
RCS file: /home2/webcvs/mirror/kdebase/kioslave/man/man2html.cpp,v
retrieving revision 1.30
diff -u -3 -p -b -u -p -r1.30 man2html.cpp
--- man2html.cpp 29 Sep 2002 21:31:13 -0000 1.30
+++ man2html.cpp 23 Oct 2002 10:51:59 -0000
@@ -516,11 +516,17 @@ static void add_links(char *c)
if (h!=c) h--;
}
if (isalnum(*h)) {
- char t,sec,subsec, *e;
+ char t,sec, *e;
+ QString subsec;
+ QString fstr(f);
e=h+1;
sec=f[1];
subsec=f[2];
- if ((subsec=='X' && f[3]!=')')|| subsec==')') subsec='\0';
+ int index = fstr.find(')', 2);
+ if (index != -1)
+ subsec = fstr.mid(2, index - 2);
+ else // No closing ')' found, take first character as subsection.
+ subsec = fstr.mid(2, 1);
while (h>c && (isalnum(h[-1]) || h[-1]=='_'
|| h[-1]==':' || h[-1]=='-' || h[-1]=='.'))
h--;
@@ -531,10 +537,10 @@ static void add_links(char *c)
t=*e;
*e='\0';
QCString str;
- if (subsec)
- str.sprintf("<A HREF=\"man:/%s(%c%c)\">%s</A>", h, sec, \
tolower(subsec), h);
- else
+ if (subsec.isEmpty())
str.sprintf("<A HREF=\"man:/%s(%c)\">%s</A>", h, sec, h);
+ else
+ str.sprintf("<A HREF=\"man:/%s(%c%s)\">%s</A>", h, sec, \
subsec.lower().latin1(), h); output_real(str.data());
*e=t;
c=e;
[Attachment #7 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic