From a3017fd80f43030fe6d97196743507b0605e9aad Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Fri, 31 Mar 2023 00:07:46 -0500 Subject: [PATCH] Random extra stuff --- Makefile | 28 ++++++++++++++++++++-------- src/Integrated.c | 8 ++++---- src/Pish.c | 5 ++--- src/main.c | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 6d352fe..28ec78d 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,24 @@ INC := -I include +CFLAGS := -Wall +CFLAGS += -Wextra +CFLAGS += -Wpointer-arith +CFLAGS += -Wcast-align +CFLAGS += -Wwrite-strings +CFLAGS += -Wswitch-default +CFLAGS += -Wunreachable-code +CFLAGS += -Winit-self +CFLAGS += -Wmissing-field-initializers +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wundef +CFLAGS += -Wold-style-definition all: compile link compile: - gcc $(INC) -c -o build/main.o src/main.c - gcc $(INC) -c -o build/Common.o src/Common.c - gcc $(INC) -c -o build/Integrated.o src/Integrated.c - gcc $(INC) -c -o build/Pish.o src/Pish.c + gcc $(CFLAGS) $(INC) -c -o build/main.o src/main.c + gcc $(CFLAGS) $(INC) -c -o build/Common.o src/Common.c + gcc $(CFLAGS) $(INC) -c -o build/Integrated.o src/Integrated.c + gcc $(CFLAGS) $(INC) -c -o build/Pish.o src/Pish.c link: gcc -o bin/pish.out build/*.o @@ -17,10 +29,10 @@ exec: compile link debug: clean debugCompile debugLink debugCompile: - gcc $(INC) -g -c -o build/main.o src/main.c - gcc $(INC) -g -c -o build/Integrated.o src/Integrated.c - gcc $(INC) -g -c -o build/Common.o src/Common.c - gcc $(INC) -g -c -o build/Pish.o src/Pish.c + gcc $(CFLAGS) $(INC) -g -c -o build/main.o src/main.c + gcc $(CFLAGS) $(INC) -g -c -o build/Integrated.o src/Integrated.c + gcc $(CFLAGS) $(INC) -g -c -o build/Common.o src/Common.c + gcc $(CFLAGS) $(INC) -g -c -o build/Pish.o src/Pish.c debugLink: gcc -g -o bin/pish.out build/*.o diff --git a/src/Integrated.c b/src/Integrated.c index c676849..5772b8a 100755 --- a/src/Integrated.c +++ b/src/Integrated.c @@ -121,7 +121,7 @@ int CountSymbol(CommandStruct* command, char symbol) void ioRedirection(CommandStruct* command) { - for (int i = 0; i argv[i], ">>")!= NULL)//append { @@ -146,7 +146,7 @@ void ioRedirection(CommandStruct* command) void output(char *command){ int newfd; - if (newfd = open(command, O_CREAT | O_CREAT, 0666) < 0) + if ((newfd = open(command, O_CREAT | O_CREAT, 0666)) < 0) { perror(command); exit(1); @@ -157,7 +157,7 @@ void output(char *command){ void input(char *command) { int newfd; - if (newfd = open(command, O_RDONLY | O_CREAT) < 0) + if ((newfd = open(command, O_RDONLY | O_CREAT)) < 0) { perror(command); exit(1); @@ -207,7 +207,7 @@ int ExecPipe(CommandStruct* commandParent, CommandStruct* commandChild, int* pip void append(char* input, char* fileName) { char buffer[4]; - int fd = open(fileName, O_APPEND | O_CREAT); + // int fd = open(fileName, O_APPEND | O_CREAT); // fp = fopen(file, "a+"); // fputs(input, fp); diff --git a/src/Pish.c b/src/Pish.c index c65d5d9..c3eafcf 100644 --- a/src/Pish.c +++ b/src/Pish.c @@ -13,8 +13,8 @@ // Main function for Pish program void Pish(void) { - CommandStruct commandParentObject = {"", 0}; - CommandStruct commandChildObject = {"", 0}; + CommandStruct commandParentObject = {{""}, 0, {""}}; + CommandStruct commandChildObject = {{""}, 0, {""}}; CommandStruct* commandParent = &commandParentObject; CommandStruct* commandChild = &commandChildObject; char inputString[1000]; // Max 1000 characters @@ -52,7 +52,6 @@ void ReadPishrc(CommandStruct *commandParent, CommandStruct *commandChild, char char buffer[1]; int pipefd[2]; int forkPID; - int *argc = &(commandParent->argc); char* pishLocation = GetHomeDir(); strcat(pishLocation, "/.pishrc"); int fd = open(pishLocation, O_RDONLY | O_CREAT, 0644); diff --git a/src/main.c b/src/main.c index 3b80286..05b7062 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ #include "Pish.h" -int main() +int main(void) { Pish(); }