@@ 47,7 47,7 @@ int nextoken(char *t, FILE *fp)
int c;
c = readtoken(t, fp);
- if (strcmp(t, "#") == 0) {
+ if (t[0] == '#') {
while ((c = fgetc(fp)) != EOF && c != '\n')
;
c = nextoken(t, fp);
@@ 189,9 189,6 @@ void loop(Tny *t)
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
- SDL_DestroyRenderer(renderer);
- SDL_DestroyWindow(window);
- SDL_Quit();
return;
} else if (e.type == SDL_KEYDOWN) {
switch (e.key.keysym.sym) {
@@ 204,7 201,7 @@ void loop(Tny *t)
}
if (e.type == SDL_KEYDOWN) {
if (t->ram[1]) {
- eval(t, t->ram[1]);
+ if (!eval(t, t->ram[1])) return;
}
}
} else if (e.type == SDL_KEYUP) {
@@ 220,7 217,7 @@ void loop(Tny *t)
}
if (t->ram[0]) {
- eval(t, t->ram[0]);
+ if (!eval(t, t->ram[0])) return;
}
frame = (frame + 1) % 60;
redraw();
@@ 276,5 273,9 @@ int main(int argc, char **argv)
printf("\n");
+ SDL_DestroyRenderer(renderer);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
return 0;
}