diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-09-08 21:20:39 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-09-08 21:20:39 +0000 |
commit | 4cd3031ed36e207ce341c0854636c9047cd35d24 (patch) | |
tree | 6e9274a96c5fdb0984a6822e351eb7230d3319ef | |
parent | da3381a039b1ab4878baa9e5fc9be39284a154f2 (diff) | |
download | mailfromd-4cd3031ed36e207ce341c0854636c9047cd35d24.tar.gz mailfromd-4cd3031ed36e207ce341c0854636c9047cd35d24.tar.bz2 |
* src/snarf.m4, src/bi_sprintf.m4, src/prog.h, src/bi_sieve.m4,release_4_4_patches
Ported r1655 from trunk.
* src/prog.c: Ported r1655 and r1660 from trunk.
* NEWS: Update, set version number 4.4.1.
* configure.ac: set version number 4.4.1.
git-svn-id: file:///svnroot/mailfromd/branches/release_4_4_patches@1661 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/bi_sieve.m4 | 2 | ||||
-rw-r--r-- | src/bi_sprintf.m4 | 19 | ||||
-rw-r--r-- | src/prog.c | 276 | ||||
-rw-r--r-- | src/prog.h | 4 | ||||
-rw-r--r-- | src/snarf.m4 | 70 |
8 files changed, 270 insertions, 120 deletions
@@ -1 +1,11 @@ | |||
1 | 2008-09-08 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | * src/snarf.m4, src/bi_sprintf.m4, src/prog.h, src/bi_sieve.m4, | ||
4 | Ported r1655 from trunk. | ||
5 | |||
6 | * src/prog.c: Ported r1655 and r1660 from trunk. | ||
7 | |||
8 | * NEWS: Update, set version number 4.4.1. | ||
9 | * configure.ac: set version number 4.4.1. | ||
10 | |||
1 | 2008-03-10 Sergey Poznyakoff <gray@gnu.org.ua> | 11 | 2008-03-10 Sergey Poznyakoff <gray@gnu.org.ua> |
@@ -1,2 +1,2 @@ | |||
1 | Mailfromd NEWS -- history of user-visible changes. 2008-03-10 | 1 | Mailfromd NEWS -- history of user-visible changes. 2008-09-09 |
2 | Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff | 2 | Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff |
@@ -7,2 +7,7 @@ Please send mailfromd bug reports to <bug-mailfromd@gnu.org.ua> | |||
7 | 7 | ||
8 | Version 4.4.1 | ||
9 | |||
10 | * Fix stack reallocation. | ||
11 | |||
12 | |||
8 | Version 4.4, 2008-03-10 | 13 | Version 4.4, 2008-03-10 |
diff --git a/configure.ac b/configure.ac index 5a146171..5a6e224c 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -19,3 +19,3 @@ m4_define([MF_VERSION_MAJOR], 4) | |||
19 | m4_define([MF_VERSION_MINOR], 4) | 19 | m4_define([MF_VERSION_MINOR], 4) |
20 | dnl m4_define([MF_VERSION_PATCH], 0) | 20 | m4_define([MF_VERSION_PATCH], 1) |
21 | AC_INIT([mailfromd], | 21 | AC_INIT([mailfromd], |
diff --git a/src/bi_sieve.m4 b/src/bi_sieve.m4 index 04ae8f95..0c5af274 100644 --- a/src/bi_sieve.m4 +++ b/src/bi_sieve.m4 | |||
@@ -153,3 +153,3 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER dbg) | |||
153 | rc = mu_sieve_compile(mach, script); | 153 | rc = mu_sieve_compile(mach, script); |
154 | if (rc == 0){ | 154 | if (rc == 0) { |
155 | mu_stream_t mstr = env_get_stream(env); | 155 | mu_stream_t mstr = env_get_stream(env); |
diff --git a/src/bi_sprintf.m4 b/src/bi_sprintf.m4 index afd63d32..051d2dc4 100644 --- a/src/bi_sprintf.m4 +++ b/src/bi_sprintf.m4 | |||
@@ -152,4 +152,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
152 | if (*q == '$') { | 152 | if (*q == '$') { |
153 | num = (unsigned) MF_VA_ARG(n-1, | 153 | MF_VA_ARG(n-1, NUMBER, num); |
154 | NUMBER); | ||
155 | p = q + 1; | 154 | p = q + 1; |
@@ -163,3 +162,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
163 | } | 162 | } |
164 | num = MF_VA_ARG(i, NUMBER); | 163 | MF_VA_ARG(i, NUMBER, num); |
165 | i++; | 164 | i++; |
@@ -195,3 +194,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
195 | if (*q == '$') { | 194 | if (*q == '$') { |
196 | num = MF_VA_ARG(n-1, NUMBER); | 195 | MF_VA_ARG(n-1, NUMBER, num); |
197 | if (num > 0) | 196 | if (num > 0) |
@@ -202,3 +201,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
202 | } | 201 | } |
203 | num = MF_VA_ARG(i, NUMBER); | 202 | MF_VA_ARG(i, NUMBER, num); |
204 | i++; | 203 | i++; |
@@ -213,3 +212,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
213 | case 's': | 212 | case 's': |
214 | str = MF_VA_ARG(argnum,STRING); | 213 | MF_VA_ARG(argnum, STRING, str); |
215 | n = strlen(str); | 214 | n = strlen(str); |
@@ -237,3 +236,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
237 | case 'd': | 236 | case 'd': |
238 | num = MF_VA_ARG(argnum,NUMBER); | 237 | MF_VA_ARG(argnum, NUMBER, num); |
239 | if (num < 0) { | 238 | if (num < 0) { |
@@ -292,3 +291,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
292 | case 'u': | 291 | case 'u': |
293 | num = MF_VA_ARG(argnum,NUMBER); | 292 | MF_VA_ARG(argnum, NUMBER, num); |
294 | /* If a precision is given with a | 293 | /* If a precision is given with a |
@@ -325,3 +324,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
325 | case 'X': | 324 | case 'X': |
326 | num = MF_VA_ARG(argnum,NUMBER); | 325 | MF_VA_ARG(argnum, NUMBER, num); |
327 | /* If a precision is given with a | 326 | /* If a precision is given with a |
@@ -371,3 +370,3 @@ MF_DEFUN_VARARGS(sprintf, STRING, STRING format) | |||
371 | case 'o': | 370 | case 'o': |
372 | num = MF_VA_ARG(argnum,NUMBER); | 371 | MF_VA_ARG(argnum, NUMBER, num); |
373 | /* If a precision is given with a | 372 | /* If a precision is given with a |
@@ -237,2 +237,6 @@ disable_prog_trace(const char *modlist) | |||
237 | 237 | ||
238 | /* Max. number of C locals to save in struct eval_environ for eventual fixups. | ||
239 | See comment to env_fixup_autos, below. */ | ||
240 | #define MAX_AUTO_PTR 128 | ||
241 | |||
238 | struct eval_environ { | 242 | struct eval_environ { |
@@ -255,2 +259,6 @@ struct eval_environ { | |||
255 | size_t temp_size; | 259 | size_t temp_size; |
260 | |||
261 | STKVAL *auto_ptr[MAX_AUTO_PTR]; /* Pointers to C automatic variables | ||
262 | referring to dataseg. */ | ||
263 | size_t numautos; /* Number of entries in auto_ptr. */ | ||
256 | 264 | ||
@@ -330,2 +338,40 @@ env_get_stream(eval_environ_t env) | |||
330 | 338 | ||
339 | |||
340 | /* A call to expand_dataseg (see below) invalidates any C variables that | ||
341 | pointed to dataseg before the call. To avoid dereferencing invalid memory | ||
342 | pointers, the addresses of such C variables are stored in env->auto_ptr | ||
343 | using env_register_auto (it is done by get_string_arg). When | ||
344 | expand_dataseg is called, it calls env_fixup_autos and passes it the | ||
345 | offset of new dataseg from old one. env_fixup_autos adds this value to | ||
346 | every address in auto_ptr, thereby fixing them. | ||
347 | |||
348 | The auto_ptr array is cleared (by calling env_unregister_autos) after | ||
349 | executing each instruction (see eval_environment). | ||
350 | */ | ||
351 | void | ||
352 | env_register_auto(eval_environ_t env, void *ptr) | ||
353 | { | ||
354 | if (env->numautos == MAX_AUTO_PTR) | ||
355 | runtime_error(env, "INTERNAL ERROR at %s:%d, please report", | ||
356 | __FILE__, __LINE__); | ||
357 | env->auto_ptr[env->numautos++] = ptr; | ||
358 | } | ||
359 | |||
360 | void | ||
361 | env_unregister_autos(eval_environ_t env) | ||
362 | { | ||
363 | env->numautos = 0; | ||
364 | } | ||
365 | |||
366 | void | ||
367 | env_fixup_autos(eval_environ_t env, ptrdiff_t offset) | ||
368 | { | ||
369 | int i; | ||
370 | for (i = 0; i < env->numautos; i++) { | ||
371 | STKVAL *pptr = env->auto_ptr[i]; | ||
372 | *pptr += offset; | ||
373 | } | ||
374 | } | ||
375 | |||
376 | |||
331 | #define STACK_EXPAND_BLOCK 64 | 377 | #define STACK_EXPAND_BLOCK 64 |
@@ -336,2 +382,4 @@ expand_dataseg(eval_environ_t env, size_t count, const char *errtext) | |||
336 | STKVAL *newds; | 382 | STKVAL *newds; |
383 | ptrdiff_t offset; | ||
384 | |||
337 | count = ((count + STACK_EXPAND_BLOCK - 1) / STACK_EXPAND_BLOCK) | 385 | count = ((count + STACK_EXPAND_BLOCK - 1) / STACK_EXPAND_BLOCK) |
@@ -348,2 +396,3 @@ expand_dataseg(eval_environ_t env, size_t count, const char *errtext) | |||
348 | 396 | ||
397 | offset = (char*)newds - (char*)env->dataseg; | ||
349 | env->dataseg = newds; | 398 | env->dataseg = newds; |
@@ -355,2 +404,3 @@ expand_dataseg(eval_environ_t env, size_t count, const char *errtext) | |||
355 | * sizeof newds[0]); | 404 | * sizeof newds[0]); |
405 | env_fixup_autos(env, offset); | ||
356 | mu_error(_("Warning: stack segment expanded, new size=%lu"), | 406 | mu_error(_("Warning: stack segment expanded, new size=%lu"), |
@@ -464,6 +514,7 @@ get_immediate(eval_environ_t env, unsigned n) | |||
464 | 514 | ||
465 | const char * | 515 | void |
466 | get_literal(eval_environ_t env, unsigned n) | 516 | get_literal(eval_environ_t env, unsigned n, const char **p) |
467 | { | 517 | { |
468 | return (char*)(env->dataseg + (size_t) get_immediate(env, n)); | 518 | *p = (char*)(env->dataseg + (size_t) get_immediate(env, n)); |
519 | env_register_auto(env, p); | ||
469 | } | 520 | } |
@@ -476,12 +527,19 @@ get_arg(eval_environ_t env, unsigned n) | |||
476 | 527 | ||
477 | char * | 528 | void |
478 | get_string_arg(eval_environ_t env, unsigned n) | 529 | get_string_arg(eval_environ_t env, unsigned n, char **p) |
479 | { | 530 | { |
480 | return (char*) (env->dataseg + (size_t) get_arg(env, n)); | 531 | *p = (char*) (env->dataseg + (size_t) get_arg(env, n)); |
532 | env_register_auto(env, p); | ||
481 | } | 533 | } |
482 | 534 | ||
483 | size_t | 535 | void |
484 | get_numeric_arg(eval_environ_t env, unsigned n) | 536 | get_numeric_arg(eval_environ_t env, unsigned n, long *np) |
485 | { | 537 | { |
486 | return (size_t) get_arg(env, n); | 538 | *np = (long) get_arg(env, n); |
539 | } | ||
540 | |||
541 | void | ||
542 | get_pointer_arg(eval_environ_t env, unsigned n, void **p) | ||
543 | { | ||
544 | *p = (void*) get_arg(env, n); | ||
487 | } | 545 | } |
@@ -491,6 +549,5 @@ push(eval_environ_t env, STKVAL val) | |||
491 | { | 549 | { |
492 | if (env->tos < env->toh) | 550 | if (env->tos < env->toh) |
493 | runtime_error(env, "INTERNAL ERROR at %s:%d, please report", | 551 | runtime_error(env, "INTERNAL ERROR at %s:%d, please report", |
494 | __FILE__, __LINE__); | 552 | __FILE__, __LINE__); |
495 | |||
496 | if (env->tos == env->toh) { | 553 | if (env->tos == env->toh) { |
@@ -593,4 +650,4 @@ instr_locus(eval_environ_t env) | |||
593 | { | 650 | { |
594 | env->locus.file = get_literal(env, 0); |