23 |
bind.c |
bind.c |
24 |
*/ |
*/ |
25 |
|
|
|
#define _GNU_SOURCE |
|
26 |
#include "include.h" |
#include "include.h" |
27 |
#include <string.h> |
#include <string.h> |
|
/* #include "varargs.h" */ |
|
28 |
|
|
29 |
struct nil3 { object nil3_self[3]; } three_nils; |
struct nil3 { object nil3_self[3]; } three_nils; |
30 |
struct nil6 { object nil6_self[6]; } six_nils; |
struct nil6 { object nil6_self[6]; } six_nils; |
908 |
}}} |
}}} |
909 |
|
|
910 |
int |
int |
911 |
|
parse_key_new_new(int n, object *base, struct key *keys, object first, va_list ap) |
912 |
|
{object *new; |
913 |
|
COERCE_VA_LIST_NEW(new,first,ap,n); |
914 |
|
|
915 |
|
/* from here down identical to parse_key_rest */ |
916 |
|
new = new + n ; |
917 |
|
{int j=keys->n; |
918 |
|
object *p= (object *)(keys->defaults); |
919 |
|
while (--j >=0) base[j]=p[j]; |
920 |
|
} |
921 |
|
{if (n==0){ return 0;} |
922 |
|
{int allow = keys->allow_other_keys; |
923 |
|
object k; |
924 |
|
|
925 |
|
if (!allow) { |
926 |
|
int i; |
927 |
|
for (i=n;i>0 && new[-i]!=sKallow_other_keys;i-=2); |
928 |
|
if (i>0 && new[-i+1]!=Cnil) |
929 |
|
allow=1; |
930 |
|
} |
931 |
|
|
932 |
|
top: |
933 |
|
while (n>=2) |
934 |
|
{int i= keys->n; |
935 |
|
iobject *ke=keys->keys ; |
936 |
|
new = new -2; |
937 |
|
k = *new; |
938 |
|
while(--i >= 0) |
939 |
|
{if ((*(ke++)).o == k) |
940 |
|
{base[i]= new[1]; |
941 |
|
n=n-2; |
942 |
|
goto top; |
943 |
|
}} |
944 |
|
/* the key is a new one */ |
945 |
|
if (allow || k==sKallow_other_keys) |
946 |
|
n=n-2; |
947 |
|
else |
948 |
|
goto error; |
949 |
|
} |
950 |
|
/* FIXME better message */ |
951 |
|
if (n!=0) FEunexpected_keyword(Cnil); |
952 |
|
return 0; |
953 |
|
error: |
954 |
|
FEunexpected_keyword(k); |
955 |
|
return -1; |
956 |
|
}}} |
957 |
|
|
958 |
|
int |
959 |
parse_key_rest(object rest, int n, object *base, struct key *keys, va_list ap) |
parse_key_rest(object rest, int n, object *base, struct key *keys, va_list ap) |
960 |
{object *new; |
{object *new; |
961 |
COERCE_VA_LIST(new,ap,n); |
COERCE_VA_LIST(new,ap,n); |
962 |
|
|
963 |
/* copy the rest arg */ |
/* copy the rest arg */ |
964 |
{object *p = new; |
{object *p = new; |
965 |
|
int m = n; |
966 |
|
while (--m >= 0) |
967 |
|
{rest->c.c_car = *p++; |
968 |
|
rest = rest->c.c_cdr;}} |
969 |
|
|
970 |
|
new = new + n ; |
971 |
|
{int j=keys->n; |
972 |
|
object *p= (object *)(keys->defaults); |
973 |
|
while (--j >=0) base[j]=p[j]; |
974 |
|
} |
975 |
|
{if (n==0){ return 0;} |
976 |
|
{int allow = keys->allow_other_keys; |
977 |
|
object k; |
978 |
|
|
979 |
|
if (!allow) { |
980 |
|
int i; |
981 |
|
for (i=n;i>0 && new[-i]!=sKallow_other_keys;i-=2); |
982 |
|
if (i>0 && new[-i+1]!=Cnil) |
983 |
|
allow=1; |
984 |
|
} |
985 |
|
|
986 |
|
top: |
987 |
|
while (n>=2) |
988 |
|
{int i= keys->n; |
989 |
|
iobject *ke=keys->keys ; |
990 |
|
new = new -2; |
991 |
|
k = *new; |
992 |
|
while(--i >= 0) |
993 |
|
{if ((*(ke++)).o == k) |
994 |
|
{base[i]= new[1]; |
995 |
|
n=n-2; |
996 |
|
goto top; |
997 |
|
}} |
998 |
|
/* the key is a new one */ |
999 |
|
if (allow || k==sKallow_other_keys) |
1000 |
|
n=n-2; |
1001 |
|
else |
1002 |
|
goto error; |
1003 |
|
} |
1004 |
|
/* FIXME better message */ |
1005 |
|
if (n!=0) FEunexpected_keyword(Cnil); |
1006 |
|
return 0; |
1007 |
|
error: |
1008 |
|
FEunexpected_keyword(k); |
1009 |
|
return -1; |
1010 |
|
}}} |
1011 |
|
|
1012 |
|
int |
1013 |
|
parse_key_rest_new(object rest, int n, object *base, struct key *keys, object first,va_list ap) |
1014 |
|
{object *new; |
1015 |
|
COERCE_VA_LIST_NEW(new,first,ap,n); |
1016 |
|
|
1017 |
|
/* copy the rest arg */ |
1018 |
|
{object *p = new; |
1019 |
int m = n; |
int m = n; |
1020 |
while (--m >= 0) |
while (--m >= 0) |
1021 |
{rest->c.c_car = *p++; |
{rest->c.c_car = *p++; |