mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Began working on a few bugs, thanks /u/skeeto!
This commit is contained in:
4
.github/workflows/c-cpp.yml
vendored
4
.github/workflows/c-cpp.yml
vendored
@@ -15,5 +15,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: install valgrind
|
||||
run: sudo apt install valgrind
|
||||
- name: make test
|
||||
- name: make test (valgrind)
|
||||
run: make test
|
||||
- name: make test (sanitized)
|
||||
run: make test-sanitized
|
||||
|
||||
7
makefile
7
makefile
@@ -1,5 +1,6 @@
|
||||
# Optimisation Options
|
||||
# export CFLAGS+=-O2 -mtune=native -march=native
|
||||
# export CFLAGS+=-fsanitize=address,undefined
|
||||
|
||||
export TOY_OUTDIR = out
|
||||
|
||||
@@ -35,6 +36,12 @@ static-release: $(TOY_OUTDIR)
|
||||
test: clean $(TOY_OUTDIR)
|
||||
$(MAKE) -C test
|
||||
|
||||
test-sanitized: export CFLAGS+=-fsanitize=address,undefined
|
||||
test-sanitized: export LIBS+=-static-libasan
|
||||
test-sanitized: export DISABLE_VALGRIND=true
|
||||
test-sanitized: clean $(TOY_OUTDIR)
|
||||
$(MAKE) -C test
|
||||
|
||||
$(TOY_OUTDIR):
|
||||
mkdir $(TOY_OUTDIR)
|
||||
|
||||
|
||||
@@ -30,7 +30,11 @@ void repl() {
|
||||
|
||||
for(;;) {
|
||||
printf("> ");
|
||||
fgets(input, size, stdin);
|
||||
|
||||
//handle EOF for exits
|
||||
if (!fgets(input, size, stdin)) {
|
||||
break;
|
||||
}
|
||||
|
||||
//escape the repl (length of 5 to accomodate the newline)
|
||||
if (strlen(input) == 5 && (!strncmp(input, "exit", 4) || !strncmp(input, "quit", 4))) {
|
||||
|
||||
@@ -180,19 +180,22 @@ static unsigned char readByte(unsigned char* tb, int* count) {
|
||||
}
|
||||
|
||||
static unsigned short readShort(unsigned char* tb, int* count) {
|
||||
unsigned short ret = *(unsigned short*)(tb + *count);
|
||||
unsigned short ret = 0;
|
||||
memcpy(&ret, tb + *count, 2);
|
||||
*count += 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int readInt(unsigned char* tb, int* count) {
|
||||
int ret = *(int*)(tb + *count);
|
||||
int ret = 0;
|
||||
memcpy(&ret, tb + *count, 4);
|
||||
*count += 4;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static float readFloat(unsigned char* tb, int* count) {
|
||||
float ret = *(float*)(tb + *count);
|
||||
float ret = 0;
|
||||
memcpy(&ret, tb + *count, 4);
|
||||
*count += 4;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ all: $(OBJ) $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe)
|
||||
|
||||
../$(TOY_OUTDIR)/%.exe: $(ODIR)/%.o
|
||||
@$(CC) -o $@ $< $(TARGETS:../source/%.c=$(ODIR)/%.o) $(CFLAGS) $(LIBS)
|
||||
ifeq ($(shell uname),Linux)
|
||||
ifeq ($(shell uname)$(DISABLE_VALGRIND),Linux)
|
||||
valgrind --leak-check=full --track-origins=yes $@
|
||||
else
|
||||
$@
|
||||
|
||||
Reference in New Issue
Block a user