altos/lisp: Move stack recursion check after null check
[fw/altos] / src / lisp / ao_lisp_stack.c
index 9c773e83cef3cf95a61aa14fda5cccd4bce73135..53adf43204bfcafa6622f64d00bcd04e39cc03bb 100644 (file)
@@ -12,7 +12,6 @@
  * General Public License for more details.
  */
 
-#define DBG_EVAL 0
 #include "ao_lisp.h"
 
 const struct ao_lisp_type ao_lisp_stack_type;
@@ -161,11 +160,11 @@ ao_lisp_stack_print(ao_poly poly)
 {
        struct ao_lisp_stack *s = ao_lisp_poly_stack(poly);
 
-       if (s->type & AO_LISP_STACK_PRINT) {
-               printf("[recurse...]");
-               return;
-       }
        while (s) {
+               if (s->type & AO_LISP_STACK_PRINT) {
+                       printf("[recurse...]");
+                       return;
+               }
                s->type |= AO_LISP_STACK_PRINT;
                printf("\t[\n");
                printf("\t\texpr:   "); ao_lisp_poly_print(s->list); printf("\n");