Commit 53070fb8 53070fb812795f4d608bbf66a46e56319ae23a3d by Sergey Poznyakoff

(decode_float): Return signed long value, as SpamAssassin scores

can be negative.
(spamd_test): Updated accordingly
1 parent 576c2273
...@@ -173,17 +173,24 @@ spamd_read_line (sieve_machine_t mach, stream_t stream, ...@@ -173,17 +173,24 @@ spamd_read_line (sieve_machine_t mach, stream_t stream,
173 #define char_to_num(c) (c-'0') 173 #define char_to_num(c) (c-'0')
174 174
175 static void 175 static void
176 decode_float (size_t *vn, char *str, int digits) 176 decode_float (long *vn, char *str, int digits)
177 { 177 {
178 size_t v; 178 long v;
179 size_t frac = 0; 179 size_t frac = 0;
180 size_t base = 1; 180 size_t base = 1;
181 int i; 181 int i;
182 int negative = 0;
182 183
183 for (i = 0; i < digits; i++) 184 for (i = 0; i < digits; i++)
184 base *= 10; 185 base *= 10;
185 186
186 v = strtoul (str, &str, 10); 187 v = strtol (str, &str, 10);
188 if (v < 0)
189 {
190 negative = 1;
191 v = - v;
192 }
193
187 v *= base; 194 v *= base;
188 if (*str == '.') 195 if (*str == '.')
189 { 196 {
...@@ -199,6 +206,8 @@ decode_float (size_t *vn, char *str, int digits) ...@@ -199,6 +206,8 @@ decode_float (size_t *vn, char *str, int digits)
199 frac *= 10; 206 frac *= 10;
200 } 207 }
201 *vn = v + frac; 208 *vn = v + frac;
209 if (negative)
210 *vn = - *vn;
202 } 211 }
203 212
204 static int 213 static int
...@@ -281,9 +290,9 @@ spamd_test (sieve_machine_t mach, list_t args, list_t tags) ...@@ -281,9 +290,9 @@ spamd_test (sieve_machine_t mach, list_t args, list_t tags)
281 char version_str[19]; 290 char version_str[19];
282 char spam_str[6], score_str[21], threshold_str[21]; 291 char spam_str[6], score_str[21], threshold_str[21];
283 int response, rc; 292 int response, rc;
284 size_t version; 293 long version;
285 int result; 294 int result;
286 size_t score, threshold, limit; 295 long score, threshold, limit;
287 stream_t stream = NULL; 296 stream_t stream = NULL;
288 sieve_value_t *arg; 297 sieve_value_t *arg;
289 message_t msg; 298 message_t msg;
......