version 1.12, 2006/10/06 23:44:30 |
version 1.13, 2006/10/09 00:24:36 |
|
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
char copyright[] = |
static const char copyright[] = |
"@(#) Copyright (c) 1980, 1987 Regents of the University of California.\n\ |
"@(#) Copyright (c) 1980, 1987 Regents of the University of California.\n\ |
All rights reserved.\n"; |
All rights reserved.\n"; |
#endif /* not lint */ |
|
|
|
#ifndef lint |
|
/*static char sccsid[] = "from: @(#)head.c 5.5 (Berkeley) 6/1/90";*/ |
/*static char sccsid[] = "from: @(#)head.c 5.5 (Berkeley) 6/1/90";*/ |
static char rcsid[] = "$OpenBSD$"; |
static const char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
|
/* handle obsolete -number syntax */ |
/* handle obsolete -number syntax */ |
if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) { |
if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) { |
p = argv[1] + 1; |
p = argv[1] + 1; |
argc--; argv++; |
argc--; |
|
argv++; |
} |
} |
|
|
while ((ch = getopt (argc, argv, "n:")) != -1) |
while ((ch = getopt(argc, argv, "n:")) != -1) { |
switch (ch) { |
switch (ch) { |
case 'n': |
case 'n': |
p = optarg; |
p = optarg; |
|
|
default: |
default: |
usage(); |
usage(); |
} |
} |
|
} |
argc -= optind, argv += optind; |
argc -= optind, argv += optind; |
|
|
if (p) { |
if (p) { |
|
|
if (!*argv) { |
if (!*argv) { |
if (!firsttime) |
if (!firsttime) |
exit(0); |
exit(0); |
} |
} else { |
else { |
|
if (!freopen(*argv, "r", stdin)) { |
if (!freopen(*argv, "r", stdin)) { |
warn("%s", *argv++); |
warn("%s", *argv++); |
continue; |
continue; |
|
|
fputs("usage: head [-n line_count] [file ...]\n", stderr); |
fputs("usage: head [-n line_count] [file ...]\n", stderr); |
exit(1); |
exit(1); |
} |
} |
|
|