(sieve_code_command): Implemented implicit typecast from string to string-list.
Showing
1 changed file
with
45 additions
and
28 deletions
... | @@ -35,8 +35,8 @@ sieve_code (sieve_op_t *op) | ... | @@ -35,8 +35,8 @@ sieve_code (sieve_op_t *op) |
35 | sizeof sieve_machine->prog[0]); | 35 | sizeof sieve_machine->prog[0]); |
36 | if (!newprog) | 36 | if (!newprog) |
37 | { | 37 | { |
38 | sieve_error ("%s:%d: out of memory!", | 38 | sieve_compile_error (sieve_filename, sieve_line_num, |
39 | sieve_filename, sieve_line_num); | 39 | "out of memory!"); |
40 | return 1; | 40 | return 1; |
41 | } | 41 | } |
42 | sieve_machine->prog = newprog; | 42 | sieve_machine->prog = newprog; |
... | @@ -124,9 +124,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) | ... | @@ -124,9 +124,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) |
124 | 124 | ||
125 | if (rc) | 125 | if (rc) |
126 | { | 126 | { |
127 | sieve_error ("%s:%d: can't create iterator: %s", | 127 | sieve_compile_error (sieve_filename, sieve_line_num, |
128 | sieve_filename, sieve_line_num, | 128 | "can't create iterator: %s", |
129 | mu_errstring (rc)); | 129 | mu_errstring (rc)); |
130 | return 1; | 130 | return 1; |
131 | } | 131 | } |
132 | 132 | ||
... | @@ -142,8 +142,8 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) | ... | @@ -142,8 +142,8 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) |
142 | sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string); | 142 | sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string); |
143 | if (!tag) | 143 | if (!tag) |
144 | { | 144 | { |
145 | sieve_error ("%s:%d: invalid tag name `%s' for `%s'", | 145 | sieve_compile_error (sieve_filename, sieve_line_num, |
146 | sieve_filename, sieve_line_num, | 146 | "invalid tag name `%s' for `%s'", |
147 | val->v.string, reg->name); | 147 | val->v.string, reg->name); |
148 | err = 1; | 148 | err = 1; |
149 | break; | 149 | break; |
... | @@ -151,9 +151,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) | ... | @@ -151,9 +151,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) |
151 | 151 | ||
152 | if (!tag_list && (rc = list_create (&tag_list))) | 152 | if (!tag_list && (rc = list_create (&tag_list))) |
153 | { | 153 | { |
154 | sieve_error ("%s:%d: can't create tag list: %s", | 154 | sieve_compile_error (sieve_filename, sieve_line_num, |
155 | sieve_filename, sieve_line_num, | 155 | "%s:%d: can't create tag list: %s", |
156 | mu_errstring (rc)); | 156 | mu_errstring (rc)); |
157 | err = 1; | 157 | err = 1; |
158 | break; | 158 | break; |
159 | } | 159 | } |
... | @@ -174,28 +174,45 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) | ... | @@ -174,28 +174,45 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) |
174 | } | 174 | } |
175 | else if (*exp_arg == SVT_VOID) | 175 | else if (*exp_arg == SVT_VOID) |
176 | { | 176 | { |
177 | sieve_error ("%s:%d: too many arguments in call to `%s'", | 177 | sieve_compile_error (sieve_filename, sieve_line_num, |
178 | sieve_filename, sieve_line_num, | 178 | "too many arguments in call to `%s'", |
179 | reg->name); | 179 | reg->name); |
180 | err = 1; | ||
181 | break; | ||
182 | } | ||
183 | else if (*exp_arg != val->type) | ||
184 | { | ||
185 | sieve_error ("%s:%d: type mismatch in argument %d to `%s'", | ||
186 | sieve_filename, sieve_line_num, | ||
187 | exp_arg - reg->req_args + 1, | ||
188 | reg->name); | ||
189 | err = 1; | 180 | err = 1; |
190 | break; | 181 | break; |
191 | } | 182 | } |
192 | else | 183 | else |
193 | { | 184 | { |
185 | if (*exp_arg != val->type) | ||
186 | { | ||
187 | if (*exp_arg == SVT_STRING_LIST && val->type == SVT_STRING) | ||
188 | { | ||
189 | list_t list; | ||
190 | |||
191 | list_create (&list); | ||
192 | list_append (list, val->v.string); | ||
193 | sieve_pfree (&sieve_machine->memory_pool, val); | ||
194 | val = sieve_value_create (SVT_STRING_LIST, list); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | sieve_compile_error (sieve_filename, sieve_line_num, | ||
199 | "type mismatch in argument %d to `%s'", | ||
200 | exp_arg - reg->req_args + 1, | ||
201 | reg->name); | ||
202 | sieve_compile_error (sieve_filename, sieve_line_num, | ||
203 | "Expected %s but passed %s", | ||
204 | sieve_type_str (*exp_arg), | ||
205 | sieve_type_str (val->type)); | ||
206 | err = 1; | ||
207 | break; | ||
208 | } | ||
209 | } | ||
210 | |||
194 | if (!arg_list && (rc = list_create (&arg_list))) | 211 | if (!arg_list && (rc = list_create (&arg_list))) |
195 | { | 212 | { |
196 | sieve_error ("%s:%d: can't create arg list: %s", | 213 | sieve_compile_error (sieve_filename, sieve_line_num, |
197 | sieve_filename, sieve_line_num, | 214 | "can't create arg list: %s", |
198 | mu_errstring (rc)); | 215 | mu_errstring (rc)); |
199 | err = 1; | 216 | err = 1; |
200 | break; | 217 | break; |
201 | } | 218 | } |
... | @@ -211,9 +228,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) | ... | @@ -211,9 +228,9 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) |
211 | { | 228 | { |
212 | if (*exp_arg != SVT_VOID) | 229 | if (*exp_arg != SVT_VOID) |
213 | { | 230 | { |
214 | sieve_error ("%s:%d: too few arguments in call to `%s'", | 231 | sieve_compile_error (sieve_filename, sieve_line_num, |
215 | sieve_filename, sieve_line_num, | 232 | "too few arguments in call to `%s'", |
216 | reg->name); | 233 | reg->name); |
217 | err = 1; | 234 | err = 1; |
218 | } | 235 | } |
219 | } | 236 | } | ... | ... |
-
Please register or sign in to post a comment