More bug fixes
This commit is contained in:
+10
-7
@@ -250,25 +250,28 @@ DEFUN(member_if, "member-if", (LispVal * pred, LispVal *list), "(pred list)",
|
||||
|
||||
DEFUN(plist_put, "plist-put", (LispVal * plist, LispVal *prop, LispVal *value),
|
||||
"(plist prop value)", "") {
|
||||
CHECK_LISTP(plist);
|
||||
DOTAILS(rest, plist) {
|
||||
LispVal *rest = plist;
|
||||
while (!NILP(rest)) {
|
||||
CHECK_LISTP(rest);
|
||||
CHECK_TYPE(XCDR(rest), TYPE_CONS);
|
||||
if (EQ(XCAR(rest), prop)) {
|
||||
CHECK_TYPE(XCDR(rest), TYPE_CONS);
|
||||
RPLACA(XCDR(rest), value);
|
||||
return plist;
|
||||
}
|
||||
rest = XCDR(XCDR(rest));
|
||||
}
|
||||
return CONS(prop, CONS(value, plist));
|
||||
}
|
||||
|
||||
DEFUN(plist_get, "plist-get", (LispVal * plist, LispVal *prop, LispVal *def),
|
||||
"(plist prop &optional default)", "") {
|
||||
CHECK_LISTP(plist);
|
||||
DOTAILS(rest, plist) {
|
||||
if (EQ(XCAR(rest), prop)) {
|
||||
return SECOND(rest);
|
||||
while (!NILP(plist)) {
|
||||
CHECK_LISTP(plist);
|
||||
CHECK_TYPE(XCDR(plist), TYPE_CONS);
|
||||
if (EQ(XCAR(plist), prop)) {
|
||||
return SECOND(plist);
|
||||
}
|
||||
plist = XCDR(XCDR(plist));
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user