summaryrefslogtreecommitdiff
path: root/bf.c
diff options
context:
space:
mode:
Diffstat (limited to 'bf.c')
-rw-r--r--bf.c12
1 files changed, 10 insertions, 2 deletions
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;
}