Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146134296
D14498.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D14498.id.diff
View Options
Index: head/usr.bin/head/head.c
===================================================================
--- head/usr.bin/head/head.c
+++ head/usr.bin/head/head.c
@@ -75,14 +75,17 @@
int
main(int argc, char *argv[])
{
- int ch;
FILE *fp;
- int first, linecnt = -1, eval = 0;
- off_t bytecnt = -1;
char *ep;
+ off_t bytecnt;
+ int ch, first, linecnt, eval;
+ linecnt = -1;
+ eval = 0;
+ bytecnt = -1;
+
obsolete(argv);
- while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1)
+ while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1) {
switch(ch) {
case 'c':
bytecnt = strtoimax(optarg, &ep, 10);
@@ -97,16 +100,18 @@
case '?':
default:
usage();
+ /* NOTREACHED */
}
+ }
argc -= optind;
argv += optind;
if (linecnt != -1 && bytecnt != -1)
errx(1, "can't combine line and byte counts");
- if (linecnt == -1 )
+ if (linecnt == -1)
linecnt = 10;
- if (*argv) {
- for (first = 1; *argv; ++argv) {
+ if (*argv != NULL) {
+ for (first = 1; *argv != NULL; ++argv) {
if ((fp = fopen(*argv, "r")) == NULL) {
warn("%s", *argv);
eval = 1;
@@ -137,7 +142,7 @@
char *cp;
size_t error, readlen;
- while (cnt && (cp = fgetln(fp, &readlen)) != NULL) {
+ while (cnt != 0 && (cp = fgetln(fp, &readlen)) != NULL) {
error = fwrite(cp, sizeof(char), readlen, stdout);
if (error != readlen)
err(1, "stdout");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 2:52 AM (3 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29093230
Default Alt Text
D14498.id.diff (1 KB)
Attached To
Mode
D14498: Change style of head(1).
Attached
Detach File
Event Timeline
Log In to Comment