summaryrefslogtreecommitdiffstats
path: root/kioslave
diff options
context:
space:
mode:
authorFrancois Andriot <francois.andriot@free.fr>2013-05-05 04:50:18 +0200
committerSlávek Banko <slavek.banko@axis.cz>2013-05-05 05:09:58 +0200
commita8fe98ad7575fd44a4b8ae674f51bd328f6cda9a (patch)
treeb5b706c8841eadbb44d8024a91a383bcbe9a39e0 /kioslave
parent770eda3afd42b8c3c9ce2775cd6d4a4ef39a6750 (diff)
downloadtdebase-a8fe98ad7575fd44a4b8ae674f51bd328f6cda9a.tar.gz
tdebase-a8fe98ad7575fd44a4b8ae674f51bd328f6cda9a.zip
Added support for makewhatis in tdeio-man
This resolves Bug 714 (cherry picked from commit 2b6bc47289c47d4c5322ac25b688d0b3027a31d0)
Diffstat (limited to 'kioslave')
-rw-r--r--kioslave/man/kio_man.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/kioslave/man/kio_man.cpp b/kioslave/man/kio_man.cpp
index 61f3ef45f..30d8dc551 100644
--- a/kioslave/man/kio_man.cpp
+++ b/kioslave/man/kio_man.cpp
@@ -46,6 +46,8 @@
#include <kfilterbase.h>
#include <kfilterdev.h>
+#include "config.h"
+
using namespace KIO;
MANProtocol *MANProtocol::_self = 0;
@@ -569,6 +571,26 @@ char *MANProtocol::readManPage(const char *_filename)
}
lastdir = filename.left(filename.findRev('/'));
+#ifdef WITH_MAKEWHATIS
+ TQIODevice *fd= KFilterDev::deviceForFile(filename);
+
+ if ( !fd || !fd->open(IO_ReadOnly))
+ {
+ delete fd;
+ return 0;
+ }
+ TQByteArray array(fd->readAll());
+ kdDebug(7107) << "read " << array.size() << endl;
+ fd->close();
+ delete fd;
+
+ if (array.isEmpty())
+ return 0;
+
+ const int len = array.size();
+ buf = new char[len + 4];
+ tqmemmove(buf + 1, array.data(), len);
+#else
myStdStream = TQString::null;
KProcess proc;
/* TODO: detect availability of 'man --recode' so that this can go
@@ -583,6 +605,7 @@ char *MANProtocol::readManPage(const char *_filename)
const int len = cstr.size()-1;
buf = new char[len + 4];
tqmemmove(buf + 1, cstr.data(), len);
+#endif
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
}