diff options
Diffstat (limited to 'comp/lucas-standen-NEA/code2')
-rw-r--r-- | comp/lucas-standen-NEA/code2/Makefile | 37 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/Makefile.new | 25 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/fileread.c (renamed from comp/lucas-standen-NEA/code2/parser.c) | 2 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/fileread.h (renamed from comp/lucas-standen-NEA/code2/parser.h) | 2 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/stdlib/Makefile | 28 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/stdlib/String/String.c | 6 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/code2/stdlib/zpylib.c | 2 | ||||
-rwxr-xr-x | comp/lucas-standen-NEA/code2/zpy | bin | 0 -> 22360 bytes | |||
-rw-r--r-- | comp/lucas-standen-NEA/code2/zpy.c | 4 |
9 files changed, 68 insertions, 38 deletions
diff --git a/comp/lucas-standen-NEA/code2/Makefile b/comp/lucas-standen-NEA/code2/Makefile index cfd4254..e01a111 100644 --- a/comp/lucas-standen-NEA/code2/Makefile +++ b/comp/lucas-standen-NEA/code2/Makefile @@ -1,26 +1,25 @@ -CC = cc -CFLAGS =-O3 +CC=cc +CFLAGS=-O3 -zpy: zpy.c comp.c parser.c tokenizer.c util.c - ${CC} *.c -c ${CFLAGS} - ${CC} *.o -o zpy ${CFLAGS} - cd stdlib && make -clean: - rm -rf zpy *.o *.core sample out stdlib/*.o - cd stdlib && make clean - cd examples && make clean +SRC = zpy.c comp.c tokenizer.c fileread.c util.c appendsnprintf.c +OBJ = ${SRC:.c=.o} -install: zpy - mkdir -p /usr/local/share/zpylib - mkdir -p /usr/local/share/zpylib/include - cp ./zpy /usr/local/bin/zpy +all: zpy +.c.o: + ${CC} -c ${CFLAGS} $< +zpy: ${OBJ} + ${CC} -o $@ ${OBJ} + cd stdlib && make +install: all + cp zpy /usr/local/bin/zpy cd stdlib && make install cd zpypkg && make install - -example: zpy - cd examples && make - +clean: + rm -rf zpy*.o + cd stdlib && make clean + cd examples && make clean uninstall: rm /usr/local/bin/zpy - rm -rf /usr/local/share/zpylib + +.PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/Makefile.new b/comp/lucas-standen-NEA/code2/Makefile.new new file mode 100644 index 0000000..8dcb4db --- /dev/null +++ b/comp/lucas-standen-NEA/code2/Makefile.new @@ -0,0 +1,25 @@ +CC=cc +CFLAGS=-O3 + +SRC = zpy.c comp.c tokenizer.c fileread.c util.c appendsnprintf.c +OBJ = ${SRC:.c=.o} + +all: zpy + +.c.o: + ${CC} -c ${CFLAGS} $< +zpy: ${OBJ} + ${CC} -o $@ ${OBJ} + cd stdlib && make +install: all + cp zpy /usr/local/bin/zpy + cd stdlib && make install + cd zpypkg && make install +clean: + rm -rf zpy*.o + cd stdlib && make clean + cd examples && make clean +uninstall: + rm /usr/local/bin/zpy + +.PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/parser.c b/comp/lucas-standen-NEA/code2/fileread.c index a84291b..0bfc497 100644 --- a/comp/lucas-standen-NEA/code2/parser.c +++ b/comp/lucas-standen-NEA/code2/fileread.c @@ -20,7 +20,7 @@ int countChars(char *s, char c){ } //# returns an array of strings (type strings) of the file contents, split by line -strings *parse(FILE *f){ +strings *fileread(FILE *f){ strings *strs = malloc(sizeof(strings)); strs->strs = malloc(sizeof(char **)); diff --git a/comp/lucas-standen-NEA/code2/parser.h b/comp/lucas-standen-NEA/code2/fileread.h index 80a5f08..fe47f25 100644 --- a/comp/lucas-standen-NEA/code2/parser.h +++ b/comp/lucas-standen-NEA/code2/fileread.h @@ -10,4 +10,4 @@ typedef struct strings { int count; } strings; -strings *parse(FILE *f); +strings *fileread(FILE *f); diff --git a/comp/lucas-standen-NEA/code2/stdlib/Makefile b/comp/lucas-standen-NEA/code2/stdlib/Makefile index 9d4bfd6..c69992c 100644 --- a/comp/lucas-standen-NEA/code2/stdlib/Makefile +++ b/comp/lucas-standen-NEA/code2/stdlib/Makefile @@ -1,17 +1,23 @@ CC=cc CFLAGS=-O3 -stdlib: - cd String && make - ${CC} zpylib.c -c -o zpylib.o ${CFLAGS} +SRC = zpylib.c +OBJ = ${SRC:.c=.o} -clean: - rm -rf *.o - cd String && make clean +all: zpy -install: - cp *.o /usr/local/share/zpylib/ - cp *.h /usr/local/share/zpylib/include/ - cp String/String.o /usr/local/share/zpylib - cp String/String.h /usr/local/share/zpylib/include +.c.o: + ${CC} -c ${CFLAGS} $< + cd String && make +install: all + cp zpy /usr/local/bin/zpy + cd stdlib && make install + cd zpypkg && make install +clean: + rm -rf zpy*.o + cd stdlib && make clean + cd examples && make clean +uninstall: + rm /usr/local/bin/zpy +.PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/stdlib/String/String.c b/comp/lucas-standen-NEA/code2/stdlib/String/String.c index 6f11119..c273351 100644 --- a/comp/lucas-standen-NEA/code2/stdlib/String/String.c +++ b/comp/lucas-standen-NEA/code2/stdlib/String/String.c @@ -16,7 +16,7 @@ void __stringprint(string *self){ } void __stringinput(string *self, size_t len){ - char *tmp = calloc(0, len); + char *tmp = calloc(1, len); fgets(tmp, len, stdin); self->fromcstring(self, tmp); } @@ -109,7 +109,7 @@ string **__stringsplit(string *self, char delim){ int j = 0; for (int i = 0; i < splitcount; i++){ - char *str = calloc(0, self->_len); + char *str = calloc(1, self->_len); int charcount = 0; for (; self->_str[j] != delim && j < self->_len; j++){ str[charcount] = self->_str[j]; @@ -129,7 +129,7 @@ string *String(char *cstring){ // returns an allocated String from a C string in size_t len = strlen(cstring); string *str = malloc(sizeof(string)); - str->_str = calloc(0, len); + str->_str = calloc(1, len); memcpy(str->_str, cstring, len); str->_len = len; diff --git a/comp/lucas-standen-NEA/code2/stdlib/zpylib.c b/comp/lucas-standen-NEA/code2/stdlib/zpylib.c index 86f0dc3..7b512dd 100644 --- a/comp/lucas-standen-NEA/code2/stdlib/zpylib.c +++ b/comp/lucas-standen-NEA/code2/stdlib/zpylib.c @@ -21,7 +21,7 @@ void printfloat(double f){ } char *readstr(){ - char *str = calloc(0, 256); + char *str = calloc(1, 256); fgets(str, 256, stdin); return str; } diff --git a/comp/lucas-standen-NEA/code2/zpy b/comp/lucas-standen-NEA/code2/zpy Binary files differnew file mode 100755 index 0000000..85eb8a2 --- /dev/null +++ b/comp/lucas-standen-NEA/code2/zpy diff --git a/comp/lucas-standen-NEA/code2/zpy.c b/comp/lucas-standen-NEA/code2/zpy.c index b96615b..65fd7ae 100644 --- a/comp/lucas-standen-NEA/code2/zpy.c +++ b/comp/lucas-standen-NEA/code2/zpy.c @@ -3,7 +3,7 @@ #include <stdbool.h> #include "util.h" -#include "parser.h" +#include "fileread.h" #include "comp.h" #include "appendsnprintf.h" @@ -61,7 +61,7 @@ int main(int argc, char **argv){ if (fout == NULL) die("no such file or directory"); - strings *stringTokens = parse(f); + strings *stringTokens = fileread(f); if (stringTokens == NULL) die("couldn't parse file, is it formated properly?"); |