summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--bf.c12
2 files changed, 11 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 82f2073..91662fe 100644
--- a/Makefile
+++ b/Makefile
@@ -2,5 +2,6 @@
PROG= bf
NOMAN=
+CFLAGS+= -Wall -ggdb
.include <bsd.prog.mk>
diff --git a/bf.c b/bf.c
index 5ef01c0..ff4f14c 100644
--- a/bf.c
+++ b/bf.c
@@ -71,7 +71,10 @@ main(int argc, char **argv)
data = alloccell();
- for (p = prog; p; p = p->next)
+ for (p = prog; p; p = p->next) {
+#if debug
+ fprintf(stderr, "\t%c: %d\n", p->value, data->value);
+#endif
switch (p->value) {
case '>':
if (!data->next) {
@@ -104,15 +107,20 @@ main(int argc, char **argv)
if (data->value == 0)
while (p && p->value != ']')
p = p->next;
+ if (!p)
+ goto quit;
break;
case ']':
if (data->value != 0)
while (p && p->value != '[')
p = p->prev;
+ if (!p)
+ goto quit;
break;
default:
break;
}
-
+ }
+quit:
return 0;
}