cat(1p): small reformatting

This commit is contained in:
Emma Tebibyte 2023-08-10 20:10:30 -06:00
parent e530f10cd5
commit da2ebdb1e1
Signed by untrusted user: emma
GPG Key ID: 6D661C738815E7DD
2 changed files with 10 additions and 5 deletions

View File

@ -11,6 +11,9 @@ PREFIX=/usr/local/bin
build: build_dir cat false true build: build_dir cat false true
clean: build_dir
rm -rf build/
cat: build_dir cat: build_dir
cc -o build/cat src/cat.c cc -o build/cat src/cat.c

View File

@ -30,8 +30,6 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
bool u = false; bool u = false;
int opt; int opt;
int i = 1;
FILE *file;
extern int optind; extern int optind;
while ((opt = getopt(argc, argv, "u")) != -1) { while ((opt = getopt(argc, argv, "u")) != -1) {
@ -51,10 +49,10 @@ int main(int argc, char *argv[]) {
} }
} }
int i = 1;
FILE *file;
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
int byte = 0; // variable for storing bytes as they are read
char buf[4096]; // buffer for buffered
int p = 0; // index counter for bytes in buffered reading
/* /*
* From cat(1p): * From cat(1p):
* *
@ -91,6 +89,10 @@ int main(int argc, char *argv[]) {
} }
} }
int byte = 0; /* variable for storing bytes as they are read */
int p = 0; /* index counter for bytes in buffered reading */
char buf[4096]; /* buffer for buffered reading */
while (byte != EOF) { while (byte != EOF) {
byte = fgetc(file); byte = fgetc(file);