From 811c11557492b9a6e6bd5ae45bb5597647ba5c99 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 11 Jan 2012 14:52:23 -0500 Subject: [PATCH 01/16] Ignore a.out.DSYM (this file sometims shows up when using the debugger) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fbd844aa..8cf8b226 100644 --- a/.gitignore +++ b/.gitignore @@ -80,4 +80,5 @@ *.1 *.5 *.8 +a.out.DSYM RPM/ -- 2.56.1 From 2c3d90ed127ab47e695350367ca3c34d4324bcc4 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 11 Jan 2012 15:04:39 -0500 Subject: [PATCH 02/16] Completely remove the use of TIME_WITH_SYS_TIME (I removed the autoconf test but never removed the code, and this caused some problems on systems that needed some prototypes in ). --- sbr/dtimep.lex | 10 ++-------- sbr/fmt_compile.c | 10 ++-------- sbr/fmt_scan.c | 10 ++-------- sbr/lock_file.c | 10 ++-------- uip/mhbuildsbr.c | 10 ++-------- uip/mhcachesbr.c | 10 ++-------- uip/picksbr.c | 10 ++-------- uip/post.c | 10 ++-------- uip/sendsbr.c | 10 ++-------- 9 files changed, 18 insertions(+), 72 deletions(-) diff --git a/sbr/dtimep.lex b/sbr/dtimep.lex index 01910868..29c4dd0c 100644 --- a/sbr/dtimep.lex +++ b/sbr/dtimep.lex @@ -160,16 +160,10 @@ static int day_map[] = { --cp; } #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST -# ifdef TIME_WITH_SYS_TIME +# ifdef HAVE_SYS_TIME_H # include -# include -# else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif # endif +#include static void zonehack (struct tws *tw) diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index a180c561..a86661e9 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -13,16 +13,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include /* * hash table for deciding if a component is "interesting" diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 8d038360..97849198 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -13,16 +13,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include #ifdef MULTIBYTE_SUPPORT # include # include diff --git a/sbr/lock_file.c b/sbr/lock_file.c index c4353b59..c7dffcfc 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -19,16 +19,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include #include #ifdef HAVE_FCNTL_H diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index ea2bcd68..2a3f8996 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -27,16 +27,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include extern int debugsw; diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 807cf600..cf9087b2 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -21,16 +21,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include extern int debugsw; diff --git a/uip/picksbr.c b/uip/picksbr.c index bd4c263e..4afd0941 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -12,16 +12,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include static struct swit parswit[] = { #define PRAND 0 diff --git a/uip/post.c b/uip/post.c index 6429cb4a..515e1d5a 100644 --- a/uip/post.c +++ b/uip/post.c @@ -23,16 +23,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include #ifdef SMTPMTS # include diff --git a/uip/sendsbr.c b/uip/sendsbr.c index f0c84f5e..6215219e 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -16,16 +16,10 @@ #include #include -#ifdef TIME_WITH_SYS_TIME +#ifdef HAVE_SYS_TIME_H # include -# include -#else -# ifdef TM_IN_SYS_TIME -# include -# else -# include -# endif #endif +#include int debugsw = 0; /* global */ int forwsw = 1; -- 2.56.1 From cfbb7d214978767f9bab016a5c00f44680126063 Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 16:45:53 -0600 Subject: [PATCH 03/16] Added #include . It's needed on Linux, should be harmless on others. --- uip/slocal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uip/slocal.c b/uip/slocal.c index 13d05116..44e5988d 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -34,6 +34,10 @@ #include #include +/* Hopefully, grp.h declares initgroups(). If we run into a platform + where it doesn't, we could consider declaring it here as well. */ +#include + /* This define is needed for Berkeley db v2 and above to * make the header file expose the 'historical' ndbm APIs. * We define it unconditionally because this is simple and -- 2.56.1 From 6a68057d8ef48bef3ee752741a53a629a2840e68 Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 16:52:17 -0600 Subject: [PATCH 04/16] Removed unused global zones and local z form dtimezone (). --- sbr/dtime.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/sbr/dtime.c b/sbr/dtime.c index 5d5375d4..7ec75511 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -53,46 +53,6 @@ struct zone { int shift; }; -static struct zone zones[] = { - { "GMT", "BST", 0 }, - { "EST", "EDT", -5 }, - { "CST", "CDT", -6 }, - { "MST", "MDT", -7 }, - { "PST", "PDT", -8 }, -#if 0 -/* RFC1123 specifies do not use military TZs */ - { "A", NULL, -1 }, - { "B", NULL, -2 }, - { "C", NULL, -3 }, - { "D", NULL, -4 }, - { "E", NULL, -5 }, - { "F", NULL, -6 }, - { "G", NULL, -7 }, - { "H", NULL, -8 }, - { "I", NULL, -9 }, - { "K", NULL, -10 }, - { "L", NULL, -11 }, - { "M", NULL, -12 }, - { "N", NULL, 1 }, -#ifndef HUJI - { "O", NULL, 2 }, -#else - { "JST", "JDT", 2 }, -#endif - { "P", NULL, 3 }, - { "Q", NULL, 4 }, - { "R", NULL, 5 }, - { "S", NULL, 6 }, - { "T", NULL, 7 }, - { "U", NULL, 8 }, - { "V", NULL, 9 }, - { "W", NULL, 10 }, - { "X", NULL, 11 }, - { "Y", NULL, 12 }, -#endif - { NULL, NULL, 0 } -}; - static int dmsize[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -333,7 +293,6 @@ char * dtimezone (int offset, int flags) { int hours, mins; - struct zone *z; static char buffer[10]; if (offset < 0) { -- 2.56.1 From 6e00dba11ff815307cd60cee7a7f69d115591c7e Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 17:06:44 -0600 Subject: [PATCH 05/16] Removed or protected some unused macros. --- sbr/client.c | 3 --- sbr/fmt_scan.c | 2 -- sbr/uprf.c | 6 ++++-- uip/inc.c | 4 +++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sbr/client.c b/sbr/client.c index 763b2a4c..7ae356ad 100644 --- a/sbr/client.c +++ b/sbr/client.c @@ -16,9 +16,6 @@ #include #include -#define TRUE 1 -#define FALSE 0 - #define MAXARGS 1000 /* diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 97849198..2bf18210 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -22,8 +22,6 @@ # include #endif -#define NFMTS MAXARGS - extern char *formataddr (); /* hook for custom address formatting */ #ifdef LBL diff --git a/sbr/uprf.c b/sbr/uprf.c index b3c81ff0..5da5e765 100644 --- a/sbr/uprf.c +++ b/sbr/uprf.c @@ -9,8 +9,10 @@ #include -#define TO_LOWER 040 -#define NO_MASK 000 +#ifndef LOCALE +# define TO_LOWER 040 +# define NO_MASK 000 +#endif int diff --git a/uip/inc.c b/uip/inc.c index 1dcba6a5..9310ae1a 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -109,7 +109,9 @@ static struct swit switches[] = { * flags for the mail source */ #define INC_FILE 0 -#define INC_POP 1 +#ifdef POP +# define INC_POP 1 +#endif /* POP */ static int inc_type; static struct Maildir_entry { -- 2.56.1 From e37dc08079906b1b2737c3dad31fa507bdc66ecb Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 22:33:45 -0600 Subject: [PATCH 06/16] Removed, or added use of, unused macros to prevent warnings from gcc -Wunused-macros. --- sbr/mts.c | 3 --- uip/msgchk.c | 2 ++ uip/slocal.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sbr/mts.c b/sbr/mts.c index 71836e4f..6e19bd1f 100644 --- a/sbr/mts.c +++ b/sbr/mts.c @@ -20,9 +20,6 @@ #include #include -#define NOTOK (-1) -#define OK 0 - /* * static prototypes */ diff --git a/uip/msgchk.c b/uip/msgchk.c index c7f32f5b..a9583513 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -65,6 +65,8 @@ static struct swit switches[] = { #define MAXVEC 51 #define NT_NONE 0x0 +#ifdef NT_NONE +#endif /* Use NT_NONE to prevent warning from gcc -Wunused-macros. */ #define NT_MAIL 0x1 #define NT_NMAI 0x2 #define NT_ALL (NT_MAIL | NT_NMAI) diff --git a/uip/slocal.c b/uip/slocal.c index 44e5988d..36a25f05 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -44,6 +44,8 @@ * harmless. */ #define DB_DBM_HSEARCH 1 +#ifdef DB_DBM_HSEARCH +#endif /* Use DB_DBM_HSEARCH to prevent warning from gcc -Wunused-macros. */ #ifdef NDBM_HEADER #include NDBM_HEADER #endif -- 2.56.1 From 91836a18d1815f1f1cf687b2ad4eeba97d7f6594 Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 22:36:20 -0600 Subject: [PATCH 07/16] Removed unsupported format and check switches, and commented out unused macro HMNG. --- uip/spost.c | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/uip/spost.c b/uip/spost.c index e9e44a80..187f9a0e 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -27,53 +27,45 @@ struct swit switches[] = { { "filter filterfile", 0 }, #define NFILTSW 1 { "nofilter", 0 }, -#define FRMTSW 2 - { "format", 0 }, -#define NFRMTSW 3 - { "noformat", 0 }, -#define REMVSW 4 +#define REMVSW 2 { "remove", 0 }, -#define NREMVSW 5 +#define NREMVSW 3 { "noremove", 0 }, -#define VERBSW 6 +#define VERBSW 4 { "verbose", 0 }, -#define NVERBSW 7 +#define NVERBSW 5 { "noverbose", 0 }, -#define WATCSW 8 +#define WATCSW 6 { "watch", 0 }, -#define NWATCSW 9 +#define NWATCSW 7 { "nowatch", 0 }, -#define BACKSW 10 +#define BACKSW 8 { "backup", 0 }, -#define NBACKSW 11 +#define NBACKSW 9 { "nobackup", 0 }, -#define ALIASW 12 +#define ALIASW 10 { "alias aliasfile", 0 }, -#define NALIASW 13 +#define NALIASW 11 { "noalias", 0 }, -#define WIDTHSW 14 +#define WIDTHSW 12 { "width columns", 0 }, -#define VERSIONSW 15 +#define VERSIONSW 13 { "version", 0 }, -#define HELPSW 16 +#define HELPSW 14 { "help", 0 }, -#define DEBUGSW 17 +#define DEBUGSW 15 { "debug", -5 }, -#define DISTSW 18 +#define DISTSW 16 { "dist", -4 }, /* interface from dist */ -#define CHKSW 19 - { "check", -5 }, /* interface from whom */ -#define NCHKSW 20 - { "nocheck", -7 }, /* interface from whom */ -#define WHOMSW 21 +#define WHOMSW 17 { "whom", -4 }, /* interface from whom */ -#define PUSHSW 22 /* fork to sendmail then exit */ +#define PUSHSW 18 /* fork to sendmail then exit */ { "push", -4 }, -#define NPUSHSW 23 /* exec sendmail */ +#define NPUSHSW 19 /* exec sendmail */ { "nopush", -6 }, -#define LIBSW 24 +#define LIBSW 20 { "library directory", -7 }, -#define ANNOSW 25 +#define ANNOSW 21 { "idanno number", -6 }, { NULL, 0 } }; @@ -86,7 +78,7 @@ struct swit switches[] = { #define HSUB 0x0004 /* Subject: header */ #define HTRY 0x0008 /* try to send to addrs on header */ #define HBCC 0x0010 /* don't output this header */ -#define HMNG 0x0020 /* mung this header */ +/* #define HMNG 0x0020 */ /* munge this header */ #define HNGR 0x0040 /* no groups allowed in this header */ #define HFCC 0x0080 /* FCC: type header */ #define HNIL 0x0100 /* okay for this header not to have addrs */ -- 2.56.1 From a4d2c92d013879e3a2bf70260c34fffae47aa1bf Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 11 Jan 2012 22:38:35 -0600 Subject: [PATCH 08/16] Enabled support for tls switch. --- uip/whom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/uip/whom.c b/uip/whom.c index d405ebb7..33a6d97c 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -112,6 +112,7 @@ main (int argc, char **argv) case NOCHKSW: case SNOOPSW: case SASLSW: + case TLSSW: vec[vecp++] = --cp; continue; -- 2.56.1 From 162f2a7d23a18a87cad101f68ab27de057de533d Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Thu, 12 Jan 2012 21:07:33 -0500 Subject: [PATCH 09/16] Create two new mh-format functions: %(putlit) and %(concataddr). %(putlit) outputs a string without any space compression or control character conversion %(concataddr) is just like %(formataddr), except that inside of repl there will not be any duplicate address supression. --- h/fmt_compile.h | 158 +++++++++++++++++++++++----------------------- man/mh-format.man | 23 ++++++- sbr/fmt_addr.c | 5 ++ sbr/fmt_compile.c | 2 + sbr/fmt_scan.c | 11 ++++ uip/fmtdump.c | 2 + uip/replsbr.c | 27 ++++++++ 7 files changed, 148 insertions(+), 80 deletions(-) diff --git a/h/fmt_compile.h b/h/fmt_compile.h index 22be4508..3cbae02d 100644 --- a/h/fmt_compile.h +++ b/h/fmt_compile.h @@ -14,95 +14,97 @@ #define FT_STR 8 /* "str" as text */ #define FT_STRF 9 /* "str" as text, filled */ #define FT_STRFW 10 /* "str" as text, filled, width in "value" */ -#define FT_PUTADDR 11 /* split and print address line */ +#define FT_STRLIT 11 /* "str" as text, no space compression */ +#define FT_PUTADDR 12 /* split and print address line */ /* types that modify the "str" or "value" registers */ -#define FT_LS_COMP 12 /* set "str" to component text */ -#define FT_LS_LIT 13 /* set "str" to literal text */ -#define FT_LS_GETENV 14 /* set "str" to getenv(text) */ -#define FT_LS_CFIND 15 /* set "str" to context_find(text) */ -#define FT_LS_DECODECOMP 16 /* set "str" to decoded component text */ -#define FT_LS_DECODE 17 /* decode "str" as RFC-2047 header */ -#define FT_LS_TRIM 18 /* trim trailing white space from "str" */ -#define FT_LV_COMP 19 /* set "value" to comp (as dec. num) */ -#define FT_LV_COMPFLAG 20 /* set "value" to comp flag word */ -#define FT_LV_LIT 21 /* set "value" to literal num */ -#define FT_LV_DAT 22 /* set "value" to dat[n] */ -#define FT_LV_STRLEN 23 /* set "value" to length of "str" */ -#define FT_LV_PLUS_L 24 /* set "value" += literal */ -#define FT_LV_MINUS_L 25 /* set "value" -= literal */ -#define FT_LV_DIVIDE_L 26 /* set "value" to value / literal */ -#define FT_LV_MODULO_L 27 /* set "value" to value % literal */ -#define FT_LV_CHAR_LEFT 28 /* set "value" to char left in output */ +#define FT_LS_COMP 13 /* set "str" to component text */ +#define FT_LS_LIT 14 /* set "str" to literal text */ +#define FT_LS_GETENV 15 /* set "str" to getenv(text) */ +#define FT_LS_CFIND 16 /* set "str" to context_find(text) */ +#define FT_LS_DECODECOMP 17 /* set "str" to decoded component text */ +#define FT_LS_DECODE 18 /* decode "str" as RFC-2047 header */ +#define FT_LS_TRIM 19 /* trim trailing white space from "str" */ +#define FT_LV_COMP 20 /* set "value" to comp (as dec. num) */ +#define FT_LV_COMPFLAG 21 /* set "value" to comp flag word */ +#define FT_LV_LIT 22 /* set "value" to literal num */ +#define FT_LV_DAT 23 /* set "value" to dat[n] */ +#define FT_LV_STRLEN 24 /* set "value" to length of "str" */ +#define FT_LV_PLUS_L 25 /* set "value" += literal */ +#define FT_LV_MINUS_L 26 /* set "value" -= literal */ +#define FT_LV_DIVIDE_L 27 /* set "value" to value / literal */ +#define FT_LV_MODULO_L 28 /* set "value" to value % literal */ +#define FT_LV_CHAR_LEFT 29 /* set "value" to char left in output */ -#define FT_LS_MONTH 29 /* set "str" to tws month */ -#define FT_LS_LMONTH 30 /* set "str" to long tws month */ -#define FT_LS_ZONE 31 /* set "str" to tws timezone */ -#define FT_LS_DAY 32 /* set "str" to tws weekday */ -#define FT_LS_WEEKDAY 33 /* set "str" to long tws weekday */ -#define FT_LS_822DATE 34 /* set "str" to 822 date str */ -#define FT_LS_PRETTY 35 /* set "str" to pretty (?) date str */ -#define FT_LV_SEC 36 /* set "value" to tws second */ -#define FT_LV_MIN 37 /* set "value" to tws minute */ -#define FT_LV_HOUR 38 /* set "value" to tws hour */ -#define FT_LV_MDAY 39 /* set "value" to tws day of month */ -#define FT_LV_MON 40 /* set "value" to tws month */ -#define FT_LV_YEAR 41 /* set "value" to tws year */ -#define FT_LV_YDAY 42 /* set "value" to tws day of year */ -#define FT_LV_WDAY 43 /* set "value" to tws weekday */ -#define FT_LV_ZONE 44 /* set "value" to tws timezone */ -#define FT_LV_CLOCK 45 /* set "value" to tws clock */ -#define FT_LV_RCLOCK 46 /* set "value" to now - tws clock */ -#define FT_LV_DAYF 47 /* set "value" to tws day flag */ -#define FT_LV_DST 48 /* set "value" to tws daylight savings flag */ -#define FT_LV_ZONEF 49 /* set "value" to tws timezone flag */ +#define FT_LS_MONTH 30 /* set "str" to tws month */ +#define FT_LS_LMONTH 31 /* set "str" to long tws month */ +#define FT_LS_ZONE 32 /* set "str" to tws timezone */ +#define FT_LS_DAY 33 /* set "str" to tws weekday */ +#define FT_LS_WEEKDAY 34 /* set "str" to long tws weekday */ +#define FT_LS_822DATE 35 /* set "str" to 822 date str */ +#define FT_LS_PRETTY 36 /* set "str" to pretty (?) date str */ +#define FT_LV_SEC 37 /* set "value" to tws second */ +#define FT_LV_MIN 38 /* set "value" to tws minute */ +#define FT_LV_HOUR 39 /* set "value" to tws hour */ +#define FT_LV_MDAY 40 /* set "value" to tws day of month */ +#define FT_LV_MON 41 /* set "value" to tws month */ +#define FT_LV_YEAR 42 /* set "value" to tws year */ +#define FT_LV_YDAY 43 /* set "value" to tws day of year */ +#define FT_LV_WDAY 44 /* set "value" to tws weekday */ +#define FT_LV_ZONE 45 /* set "value" to tws timezone */ +#define FT_LV_CLOCK 46 /* set "value" to tws clock */ +#define FT_LV_RCLOCK 47 /* set "value" to now - tws clock */ +#define FT_LV_DAYF 48 /* set "value" to tws day flag */ +#define FT_LV_DST 49 /* set "value" to tws daylight savings flag */ +#define FT_LV_ZONEF 50 /* set "value" to tws timezone flag */ -#define FT_LS_PERS 50 /* set "str" to person part of addr */ -#define FT_LS_MBOX 51 /* set "str" to mbox part of addr */ -#define FT_LS_HOST 52 /* set "str" to host part of addr */ -#define FT_LS_PATH 53 /* set "str" to route part of addr */ -#define FT_LS_GNAME 54 /* set "str" to group part of addr */ -#define FT_LS_NOTE 55 /* set "str" to comment part of addr */ -#define FT_LS_ADDR 56 /* set "str" to mbox@host */ -#define FT_LS_822ADDR 57 /* set "str" to 822 format addr */ -#define FT_LS_FRIENDLY 58 /* set "str" to "friendly" format addr */ -#define FT_LV_HOSTTYPE 59 /* set "value" to addr host type */ -#define FT_LV_INGRPF 60 /* set "value" to addr in-group flag */ -#define FT_LS_UNQUOTE 61 /* remove RFC 2822 quotes from "str" */ -#define FT_LV_NOHOSTF 62 /* set "value" to addr no-host flag */ +#define FT_LS_PERS 51 /* set "str" to person part of addr */ +#define FT_LS_MBOX 52 /* set "str" to mbox part of addr */ +#define FT_LS_HOST 53 /* set "str" to host part of addr */ +#define FT_LS_PATH 54 /* set "str" to route part of addr */ +#define FT_LS_GNAME 55 /* set "str" to group part of addr */ +#define FT_LS_NOTE 56 /* set "str" to comment part of addr */ +#define FT_LS_ADDR 57 /* set "str" to mbox@host */ +#define FT_LS_822ADDR 58 /* set "str" to 822 format addr */ +#define FT_LS_FRIENDLY 59 /* set "str" to "friendly" format addr */ +#define FT_LV_HOSTTYPE 60 /* set "value" to addr host type */ +#define FT_LV_INGRPF 61 /* set "value" to addr in-group flag */ +#define FT_LS_UNQUOTE 62 /* remove RFC 2822 quotes from "str" */ +#define FT_LV_NOHOSTF 63 /* set "value" to addr no-host flag */ /* Date Coercion */ -#define FT_LOCALDATE 63 /* Coerce date to local timezone */ -#define FT_GMTDATE 64 /* Coerce date to gmt */ +#define FT_LOCALDATE 64 /* Coerce date to local timezone */ +#define FT_GMTDATE 65 /* Coerce date to gmt */ /* pre-format processing */ -#define FT_PARSEDATE 65 /* parse comp into a date (tws) struct */ -#define FT_PARSEADDR 66 /* parse comp into a mailaddr struct */ -#define FT_FORMATADDR 67 /* let external routine format addr */ -#define FT_MYMBOX 68 /* do "mymbox" test on comp */ +#define FT_PARSEDATE 66 /* parse comp into a date (tws) struct */ +#define FT_PARSEADDR 67 /* parse comp into a mailaddr struct */ +#define FT_FORMATADDR 68 /* let external routine format addr */ +#define FT_CONCATADDR 69 /* formataddr w/out duplicate removal */ +#define FT_MYMBOX 70 /* do "mymbox" test on comp */ /* misc. */ /* ADDTOSEQ only works if you include "options LBL" */ -#define FT_ADDTOSEQ 69 /* add current msg to a sequence */ +#define FT_ADDTOSEQ 71 /* add current msg to a sequence */ /* conditionals & control flow (must be last) */ -#define FT_SAVESTR 70 /* save current str reg */ -#define FT_DONE 71 /* stop formatting */ -#define FT_PAUSE 72 /* pause */ -#define FT_NOP 73 /* nop */ -#define FT_GOTO 74 /* (relative) goto */ -#define FT_IF_S_NULL 75 /* test if "str" null */ -#define FT_IF_S 76 /* test if "str" non-null */ -#define FT_IF_V_EQ 77 /* test if "value" = literal */ -#define FT_IF_V_NE 78 /* test if "value" != literal */ -#define FT_IF_V_GT 79 /* test if "value" > literal */ -#define FT_IF_MATCH 80 /* test if "str" contains literal */ -#define FT_IF_AMATCH 81 /* test if "str" starts with literal */ -#define FT_S_NULL 82 /* V = 1 if "str" null */ -#define FT_S_NONNULL 83 /* V = 1 if "str" non-null */ -#define FT_V_EQ 84 /* V = 1 if "value" = literal */ -#define FT_V_NE 85 /* V = 1 if "value" != literal */ -#define FT_V_GT 86 /* V = 1 if "value" > literal */ -#define FT_V_MATCH 87 /* V = 1 if "str" contains literal */ -#define FT_V_AMATCH 88 /* V = 1 if "str" starts with literal */ +#define FT_SAVESTR 72 /* save current str reg */ +#define FT_DONE 73 /* stop formatting */ +#define FT_PAUSE 74 /* pause */ +#define FT_NOP 75 /* nop */ +#define FT_GOTO 76 /* (relative) goto */ +#define FT_IF_S_NULL 77 /* test if "str" null */ +#define FT_IF_S 78 /* test if "str" non-null */ +#define FT_IF_V_EQ 79 /* test if "value" = literal */ +#define FT_IF_V_NE 80 /* test if "value" != literal */ +#define FT_IF_V_GT 81 /* test if "value" > literal */ +#define FT_IF_MATCH 82 /* test if "str" contains literal */ +#define FT_IF_AMATCH 83 /* test if "str" starts with literal */ +#define FT_S_NULL 84 /* V = 1 if "str" null */ +#define FT_S_NONNULL 85 /* V = 1 if "str" non-null */ +#define FT_V_EQ 86 /* V = 1 if "value" = literal */ +#define FT_V_NE 87 /* V = 1 if "value" != literal */ +#define FT_V_GT 88 /* V = 1 if "value" > literal */ +#define FT_V_MATCH 89 /* V = 1 if "str" contains literal */ +#define FT_V_AMATCH 90 /* V = 1 if "str" starts with literal */ #define IF_FUNCS FT_S_NULL /* start of "if" functions */ diff --git a/man/mh-format.man b/man/mh-format.man index 8925b8cb..c50e02f3 100644 --- a/man/mh-format.man +++ b/man/mh-format.man @@ -1,5 +1,5 @@ .\" -.\" THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. +.\" %nmhwarning% .\" .TH MH-FORMAT %manext5% "%nmhdate%" MH.6.8 [%nmhversion%] .SH NAME @@ -288,9 +288,14 @@ putstrf expr print \fIstr\fR in a fixed width putnum expr print \fInum\fR putnumf expr print \fInum\fR in a fixed width .\" addtoseq literal add msg to sequence (LBL option) +putlit expr print \fIstr\fR without space compression nodate string integer Argument not a date string (0 or 1) formataddr expr append \fIarg\fR to \fIstr\fR as a (comma separated) address list +concataddr expr append \fIarg\fR to \fIstr\fR as a + (comma separated) address list, + including duplicates, + see Special Handling putaddr literal print \fIstr\fR address list with \fIarg\fR as optional label; get line width from \fInum\fR @@ -387,10 +392,24 @@ right-justification of the string within the field, with padding on the left up to the field width. The functions (\fIputnum\fR\^) and (\fIputstr\fR\^) are somewhat special: they print their result in the minimum number of characters -required, and ignore any leading field width argument. +required, and ignore any leading field width argument. The (\fIputlit\fR\^) +function outputs the exact contents of str register without any changes +such as duplicate space removal or control character conversion. .PP The available output width is kept in an internal register; any output past this width will be truncated. +.SS Special Handling +A few functions have different behavior depending on what command they are +being invoked from. +.PP +In +.BR repl +the (\fIformataddr\fR\^) function stores all email addresses encountered into +an internal cache and will use this cache to suppress duplicate addresses. +If you need to create an address list that includes previously-seen +addresses you may use the (\fIconcataddr\fR\^) function, which is identical +to (\fIformataddr\fR\^) in all other respects. Note that (\fIconcataddr\fR\^) +will NOT add addresses to the duplicate-suppression cache. .SS Examples With all this in mind, here's the default format string for diff --git a/sbr/fmt_addr.c b/sbr/fmt_addr.c index be9b4839..3186deaa 100644 --- a/sbr/fmt_addr.c +++ b/sbr/fmt_addr.c @@ -112,3 +112,8 @@ formataddr (char *orig, char *str) last_dst = dst; return (buf); } + +char *concataddr (char *orig, char *str) +{ + return formataddr(orig, str); +} diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index a86661e9..83687289 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -75,6 +75,7 @@ static struct ftable functable[] = { { "putnum", TF_EXPR, FT_NUM, 0, 0 }, { "putnumf", TF_EXPR, FT_NUMF, 0, 0 }, { "putaddr", TF_STR, FT_PUTADDR, 0, 0 }, + { "putlit", TF_STR, FT_STRLIT, 0, 0 }, { "void", TF_NOP, 0, 0, 0 }, { "comp", TF_COMP, FT_LS_COMP, 0, TFL_PUTS }, @@ -139,6 +140,7 @@ static struct ftable functable[] = { { "ingrp", TF_COMP, FT_LV_INGRPF, FT_PARSEADDR, TFL_PUTN }, { "nohost", TF_COMP, FT_LV_NOHOSTF, FT_PARSEADDR, TFL_PUTN }, { "formataddr", TF_EXPR_SV,FT_FORMATADDR, FT_FORMATADDR, 0 }, + { "concataddr", TF_EXPR_SV,FT_CONCATADDR, FT_FORMATADDR, 0 }, { "friendly", TF_COMP, FT_LS_FRIENDLY, FT_PARSEADDR, TFL_PUTS }, { "mymbox", TF_COMP, FT_LV_COMPFLAG, FT_MYMBOX, TFL_PUTN }, diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 2bf18210..5240781b 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -23,6 +23,7 @@ #endif extern char *formataddr (); /* hook for custom address formatting */ +extern char *concataddr (); /* address formatting but allowing duplicates */ #ifdef LBL struct msgs *fmt_current_folder; /* current folder (set by main program) */ @@ -347,6 +348,11 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) case FT_STRF: cptrimmed (&cp, str, fmt->f_width, fmt->f_fill, ep - cp); break; + case FT_STRLIT: + sp = str; + while ((c = *sp++) && cp < ep) + *cp++ = c; + break; case FT_STRFW: adios (NULL, "internal error (FT_STRFW)"); @@ -786,6 +792,11 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) str = formataddr (savestr, str); break; + case FT_CONCATADDR: + /* The same as formataddr, but doesn't do duplicate suppression */ + str = concataddr (savestr, str); + break; + case FT_PUTADDR: /* output the str register as an address component, * splitting it into multiple lines if necessary. The diff --git a/uip/fmtdump.c b/uip/fmtdump.c index 2abf05e5..65663175 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -354,6 +354,7 @@ f_typestr(int t) case FT_STRF: return("STRF"); case FT_STRFW: return("STRFW"); case FT_PUTADDR: return("PUTADDR"); + case FT_STRLIT: return("STRLIT"); case FT_LS_COMP: return("LS_COMP"); case FT_LS_LIT: return("LS_LIT"); case FT_LS_GETENV: return("LS_GETENV"); @@ -408,6 +409,7 @@ f_typestr(int t) case FT_PARSEDATE: return("PARSEDATE"); case FT_PARSEADDR: return("PARSEADDR"); case FT_FORMATADDR: return("FORMATADDR"); + case FT_CONCATADDR: return("CONCATADDR"); case FT_MYMBOX: return("MYMBOX"); #ifdef FT_ADDTOSEQ case FT_ADDTOSEQ: return("ADDTOSEQ"); diff --git a/uip/replsbr.c b/uip/replsbr.c index 3dda4708..9ca0bb94 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -25,6 +25,7 @@ static char *badaddrs = NULL; static char *dfhost = NULL; static struct mailname mq = { NULL }; +static int nodupcheck = 0; /* If set, no check for duplicates */ /* * Buffer size for content part of header fields. @@ -380,12 +381,38 @@ formataddr (char *orig, char *str) } +/* + * fmt_scan will call this routine if the user includes the function + * "(concataddr {component})" in a format string. This behaves exactly + * like formataddr, except that it does NOT suppress duplicate addresses + * between calls. + * + * As an implementation detail: I thought about splitting out formataddr() + * into the generic part and duplicate-suppressing part, but the call to + * insert() was buried deep within a couple of loops and I didn't see a + * way to do it easily. So instead we simply set a special flag to stop + * the duplicate check and call formataddr(). + */ +char * +concataddr(char *orig, char *str) +{ + char *cp; + + nodupcheck = 1; + cp = formataddr(orig, str); + nodupcheck = 0; + return cp; +} + static int insert (struct mailname *np) { char buffer[BUFSIZ]; register struct mailname *mp; + if (nodupcheck) + return 1; + if (np->m_mbox == NULL) return 0; -- 2.56.1 From b70215dfee4aeb9f530a104e348ce2c28e97add6 Mon Sep 17 00:00:00 2001 From: David Levine Date: Thu, 12 Jan 2012 22:14:59 -0600 Subject: [PATCH 10/16] Added -Wunused-macros with gcc, if supported. Added -Wno-unused-macros, if supported, to compile of sbr/dtimep.o with gcc because it uses generated code that would be too much trouble to clean up. --- configure.ac | 17 ++++++++++++++++- sbr/Makefile.in | 6 ++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 43a1029d..28821ae9 100644 --- a/configure.ac +++ b/configure.ac @@ -218,6 +218,20 @@ fi AC_PROG_CC +AC_CACHE_CHECK(whether preprocessor supports -Wunused-macros, + nmh_cv_has_unusedmacros, + [nmh_saved_cppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -Wunused-macros -Wno-unused-macros" + AC_TRY_COMPILE([],[],nmh_cv_has_unusedmacros=yes,nmh_cv_has_unusedmacros=no) + CPPFLAGS="$nmh_saved_cppflags"]) + +if test "$nmh_cv_has_unusedmacros" = 'yes'; then + test -z "$CPPLAGS" && CPPFLAGS=-Wunused-macros \ + || CPPFLAGS="$CPPFLAGS -Wunused-macros" + DISABLE_UNUSED_MACROS_WARNING=-Wno-unused-macros +fi +AC_SUBST(DISABLE_UNUSED_MACROS_WARNING)dnl + AC_CACHE_CHECK(whether compiler supports -Wno-pointer-sign, nmh_cv_has_noptrsign, [nmh_saved_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wno-pointer-sign" @@ -456,7 +470,8 @@ dnl before system header files. case "$target_os" in linux*) # Like DEFS, but doesn't get stomped on by configure when using config.h: - OURDEFS="$OURDEFS -D_GNU_SOURCE" + test -z "$OURDEFS" && OURDEFS="-D_GNU_SOURCE" \ + || OURDEFS="$OURDEFS -D_GNU_SOURCE" ;; esac AC_SUBST(OURDEFS) diff --git a/sbr/Makefile.in b/sbr/Makefile.in index 555d0312..c9494693 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -16,6 +16,7 @@ etcdir = @sysconfdir@ CC = @CC@ CFLAGS = @CFLAGS@ +DISABLE_UNUSED_MACROS_WARNING = @DISABLE_UNUSED_MACROS_WARNING@ DEFS = @DEFS@ CONFIGDEFS = -DNMHETCDIR='"$(etcdir)"' -DMAILSPOOL='"$(mailspool)"' -DSENDMAILPATH='"$(sendmailpath)"' INCLUDES = -I. -I$(top_srcdir) @CPPFLAGS@ @@ -39,7 +40,7 @@ COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(CFLAGS) .SUFFIXES: -.SUFFIXES: .c .o +.SUFFIXES: .c .o .lex .c.o: $(COMPILE) $< @@ -97,8 +98,9 @@ lint: sigmsg.h # some lexes will only accept '-n -t', not '-nt'. # Also, not all makes accept $< in non-pattern rules, # hence the explicit filenames here. -dtimep.c: dtimep.lex +dtimep.o: dtimep.lex $(LEX) -n -t $(srcdir)/dtimep.lex > dtimep.c + $(COMPILE) $(DISABLE_UNUSED_MACROS_WARNING) dtimep.c client.o: client.c $(COMPILE2) $(srcdir)/client.c -- 2.56.1 From 3a84d814004fd4557bf4f44952648e9e69bd22a8 Mon Sep 17 00:00:00 2001 From: David Levine Date: Thu, 12 Jan 2012 22:19:24 -0600 Subject: [PATCH 11/16] Added NMH_UNUSED macro for suppressing warnings about unused parameters with gcc -Wunused-parameter --- h/mh.h | 2 ++ mts/smtp/smtp.c | 6 ++++++ sbr/getans.c | 2 ++ sbr/lock_file.c | 4 ++++ sbr/mts.c | 2 ++ uip/folder.c | 2 ++ uip/mhlsbr.c | 6 ++++++ uip/mhparse.c | 2 ++ uip/mhshowsbr.c | 5 +++++ uip/msh.c | 6 ++++++ uip/mshcmds.c | 4 ++++ uip/picksbr.c | 4 ++++ uip/post.c | 2 ++ uip/prompter.c | 2 ++ uip/rcvtty.c | 2 ++ uip/replsbr.c | 2 ++ uip/slocal.c | 2 ++ 17 files changed, 55 insertions(+) diff --git a/h/mh.h b/h/mh.h index e3a382a3..b0a841a2 100644 --- a/h/mh.h +++ b/h/mh.h @@ -32,8 +32,10 @@ typedef unsigned char boolean; /* not int so we can pack in a structure */ */ #if __GNUC__ > 2 #define NORETURN __attribute__((__noreturn__)) +#define NMH_UNUSED(i) (void) i #else #define NORETURN +#define NMH_UNUSED(i) i #endif /* diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index caa1c736..df1dbbf4 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -396,6 +396,8 @@ smtp_init (char *client, char *server, char *port, int watch, int verbose, return RP_RPLY; } } +#else /* TLS_SUPPORT */ + NMH_UNUSED (tls); #endif /* TLS_SUPPORT */ #ifdef CYRUS_SASL @@ -1121,6 +1123,8 @@ static int sm_get_pass(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) { + NMH_UNUSED (conn); + char **pw_context = (char **) context; char *pass = NULL; int len; @@ -1666,6 +1670,8 @@ sm_rerror (int rc) static void alrmser (int i) { + NMH_UNUSED (i); + #ifndef RELIABLE_SIGNALS SIGNAL (SIGALRM, alrmser); #endif diff --git a/sbr/getans.c b/sbr/getans.c index 5c70ba06..173e1b43 100644 --- a/sbr/getans.c +++ b/sbr/getans.c @@ -70,6 +70,8 @@ getans (char *prompt, struct swit *ansp) static void intrser (int i) { + NMH_UNUSED (i); + /* * should this be siglongjmp? */ diff --git a/sbr/lock_file.c b/sbr/lock_file.c index c7dffcfc..d3787490 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -167,6 +167,8 @@ lkclose (int fd, char *file) lockfile_remove(lkinfo.curlock); #endif /* HAVE_LIBLOCKFILE */ timerOFF (fd); /* turn off lock timer */ +#else /* DOT_LOCKING */ + NMH_UNUSED (file); #endif /* DOT_LOCKING */ return (close (fd)); @@ -258,6 +260,8 @@ lkfclose (FILE *fp, char *file) lockfile_remove(lkinfo.curlock); #endif /* HAVE_LIBLOCKFILE */ timerOFF (fileno(fp)); /* turn off lock timer */ +#else /* DOT_LOCKING */ + NMH_UNUSED (file); #endif /* DOT_LOCKING */ return (fclose (fp)); diff --git a/sbr/mts.c b/sbr/mts.c index 6e19bd1f..834579d1 100644 --- a/sbr/mts.c +++ b/sbr/mts.c @@ -141,6 +141,8 @@ static struct bind binds[] = { void mts_init (char *name) { + NMH_UNUSED (name); + const char *cp; FILE *fp; static int inited = 0; diff --git a/uip/folder.c b/uip/folder.c index 3e7c85d8..f3b4ba4e 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -457,6 +457,8 @@ get_folder_info_body (char *fold, char *msg, boolean *crawl_children) static boolean get_folder_info_callback (char *fold, void *baton) { + NMH_UNUSED (baton); + boolean crawl_children; get_folder_info_body (fold, NULL, &crawl_children); fflush (stdout); diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 4cd3770e..a0d13068 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1447,6 +1447,8 @@ putch (char ch) static void intrser (int i) { + NMH_UNUSED (i); + discard (stdout); putchar ('\n'); longjmp (env, DONE); @@ -1456,6 +1458,8 @@ intrser (int i) static void pipeser (int i) { + NMH_UNUSED (i); + done (NOTOK); } @@ -1463,6 +1467,8 @@ pipeser (int i) static void quitser (int i) { + NMH_UNUSED (i); + putchar ('\n'); fflush (stdout); done (NOTOK); diff --git a/uip/mhparse.c b/uip/mhparse.c index 4959dfec..1b49efdf 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -1042,6 +1042,8 @@ invalid: static int InitGeneric (CT ct) { + NMH_UNUSED (ct); + return OK; /* not much to do here */ } diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 52258256..44371f1c 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -1051,6 +1051,9 @@ show_message_rfc822 (CT ct, int serial, int alternate) static int show_partial (CT ct, int serial, int alternate) { + NMH_UNUSED (serial); + NMH_UNUSED (alternate); + content_error (NULL, ct, "in order to display this message, you must reassemble it"); return NOTOK; @@ -1084,6 +1087,8 @@ show_external (CT ct, int serial, int alternate) static void intrser (int i) { + NMH_UNUSED (i); + putchar ('\n'); siglongjmp (intrenv, DONE); } diff --git a/uip/msh.c b/uip/msh.c index 3a5cc976..23398217 100644 --- a/uip/msh.c +++ b/uip/msh.c @@ -805,6 +805,7 @@ m_gMsgs (int n) FILE * msh_ready (int msgnum, int full) { + NMH_UNUSED (full); register int msgp; int fd; char *cp; @@ -1582,6 +1583,7 @@ seq_setcur (struct msgs *mp, int msgnum) static void intrser (int i) { + NMH_UNUSED (i); discard (stdout); interrupted++; } @@ -1590,6 +1592,7 @@ intrser (int i) static void pipeser (int i) { + NMH_UNUSED (i); if (broken_pipe++ == 0) fprintf (stderr, "broken pipe\n"); told_to_quit++; @@ -1600,6 +1603,7 @@ pipeser (int i) static void quitser (int i) { + NMH_UNUSED (i); told_to_quit++; interrupted++; } @@ -1608,6 +1612,7 @@ quitser (int i) static void alrmser (int i) { + NMH_UNUSED (i); longjmp (peerenv, DONE); } @@ -1672,6 +1677,7 @@ pINI (void) static int pQRY (char *str, int scansw) { + NMH_UNUSED (str); if (pQRY1 (scansw) == NOTOK || pQRY2 () == NOTOK) return NOTOK; diff --git a/uip/mshcmds.c b/uip/mshcmds.c index 64957e8e..b46f753c 100644 --- a/uip/mshcmds.c +++ b/uip/mshcmds.c @@ -1086,6 +1086,8 @@ static char *hlpmsg[] = { void helpcmd (char **args) { + NMH_UNUSED (args); + int i; for (i = 0; hlpmsg[i]; i++) { @@ -2366,6 +2368,8 @@ show (int msgnum) static int eom_action (int c) { + NMH_UNUSED (c); + return (ftell (mhlfp) >= Msgs[mhlnum].m_stop); } diff --git a/uip/picksbr.c b/uip/picksbr.c index 4afd0941..85bc4bcd 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -656,6 +656,8 @@ static int GREPaction (params) plist { + NMH_UNUSED (msgnum); + int c, body, lf; long pos = start; register char *p1, *p2, *ebp, *cbp; @@ -929,6 +931,8 @@ static int TWSaction (params) plist { + NMH_UNUSED (stop); + int state; register char *bp; char buf[BUFSIZ], name[NAMESZ]; diff --git a/uip/post.c b/uip/post.c index 515e1d5a..20482282 100644 --- a/uip/post.c +++ b/uip/post.c @@ -1608,6 +1608,8 @@ do_text (char *file, int fd) static void sigser (int i) { + NMH_UNUSED (i); + unlink (tmpfil); if (msgflags & MINV) unlink (bccfil); diff --git a/uip/prompter.c b/uip/prompter.c index a016c1f1..981e8201 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -396,6 +396,8 @@ getln (char *buffer, int n) static void intrser (int i) { + NMH_UNUSED (i); + if (wtuser) longjmp (sigenv, NOTOK); sigint++; diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 5a3093be..74d19d5d 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -207,6 +207,8 @@ main (int argc, char **argv) static void alrmser (int i) { + NMH_UNUSED (i); + longjmp (myctx, 1); } diff --git a/uip/replsbr.c b/uip/replsbr.c index 9ca0bb94..7f0f5237 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -71,6 +71,8 @@ void replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, int mime, char *form, char *filter, char *fcc) { + NMH_UNUSED (msg); + register int state, i; register struct comp *cptr; register char *tmpbuf; diff --git a/uip/slocal.c b/uip/slocal.c index 36a25f05..f08f2ffc 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1210,6 +1210,8 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) static void alrmser (int i) { + NMH_UNUSED (i); + longjmp (myctx, DONE); } -- 2.56.1 From 5ee3667d7daf6e7090e3de104c3679259eb26da5 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 13 Jan 2012 09:30:03 -0500 Subject: [PATCH 12/16] Update README.developers with the correct version of autoconf we need. --- docs/README.developers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.developers b/docs/README.developers index 4381a2ab..af384124 100644 --- a/docs/README.developers +++ b/docs/README.developers @@ -16,7 +16,7 @@ autoconf files If you wish to change the `configure' script or its related files, you'll need to first install GNU m4, available from and then GNU autoconf (). Nmh is currently using -a minimum of autoconf 2.54. +a minimum of autoconf 2.61. Most of the configure-related files are automatically generated. The only files you should need to manually edit are acconfig.h and configure.in. Don't, for -- 2.56.1 From c3ed95b3c5530b84a73dbdd531cb9aca9ba8dea0 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 13 Jan 2012 12:04:13 -0500 Subject: [PATCH 13/16] Add some comments to the format compiler and engine. --- docs/pending-release-notes | 1 + sbr/fmt_compile.c | 91 ++++++++++++++++++++++++++++++++++++++ sbr/fmt_scan.c | 3 ++ 3 files changed, 95 insertions(+) diff --git a/docs/pending-release-notes b/docs/pending-release-notes index c73464c7..f7e0ac76 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -14,3 +14,4 @@ Things to add to the release notes for the next full release: message parts in MIME messages) has been removed. - fileproc and mhlproc mh-profile entries will now be obeyed by send, rcvdist, and whatnow. +- New format instructions %(putlit) and %(concataddr) have been implemented. diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 83687289..f643421a 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -5,6 +5,38 @@ * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. + * + * This code compiles the format strings (documented in mh-format(5)) into + * an internal form to be later processed by fmt_scan.c. + * + * What happens here is that the format strings are parsed and an array + * of struct format structures are returned. Each format structure is + * a single operation interpreted by the the routines in fmt_scan.c. + * + * There is a NOT a one-to-one correspondence between format strings and + * format instructions; some functions have side effects that can result + * in multiple instructions being generated. The exact list of instructions + * generated by a format string can be seem with the nmh fmtdump utility. + * + * A list of format instructions can be found in fmt_compile.h. + * + * If you wish to add a new function, you will need to do the following + * things: + * + * - Add a new instruction to the list of instructions in fmt_compile.h. + * Note that test instructions (starting with FT_IF_S_NULL) have special + * handling, so if you are NOT writing a test function then you need + * to insert it into the list before that _and_ bump all of the + * following instruction numbers. + * + * - Add the function name to the functable[] array below, and write any + * special code that your function may require in terms of parsing + * (it very well may not need anything). + * + * - Add the code in fmt_scan.c to handle your new function. + * + * - Document the new function in the mh-format(5) man page. + * */ #include @@ -51,6 +83,31 @@ extern struct mailname fmt_mnull; #define TFL_PUTS 1 /* implicit putstr if top level */ #define TFL_PUTN 2 /* implicit putnum if top level */ +/* + * The functable array maps between the text names of format functions and + * the format instructions interpreted by the engine in fmt_scan.c. + * + * The elements of this structure are as follows: + * + * name - The name of the function as seen in the format string. This is + * what maps a particular function name into a format instruction. + * type - The type of argument this function expects. Those types are + * listed above (with the TF_ prefix). This affects what gets + * placed in the format instruction (the f_un union). + * f_type - The instruction corresponding to this function (from the list + * in fmt_compile.h). + * extra - Used by some functions to provide extra data to the compiler. + * Uses include: + * - Providing an alternate instruction to combine a load + * and test operation (see do_if()). + * - Passed in f_value in the format instruction to provide + * extra information for the engine (see FT_LV_DAT handling + * in fmt_scan.c). + * - Provide a hint as to preprocessing that is required for + * this instruction (see do_name()). + * flags - See the definitions for TFL_PUTS & TFL_PUTN above. + */ + struct ftable { char *name; /* function name */ char type; /* argument type */ @@ -206,6 +263,9 @@ static char *do_loop(char *); static char *do_if(char *); +/* + * Lookup a function name in the functable + */ static struct ftable * lookup(char *name) { @@ -353,6 +413,9 @@ compile (char *sp) } +/* + * Process functions & components (handle field width here as well + */ static char * do_spec(char *sp) { @@ -404,6 +467,11 @@ do_spec(char *sp) return (cp); } +/* + * Process a component name. Normally this involves generating an FT_COMP + * instruction for the specified component. If preprocess is set, then we + * do some extra processing. + */ static char * do_name(char *sp, int preprocess) { @@ -458,6 +526,10 @@ do_name(char *sp, int preprocess) return (cp); } +/* + * Generate one or more instructions corresponding to the named function. + * The different type of function arguments are handled here. + */ static char * do_func(char *sp) { @@ -550,6 +622,10 @@ do_func(char *sp) return (cp); } +/* + * Handle an expression as an argument. Basically we call one of do_name(), + * do_func(), or do_if() + */ static char * do_expr (char *sp, int preprocess) { @@ -571,6 +647,15 @@ do_expr (char *sp, int preprocess) return (cp); } +/* + * I am guessing this was for some kind of loop statement, which would have + * looked like %[ .... %]. It looks like the way this would have worked + * is that the format engine would have seen that FT_DONE had a 1 in the + * f_un.f_un_value and then decided whether or not to continue the loop. + * There is no support for this in the format engine, so right now if + * you try using it you will reach the FT_DONE and simply stop. I'm leaving + * this here in case someone wants to continue the work. + */ static char * do_loop(char *sp) { @@ -589,6 +674,12 @@ do_loop(char *sp) return cp; } +/* + * Handle an if-elsif-endif statement. Note here that the branching + * is handled by the f_skip member of the struct format (which is really + * just f_width overloaded). This number controls how far to move forward + * (or back) in the format instruction array. + */ static char * do_if(char *sp) { diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 5240781b..574eeb31 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -5,6 +5,9 @@ * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. + * + * This is the engine that processes the format instructions created by + * fmt_compile (found in fmt_compile.c). */ #include -- 2.56.1 From d6e99ba43296f69099e64845ef0f8e09b037a344 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 14 Jan 2012 09:16:16 -0600 Subject: [PATCH 14/16] Documented support of OURDEFS to pass compile flags to configure. --- INSTALL | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/INSTALL b/INSTALL index 79f8f6f0..f1a40d2c 100644 --- a/INSTALL +++ b/INSTALL @@ -33,11 +33,11 @@ need an ANSI C compiler such as gcc. ./configure [options] - This will check the configuration of your OS, and create the + This will check the configuration of your OS, and create the include file config.h, as well as the various Makefiles. - The configure script accepts various options. The options of - most interest are listed in a section below. To see the list + The configure script accepts various options. The options of + most interest are listed in a section below. To see the list of all available options, you can run ./configure --help @@ -68,8 +68,8 @@ need an ANSI C compiler such as gcc. injecting the message to a mail transfer agent (such as sendmail) on the local machine via SMTP. - If, instead, all your mail sending and receiving occurs on a - remote POP/SMTP server, you will need to look at the values of the + If, instead, all your mail sending and receiving occurs on a + remote POP/SMTP server, you will need to look at the values of the variables "localname", "pophost", and "servers": a) "localname" defines the hostname that nmh considers local. @@ -125,13 +125,17 @@ the "configure" script does not know about, by either editing the user configuration section of the top level Makefile (after running configure) or giving "configure" initial values for these variables by setting them in the environment. Using a Bourne-compatible shell (such as sh,ksh,zsh), - + you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - + Or on systems that have the "env" program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure +If you want to add to, not replace, compile flags, you can use +OURDEFS with env or like this: + OURDEFS='-Wextra -Wno-sign-compare' ./configure + ---------------------------------------- Building nmh on additional architectures ---------------------------------------- @@ -140,7 +144,7 @@ This should restore the nmh source distribution back to its original state. You can then configure nmh as above on other architectures in which you wish to build nmh. Or alternatively, you can use a different build directory for each architecture. - + --------------------------------- Using a different build directory --------------------------------- @@ -151,7 +155,7 @@ architecture at the same time. To do this, you must use a version of the directory where you want the object files and executables to go and run the "configure" script. "configure" automatically checks for the source code in the directory that "configure" is in. For example, - + cd /usr/local/solaris/nmh /usr/local/src/nmh-1.0/configure make @@ -179,7 +183,7 @@ Options for configure --enable-debug Enable debugging support. ---enable-masquerade[='draft_from mmailid username_extension'] +--enable-masquerade[='draft_from mmailid username_extension'] If this option is disabled, the mts.conf file will contain the line "masquerade: " (with no value), which may be manually edited later. You may find it convenient to specify a value at -- 2.56.1 From e4ccf20dcb722d8110e2a22f03e960e8f9f67898 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 14 Jan 2012 09:19:49 -0600 Subject: [PATCH 15/16] configure.ac and aclocal.m4 instead of configure.in and acconfig.h. --- docs/README.developers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.developers b/docs/README.developers index af384124..2946d8c1 100644 --- a/docs/README.developers +++ b/docs/README.developers @@ -19,7 +19,7 @@ GNU autoconf (). Nmh is currently using a minimum of autoconf 2.61. Most of the configure-related files are automatically generated. The only files -you should need to manually edit are acconfig.h and configure.in. Don't, for +you should need to manually edit are configure.ac and aclocal.m4. Don't, for instance, edit config.h.in. Though it is an input file from the point of view of the users (and the configure script) it is an output file from the point of view of the developers (and the autoconf script). -- 2.56.1 From 2ce001e1b0b7cc5366ea2804f66726e57910282b Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 14 Jan 2012 09:21:32 -0600 Subject: [PATCH 16/16] gcc -Wmissing-field-initializers noticed several struct initializations that didn't explicitly list all fields. Most were of no consequence because they were for static data, so they were all initialized properly. However, the two in mhlsbr.c were missing an initialization of other than their last field, and they contained some subsequent values other than zero. So, those later fields were initialized incorrectly. Also, changed the initialization of global.c_ovtxt from "" to NULL because free_queue () freed it if non-NULL, though I think the "" was always overwritten. --- sbr/addrsbr.c | 2 +- uip/mhlsbr.c | 4 ++-- uip/post.c | 8 ++++---- uip/replsbr.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index 649e06f4..a99d9aab 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -361,7 +361,7 @@ ismymbox (struct mailname *np) char buffer[BUFSIZ]; struct mailname *mp; static char *am = NULL; - static struct mailname mq={NULL}; + static struct mailname mq; /* * If this is the first call, initialize diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index a0d13068..68a265d5 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -134,11 +134,11 @@ static struct mcomp *fmthd = NULL; static struct mcomp *fmttl = NULL; static struct mcomp global = { - NULL, NULL, "", NULL, NULL, 0, -1, 80, -1, 40, BELL, 0 + NULL, NULL, NULL, NULL, NULL, NULL, 0, -1, 80, -1, 40, BELL, NULL }; static struct mcomp holder = { - NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NOCOMPONENT, 0 + NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NOCOMPONENT, NULL }; struct pair { diff --git a/uip/post.c b/uip/post.c index 20482282..88455607 100644 --- a/uip/post.c +++ b/uip/post.c @@ -266,10 +266,10 @@ static char *fccfold[FCCS]; /* foldernames for FCC'ing */ static struct headers *hdrtab; /* table for the message we're doing */ -static struct mailname localaddrs={NULL}; /* local addrs */ -static struct mailname netaddrs={NULL}; /* network addrs */ -static struct mailname uuaddrs={NULL}; /* uucp addrs */ -static struct mailname tmpaddrs={NULL}; /* temporary queue */ +static struct mailname localaddrs; /* local addrs */ +static struct mailname netaddrs; /* network addrs */ +static struct mailname uuaddrs; /* uucp addrs */ +static struct mailname tmpaddrs; /* temporary queue */ #ifdef SMTPMTS static int snoop = 0; diff --git a/uip/replsbr.c b/uip/replsbr.c index 7f0f5237..ace850db 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -24,7 +24,7 @@ static int dftype=0; static char *badaddrs = NULL; static char *dfhost = NULL; -static struct mailname mq = { NULL }; +static struct mailname mq; static int nodupcheck = 0; /* If set, no check for duplicates */ /* -- 2.56.1