--- h/fmt_compile.h.virgin	Wed May 18 05:50:45 2005
+++ h/fmt_compile.h	Sat Dec 30 17:05:07 2006
@@ -83,7 +83,7 @@
 #define FT_FORMATADDR	67	/* let external routine format addr    */
 #define FT_MYMBOX	68	/* do "mymbox" test on comp            */
 
-/* misc. */		/* ADDTOSEQ only works if you include "options LBL" */
+/* misc. */
 #define FT_ADDTOSEQ	69	/* add current msg to a sequence       */
 
 /* conditionals & control flow (must be last) */
--- h/fmt_scan.h.virgin	Sat Dec 30 17:11:20 2006
+++ h/fmt_scan.h	Sat Dec 30 17:11:40 2006
@@ -93,3 +93,4 @@
 struct format *fmt_scan (struct format *, char *, int, int *);
 char *new_fs (char *, char *, char *);
 int fmt_compile (char *, struct format **);
+char *formataddr (char *, char *);
--- h/mh.h.virgin	Sat Dec 30 17:20:38 2006
+++ h/mh.h	Sat Dec 30 17:20:55 2006
@@ -273,6 +273,7 @@
 extern char *defpath;		/* pathname of user's profile      */
 extern char *ctxpath;		/* pathname of user's context      */
 extern struct node *m_defs;	/* list of profile/context entries */
+extern struct msgs *fmt_current_folder; /* global for sbr/fmt_scan.c */
 
 /*
  * These standard strings are defined in config.c.  They are the
--- h/prototypes.h.virgin	Sat Dec 30 17:14:40 2006
+++ h/prototypes.h	Sat Dec 30 17:52:14 2006
@@ -26,14 +26,27 @@
  * prototypes from the nmh subroutine library
  */
 char *add (char *, char *);
-void adios (char *, char *, ...);
-void admonish (char *, char *, ...);
+void adios (char *, char *, ...)
+#if __STDC__
+    __attribute__((volatile, format (printf, 2, 3)))
+#endif
+;
+void admonish (char *, char *, ...)
+#if __STDC__
+    __attribute__((format (printf, 2, 3)))
+#endif
+;
 void advertise (char *, char *, char *, va_list);
-void advise (char *, char *, ...);
+void advise (char *, char *, ...)
+#if __STDC__
+    __attribute__((format (printf, 2, 3)))
+#endif
+;
 void ambigsw (char *, struct swit *);
 int atooi(char *);
 char **brkstring (char *, char *, char *);
 int check_charset (char *, int);
+int client (char *, char *, char *, int, char *, int);
 void closefds(int);
 char *concat (char *, ...);
 int context_del (char *);
@@ -48,7 +61,11 @@
 void cpydgst (int, int, char *, char *);
 int decode_rfc2047 (char *, char *, size_t);
 void discard (FILE *);
-int done (int);
+int done (int)
+#if __STDC__
+    __attribute__((volatile))
+#endif
+;
 int ext_hook(char *, char *, char *);
 int fdcompare (int, int);
 int folder_addmsg (struct msgs **, char *, int, int, int, int, char *);
@@ -61,7 +78,7 @@
 char **getans (char *, struct swit *);
 int getanswer (char *);
 char **getarguments (char *, int, char **, int);
-char *get_charset();
+char *get_charset(void);
 char *getcpy (char *);
 char *getfolder(int);
 int lkclose(int, char*);
@@ -72,7 +89,7 @@
 char *m_backup (char *);
 int m_convert (struct msgs *, char *);
 char *m_draft (char *, char *, int, int *);
-void m_eomsbr (int (*)());
+void m_eomsbr (int (*)(int));
 int m_getfld (int, unsigned char *, unsigned char *, int, FILE *);
 int m_gmprot (void);
 char *m_maildir (char *);
@@ -134,7 +151,11 @@
  * prototypes for compatibility functions in library
  */
 #ifndef HAVE_SNPRINTF_PROTOTYPE
-int snprintf (char *, size_t, const char *, ...);
+int snprintf (char *, size_t, const char *, ...)
+#if __STDC__
+    __attribute__((format (printf, 3, 4)))
+#endif
+;
 int vsnprintf (char *, size_t, const char *, va_list);
 #endif
 
@@ -160,10 +181,29 @@
 int annotate (char *, char *, char *, int, int, int, int);
 void annolist(char *, char *, char *, int);
 void annopreserve(int);
+void clear_screen(void);
 int distout (char *, char *, char *);
+int ftp_get(char *, char *, char *, char *, char *, char *, int, int);
+int ftp_trans(char *, char *, char *, char *, char *, char *, char *, int, int);
+struct hostent *gethostbystring(char *);
+int make_intermediates (char *);
+int mhl(int , char **);
+int mhlsbr (int, char **, FILE *(*)(char *));
+int pidcheck (int);
 void replout (FILE *, char *, char *, struct msgs *, int,
 	int, char *, char *, char *);
+void set_endian (void);
+char *sc_gettermcap(char *);
+int sc_hardcopy(void);
+int sc_length(void);
+int sc_width(void);
 int sendsbr (char **, int, char *, struct stat *, int, char *);
+int SOprintf (char *, ...)
+#if __STDC__
+    __attribute__((format (printf, 1, 2)))
+#endif
+;
 int what_now (char *, int, int, char *, char *,
 	int, struct msgs *, char *, int, char *);
-
+int WhatNow(int, char **);
+int writeBase64aux (FILE *, FILE *);
--- sbr/fmt_scan.c.virgin	Sat Dec 30 17:06:51 2006
+++ sbr/fmt_scan.c	Sat Dec 30 17:10:47 2006
@@ -28,11 +28,7 @@
 
 #define	NFMTS MAXARGS
 
-extern char *formataddr ();	/* hook for custom address formatting */
-
-#ifdef LBL
 struct msgs *fmt_current_folder; /* current folder (set by main program) */
-#endif
 
 extern int fmt_norm;		/* defined in sbr/fmt_def.c = AD_NAME */
 struct mailname fmt_mnull;
@@ -263,7 +259,7 @@
 fmt_scan (struct format *format, char *scanl, int width, int *dat)
 {
     char *cp, *ep, *sp;
-    char *savestr, *str = NULL;
+    char *savestr = NULL, *str = NULL;
     char buffer[BUFSIZ], buffer2[BUFSIZ];
     int i, c, ljust, n;
     int value = 0;
@@ -860,14 +856,12 @@
 	    break;
 
 	case FT_ADDTOSEQ:
-#ifdef LBL
 	    /* If we're working on a folder (as opposed to a file), add the
 	     * current msg to sequence given in literal field.  Don't
 	     * disturb string or value registers.
 	     */
 	    if (fmt_current_folder)
-		    seq_addmsg(fmt_current_folder, fmt->f_text, dat[0], -1);
-#endif
+		    seq_addmsg(fmt_current_folder, fmt->f_text, dat[0], -1, 0);
 	    break;
 	}
 	fmt++;
--- sbr/seq_add.c.virgin	Sat Dec 30 17:33:50 2006
+++ sbr/seq_add.c	Sat Dec 30 17:35:26 2006
@@ -177,7 +177,7 @@
 	make_seq_public (mp, i);
     else if (public == 0)
 	make_seq_private (mp, i);
-    else if (new_seq) {
+    else if (public == -1) {
 	/*
 	 * If public == -1, then only set the
          * public/private bit for new sequences.
--- uip/inc.c.virgin	Sat Dec 30 17:16:51 2006
+++ uip/inc.c	Sat Dec 30 17:29:36 2006
@@ -29,10 +29,10 @@
 #endif
 
 #include <h/mh.h>
+#include <h/dropsbr.h>
 #include <fcntl.h>
 
 #ifdef POP
-# include <h/dropsbr.h>
 # include <h/popsbr.h>
 #endif
 
@@ -218,10 +218,8 @@
 static FILE *in;
 
 /*
- * prototypes
+ * static prototypes
  */
-char *map_name(char *);
-
 #ifdef POP
 int done(int);
 static int pop_action(char *);
@@ -229,15 +227,14 @@
 static int map_count(void);
 #endif
 
-
 int
 main (int argc, char **argv)
 {
     int chgflag = 1, trnflag = 1;
     int noisy = 1, width = 0;
-    int rpop, i, hghnum, msgnum;
+    int rpop, i = -1, hghnum = -2, msgnum = -3;
     int kpop = 0, sasl = 0;
-    char *cp, *maildir, *folder = NULL;
+    char *cp, *maildir = NULL, *folder = NULL;
     char *format = NULL, *form = NULL;
     char *host = NULL, *user = NULL, *proxy = NULL;
     char *audfile = NULL, *from = NULL, *saslmech = NULL;
@@ -579,6 +576,7 @@
     /* read folder and create message structure */
     if (!(mp = folder_read (folder)))
 	adios (NULL, "unable to read folder %s", folder);
+    fmt_current_folder = mp;
 
 #ifdef POP
 go_to_it:
@@ -679,9 +677,12 @@
 	     * messages.  If not, then realloc the folder and add enough
 	     * space for all new messages plus 10 additional slots.
 	     */
-	    if (mp->hghmsg + nmsgs >= mp->hghoff
-		&& !(mp = folder_realloc (mp, mp->lowoff, mp->hghmsg + nmsgs + 10)))
-		adios (NULL, "unable to allocate folder storage");
+	    if (mp->hghmsg + nmsgs >= mp->hghoff) {
+		if (!(mp = folder_realloc (mp, mp->lowoff,
+		    mp->hghmsg + nmsgs + 10)))
+		    adios (NULL, "unable to allocate folder storage");
+		fmt_current_folder = mp;
+	    }
 	}
 
 	for (i = 1; i <= nmsgs; i++) {
@@ -796,11 +797,13 @@
 	     * Check if we need to allocate more space for message status.
 	     * If so, then add space for an additional 100 messages.
 	     */
-	    if (msgnum >= mp->hghoff
-		&& !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
-		advise (NULL, "unable to allocate folder storage");
-		i = NOTOK;
-		break;
+	    if (msgnum >= mp->hghoff) {
+		if (!(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
+		    advise (NULL, "unable to allocate folder storage");
+		    i = NOTOK;
+		    break;
+		}
+		fmt_current_folder = mp;
 	    }
 
 #if 0
@@ -816,9 +819,28 @@
 	    /* link message into folder */
 	    newmsg = folder_addmsg(mp, tmpfilenam);
 #endif
+
+	    /* message must exist during scan() for "addtoseq" to work */
+	    ++mp->hghmsg;
+	    ++mp->nummsg;
+	    ++msgnum;
+	    clear_msg_flags (mp, msgnum);
+	    set_exists (mp, msgnum);
+
 	    /* create scanline for new message */
-	    switch (i = scan (in, msgnum + 1, msgnum + 1, nfs, width,
-			      msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
+	    i = scan (in, msgnum, msgnum, nfs, width,
+		msgnum == hghnum && chgflag, 1, NULL, 0L, noisy);
+
+	    /* back out if there isn't a new message */
+	    if (i != SCNMSG && i != SCNENC) {
+		clear_msg_flags (mp, msgnum);
+		--mp->hghmsg;
+		--mp->nummsg;
+		--msgnum;
+	    }
+
+	    switch (i) {
+
 	    case SCNFAT:
 	    case SCNEOF: 
 		break;
@@ -855,13 +877,9 @@
 		if (noisy)
 		    fflush (stdout);
 
-		msgnum++;
-		mp->hghmsg++;
-		mp->nummsg++;
-		if (mp->lowmsg == 0) mp->lowmsg = 1;
+		if (mp->lowmsg == 0)
+		    mp->lowmsg = 1;
 
-		clear_msg_flags (mp, msgnum);
-		set_exists (mp, msgnum);
 		set_unseen (mp, msgnum);
 		mp->msgflags |= SEQMOD;
 		continue;
@@ -871,10 +889,11 @@
     }
 
 #ifdef POP
-    if (p < 0) {		/* error */
+    if (p < 0)			/* error */
 #else
-    if (i < 0) {		/* error */
+    if (i < 0)			/* error */
 #endif
+	{
 	if (locked) {
             GETGROUPPRIVS();      /* Be sure we can unlock mail file */
             (void) lkfclose (in, newmail); in = NULL;
--- uip/scan.c.virgin	Sat Dec 30 17:30:01 2006
+++ uip/scan.c	Sat Dec 30 17:32:36 2006
@@ -51,20 +51,6 @@
     { NULL, 0 }
 };
 
-
-/*
- * global for sbr/formatsbr.c - yech!
- */
-#ifdef LBL
-extern struct msgs *fmt_current_folder;	
-#endif
-
-/*
- * prototypes
- */
-void clear_screen(void);  /* from termsbr.c */
-
-
 int
 main (int argc, char **argv)
 {
@@ -277,11 +263,7 @@
     }
 
     ontty = isatty (fileno (stdout));
-
-#ifdef LBL
-    else
-	fmt_current_folder = mp;
-#endif
+    fmt_current_folder = mp;
 
     for (msgnum = revflag ? mp->hghsel : mp->lowsel;
 	 (revflag ? msgnum >= mp->lowsel : msgnum <= mp->hghsel);
@@ -343,9 +325,7 @@
 	}
     }
 
-#ifdef LBL
     seq_save (mp);	/* because formatsbr might have made changes */
-#endif
 
     folder_free (mp);	/* free folder/message structure */
     if (clearflag)
--- man/mh-format.man.virgin	Sat Dec 30 19:21:54 2006
+++ man/mh-format.man	Sat Dec 30 19:21:58 2006
@@ -270,6 +270,8 @@
 getenv 	literal	string	Set \fIstr\fR to environment value of \fIarg\fR
 profile	literal	string	Set \fIstr\fR to profile component \fIarg\fR 
 			value
+addtoseq	literal		Add the current message to sequence
+			\fIarg\fR
 .\" dat	literal	int	return value of dat[arg]
 nonzero	expr	boolean	\fInum\fR is non-zero
 zero	expr	boolean	\fInum\fR is zero
@@ -618,6 +620,24 @@
 or more digits.
 If so, it is printed at full width: otherwise
 at 4 digits.
+.PP
+.RS
+.nf
+%<{from}%<(match fax@)\\
+.br
+%<{subject}%<(match facsimile not received)%(addtoseq trash)%>\\
+.br
+%>%>%>
+.fi
+.RE
+.PP
+Messages that have matching header components are placed into the
+.RI ` trash '
+sequence. Using this with 
+.B inc
+makes it possible to autofile messages into sequences when incorporating
+new mail.
+
 .SH "SEE ALSO"
 scan(1), repl(1), ap(8), dp(8)
 
