summaryrefslogtreecommitdiffstats
path: root/kioslave/man
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
commit10e41144596fc9ced40fc349d9ecd099b1c2ea19 (patch)
tree88ab04e475ff5a4cd889cb082f5760b6e0bf5e4e /kioslave/man
parent4aed2c8219774f5d797760606b8489a92ddc5163 (diff)
downloadtdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.tar.gz
tdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.zip
Initial import of Trinity 3.5.11 to kdebase
Extends krandrtray, adds iccconfig kcontrol module, adds run dialog autocomplete and lots of bugfixes Will need to check for commit warnings and repair as encountered Also needs full compile test git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1061475 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslave/man')
-rw-r--r--kioslave/man/kio_man.cpp35
-rw-r--r--kioslave/man/kio_man.h1
-rw-r--r--kioslave/man/man2html.cpp25
3 files changed, 32 insertions, 29 deletions
diff --git a/kioslave/man/kio_man.cpp b/kioslave/man/kio_man.cpp
index 0511a165d..068287b7e 100644
--- a/kioslave/man/kio_man.cpp
+++ b/kioslave/man/kio_man.cpp
@@ -517,6 +517,11 @@ void MANProtocol::slotGetStdOutput(KProcess* /* p */, char *s, int len)
myStdStream += QString::fromLocal8Bit(s, len);
}
+void MANProtocol::slotGetStdOutputUtf8(KProcess* /* p */, char *s, int len)
+{
+ myStdStream += QString::fromUtf8(s, len);
+}
+
char *MANProtocol::readManPage(const char *_filename)
{
QCString filename = _filename;
@@ -564,24 +569,20 @@ char *MANProtocol::readManPage(const char *_filename)
}
lastdir = filename.left(filename.findRev('/'));
- QIODevice *fd= KFilterDev::deviceForFile(filename);
-
- if ( !fd || !fd->open(IO_ReadOnly))
- {
- delete fd;
- return 0;
- }
- QByteArray array(fd->readAll());
- kdDebug(7107) << "read " << array.size() << endl;
- fd->close();
- delete fd;
-
- if (array.isEmpty())
- return 0;
-
- const int len = array.size();
+ myStdStream = QString::null;
+ KProcess proc;
+ /* TODO: detect availability of 'man --recode' so that this can go
+ * upstream */
+ proc << "man" << "--recode" << "UTF-8" << filename;
+
+ QApplication::connect(&proc, SIGNAL(receivedStdout (KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutputUtf8(KProcess *, char *, int)));
+ proc.start(KProcess::Block, KProcess::All);
+
+ const QCString cstr=myStdStream.utf8();
+ const int len = cstr.size()-1;
buf = new char[len + 4];
- qmemmove(buf + 1, array.data(), len);
+ qmemmove(buf + 1, cstr.data(), len);
buf[0]=buf[len]='\n'; // Start and end with a end of line
buf[len+1]=buf[len+2]='\0'; // Two NUL characters at end
}
diff --git a/kioslave/man/kio_man.h b/kioslave/man/kio_man.h
index f571082db..d1d924ce0 100644
--- a/kioslave/man/kio_man.h
+++ b/kioslave/man/kio_man.h
@@ -61,6 +61,7 @@ public:
private slots:
void slotGetStdOutput(KProcess*, char*, int);
+ void slotGetStdOutputUtf8(KProcess*, char*, int);
private:
void checkManPaths();
diff --git a/kioslave/man/man2html.cpp b/kioslave/man/man2html.cpp
index 725fba36a..b502e8edc 100644
--- a/kioslave/man/man2html.cpp
+++ b/kioslave/man/man2html.cpp
@@ -705,17 +705,18 @@ static void add_links(char *c)
}
int i,j,nr;
- char *f, *g,*h;
+ char *f, *h;
+ char *g;
const int numtests=6; // Nmber of tests
char *idtest[numtests]; // url, mailto, www, ftp, manpage, C header file
bool ok;
/* search for (section) */
nr=0;
idtest[0]=strstr(c+1,"://");
- idtest[1]=strchr(c+1,'@');
+ idtest[1]=(char*)strchr(c+1,'@');
idtest[2]=strstr(c,"www.");
idtest[3]=strstr(c,"ftp.");
- idtest[4]=strchr(c+1,'(');
+ idtest[4]=(char*)strchr(c+1,'(');
idtest[5]=strstr(c+1,".h&gt;");
for (i=0; i<numtests; ++i) nr += (idtest[i]!=NULL);
while (nr) {
@@ -770,7 +771,7 @@ static void add_links(char *c)
case 4: /* manpage */
f=idtest[j];
/* check section */
- g=strchr(f,')');
+ g=(char*)strchr(f,')');
// The character before f must alphanumeric, the end of a HTML tag or the end of a &nbsp;
if (g!=NULL && f>c && (g-f)<12 && (isalnum(f[-1]) || f[-1]=='>' || ( f[-1] == ';' ) ) &&
isdigit(f[1]) && f[1]!='0' && ((g-f)<=2 || isalpha(f[2])))
@@ -936,10 +937,10 @@ static void add_links(char *c)
}
nr=0;
if (idtest[0] && idtest[0]<=c) idtest[0]=strstr(c+1,"://");
- if (idtest[1] && idtest[1]<=c) idtest[1]=strchr(c+1,'@');
+ if (idtest[1] && idtest[1]<=c) idtest[1]=(char*)strchr(c+1,'@');
if (idtest[2] && idtest[2]<c) idtest[2]=strstr(c,"www.");
if (idtest[3] && idtest[3]<c) idtest[3]=strstr(c,"ftp.");
- if (idtest[4] && idtest[4]<=c) idtest[4]=strchr(c+1,'(');
+ if (idtest[4] && idtest[4]<=c) idtest[4]=(char*)strchr(c+1,'(');
if (idtest[5] && idtest[5]<=c) idtest[5]=strstr(c+1,".h&gt;");
for (i=0; i<numtests; i++) nr += (idtest[i]!=NULL);
}
@@ -3714,8 +3715,8 @@ static char *scan_request(char *c)
char* font[2] = { "B", "R" };
c+=j;
if (*c=='\n') c++;
- char *eol=strchr(c,'\n');
- char *semicolon=strchr(c,';');
+ char *eol=(char*)strchr(c,'\n');
+ char *semicolon=(char*)strchr(c,';');
if ((semicolon!=0) && (semicolon<eol)) *semicolon=' ';
sl=fill_words(c, wordlist, &words, true, &c);
@@ -4338,7 +4339,7 @@ static char *scan_request(char *c)
case REQ_Bl: // mdoc(7) "Begin List"
{
char list_options[NULL_TERMINATED(MED_STR_MAX)];
- char *nl = strchr(c,'\n');
+ char *nl = (char*)strchr(c,'\n');
c=c+j;
if (dl_set[itemdepth])
/* These things can nest. */
@@ -4519,7 +4520,7 @@ static char *scan_request(char *c)
case REQ_Bd: /* mdoc(7) */
{ /* Seems like a kind of example/literal mode */
char bd_options[NULL_TERMINATED(MED_STR_MAX)];
- char *nl = strchr(c,'\n');
+ char *nl = (char*)strchr(c,'\n');
c=c+j;
if (nl)
strlimitcpy(bd_options, c, nl - c, MED_STR_MAX);
@@ -4877,8 +4878,8 @@ static char *scan_request(char *c)
}
else if (!mandoc_name_count)
{
- const char *nextbreak = strchr(c, '\n');
- const char *nextspace = strchr(c, ' ');
+ char *nextbreak = (char*)strchr(c, '\n');
+ char *nextspace = (char*)strchr(c, ' ');
if (nextspace < nextbreak)
nextbreak = nextspace;