summaryrefslogtreecommitdiff
path: root/transex3
diff options
context:
space:
mode:
authorNils Fuhrmann <nf@openoffice.org>2000-12-07 09:17:44 +0000
committerNils Fuhrmann <nf@openoffice.org>2000-12-07 09:17:44 +0000
commitcb6d3ff7ea5b0e019978316641dc7ac97433fb85 (patch)
tree510b1c753c988866a165179e23789c6a8c9cfaf6 /transex3
parent2e23576da2055fbf9aabd35eba9e72745060a84b (diff)
Fixes for invalid file format
Diffstat (limited to 'transex3')
-rw-r--r--transex3/source/xgfconv.cxx31
1 files changed, 26 insertions, 5 deletions
diff --git a/transex3/source/xgfconv.cxx b/transex3/source/xgfconv.cxx
index 2d1eb0140203..7445f37cdaa3 100644
--- a/transex3/source/xgfconv.cxx
+++ b/transex3/source/xgfconv.cxx
@@ -11,18 +11,29 @@ int _cdecl main( int argc, char *argv[] )
#endif
/*****************************************************************************/
{
- if ( argc != 2 ) {
- fprintf( stderr, "xgfconv InputFile\n" );
+ if ( argc != 3 ) {
+ fprintf( stderr, "xgfconv InputFile OutputFile\n" );
return ( 5 );
}
ByteString sInput( argv[ 1 ] );
+ ByteString sOutput( argv[ 2 ] );
SvFileStream aInput( String( sInput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
- if ( !aInput.IsOpen())
+ if ( !aInput.IsOpen()) {
+ fprintf( stderr, "ERROR: Unable to open input file!\n" );
return ( 5 );
+ }
+
+ SvFileStream aOutput( String( sOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
+ if ( !aOutput.IsOpen()) {
+ fprintf( stderr, "ERROR: Unable to open output file!\n" );
+ aInput.Close();
+ return ( 5 );
+ }
ByteString sLine;
+ BOOL bFirst = TRUE;
while ( !aInput.IsEof()) {
aInput.ReadLine( sLine );
ByteString sLangId = sLine.GetToken( 0, '\t' );
@@ -31,12 +42,22 @@ int _cdecl main( int argc, char *argv[] )
USHORT nLangId = sLangId.ToInt32();
CharSet aCharSet = Export::GetCharSet( nLangId );
- if ( aCharSet != 0xFFFF ) {
+ if ( aCharSet != 0xFFFF && sText.Len()) {
sText = UTF8Converter::ConvertToUTF8( sText, aCharSet );
- fprintf( stdout, "%s\t%s\n", sFile.GetBuffer(), sText.GetBuffer());
+ ByteString sOutput = sFile;
+ sOutput += "\t";
+ sOutput += sText;
+ if ( !bFirst ) {
+ ByteString sEmpty;
+ aOutput.WriteLine( sEmpty );
+ }
+ else
+ bFirst = FALSE;
+ aOutput.Write( sOutput.GetBuffer(), sOutput.Len());
}
}
aInput.Close();
+ aOutput.Close();
return ( 0 );
}