From: ceriel Date: Wed, 25 Nov 1987 16:55:51 +0000 (+0000) Subject: fixed to also read from standard input X-Git-Tag: release-5-5~3701 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=048eac2d67dd1c50b47cfbc42118b84979f52f3c;p=ack.git fixed to also read from standard input --- diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index a785f739e..6f4543d60 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -95,10 +95,11 @@ long get32(); in_init(filename) char *filename; { - if ((emfile=freopen(filename,"r",stdin))==NULL) + emfile = stdin; + if (filename && (emfile=freopen(filename,"r",stdin))==NULL) error("Can't open %s",filename); if (get16()!=sp_magic) - error("Bad format %s",filename); + error("Bad format %s",filename ? filename : "standard-input"); } in_start() { diff --git a/mach/proto/ncg/main.c b/mach/proto/ncg/main.c index 43f80ae69..e6f6c0b3a 100644 --- a/mach/proto/ncg/main.c +++ b/mach/proto/ncg/main.c @@ -68,10 +68,10 @@ main(argc,argv) char **argv; { error("Unknown flag %c",argv[0][1]); } } - if (argc < 1 || argc > 2) - error("Usage: %s EMfile [ asfile ]",progname); - in_init(argv[0]); - out_init(argv[1]); + if (argc > 2) + error("Usage: %s [ EMfile ] [ asfile ]",progname); + in_init(argc >= 1 ? argv[0] : (char *) 0); + out_init(argc >= 2 ? argv[1] : (char *) 0); readcodebytes(); itokcost(); in_start();