From 8aa7eddd317f6702651bc727d0c30eef72d8060a Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Fri, 21 Jan 2005 10:35:34 +0000 Subject: INTEGRATION: CWS sysui03 (1.3.8); FILE MERGED 2005/01/10 11:50:10 obr 1.3.8.1: #i38980# don't create output file for non-existing input --- setup_native/source/ulfconv/ulfconv.cxx | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'setup_native/source/ulfconv') diff --git a/setup_native/source/ulfconv/ulfconv.cxx b/setup_native/source/ulfconv/ulfconv.cxx index 3f1646330a82..7ea9b0977580 100644 --- a/setup_native/source/ulfconv/ulfconv.cxx +++ b/setup_native/source/ulfconv/ulfconv.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ulfconv.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: obo $ $Date: 2004-11-18 08:21:15 $ + * last change: $Author: kz $ $Date: 2005-01-21 11:35:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -289,6 +289,8 @@ int main( int argc, char * const argv[] ) FILE *istream = stdin; FILE *ostream = stdout; + char *outfile = NULL; + int errflg = 0; int argi; @@ -306,11 +308,7 @@ int main( int argc, char * const argv[] ) } ++argi; - ostream = fopen(argv[argi], "w"); - if ( ostream == NULL ) { - fprintf(stderr, "ulfconv: %s : %s\n", argv[argi], strerror(errno)); - exit(2); - } + outfile = argv[argi]; break; case 't': if (argi+1 >= argc || argv[argi+1][0] == '-') @@ -339,8 +337,8 @@ int main( int argc, char * const argv[] ) } /* assign input file to stdin */ - if ( argi < argc ) { - + if ( argi < argc ) + { istream = fopen(argv[argi], "r"); if ( istream == NULL ) { fprintf(stderr, "ulfconv: %s : %s\n", argv[argi], strerror(errno)); @@ -348,6 +346,16 @@ int main( int argc, char * const argv[] ) } } + /* open output file if any */ + if ( outfile ) + { + ostream = fopen(outfile, "w"); + if ( ostream == NULL ) { + fprintf(stderr, "ulfconv: %s : %s\n", argv[argi], strerror(errno)); + exit(2); + } + } + /* read line by line from stdin */ char buffer[65536]; while ( NULL != fgets(buffer, sizeof(buffer), istream) ) { -- cgit v1.2.3