diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2013-07-29 12:42:16 -0500 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2013-07-29 12:42:16 -0500 |
commit | 14ffd77b37186e7defbc11730c35700fc21e9fbb (patch) | |
tree | 5a1c4c2c9439b419e71b5fbdfd436f3c466a7731 | |
parent | 5a7a258f87bde70c23367a95a3af747379623afd (diff) | |
download | tdebase-14ffd77b37186e7defbc11730c35700fc21e9fbb.tar.gz tdebase-14ffd77b37186e7defbc11730c35700fc21e9fbb.zip |
Update method used to detect man page interface.
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | config.h.cmake | 3 | ||||
-rw-r--r-- | tdeioslave/man/tdeio_man.cpp | 75 | ||||
-rw-r--r-- | tdeioslave/man/tdeio_man.h | 1 |
4 files changed, 46 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 932f0d313..5b0818996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,15 +271,6 @@ 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() - ##### Checks for a distribution-specific 1st menu item, generally a control center if(EXISTS "/usr/share/applications/YaST.desktop") set( KICKOFF_DIST_CONFIG_SHORTCUT1 "/usr/share/applications/YaST.desktop" ) diff --git a/config.h.cmake b/config.h.cmake index 7cb3aa1fc..f5b429ed0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -196,9 +196,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@" - // Kickoff menu #cmakedefine KICKOFF_DIST_CONFIG_SHORTCUT1 "@KICKOFF_DIST_CONFIG_SHORTCUT1@" #cmakedefine KICKOFF_DIST_CONFIG_SHORTCUT2 "@KICKOFF_DIST_CONFIG_SHORTCUT2@" diff --git a/tdeioslave/man/tdeio_man.cpp b/tdeioslave/man/tdeio_man.cpp index d6574f064..92530facb 100644 --- a/tdeioslave/man/tdeio_man.cpp +++ b/tdeioslave/man/tdeio_man.cpp @@ -581,47 +581,62 @@ char *MANProtocol::readManPage(const char *_filename) } lastdir = filename.left(filename.findRev('/')); -#ifdef WITH_MAKEWHATIS - TQIODevice *fd= KFilterDev::deviceForFile(filename); + size_t len; - 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( hasManRecode() ) { + myStdStream = TQString::null; + TDEProcess proc; - if (array.isEmpty()) - return 0; + proc << "man" << "--recode" << "UTF-8" << filename; - 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 - * upstream */ - proc << "man" << "--recode" << "UTF-8" << filename; + TQApplication::connect(&proc, TQT_SIGNAL(receivedStdout (TDEProcess *, char *, int)), + this, TQT_SLOT(slotGetStdOutputUtf8(TDEProcess *, char *, int))); + proc.start(TDEProcess::Block, TDEProcess::All); - TQApplication::connect(&proc, TQT_SIGNAL(receivedStdout (TDEProcess *, char *, int)), - this, TQT_SLOT(slotGetStdOutputUtf8(TDEProcess *, char *, int))); - proc.start(TDEProcess::Block, TDEProcess::All); + const TQCString cstr=myStdStream.utf8(); + len = cstr.size() != 0 ? cstr.size() - 1 : 0; + buf = new char[len + 4]; + tqmemmove(buf + 1, cstr.data(), len); + } else { + TQIODevice *fd= KFilterDev::deviceForFile(filename); - const TQCString cstr=myStdStream.utf8(); - const int len = cstr.size()-1; - buf = new char[len + 4]; - tqmemmove(buf + 1, cstr.data(), len); -#endif + 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; + + len = array.size(); + buf = new char[len + 4]; + tqmemmove(buf + 1, array.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 } return buf; } +bool MANProtocol::hasManRecode(bool force) { + static bool rv=0, wasChecked=0; + if ( !wasChecked || force ) { + TDEProcess proc; + // lets' try to recode the man page of man. + // that should be enough to be sure that man-db is installed. + proc << "man" << "--recode" << "UTF-8" << "man"; + + proc.start(TDEProcess::Block, TDEProcess::All); + rv = proc.exitStatus() == 0; + wasChecked = 1; + } + return rv; +} void MANProtocol::outputError(const TQString& errmsg) { diff --git a/tdeioslave/man/tdeio_man.h b/tdeioslave/man/tdeio_man.h index 7ba9d1dbc..e621a7fbf 100644 --- a/tdeioslave/man/tdeio_man.h +++ b/tdeioslave/man/tdeio_man.h @@ -66,6 +66,7 @@ private slots: private: void checkManPaths(); TQStringList manDirectories(); + static bool hasManRecode(bool force=0); TQMap<TQString, TQString> buildIndexMap(const TQString& section); bool addWhatIs(TQMap<TQString, TQString>& i, const TQString& f, const TQString& mark); void parseWhatIs( TQMap<TQString, TQString> &i, TQTextStream &t, const TQString &mark ); |