summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--config.h.cmake3
-rw-r--r--tdeioslave/man/tdeio_man.cpp23
3 files changed, 36 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0810f94ea..9ff608393 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,6 +269,16 @@ if( BUILD_STARTTDE )
endif()
+##### Determine whether older manpage support is used ##########
+
+if( EXISTS "/usr/sbin/makewhatis" )
+ set( WITH_MAKEWHATIS "1" )
+ message( STATUS "Selected makewhatis for tdeio-man on your system" )
+else()
+ message( STATUS "Selected man-db for tdeio-man on your system" )
+endif()
+
+
##### write configure files #####################
configure_file( config.h.cmake config.h @ONLY )
diff --git a/config.h.cmake b/config.h.cmake
index 3b8dbfa1c..282e3a80d 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -192,3 +192,6 @@
// Defined when wanting ksmserver shutdown debugging timing markers in .xsession-errors
#cmakedefine BUILD_PROFILE_SHUTDOWN 1
+
+// Use makewhatis manpage support
+#cmakedefine WITH_MAKEWHATIS "@WITH_MAKEWHATIS@"
diff --git a/tdeioslave/man/tdeio_man.cpp b/tdeioslave/man/tdeio_man.cpp
index d48fd9746..07636c0a3 100644
--- a/tdeioslave/man/tdeio_man.cpp
+++ b/tdeioslave/man/tdeio_man.cpp
@@ -46,6 +46,8 @@
#include <kfilterbase.h>
#include <kfilterdev.h>
+#include "config.h"
+
using namespace TDEIO;
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;
TDEProcess 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
}