summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2009-11-13 19:13:08 +0100
committerKurt Zenker <kz@openoffice.org>2009-11-13 19:13:08 +0100
commit02f6dbeae398c0735521c710a91c8e492941bc02 (patch)
tree8b1cf664bdb82ee4684be048487c51e685ad1b04
parentf79407b9b4aeeb778e1de4bf66aef3ebec785306 (diff)
parente9a9ad41f2482c12f4e5fc7af966675bf0c3a568 (diff)
CWS-TOOLING: integrate CWS cmcfixes65
-rw-r--r--transex3/source/directory.cxx17
-rw-r--r--transex3/source/help/HelpLinker.cxx60
-rw-r--r--transex3/source/localize.cxx6
3 files changed, 54 insertions, 29 deletions
diff --git a/transex3/source/directory.cxx b/transex3/source/directory.cxx
index a4a2abc70e0f..ed0fe27d22c2 100644
--- a/transex3/source/directory.cxx
+++ b/transex3/source/directory.cxx
@@ -174,6 +174,16 @@ void Directory::readDirectory ( const rtl::OUString& sFullpath )
#else
+class dirholder
+{
+private:
+ DIR *mpDir;
+public:
+ dirholder(DIR *pDir) : mpDir(pDir) {}
+ int close() { int nRet = mpDir ? closedir(mpDir) : 0; mpDir = NULL; return nRet; }
+ ~dirholder() { close(); }
+};
+
void Directory::readDirectory( const rtl::OUString& sFullpath )
{
struct stat statbuf;
@@ -195,13 +205,14 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
if( S_ISDIR(statbuf.st_mode ) == 0 ) { return; }// error } return; // not dir
if( (dir = opendir( path ) ) == NULL ) {printf("readerror 2 in %s \n",path); return; } // error } return; // error
+ dirholder aHolder(dir);
sFullpathext += rtl::OString( "/" );
const rtl::OString sDot ( "." ) ;
const rtl::OString sDDot( ".." );
- chdir( path );
+ if ( chdir( path ) == -1 ) { printf("chdir error in %s \n",path); return; } // error
while( ( dirp = readdir( dir ) ) != NULL )
{
@@ -253,8 +264,8 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
}
}
}
- chdir( ".." );
- if( closedir( dir ) < 0 ) return ; // error
+ if ( chdir( ".." ) == -1 ) { printf("chdir error in .. \n"); return; } // error
+ if( aHolder.close() < 0 ) return ; // error
std::sort( aFileVec.begin() , aFileVec.end() , File::lessFile );
std::sort( aDirVec.begin() , aDirVec.end() , Directory::lessDir );
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<std::string> &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;
}
diff --git a/transex3/source/localize.cxx b/transex3/source/localize.cxx
index bcd45d7027a4..31143ab50d38 100644
--- a/transex3/source/localize.cxx
+++ b/transex3/source/localize.cxx
@@ -345,7 +345,8 @@ void SourceTreeLocalizer::WorkOnFile(
sCommand +=" -QQ ";
}
//printf("DBG: %s\n",sCommand.GetBuffer());
- system( sCommand.GetBuffer());
+ if (system(sCommand.GetBuffer()) == -1)
+ fprintf(stderr, "%s failed\n", sCommand.GetBuffer());
nFileCnt++;
printf(".");
fflush( stdout );
@@ -621,7 +622,8 @@ BOOL SourceTreeLocalizer::MergeSingleFile(
DirEntry aOldCWD;
aPath.SetCWD();
- system( sCommand.GetBuffer());
+ if (system(sCommand.GetBuffer()) == -1)
+ fprintf(stderr, "%s failed\n", sCommand.GetBuffer());
nFileCnt++;
printf(".");
//if( bQuiet2 ){ printf("."); }