core: assq: Prepare for M2-Planet.

* src/mes.c (assq): Prepare for M2-Planet.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2019-10-24 19:01:43 +02:00
parent 182b568097
commit 1c69559575
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 25 additions and 10 deletions

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;
}