PR/33995: Aleksey Cheusov: support use "-" to indicate stdin from SUS

This commit is contained in:
jnemeth 2006-07-29 02:01:24 +00:00
parent 7cfa6f224f
commit a8488a76e0

View File

@ -1,4 +1,4 @@
/* $NetBSD: cut.c,v 1.20 2006/04/25 19:34:42 christos Exp $ */
/* $NetBSD: cut.c,v 1.21 2006/07/29 02:01:24 jnemeth Exp $ */
/*
* Copyright (c) 1989, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95";
#endif
__RCSID("$NetBSD: cut.c,v 1.20 2006/04/25 19:34:42 christos Exp $");
__RCSID("$NetBSD: cut.c,v 1.21 2006/07/29 02:01:24 jnemeth Exp $");
#endif /* not lint */
#include <ctype.h>
@ -117,10 +117,14 @@ main(int argc, char *argv[])
if (*argv)
for (; *argv; ++argv) {
if (!(fp = fopen(*argv, "r")))
err(1, "%s", *argv);
fcn(fp, *argv);
(void)fclose(fp);
if (strcmp(*argv, "-") == 0)
fcn(stdin, "stdin");
else {
if ((fp = fopen(*argv, "r")) == NULL)
err(1, "%s", *argv);
fcn(fp, *argv);
(void)fclose(fp);
}
}
else
fcn(stdin, "stdin");