diff options
| author | Mattias EngdegÄrd | 2022-02-01 20:43:15 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-02-01 20:45:36 +0100 |
| commit | 4af491605c58a4033116f17be15977e9b885fdee (patch) | |
| tree | 60a40cf550d83e89b82bc7b467595c8ac2562762 /src | |
| parent | e94f08b2d9b3dc77b5ffc609b62f54f9730895ef (diff) | |
| download | emacs-4af491605c58a4033116f17be15977e9b885fdee.tar.gz emacs-4af491605c58a4033116f17be15977e9b885fdee.zip | |
; * src/eval.c (funcall_subr): Fix last change
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/src/eval.c b/src/eval.c index 4f1c9077511..3e648ed6216 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -3105,60 +3105,64 @@ Lisp_Object | |||
| 3105 | funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *args) | 3105 | funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *args) |
| 3106 | { | 3106 | { |
| 3107 | eassume (numargs >= 0); | 3107 | eassume (numargs >= 0); |
| 3108 | /* Conforming call to finite-arity subr. */ | 3108 | if (numargs >= subr->min_args) |
| 3109 | if (numargs >= subr->min_args && numargs <= subr->max_args) | ||
| 3110 | { | 3109 | { |
| 3111 | Lisp_Object argbuf[8]; | 3110 | /* Conforming call to finite-arity subr. */ |
| 3112 | Lisp_Object *a; | 3111 | if (numargs <= subr->max_args) |
| 3113 | if (numargs < subr->max_args) | 3112 | { |
| 3114 | { | 3113 | Lisp_Object argbuf[8]; |
| 3115 | eassume (subr->max_args <= ARRAYELTS (argbuf)); | 3114 | Lisp_Object *a; |
| 3116 | a = argbuf; | 3115 | if (numargs < subr->max_args) |
| 3117 | memcpy (a, args, numargs * word_size); | 3116 | { |
| 3118 | memclear (a + numargs, (subr->max_args - numargs) * word_size); | 3117 | eassume (subr->max_args <= ARRAYELTS (argbuf)); |
| 3119 | } | 3118 | a = argbuf; |
| 3120 | else | 3119 | memcpy (a, args, numargs * word_size); |
| 3121 | a = args; | 3120 | memclear (a + numargs, (subr->max_args - numargs) * word_size); |
| 3122 | switch (subr->max_args) | 3121 | } |
| 3123 | { | 3122 | else |
| 3124 | case 0: | 3123 | a = args; |
| 3125 | return subr->function.a0 (); | 3124 | switch (subr->max_args) |
| 3126 | case 1: | 3125 | { |
| 3127 | return subr->function.a1 (a[0]); | 3126 | case 0: |
| 3128 | case 2: | 3127 | return subr->function.a0 (); |
| 3129 | return subr->function.a2 (a[0], a[1]); | 3128 | case 1: |
| 3130 | case 3: | 3129 | return subr->function.a1 (a[0]); |
| 3131 | return subr->function.a3 (a[0], a[1], a[2]); | 3130 | case 2: |
| 3132 | case 4: | 3131 | return subr->function.a2 (a[0], a[1]); |
| 3133 | return subr->function.a4 (a[0], a[1], a[2], a[3]); | 3132 | case 3: |
| 3134 | case 5: | 3133 | return subr->function.a3 (a[0], a[1], a[2]); |
| 3135 | return subr->function.a5 (a[0], a[1], a[2], a[3], a[4]); | 3134 | case 4: |
| 3136 | case 6: | 3135 | return subr->function.a4 (a[0], a[1], a[2], a[3]); |
| 3137 | return subr->function.a6 (a[0], a[1], a[2], a[3], a[4], a[5]); | 3136 | case 5: |
| 3138 | case 7: | 3137 | return subr->function.a5 (a[0], a[1], a[2], a[3], a[4]); |
| 3139 | return subr->function.a7 (a[0], a[1], a[2], a[3], a[4], a[5], a[6]); | 3138 | case 6: |
| 3140 | case 8: | 3139 | return subr->function.a6 (a[0], a[1], a[2], a[3], a[4], a[5]); |
| 3141 | return subr->function.a8 (a[0], a[1], a[2], a[3], a[4], a[5], a[6], | 3140 | case 7: |
| 3142 | a[7]); | 3141 | return subr->function.a7 (a[0], a[1], a[2], a[3], a[4], a[5], |
| 3143 | default: | 3142 | a[6]); |
| 3144 | /* If a subr takes more than 8 arguments without using MANY | 3143 | case 8: |
| 3145 | or UNEVALLED, we need to extend this function to support it. | 3144 | return subr->function.a8 (a[0], a[1], a[2], a[3], a[4], a[5], |
| 3146 | Until this is done, there is no way to call the function. */ | 3145 | a[6], a[7]); |
| 3147 | emacs_abort (); | 3146 | default: |
| 3148 | } | 3147 | /* If a subr takes more than 8 arguments without using MANY |
| 3149 | } | 3148 | or UNEVALLED, we need to extend this function to support it. |
| 3149 | Until this is done, there is no way to call the function. */ | ||
| 3150 | emacs_abort (); | ||
| 3151 | } | ||
| 3152 | } | ||
| 3150 | 3153 | ||
| 3151 | /* Call to n-adic subr. */ | 3154 | /* Call to n-adic subr. */ |
| 3152 | if (subr->max_args == MANY) | 3155 | if (subr->max_args == MANY) |
| 3153 | return subr->function.aMANY (numargs, args); | 3156 | return subr->function.aMANY (numargs, args); |
| 3157 | } | ||
| 3154 | 3158 | ||
| 3155 | /* Anything else is an error. */ | 3159 | /* Anything else is an error. */ |
| 3156 | Lisp_Object fun; | 3160 | Lisp_Object fun; |
| 3157 | XSETSUBR (fun, subr); | 3161 | XSETSUBR (fun, subr); |
| 3158 | if (subr->max_args >= 0) | 3162 | if (subr->max_args == UNEVALLED) |
| 3159 | xsignal2 (Qwrong_number_of_arguments, fun, make_fixnum (numargs)); | ||
| 3160 | else | ||
| 3161 | xsignal1 (Qinvalid_function, fun); | 3163 | xsignal1 (Qinvalid_function, fun); |
| 3164 | else | ||
| 3165 | xsignal2 (Qwrong_number_of_arguments, fun, make_fixnum (numargs)); | ||
| 3162 | } | 3166 | } |
| 3163 | 3167 | ||
| 3164 | /* Call the compiled Lisp function FUN. If we have not yet read FUN's | 3168 | /* Call the compiled Lisp function FUN. If we have not yet read FUN's |