diff options
| author | bjh21 <bjh21@NetBSD.org> | 2003-06-26 23:19:15 +0000 |
|---|---|---|
| committer | bjh21 <bjh21@NetBSD.org> | 2003-06-26 23:19:15 +0000 |
| commit | 4fca23a8b3f329059551e137dd7b9ca14f6120fa (patch) | |
| tree | 414d246da3c42ce7bead7a5a0efad9f47386f99c /usr.bin/split | |
| parent | 946564c3f6c751d9f0efa0871d0dcabb7300b309 (diff) | |
Simplify the handling of ifd by initialising it to the default
(STDIN_FILENO), and only overriding that if the user specifies a different
input file.
Diffstat (limited to 'usr.bin/split')
| -rw-r--r-- | usr.bin/split/split.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 58bb1acc737..ec9d6bc3465 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -1,4 +1,4 @@ -/* $NetBSD: split.c,v 1.15 2003/06/26 23:06:52 bjh21 Exp $ */ +/* $NetBSD: split.c,v 1.16 2003/06/26 23:19:15 bjh21 Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)split.c 8.3 (Berkeley) 4/25/94"; #endif -__RCSID("$NetBSD: split.c,v 1.15 2003/06/26 23:06:52 bjh21 Exp $"); +__RCSID("$NetBSD: split.c,v 1.16 2003/06/26 23:19:15 bjh21 Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -60,7 +60,7 @@ __RCSID("$NetBSD: split.c,v 1.15 2003/06/26 23:06:52 bjh21 Exp $"); #define DEFLINE 1000 /* Default num lines per file. */ static int file_open; /* If a file open. */ -static int ifd = -1, ofd = -1; /* Input/output file descriptors. */ +static int ifd = STDIN_FILENO, ofd = -1; /* Input/output file descriptors. */ static char *fname; /* File name prefix. */ static size_t sfxlen = 2; /* suffix length. */ @@ -131,9 +131,8 @@ main(int argc, char *argv[]) argc -= optind; if (*argv != NULL) { - if (strcmp(*argv, "-") == 0) - ifd = STDIN_FILENO; - else if ((ifd = open(*argv, O_RDONLY, 0)) < 0) + if (strcmp(*argv, "-") != 0 && + (ifd = open(*argv, O_RDONLY, 0)) < 0) err(1, "%s", *argv); ++argv; } @@ -165,9 +164,6 @@ main(int argc, char *argv[]) else if (bytecnt) usage(); - if (ifd == -1) /* Stdin by default. */ - ifd = 0; - if (bytecnt) split1(bytecnt); else |
