From cd053a291eb3979b6db4fd93cf193d6832237160 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 23 Mar 1998 23:19:01 +0000 Subject: update from automake-2.1h --- src/ansi2knr.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ansi2knr.c b/src/ansi2knr.c index c6ee83309..791eee04c 100644 --- a/src/ansi2knr.c +++ b/src/ansi2knr.c @@ -184,7 +184,7 @@ main(argc, argv) */ int convert_varargs = 1; - if ( argc > 1 && argv[1][0] == '-' ) + if ( argc > 1 && argv[1][0] == '-' && argv[1][1] ) { if ( !strcmp(argv[1], "--varargs") ) { convert_varargs = 1; argc--; @@ -195,30 +195,29 @@ main(argc, argv) exit(1); } } - if (argc < 2 || argc > 3) + switch ( argc ) { + default: printf("Usage: ansi2knr input_file [output_file]\n"); + exit(0); + case 2: + out = stdout; + break; + case 3: + out = fopen(argv[2], "w"); + if ( out == NULL ) + { fprintf(stderr, "Cannot open output file %s\n", argv[2]); exit(1); } - in = fopen(argv[1], "r"); + } + if ( argv[1][0] == '-' && !argv[1][1] ) + in = stdin; + else + in = fopen(argv[1], "r"); if ( in == NULL ) - { - fprintf(stderr, "Cannot open input file %s\n", argv[1]); + { fprintf(stderr, "Cannot open input file %s\n", argv[1]); exit(1); } - if (argc == 3) - { - out = fopen(argv[2], "w"); - if ( out == NULL ) - { - fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - else - { - out = stdout; - } fprintf(out, "#line 1 \"%s\"\n", argv[1]); buf = malloc(bufsize); line = buf; -- cgit v1.2.3-70-g09d2