core: assq: Prepare for M2-Planet.

* src/mes.c (assq): Prepare for M2-Planet.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-07-16 19:01:43 +02:00
parent 4c83a3bc6b
commit 673ca85c64
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -244,26 +244,41 @@ assq (SCM x, SCM a)
if (TYPE (a) != TPAIR)
return cell_f;
int t = TYPE (x);
if (t == TSYMBOL || t == TSPECIAL)
while (a != cell_nil && x != CAAR (a))
a = CDR (a);
while (a != cell_nil)
{
if (x == CAAR (a))
return CAR (a);
a = CDR (a);
}
else if (t == TCHAR || t == TNUMBER)
{
long v = VALUE (x);
while (a != cell_nil && v != VALUE (CAAR (a)))
a = CDR (a);
while (a != cell_nil)
{
if (v == VALUE (CAAR (a)))
return CAR (a);
a = CDR (a);
}
}
else if (t == TKEYWORD)
{
while (a != cell_nil && string_equal_p (x, CAAR (a)) == cell_f)
a = CDR (a);
while (a != cell_nil)
{
if (string_equal_p (x, CAAR (a)) == cell_t)
return CAR (a);
a = CDR (a);
}
}
else
/* pointer equality, e.g. on strings. */
while (a != cell_nil && x != CAAR (a))
a = CDR (a);
if (a != cell_nil)
return CAR (a);
while (a != cell_nil)
{
if (x == CAAR (a))
return CAR (a);
a = CDR (a);
}
return cell_f;
}