mes.c: evcon: support clause without cdr. Fixes or.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-17 12:57:06 +02:00
parent f1bd1d461f
commit 71a89be833

28
mes.c
View file

@ -412,27 +412,29 @@ eval_ (scm *e, scm *a)
scm * scm *
evcon_ (scm *c, scm *a) evcon_ (scm *c, scm *a)
{ {
if (c == &scm_nil) return &scm_unspecified;
scm *clause = car (c);
#if DEBUG #if DEBUG
printf ("evcon_ clause="); printf ("evcon_ clause=");
display (car (c)); display (clause);
puts (""); puts ("");
#endif #endif
if (c == &scm_nil) return &scm_unspecified; scm *expr = eval (car (clause), a);
if (eval (caar (c), a) != &scm_f) { if (expr != &scm_f) {
#if DEBUG #if DEBUG
//if (fn != &scm_display && fn != &scm_call)
//if (fn != &scm_call)
printf ("#t clause="); printf ("#t clause=");
display (car (c)); display (clause);
printf (" cddar="); // printf (" cddr=");
display (cddar (c)); // display (cddr (clause));
printf (" nil=%d", cddar (c) == &scm_nil); // printf (" nil=%d", cddr (c) == &scm_nil);
puts (""); puts ("");
#endif #endif
if (cddar (c) == &scm_nil) if (cdr (clause) == &scm_nil)
return eval (cadar (c), a); return expr;
eval (cadar (c), a); if (cddr (clause) == &scm_nil)
return evcon_ (cons (cons (&scm_t, cddar (c)), &scm_nil), a); return eval (cadr (clause), a);
eval (cadr (clause), a);
return evcon_ (cons (cons (&scm_t, cddr (clause)), &scm_nil), a);
} }
return evcon_ (cdr (c), a); return evcon_ (cdr (c), a);
} }