diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-01 00:38:33 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-01 00:38:33 -0400 |
commit | 5a0ec4ed3711beda63450fcfe0bbbd1656fbb1ae (patch) | |
tree | ea3b2d94a7c5a1d368e09a60975976fcb6c21ce2 | |
parent | tee, whoami, wc (diff) | |
download | lazysphere-5a0ec4ed3711beda63450fcfe0bbbd1656fbb1ae.tar.gz lazysphere-5a0ec4ed3711beda63450fcfe0bbbd1656fbb1ae.tar.bz2 lazysphere-5a0ec4ed3711beda63450fcfe0bbbd1656fbb1ae.zip |
move back to c99
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/command.h | 7 | ||||
-rw-r--r-- | src/commands/cat.c | 4 | ||||
-rw-r--r-- | src/commands/dd.c | 1 | ||||
-rw-r--r-- | src/commands/echo.c | 3 | ||||
-rw-r--r-- | src/commands/ed.c | 5 | ||||
-rw-r--r-- | src/commands/groups.c | 1 | ||||
-rw-r--r-- | src/commands/head.c | 3 | ||||
-rw-r--r-- | src/commands/id.c | 2 | ||||
-rw-r--r-- | src/commands/ls.c | 6 | ||||
-rw-r--r-- | src/commands/printf.c | 1 | ||||
-rw-r--r-- | src/commands/tail.c | 6 | ||||
-rw-r--r-- | src/commands/tee.c | 3 | ||||
-rw-r--r-- | src/commands/wc.c | 2 | ||||
-rw-r--r-- | src/commands/whoami.c | 2 |
15 files changed, 8 insertions, 40 deletions
@@ -2,7 +2,7 @@ CC = gcc INCFLAGS = -Isrc -CCFLAGS = -std=gnu99 -Wall -Wextra -pedantic -O2 +CCFLAGS = -std=c99 -Wall -Wextra -pedantic -O2 -D_DEFAULT_SOURCE CCFLAGS += $(INCFLAGS) LDFLAGS += $(INCFLAGS) diff --git a/src/command.h b/src/command.h index ab1ccea..015b1a2 100644 --- a/src/command.h +++ b/src/command.h @@ -3,6 +3,13 @@ #include <stdint.h> #include <stdlib.h> #include <stdbool.h> +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> #define ARGUMENTS int argc, char** argv #define NEXT_ARGS argc - 1, &argv[1] diff --git a/src/commands/cat.c b/src/commands/cat.c index b862c13..bb050c0 100644 --- a/src/commands/cat.c +++ b/src/commands/cat.c @@ -1,10 +1,6 @@ #include "../command.h" #include <ctype.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <sys/stat.h> struct Flags { bool number_lines; diff --git a/src/commands/dd.c b/src/commands/dd.c index 87c9eb8..2b6955f 100644 --- a/src/commands/dd.c +++ b/src/commands/dd.c @@ -1,5 +1,4 @@ #include "../command.h" -#include <stdio.h> static void help() { printf("Usage: dd [if=FILE] [of=FILE] [bs=N] [count=N]\n\n"); diff --git a/src/commands/echo.c b/src/commands/echo.c index b80f872..a13947c 100644 --- a/src/commands/echo.c +++ b/src/commands/echo.c @@ -1,8 +1,5 @@ #include "../command.h" -#include <stdio.h> -#include <string.h> - static void print_with_escape_codes(const char* str) { size_t index = 0; diff --git a/src/commands/ed.c b/src/commands/ed.c index ca25de1..ed4ce24 100644 --- a/src/commands/ed.c +++ b/src/commands/ed.c @@ -1,11 +1,6 @@ #include "../command.h" #include "../util//regex.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - #define INPUT_LEN 1024 static char** lines = NULL; diff --git a/src/commands/groups.c b/src/commands/groups.c index 4aa7776..aea92af 100644 --- a/src/commands/groups.c +++ b/src/commands/groups.c @@ -2,7 +2,6 @@ #include <grp.h> #include <pwd.h> -#include <unistd.h> COMMAND_EMPTY(groups) { diff --git a/src/commands/head.c b/src/commands/head.c index 446a9e6..018da5a 100644 --- a/src/commands/head.c +++ b/src/commands/head.c @@ -1,8 +1,5 @@ #include "../command.h" -#include <stdio.h> -#include <string.h> - struct Flags { int count; bool lines; diff --git a/src/commands/id.c b/src/commands/id.c index 3990dc8..578c1e3 100644 --- a/src/commands/id.c +++ b/src/commands/id.c @@ -2,8 +2,6 @@ #include <grp.h> #include <pwd.h> -#include <unistd.h> -#include <sys/types.h> COMMAND_EMPTY(user_id) { diff --git a/src/commands/ls.c b/src/commands/ls.c index 934762d..855168c 100644 --- a/src/commands/ls.c +++ b/src/commands/ls.c @@ -1,13 +1,7 @@ #include "../command.h" -#include <errno.h> #include <grp.h> #include <pwd.h> -#include <stdio.h> -#include <string.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <unistd.h> #include <dirent.h> #include <ftw.h> #include <limits.h> diff --git a/src/commands/printf.c b/src/commands/printf.c index ce1631c..2a84b80 100644 --- a/src/commands/printf.c +++ b/src/commands/printf.c @@ -1,5 +1,4 @@ #include "../command.h" -#include <stdlib.h> static long cast_long(const char* arg) { char* end; diff --git a/src/commands/tail.c b/src/commands/tail.c index 24d7b1f..118a771 100644 --- a/src/commands/tail.c +++ b/src/commands/tail.c @@ -1,11 +1,5 @@ #include "../command.h" -#include <stdio.h> -#include <string.h> -#include <sys/select.h> -#include <sys/stat.h> -#include <unistd.h> - struct Flags { bool lines; int count; diff --git a/src/commands/tee.c b/src/commands/tee.c index 224463c..c500508 100644 --- a/src/commands/tee.c +++ b/src/commands/tee.c @@ -1,9 +1,6 @@ #include "../command.h" #include <signal.h> -#include <stdio.h> -#include <string.h> - static void help() { printf("Usage: tee [-ai] [FILE]...\n\n"); diff --git a/src/commands/wc.c b/src/commands/wc.c index 7132370..892ef2e 100644 --- a/src/commands/wc.c +++ b/src/commands/wc.c @@ -1,8 +1,6 @@ #include "../command.h" #include <ctype.h> -#include <stdio.h> -#include <string.h> struct Flags { bool newlines; diff --git a/src/commands/whoami.c b/src/commands/whoami.c index efc9bcd..f19a724 100644 --- a/src/commands/whoami.c +++ b/src/commands/whoami.c @@ -1,8 +1,6 @@ #include "../command.h" #include <pwd.h> -#include <sys/types.h> -#include <unistd.h> static void help() { printf("Usage: whoami\n\n"); |