From e9a9ad41f2482c12f4e5fc7af966675bf0c3a568 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 30 Oct 2009 09:37:43 +0000 Subject: #cmcfixes65: #i106469# fix fortify warnings --- transex3/source/help/HelpLinker.cxx | 60 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) (limited to 'transex3/source/help/HelpLinker.cxx') diff --git a/transex3/source/help/HelpLinker.cxx b/transex3/source/help/HelpLinker.cxx index 67049df439e1..19b9ead8521e 100644 --- a/transex3/source/help/HelpLinker.cxx +++ b/transex3/source/help/HelpLinker.cxx @@ -174,15 +174,23 @@ void writeKeyValue_DBHelp( FILE* pFile, const std::string& aKeyStr, const std::s if( pFile == NULL ) return; char cLF = 10; - int nKeyLen = aKeyStr.length(); - int nValueLen = aValueStr.length(); + unsigned int nKeyLen = aKeyStr.length(); + unsigned int nValueLen = aValueStr.length(); fprintf( pFile, "%x ", nKeyLen ); if( nKeyLen > 0 ) - fwrite( aKeyStr.c_str(), 1, nKeyLen, pFile ); - fprintf( pFile, " %x ", nValueLen ); + { + if (fwrite( aKeyStr.c_str(), 1, nKeyLen, pFile ) != nKeyLen) + fprintf(stderr, "fwrite to db failed\n"); + } + if (fprintf( pFile, " %x ", nValueLen ) < 0) + fprintf(stderr, "fwrite to db failed\n"); if( nValueLen > 0 ) - fwrite( aValueStr.c_str(), 1, nValueLen, pFile ); - fprintf( pFile, "%c", cLF ); + { + if (fwrite( aValueStr.c_str(), 1, nValueLen, pFile ) != nValueLen) + fprintf(stderr, "fwrite to db failed\n"); + } + if (fprintf( pFile, "%c", cLF ) < 0) + fprintf(stderr, "fwrite to db failed\n"); } class HelpKeyword @@ -384,8 +392,8 @@ void HelpLinker::initIndexerPreProcessor() */ void HelpLinker::link() throw( HelpProcessingException ) { - bool bIndexForExtension = true; - + bool bIndexForExtension = true; + if( bExtensionMode ) { indexDirParentName = sourceRoot; @@ -476,8 +484,10 @@ void HelpLinker::link() throw( HelpProcessingException ) if( !bExtensionMode ) { +#ifndef OS2 // YD @TODO@ crashes libc runtime :-( std::cout << "Making " << outputFile.native_file_string() << " from " << helpFiles.size() << " input files" << std::endl; +#endif } // here we start our loop over the hzip files. @@ -928,34 +938,34 @@ void HelpLinker::main(std::vector &args, std::string* pExtensionPat aStrStream << "no index caption stylesheet given" << std::endl; throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); } - else if ( bExtensionMode ) - { - rtl::OUString aIdxCaptionPathFileURL( aOfficeHelpPath ); - aIdxCaptionPathFileURL += rtl::OUString::createFromAscii( "/idxcaption.xsl" ); - + else if ( bExtensionMode ) + { + rtl::OUString aIdxCaptionPathFileURL( aOfficeHelpPath ); + aIdxCaptionPathFileURL += rtl::OUString::createFromAscii( "/idxcaption.xsl" ); + rtl::OString aOStr_IdxCaptionPathFileURL( rtl::OUStringToOString ( aIdxCaptionPathFileURL, fs::getThreadTextEncoding() ) ); std::string aStdStr_IdxCaptionPathFileURL( aOStr_IdxCaptionPathFileURL.getStr() ); - - idxCaptionStylesheet = fs::path( aStdStr_IdxCaptionPathFileURL ); - } + + idxCaptionStylesheet = fs::path( aStdStr_IdxCaptionPathFileURL ); + } if (!bExtensionMode && idxContentStylesheet.empty()) { std::stringstream aStrStream; aStrStream << "no index content stylesheet given" << std::endl; throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); } - else if ( bExtensionMode ) - { - rtl::OUString aIdxContentPathFileURL( aOfficeHelpPath ); - aIdxContentPathFileURL += rtl::OUString::createFromAscii( "/idxcontent.xsl" ); - + else if ( bExtensionMode ) + { + rtl::OUString aIdxContentPathFileURL( aOfficeHelpPath ); + aIdxContentPathFileURL += rtl::OUString::createFromAscii( "/idxcontent.xsl" ); + rtl::OString aOStr_IdxContentPathFileURL( rtl::OUStringToOString ( aIdxContentPathFileURL, fs::getThreadTextEncoding() ) ); std::string aStdStr_IdxContentPathFileURL( aOStr_IdxContentPathFileURL.getStr() ); - - idxContentStylesheet = fs::path( aStdStr_IdxContentPathFileURL ); - } + + idxContentStylesheet = fs::path( aStdStr_IdxContentPathFileURL ); + } if (!bExtensionMode && embeddStylesheet.empty()) { std::stringstream aStrStream; @@ -1014,7 +1024,9 @@ int main(int argc, char**argv) exit(1); } sal_uInt32 endtime = osl_getGlobalTimer(); +#ifndef OS2 // YD @TODO@ crashes libc runtime :-( std::cout << "time taken was " << (endtime-starttime)/1000.0 << " seconds" << std::endl; +#endif return 0; } -- cgit From 2f144f86f48f4bbe9b309e35ccac8810467c4416 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 13 Nov 2009 11:06:34 +0000 Subject: #i106889# upgrade expat to 2.0.1 --- transex3/source/help/HelpLinker.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'transex3/source/help/HelpLinker.cxx') diff --git a/transex3/source/help/HelpLinker.cxx b/transex3/source/help/HelpLinker.cxx index 19b9ead8521e..47d9181a75a0 100644 --- a/transex3/source/help/HelpLinker.cxx +++ b/transex3/source/help/HelpLinker.cxx @@ -45,11 +45,7 @@ #include #include -#ifdef SYSTEM_EXPAT #include -#else -#include -#endif #define DBHELP_ONLY -- cgit From 231200087c468fb036324d27784c9b3379b8bdfe Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 3 Dec 2009 17:21:16 +0000 Subject: #i107283# Pass config help path as argument to compileExtensionHelp() --- transex3/source/help/HelpLinker.cxx | 64 +++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'transex3/source/help/HelpLinker.cxx') diff --git a/transex3/source/help/HelpLinker.cxx b/transex3/source/help/HelpLinker.cxx index 19b9ead8521e..d2bf955069f7 100644 --- a/transex3/source/help/HelpLinker.cxx +++ b/transex3/source/help/HelpLinker.cxx @@ -118,35 +118,41 @@ void IndexerPreProcessor::processDocument { std::string aStdStr_EncodedDocPathURL = getEncodedPath( EncodedDocPath ); - xmlDocPtr resCaption = xsltApplyStylesheet( m_xsltStylesheetPtrCaption, doc, NULL ); - xmlNodePtr pResNodeCaption = resCaption->xmlChildrenNode; - if( pResNodeCaption ) + if( m_xsltStylesheetPtrCaption ) { - fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL; - std::string aCaptionPureTextFileStr_docURL = fsCaptionPureTextFile_docURL.native_file_string(); - FILE* pFile_docURL = fopen( aCaptionPureTextFileStr_docURL.c_str(), "w" ); - if( pFile_docURL ) + xmlDocPtr resCaption = xsltApplyStylesheet( m_xsltStylesheetPtrCaption, doc, NULL ); + xmlNodePtr pResNodeCaption = resCaption->xmlChildrenNode; + if( pResNodeCaption ) { - fprintf( pFile_docURL, "%s\n", pResNodeCaption->content ); - fclose( pFile_docURL ); + fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL; + std::string aCaptionPureTextFileStr_docURL = fsCaptionPureTextFile_docURL.native_file_string(); + FILE* pFile_docURL = fopen( aCaptionPureTextFileStr_docURL.c_str(), "w" ); + if( pFile_docURL ) + { + fprintf( pFile_docURL, "%s\n", pResNodeCaption->content ); + fclose( pFile_docURL ); + } } + xmlFreeDoc(resCaption); } - xmlFreeDoc(resCaption); - xmlDocPtr resContent = xsltApplyStylesheet( m_xsltStylesheetPtrContent, doc, NULL ); - xmlNodePtr pResNodeContent = resContent->xmlChildrenNode; - if( pResNodeContent ) + if( m_xsltStylesheetPtrContent ) { - fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL; - std::string aContentPureTextFileStr_docURL = fsContentPureTextFile_docURL.native_file_string(); - FILE* pFile_docURL = fopen( aContentPureTextFileStr_docURL.c_str(), "w" ); - if( pFile_docURL ) + xmlDocPtr resContent = xsltApplyStylesheet( m_xsltStylesheetPtrContent, doc, NULL ); + xmlNodePtr pResNodeContent = resContent->xmlChildrenNode; + if( pResNodeContent ) { - fprintf( pFile_docURL, "%s\n", pResNodeContent->content ); - fclose( pFile_docURL ); + fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL; + std::string aContentPureTextFileStr_docURL = fsContentPureTextFile_docURL.native_file_string(); + FILE* pFile_docURL = fopen( aContentPureTextFileStr_docURL.c_str(), "w" ); + if( pFile_docURL ) + { + fprintf( pFile_docURL, "%s\n", pResNodeContent->content ); + fclose( pFile_docURL ); + } } + xmlFreeDoc(resContent); } - xmlFreeDoc(resContent); } struct Data @@ -245,8 +251,9 @@ public: class HelpLinker { public: - void main(std::vector &args, std::string* pExtensionPath = NULL ) - throw( HelpProcessingException ); + void main(std::vector &args, + std::string* pExtensionPath = NULL, const rtl::OUString* pOfficeHelpPath = NULL ) + throw( HelpProcessingException ); HelpLinker() : init(true) @@ -751,21 +758,21 @@ void HelpLinker::link() throw( HelpProcessingException ) } -void HelpLinker::main(std::vector &args, std::string* pExtensionPath) - throw( HelpProcessingException ) +void HelpLinker::main( std::vector &args, + std::string* pExtensionPath, const rtl::OUString* pOfficeHelpPath ) + throw( HelpProcessingException ) { rtl::OUString aOfficeHelpPath; bExtensionMode = false; - if( pExtensionPath && pExtensionPath->length() > 0 ) + if( pExtensionPath && pExtensionPath->length() > 0 && pOfficeHelpPath ) { helpFiles.clear(); bExtensionMode = true; extensionPath = *pExtensionPath; sourceRoot = fs::path(extensionPath); - aOfficeHelpPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/help") ); - rtl::Bootstrap::expandMacros( aOfficeHelpPath ); + aOfficeHelpPath = *pOfficeHelpPath; } if (args.size() > 0 && args[0][0] == '@') { @@ -1065,6 +1072,7 @@ HelpProcessingErrorInfo& HelpProcessingErrorInfo::operator=( const struct HelpPr // Returns true in case of success, false in case of error HELPLINKER_DLLPUBLIC bool compileExtensionHelp ( + const rtl::OUString& aOfficeHelpPath, const rtl::OUString& aExtensionName, const rtl::OUString& aExtensionLanguageRoot, sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles, @@ -1107,7 +1115,7 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp try { HelpLinker* pHelpLinker = new HelpLinker(); - pHelpLinker->main( args,&aStdStrExtensionPath ); + pHelpLinker->main( args, &aStdStrExtensionPath, &aOfficeHelpPath ); delete pHelpLinker; } catch( const HelpProcessingException& e ) -- cgit