cmp: cleanup

This commit is contained in:
Connor Lane Smith 2011-06-10 02:00:27 +01:00
parent 188d8ff93a
commit 8d087ae4fb

11
cmp.c
View File

@ -2,16 +2,13 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "util.h"
static bool lflag = false;
static bool sflag = false;
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
bool lflag = false;
bool sflag = false;
bool same = true; bool same = true;
char c; char c;
int b[2], i; int b[2], i;
@ -30,12 +27,12 @@ main(int argc, char *argv[])
exit(2); exit(2);
} }
if(optind != argc-2) { if(optind != argc-2) {
eprintf("usage: %s [-ls] file1 file2\n", argv[0]); fprintf(stderr, "usage: %s [-ls] file1 file2\n", argv[0]);
exit(2); exit(2);
} }
for(i = 0; i < 2; i++) for(i = 0; i < 2; i++)
if(!(fp[i] = fopen(argv[optind+i], "r"))) { if(!(fp[i] = fopen(argv[optind+i], "r"))) {
eprintf("fopen %s:", argv[optind+i]); fprintf(stderr, "fopen %s:", argv[optind+i]);
exit(2); exit(2);
} }
for(n = 1; ((b[0] = getc(fp[0])) != EOF) | ((b[1] = getc(fp[1])) != EOF); n++) { for(n = 1; ((b[0] = getc(fp[0])) != EOF) | ((b[1] = getc(fp[1])) != EOF); n++) {