diff options
author | Jim Meyering <jim@meyering.net> | 1998-03-23 23:19:01 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1998-03-23 23:19:01 +0000 |
commit | cd053a291eb3979b6db4fd93cf193d6832237160 (patch) | |
tree | 5ecd0c00c1e90580805f8aa97e0a600b4739b5e1 /src | |
parent | fa4148be50065a002282e39a8234b9113f4c6dc5 (diff) | |
download | coreutils-cd053a291eb3979b6db4fd93cf193d6832237160.tar.xz |
update from automake-2.1h
Diffstat (limited to 'src')
-rw-r--r-- | src/ansi2knr.c | 35 |
1 files changed, 17 insertions, 18 deletions
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; |