aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-09-08 21:20:39 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-09-08 21:20:39 +0000
commit4cd3031ed36e207ce341c0854636c9047cd35d24 (patch)
tree6e9274a96c5fdb0984a6822e351eb7230d3319ef
parentda3381a039b1ab4878baa9e5fc9be39284a154f2 (diff)
downloadmailfromd-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--ChangeLog10
-rw-r--r--NEWS7
-rw-r--r--configure.ac2
-rw-r--r--src/bi_sieve.m42
-rw-r--r--src/bi_sprintf.m419
-rw-r--r--src/prog.c276
-rw-r--r--src/prog.h4
-rw-r--r--src/snarf.m470
8 files changed, 270 insertions, 120 deletions
diff --git a/ChangeLog b/ChangeLog
index 3602649b..5ab79460 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1 +1,11 @@
12008-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
12008-03-10 Sergey Poznyakoff <gray@gnu.org.ua> 112008-03-10 Sergey Poznyakoff <gray@gnu.org.ua>
diff --git a/NEWS b/NEWS
index 674dbae4..a212fcc2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,2 @@
1Mailfromd NEWS -- history of user-visible changes. 2008-03-10 1Mailfromd NEWS -- history of user-visible changes. 2008-09-09
2Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff 2Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff
@@ -7,2 +7,7 @@ Please send mailfromd bug reports to <bug-mailfromd@gnu.org.ua>
7 7
8Version 4.4.1
9
10* Fix stack reallocation.
11
12
8Version 4.4, 2008-03-10 13Version 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)
19m4_define([MF_VERSION_MINOR], 4) 19m4_define([MF_VERSION_MINOR], 4)
20dnl m4_define([MF_VERSION_PATCH], 0) 20m4_define([MF_VERSION_PATCH], 1)
21AC_INIT([mailfromd], 21AC_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
diff --git a/src/prog.c b/src/prog.c
index 26621102..9dc17daa 100644
--- a/src/prog.c
+++ b/src/prog.c
@@ -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
238struct eval_environ { 242struct 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 */
351void
352env_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
360void
361env_unregister_autos(eval_environ_t env)
362{
363 env->numautos = 0;
364}
365
366void
367env_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
465const char * 515void
466get_literal(eval_environ_t env, unsigned n) 516get_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
477char * 528void
478get_string_arg(eval_environ_t env, unsigned n) 529get_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
483size_t 535void
484get_numeric_arg(eval_environ_t env, unsigned n) 536get_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
541void
542get_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);