Merge branch 'master' of ssh://marmaro.de:443/var/git/mmh
authormarkus schnalke <meillo@marmaro.de>
Sat, 14 Feb 2015 16:44:14 +0000 (17:44 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sat, 14 Feb 2015 16:44:14 +0000 (17:44 +0100)
Conflicts:
uip/mhl.c
uip/mhlist.c
uip/mhmail.c
uip/pick.c
uip/send.c

65 files changed:
h/mh.h
man/anno.man1
man/burst.man1
man/dist.man1
man/forw.man1
man/mark.man1
man/mh-draft.man7
man/mh-sequence.man7
man/mhlist.man1
man/mhpath.man1
man/mhstore.man1
man/pick.man1
man/refile.man1
man/repl.man1
man/rmm.man1
man/show.man1
sbr/Makefile.in
sbr/done.c [deleted file]
sbr/error.c
sbr/m_draft.c
test/tests/pick/test-normal-output [new file with mode: 0644]
test/tests/pick/test-output-on-error [new file with mode: 0644]
uip/ali.c
uip/anno.c
uip/ap.c
uip/burst.c
uip/comp.c
uip/dist.c
uip/distsbr.c
uip/dp.c
uip/flist.c
uip/fmtdump.c
uip/folder.c
uip/forw.c
uip/inc.c
uip/mark.c
uip/mhbuild.c
uip/mhfree.c
uip/mhl.c
uip/mhlist.c
uip/mhmail.c
uip/mhparam.c
uip/mhparse.c
uip/mhpath.c
uip/mhshow.c
uip/mhstore.c
uip/mhtest.c
uip/new.c
uip/packf.c
uip/pick.c
uip/prompter.c
uip/rcvdist.c
uip/rcvpack.c
uip/rcvstore.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/send.c
uip/slocal.c
uip/sortm.c
uip/spost.c
uip/whatnow.c
uip/whom.c

diff --git a/h/mh.h b/h/mh.h
index 9d22c2b..6b8f4a9 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -268,6 +268,4 @@ extern char *version_num;
 extern char *version_str;
 extern char *whatnowproc;
 
-extern void (*done) (int) NORETURN;
-
 #include <h/prototypes.h>
index d545f2d..9772031 100644 (file)
@@ -216,7 +216,7 @@ dist(1), forw(1), repl(1)
 .SH DEFAULTS
 .nf
 .RI ` +folder "' defaults to the current folder"
-.RI ` msgs "' defaults to cur"
+.RI ` msgs "' defaults to the current message"
 .RB ` \-date '
 .RB ` \-nopreserve '
 .fi
index b5babf6..a13e476 100644 (file)
@@ -64,7 +64,7 @@ mhstore(1),
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-noverbose '
 .fi
 
index 8e27f66..773663b 100644 (file)
@@ -130,7 +130,7 @@ comp(1), forw(1), repl(1), send(1), whatnow(1)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msg "' defaults to cur"
+.RB ` msg "' defaults to the current message"
 .RB ` \-noannotate '
 .fi
 
index ae4f670..8091c42 100644 (file)
@@ -190,7 +190,7 @@ mhbuild(1), comp(1), repl(1), send(1), whatnow(1), mh\-format(5),
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-noannotate '
 .fi
 
index 6577f64..dacf4ce 100644 (file)
@@ -28,7 +28,7 @@ message numbers from folder\-specific message sequences, or by listing
 those sequences and messages.
 .PP
 A message sequence is a keyword, just like one of the `reserved'
-message names, such as `first' or `next'.  Unlike the
+message names, such as `f' or `n' (see mh-sequence(7)).  Unlike the
 `reserved' message names, which have a fixed semantics on
 a per\-folder basis, the semantics of a message sequence may be
 defined, modified, and removed by the user.  Message sequences are
@@ -54,7 +54,7 @@ create a new sequence.  For each sequence named via the
 .I name
 argument (which must occur at least once) the messages named via
 .I msgs
-(which defaults to `cur' if no
+(which defaults to `c' if no
 .I msgs
 are given), are added to the
 sequence.  The messages to be added need not be absent from the sequence.
@@ -148,8 +148,8 @@ The current restrictions on sequences are:
 .IP \(bu 2
 The name used to denote a message sequence must consist of an alphabetic
 character followed by zero or more alphanumeric characters, and cannot
-be one of the (reserved) message names `new', `first',
-`last', `all', `next', or `prev'.
+be one of the (reserved) message names `c', `f',
+`l', `a', `n', `p', or `b'.
 .PP
 .IP \(bu 2
 Only a certain number of sequences may be defined for a given folder.
@@ -187,7 +187,7 @@ flist(1), pick(1), mh-sequence(7)
 .nf
 .RB ` +folder "' defaults to the current folder"
 .RB ` \-add "' if " \-sequence " is specified, " \-list " otherwise"
-.RB ` msgs "' defaults to cur (or all if " \-list " is specified)"
+.RB ` msgs "' defaults to `c' (or `a' if " \-list " is specified)"
 .RB ` \-nozero '
 
 .SH CONTEXT
index 40ab626..04c8446 100644 (file)
@@ -33,7 +33,7 @@ with
 in which case the current draft is used.
 .PP
 The last draft message
-the user was composing is known as `cur' in the draft folder.
+the user was composing is the current message in the draft folder.
 .PP
 The user can send off whatever drafts desired from the shell using the
 standard
@@ -41,7 +41,7 @@ standard
 `msgs' convention to the
 .B send
 command..
-If no `msgs' are given, it defaults to `cur'.
+If no `msgs' are given, it defaults to `c'.
 .PP
 .RS
 .nf
@@ -63,8 +63,8 @@ repl
 .fi
 .RE
 .PP
-constructs the message draft in the draft folder using the `new'
-message number.  Furthermore, they each define `cur' in this folder to
+constructs the message draft in the draft folder using the `b'
+message number.  Furthermore, they each define `c' in this folder to
 be that message draft.  If the user were to use the
 .B quit
 option at `What now?' level, then later on, if no other draft composition
@@ -85,7 +85,7 @@ comp -use
 .RE
 .PP
 Instead, if other drafts had been composed in the meantime, so that this
-message draft was no longer known as `cur' in the `draft' folder, then
+message draft was no longer known as `c' in the `draft' folder, then
 the user could
 .B scan
 the folder to see which message draft in the
index 60568ed..516b8af 100644 (file)
@@ -28,20 +28,19 @@ or one of these `reserved' message names:
 .nf
 .ta +\w'\fIName\fP      'u
 .I "Name       Description
-first  the first message in the folder
-last   the last message in the folder
-cur    the most recently accessed message
-prev   the message numerically preceding `cur'
-next   the message numerically following `cur'
+f      the first message in the folder
+p      the message numerically preceding `c'
+c      the most recently accessed message
+n      the message numerically following `c'
+l      the last message in the folder
 .fi
 .RE
 .PP
-In commands that take a `msg' argument, the default is `cur'.
-As a shorthand, `\&.' is equivalent to `cur'.
+In commands that take a `msg' argument, the default is `c'.
 .PP
 For example: In a folder containing five messages numbered 5, 10, 94, 177
-and 325, `first' is 5 and `last' is 325.  If `cur'
-is 94, then `prev' is 10 and `next' is 177.
+and 325, `f' is 5 and `l' is 325.  If `c'
+is 94, then `p' is 10 and `n' is 177.
 .PP
 The word `msgs' indicates that one or more messages may be specified.
 Such a specification consists of one message designation or of several
@@ -49,32 +48,51 @@ message designations separated by spaces.  A message designation consists
 either of a message name as defined above, or a message range.
 .PP
 A message range is specified as `name1\-name2' or
-`name:n', where `name', `name1' and `name2' are message names,
-and `n' is an integer.
+`name:i', where `name', `name1' and `name2' are message names,
+and `i' is an integer.
 .PP
 The specification `name1\-name2' designates all currently existing
 messages from `name1' to `name2' inclusive.  The `reserved'
-message name `all' is a shorthand for the message range
-`first\-last'.
+message name `a' (``all'') is a shorthand for the message range
+`f\-l'.
 .PP
-The specification `name:n' designates up to `n' messages.
+.RS 5
+.nf
+.ta +\w'\fIName\fP      'u
+.I "Name       Description
+a      all messages in the folder (i.e. `f\-l')
+.fi
+.RE
+.PP
+The specification `name:i' designates up to `i' messages.
 These messages start with `name' if `name' is a message number or one of
-the reserved names `first' `cur', or `next', The
-messages end with `name' if `name' is `prev' or `last'.
-The interpretation of `n' may be overridden by preceding `n' with a
-plus or minus sign; `+n' always means up to `n' messages starting with
-`name', and `\-n' always means up to `n' messages ending with `name'.
+the reserved names `f' `c', or `n', The
+messages end with `name' if `name' is `p' or `l'.
+The interpretation of `i' may be overridden by preceding `i' with a
+plus or minus sign; `+i' always means up to `i' messages starting with
+`name', and `\-i' always means up to `i' messages ending with `name'.
 .PP
 In commands which accept a `msgs' argument, the default is either
-`cur' or `all', depending on which makes more sense
-for each command (see the individual man pages for details).  Repeated
+`c' or `a', depending on which makes more sense
+for each command (see the individual man pages for details).
+.PP
+Repeated
 specifications of the same message have the same effect as a single
 specification of the message.
 .PP
-There is also a special `reserved' message name `new'
-which is used by the
+There is also a special `reserved' message name `b' (``beyond'')
+which can be used with the
 .B mhpath
-command.
+command. It refers to the next (not yet used) message number 
+after `l'.
+.PP
+.RS 5
+.nf
+.ta +\w'\fIName\fP      'u
+.I "Name       Description
+b      the next message number beyond `l'
+.fi
+.RE
 
 .SS "User\-Defined Message Sequences"
 In addition to the `reserved' (pre-defined) message names given
@@ -96,17 +114,17 @@ command expects a `msg' or
 `msgs' argument.
 .PP
 Some forms of message ranges are allowed with user-defined sequences.
-The specification `name:n' may be used, and it designates up
-to the first `n' messages (or last `n' messages for `\-n') which are
+The specification `name:i' may be used, and it designates up
+to the first `i' messages (or last `i' messages for `\-i') which are
 elements of the user-defined sequence `name'.
 .PP
-The specifications `name:next' and `name:prev' may also
+The specifications `name:n' and `name:p' may also
 be used, and they designate the next or previous message (relative to the
 current message) which is an element of the user-defined sequence `name'.
-The specifications `name:first' and `name:last' are
+The specifications `name:f' and `name:l' are
 equivalent to `name:1' and `name:\-1', respectively.  The
-specification `name:cur' is not allowed (use just `cur'
-instead).  The syntax of these message range specifications is subject
+specification `name:c' is not allowed (use just `c' instead).
+Note: The syntax of these message range specifications is subject
 to change in the future.
 .PP
 User-defined sequence names are specific to each folder.  They are
@@ -115,7 +133,7 @@ defined using the
 and
 .B mark
 commands.
-.PP
+
 .SS "Public and Private User-Defined Sequences"
 There are two varieties of user-defined sequences:
 public and private.  Public sequences of a folder are accessible to any
index e0724b2..80bdcca 100644 (file)
@@ -141,7 +141,7 @@ mhbuild(1), show(1), mhstore(1), sendfiles(1)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-noverbose '
 .fi
 
index 1c35fcd..d5d3327 100644 (file)
@@ -30,18 +30,18 @@ commands, a message argument to
 may often be intended for writing.  Because of this:
 .PP
 .IP 1) 4
-the name `new' has been added to
+the name `b' has been added to
 .BR mhpath 's
 list of
-reserved message names (the others are `first', `last',
-`prev', `next', `cur', and `all').
-The new message is equivalent to the message after the last message
+reserved message names (the others are `f', `l',
+`p', `n', `c', and `a').
+The `b' (beyond) message is equivalent to the message after the last message
 in a folder (and equivalent to 1 in a folder without messages).
-The `new' message may not be used as part of a message range.
+The `b' message may not be used as part of a message range.
 .IP 2) 4
 Within a message list, the following designations may refer to messages
 that do not exist: a single numeric message name, the single message name
-`cur', and (obviously) the single message name `new'.
+`c', and (obviously) the single message name `b'.
 All other message designations must refer to at least one existing
 message, if the folder contains messages.
 .IP 3) 4
@@ -59,7 +59,7 @@ Cur is 4.
 % mhpath
 /r/phyl/Mail/foo
 
-% mhpath all
+% mhpath a
 /r/phyl/Mail/foo/3
 /r/phyl/Mail/foo/5
 /r/phyl/Mail/foo/6
@@ -72,23 +72,23 @@ Cur is 4.
 /r/phyl/Mail/foo/5
 /r/phyl/Mail/foo/6
 
-% mhpath new
+% mhpath b
 /r/phyl/Mail/foo/7
 
-% mhpath last new
+% mhpath l b
 /r/phyl/Mail/foo/6
 /r/phyl/Mail/foo/7
 
-% mhpath last\-new
-bad message list `last\-new'.
+% mhpath l\-b
+bad message list `l\-b'.
 
-% mhpath cur
+% mhpath c
 /r/phyl/Mail/foo/4
 
 % mhpath 1\-2
 no messages in range `1\-2'.
 
-% mhpath first:2
+% mhpath f:2
 /r/phyl/Mail/foo/3
 /r/phyl/Mail/foo/5
 
index 8445a5f..e4fdfdc 100644 (file)
@@ -340,7 +340,7 @@ mhbuild(1), mhlist(1), show(1), sendfiles(1)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-auto '
 
 .SH CONTEXT
index 7b1263f..42971fe 100644 (file)
@@ -352,14 +352,14 @@ not, and merely matches the messages you specify.  This lets you type
 something like:
 .PP
 .RS 5
-show\0`pick\0last:20\0\-seq\0fear`
+show\0`pick\0l:20\0\-seq\0fear`
 .RE
 .PP
 instead of typing
 .PP
 .RS 5
 .nf
-mark\0\-add\0\-nozero\0\-seq\0fear\0last:20
+mark\0\-add\0\-nozero\0\-seq\0fear\0l:20
 show\0fear
 .fi
 .RE
index 3bc85f7..47f825b 100644 (file)
@@ -38,7 +38,7 @@ multiply\-index messages.  For example, if a message is received from
 Jones about the ARPA Map Project, the command
 .PP
 .RS 5
-refile\0cur\0+jones\0+Map
+refile\0c\0+jones\0+Map
 .RE
 .PP
 would allow the message to be found in either of the two folders `jones'
@@ -49,7 +49,7 @@ You may specify the source folder using
 .IR +folder .
 If this is
 not given, the current folder is used by default.  If no message is
-specified, then `cur' is used by default.
+specified, then the current message is used by default.
 .PP
 The option
 .B \-file
@@ -120,7 +120,7 @@ folder(1), rmf(1), rmm(1)
 .SH DEFAULTS
 .nf
 .RB ` "\-src\ +folder" "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-nolink '
 .fi
 
index c0feecb..698d9c8 100644 (file)
@@ -381,7 +381,7 @@ mhbuild(1), comp(1), forw(1), send(1), whatnow(1), mh\-format(5)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msg "' defaults to cur"
+.RB ` msg "' defaults to the current message"
 .RB ` \-nogroup '
 .RB ` "\-nocc\ all" "' with `\-nogroup', `\-cc\ all' with `\-group'"
 .RB ` \-noannotate '
index 07d6cc3..07af34f 100644 (file)
@@ -64,7 +64,7 @@ refile(1), rmf(1)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-nounlink '
 .fi
 
index f7b30fd..d4f90d1 100644 (file)
@@ -423,7 +423,7 @@ mhbuild(1), mhl(1), mhlist(1), mhstore(1), sendfiles(1)
 .SH DEFAULTS
 .nf
 .RB ` +folder "' defaults to the current folder"
-.RB ` msgs "' defaults to cur"
+.RB ` msgs "' defaults to the current message"
 .RB ` \-form \ mhl.headers'
 .RB ` \-noverbose '
 .fi
index 9729346..e5d8ffd 100644 (file)
@@ -50,7 +50,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c  \
        context_find.c context_read.c  \
        context_replace.c context_save.c \
        cpydata.c cpydgst.c crawl_folders.c  \
-       discard.c done.c dtime.c dtimep.c  \
+       discard.c dtime.c dtimep.c  \
        error.c execprog.c ext_hook.c folder_addmsg.c folder_delmsgs.c  \
        folder_free.c folder_read.c  \
        folder_realloc.c gans.c getans.c getanswer.c  \
diff --git a/sbr/done.c b/sbr/done.c
deleted file mode 100644 (file)
index 3545d10..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-** done.c -- terminate the program
-**
-** 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.
-*/
-
-#include <h/mh.h>
-
-void (*done) (int) NORETURN = exit;
index d8313ce..599b91d 100644 (file)
@@ -35,7 +35,7 @@ adios(char *what, char *fmt, ...)
        va_start(ap, fmt);
        advertise(what, NULL, fmt, ap);
        va_end(ap);
-       done(1);
+       exit(1);
 }
 
 
index 3659ff3..e97dd1e 100644 (file)
@@ -23,7 +23,7 @@ m_draft(char *which)
        char *folder;
 
        folder = getcpy(toabsdir(draftfolder));
-       create_folder(folder, 0, done);
+       create_folder(folder, 0, exit);
        if (!(mp = folder_read(folder))) {
                adios(NULL, "unable to read folder %s", folder);
        }
@@ -51,7 +51,7 @@ m_draft(char *which)
        ** (to start a new draft).
        */
        if (!m_convert(mp, which))
-               done(1);
+               exit(1);
        seq_setprev(mp);
 
        snprintf(buffer, sizeof(buffer), "%s/%s", mp->foldpath,
diff --git a/test/tests/pick/test-normal-output b/test/tests/pick/test-normal-output
new file mode 100644 (file)
index 0000000..bd1a2e7
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+######################################################
+#
+# Test that all messages are picked and no ``0'' is giving out.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# All messages should be go to stdout
+cat > $expected_out <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+EOF
+# Nothing should to go stderr
+cat /dev/null > $expected_err
+
+pick > $actual_out 2> $actual_err
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out
diff --git a/test/tests/pick/test-output-on-error b/test/tests/pick/test-output-on-error
new file mode 100644 (file)
index 0000000..8d96224
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+######################################################
+#
+# Test output is handelt corect and ``0'' is giving to stdout.
+#
+######################################################
+
+expected_err=$MH_TEST_DIR/$$.expected_err
+expected_out=$MH_TEST_DIR/$$.expected_out
+actual_err=$MH_TEST_DIR/$$.actual_err
+actual_out=$MH_TEST_DIR/$$.actual_out
+
+# A zero should go to standard out to protect other programms
+cat > $expected_out <<EOF
+0
+EOF
+# Error message should go to stderr.
+cat > $expected_err <<EOF
+pick: no messages match specification
+EOF
+
+pick -after tomorrow > $actual_out 2> $actual_err
+diff -u $expected_err $actual_err
+diff -u $expected_out $actual_out
index 2c80147..4d7617b 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -72,7 +72,8 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -80,10 +81,10 @@ main(int argc, char **argv)
                                snprintf(buf, sizeof(buf), "%s [switches] aliases ...",
                                        invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FILESW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -145,7 +146,7 @@ main(int argc, char **argv)
                for (i = 0; i < vecp; i++)
                        print_usr(vec[i], list, normalize);
 
-               done(0);
+               exit(0);
        }
 
        if (vecp) {
@@ -161,8 +162,7 @@ main(int argc, char **argv)
                }
        }
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 static void
index e874238..0483dff 100644 (file)
@@ -86,7 +86,8 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -95,10 +96,10 @@ main(int argc, char **argv)
                                        "%s [+folder] [msgs] [switches]",
                                        invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case DELETESW:  /* delete annotations */
                                mode = MODE_DEL;
@@ -202,7 +203,7 @@ main(int argc, char **argv)
                else
                        annotate(file, comp, text, datesw, number,
                                        append, preserve);
-               done(0);
+               exit(0);
        }
 
        if (!msgs.size)
@@ -223,9 +224,12 @@ main(int argc, char **argv)
                adios(NULL, "no messages in %s", folder);
 
        /* parse all the message ranges/sequences and set SELECTED */
-       for (msgnum = 0; msgnum < msgs.size; msgnum++)
-               if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+       for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+               if (!m_convert(mp, msgs.msgs[msgnum])) {
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
+               }
+       }
 
        /* annotate all the SELECTED messages */
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -243,8 +247,7 @@ main(int argc, char **argv)
        seq_save(mp);
        folder_free(mp);
        context_save();
-       done(0);
-       return 1;
+       return 0;
 }
 
 static void
@@ -258,7 +261,8 @@ make_comp(unsigned char **ap)
                fflush(stdout);
 
                if (!fgets(buffer, sizeof buffer, stdin)) {
-                       done(1);
+                       /* sysexits.h EX_IOERR */
+                       exit(1);
                }
                *ap = trimcpy(buffer);
        }
index c293a53..41554d7 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -61,7 +61,8 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
 
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
@@ -69,10 +70,10 @@ main(int argc, char **argv)
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] addrs ...", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -112,7 +113,7 @@ main(int argc, char **argv)
        for (addrp = 0; addrs[addrp]; addrp++)
                status += process(addrs[addrp], normalize);
 
-       done(status);
+       exit(status);
        return 1;
 }
 
index e657c33..db2ddc6 100644 (file)
@@ -59,17 +59,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case VERBSW:
                                verbosw++;
@@ -109,7 +110,8 @@ main(int argc, char **argv)
        /* parse all the message ranges/sequences and set SELECTED */
        for (msgnum = 0; msgnum < msgp; msgnum++)
                if (!m_convert(mp, msgs[msgnum]))
-                       done(1);
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
        seq_setprev(mp);  /* set the previous-sequence */
 
        smsgs = (struct smsg *)
@@ -148,8 +150,7 @@ main(int argc, char **argv)
        seq_save(mp);
        context_save();
        folder_free(mp);
-       done(0);
-       return 1;
+       return 0;
 }
 
 
index 4768fc4..f867593 100644 (file)
@@ -55,17 +55,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case EDITRSW:
                                if (!(ed = *argp++) || *ed == '-')
@@ -132,7 +133,8 @@ main(int argc, char **argv)
                        adios(NULL, "no messages in %s", folder);
                /* parse the message range/sequence/name and set SELECTED */
                if (!m_convert(mp, msg))
-                       done(1);
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
                seq_setprev(mp);  /* set the previous-sequence */
                if (mp->numsel > 1)
                        adios(NULL, "only one message at a time!");
@@ -162,6 +164,6 @@ main(int argc, char **argv)
 
        context_save();
        what_now(ed, use, drft, NULL, 0, NULLMP, NULL, cwd);
-       done(1);
+       /* sysexits.h EX_SOFTWARE */
        return 1;
 }
index c1f4f9d..47d7ed5 100644 (file)
@@ -55,17 +55,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE*/
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case ANNOSW:
                                anot++;
@@ -136,7 +137,8 @@ main(int argc, char **argv)
 
        /* parse the message range/sequence/name and set SELECTED */
        if (!m_convert(mp, msg))
-               done(1);
+               /* sysexits.h EX_USAGE*/
+               exit(1);
        seq_setprev(mp);
 
        if (mp->numsel > 1)
@@ -152,6 +154,6 @@ main(int argc, char **argv)
        context_save();
 
        what_now(ed, NOUSE, drft, msgnam, 1, mp, anot ? "Resent" : NULL, cwd);
-       done(1);
+       /*sysexits.h EX_SOFTWARE*/
        return 1;
 }
index a9a52b1..42c3ce8 100644 (file)
@@ -16,7 +16,7 @@ static int  txtfd = NOTOK;
 /*
 ** static prototypes
 */
-static void ready_msg(char *);
+static int ready_msg(char *);
 
 int
 distout(char *drft, char *msgnam, char *backup)
@@ -29,18 +29,23 @@ distout(char *drft, char *msgnam, char *backup)
 
        strcpy(backup, m_mktemp(toabsdir(invo_name), NULL, NULL));
        if (rename(drft, backup) == NOTOK) {
-               adios(backup, "unable to rename %s to",drft);
+               advise(backup, "unable to rename %s to",drft);
+               return NOTOK;
        }
        if (!(ifp = fopen(backup, "r"))) {
-               adios(backup, "unable to read");
+               advise(backup, "unable to read");
+               return NOTOK;
        }
 
        if (!(ofp = fopen(drft, "w"))) {
-               adios(drft, "unable to create temporary file");
+               advise(drft, "unable to create temporary file");
+               return NOTOK;
        }
        chmod(drft, m_gmprot());
 
-       ready_msg(msgnam);
+       if (ready_msg(msgnam) != OK) {
+               return NOTOK;
+       }
        lseek(hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
        cpydata(hdrfd, fileno(ofp), msgnam, drft);
 
@@ -92,12 +97,13 @@ leave_bad: ;
                        fclose(ofp);
                        unlink(drft);
                        if (rename(backup, drft) == NOTOK) {
-                               adios(drft, "unable to rename %s to", backup);
+                               advise(drft, "unable to rename %s to", backup);
                        }
                        return NOTOK;
 
                default:
-                       adios(NULL, "getfld() returned %d", state);
+                       advise(NULL, "getfld() returned %d", state);
+                       return NOTOK;
                }
        }
 
@@ -110,7 +116,7 @@ process: ;
                fclose(ofp);
                unlink(drft);
                if (rename(backup, drft) == NOTOK) {
-                       adios(drft, "unable to rename %s to", backup);
+                       advise(drft, "unable to rename %s to", backup);
                }
                return NOTOK;
        }
@@ -127,7 +133,7 @@ process: ;
 }
 
 
-static void
+static int
 ready_msg(char *msgnam)
 {
        int state, out;
@@ -144,17 +150,20 @@ ready_msg(char *msgnam)
                txtfd = NOTOK;
        }
        if (!(ifp = fopen(msgnam, "r"))) {
-               adios(msgnam, "unable to open message");
+               advise(msgnam, "unable to open message");
+               return NOTOK;
        }
 
        cp = m_mktemp2(NULL, "dist", &hdrfd, NULL);
        if (!cp) {
-               adios("distsbr", "unable to create temporary file");
+               advise("distsbr", "unable to create temporary file");
+               return NOTOK;
        }
        fchmod(hdrfd, 0600);
        strncpy(tmpfil, cp, sizeof(tmpfil));
        if ((out = dup(hdrfd)) == NOTOK || !(ofp = fdopen(out, "w"))) {
-               adios(NULL, "no file descriptors -- you lose big");
+               advise(NULL, "no file descriptors -- you lose big");
+               return NOTOK;
        }
        unlink(tmpfil);
 
@@ -185,13 +194,15 @@ ready_msg(char *msgnam)
 
                        cp = m_mktemp2(NULL, "dist", &txtfd, NULL);
                        if (!cp) {
-                               adios("distsbr", "unable to create temp file");
+                               advise("distsbr", "unable to create temp file");
+                               return NOTOK;
                        }
                        fchmod(txtfd, 0600);
                        strncpy(tmpfil, cp, sizeof(tmpfil));
                        if ((out = dup(txtfd)) == NOTOK ||
                                        !(ofp = fdopen(out, "w"))) {
-                               adios(NULL, "no file descriptors -- you lose");
+                               advise(NULL, "no file descriptors -- you lose");
+                               return NOTOK;
                        }
                        unlink(tmpfil);
                        fprintf(ofp, "\n%s", buffer);
@@ -205,13 +216,16 @@ ready_msg(char *msgnam)
 
                case LENERR:
                case FMTERR:
-                       adios(NULL, "format error in message %s", msgnam);
+                       advise(NULL, "format error in message %s", msgnam);
+                       return NOTOK;
 
                default:
-                       adios(NULL, "getfld() returned %d", state);
+                       advise(NULL, "getfld() returned %d", state);
+                       return NOTOK;
                }
        }
 process: ;
        fclose(ifp);
        fclose(ofp);
+       return OK;
 }
index 1a91678..22e725c 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -56,17 +56,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] dates ...", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -101,8 +102,7 @@ main(int argc, char **argv)
                status += process(dates[datep]);
 
        context_save();  /* save the context file */
-       done(status);
-       return 1;
+       return status;
 }
 
 
index 057d5f4..c0c8b5f 100644 (file)
@@ -149,17 +149,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder1 [+folder2 ...]][switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case SEQSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -260,8 +261,7 @@ main(int argc, char **argv)
        qsort(folders, nFolders, sizeof(struct Folder),
                        (qsort_comp) CompareFolders);
        PrintFolders();
-       done(0);
-       return 1;
+       return 0;
 }
 
 /*
index a0e6e14..dd5dbcb 100644 (file)
@@ -60,7 +60,8 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /*sysexits.h EX_USAGE*/
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -68,10 +69,10 @@ main(int argc, char **argv)
                                snprintf(buf, sizeof(buf), "%s [switches]",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -94,8 +95,7 @@ main(int argc, char **argv)
        fmt_compile(fmtstr, &fmt);
 
        fmt_dump(fmt);
-       done(0);
-       return 1;
+       return 0;
 }
 
 static void
index 8638151..e46519b 100644 (file)
@@ -136,17 +136,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /*sysexits.h EX_USAGE*/
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msg] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case ALLSW:
                                all = 1;
@@ -314,8 +315,9 @@ main(int argc, char **argv)
                }
                printf("\n");
 
-               if (!printsw)
-                       done(0);
+               if (!printsw) {
+                       exit(0);
+               }
        }
 
        /* Allocate initial space to record folder information */
@@ -365,7 +367,7 @@ main(int argc, char **argv)
                ** Check if folder exists.  If not, then see if
                ** we should create it, or just exit.
                */
-               create_folder(toabsdir(folder), fcreat, done);
+               create_folder(toabsdir(folder), fcreat, exit);
 
                if (get_folder_info(folder, msg) && argfolder) {
                        /* update current folder */
@@ -379,8 +381,7 @@ main(int argc, char **argv)
        print_folders();
 
        context_save();
-       done(0);
-       return 1;
+       return 0;
 }
 
 static int
@@ -422,8 +423,9 @@ get_folder_info_body(char *fold, char *msg, boolean *crawl_children)
                        retval = 0;
 
                if (fpack) {
-                       if (folder_pack(&mp, fverb) == -1)
-                               done(1);
+                       if (folder_pack(&mp, fverb) == -1) {
+                               exit(0);
+                       }
                        seq_save(mp);  /* synchronize the sequences */
                        context_save();  /* save the context file */
                }
index 57e508f..1ba80ee 100644 (file)
@@ -82,17 +82,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case ANNOSW:
                                anot++;
@@ -189,9 +190,12 @@ main(int argc, char **argv)
                adios(NULL, "no messages in %s", folder);
 
        /* parse all the message ranges/sequences and set SELECTED */
-       for (msgnum = 0; msgnum < msgp; msgnum++)
-               if (!m_convert(mp, msgs[msgnum]))
-                       done(1);
+       for (msgnum = 0; msgnum < msgp; msgnum++) {
+               if (!m_convert(mp, msgs[msgnum])) {
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
+               }
+       }
        seq_setprev(mp);  /* set the previous sequence */
 
        if ((out = creat(drft, m_gmprot())) == NOTOK)
@@ -242,10 +246,10 @@ main(int argc, char **argv)
        context_save();  /* save the context file */
 
        if (buildsw)
-               done(0);
+               exit(0);
        what_now(ed, NOUSE, drft, NULL, 0, mp,
                anot ? "Forwarded" : NULL, cwd);
-       done(1);
+       /* sysexits.h EX_SOFTWARE */
        return 1;
 }
 
index f737d69..213cc5d 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -119,7 +119,7 @@ static FILE *in;
 /*
 ** prototypes
 */
-static void inc_done(int) NORETURN;
+static void inc_done();
 
 
 int
@@ -143,7 +143,7 @@ main(int argc, char **argv)
        /* copy of mail directory because the static gets overwritten */
        char *maildir_copy = NULL;
 
-       done=inc_done;
+       atexit(inc_done);
 
 /*
 ** absolutely the first thing we do is save our privileges,
@@ -166,17 +166,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case AUDSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -289,7 +290,7 @@ main(int argc, char **argv)
        if ((maildir_copy = strdup(maildir)) == NULL)
                adios(maildir, "error allocating memory to copy maildir");
 
-       create_folder(maildir, noisy ? 0 : 1, done);
+       create_folder(maildir, noisy ? 0 : 1, exit);
 
        if (chdir(maildir) == NOTOK)
                adios(maildir, "unable to change directory to");
@@ -480,17 +481,15 @@ main(int argc, char **argv)
        seq_setunseen(mp, 1);  /* add new msgs to unseen sequences */
        seq_save(mp);  /* synchronize sequences   */
        context_save();  /* save the context file   */
-       done(0);
-       return 1;
+       return 0;
 }
 
 static void
-inc_done(int status)
+inc_done()
 {
        if (locked) {
                GETGROUPPRIVS();
                lkfclose(in, newmail);
                DROPGROUPPRIVS();
        }
-       exit(status);
 }
index d4a3729..e58ec64 100644 (file)
@@ -73,17 +73,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /*sysexits.h EX_USAGE*/
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case ADDSW:
                                addsw++;
@@ -171,9 +172,12 @@ main(int argc, char **argv)
                adios(NULL, "no messages in %s", folder);
 
        /* parse all the message ranges/sequences and set SELECTED */
-       for (msgnum = 0; msgnum < msgs.size; msgnum++)
-               if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+       for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+               if (!m_convert(mp, msgs.msgs[msgnum])) {
+                       /*sysexits.h EX_USAGE*/
+                       exit(1);
+               }
+       }
 
        if (publicsw == 1 && is_readonly(mp))
                adios(NULL, "folder %s is read-only, so -public not allowed",
@@ -190,16 +194,20 @@ main(int argc, char **argv)
 
        /* Adding messages to sequences */
        if (addsw) {
-               for (seqp = 0; seqs[seqp]; seqp++)
-                       if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
-                               done(1);
+               for (seqp = 0; seqs[seqp]; seqp++) {
+                       if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw)) {
+                               /*TODO find best exitcode*/
+                               exit(1);
+                       }
+               }
        }
 
        /* Deleting messages from sequences */
        if (deletesw) {
                for (seqp = 0; seqs[seqp]; seqp++)
                        if (!seq_delsel(mp, seqs[seqp], publicsw, zerosw))
-                               done(1);
+                               /*TODO find best exitcode*/
+                               exit(1);
        }
 
        /* Listing messages in sequences */
@@ -222,8 +230,7 @@ main(int argc, char **argv)
        context_replace(curfolder, folder);  /* update current folder */
        context_save();  /* save the context file */
        folder_free(mp);  /* free folder/message structure */
-       done(0);
-       return 1;
+       return 0;
 }
 
 
index fde4a1d..6e0861e 100644 (file)
@@ -92,7 +92,7 @@ static int unlink_infile  = 0;
 static char outfile[BUFSIZ];
 static int unlink_outfile = 0;
 
-static void unlink_done(int) NORETURN;
+static void unlink_done();
 
 /* mhoutsbr.c */
 int output_message(CT, char *);
@@ -115,7 +115,7 @@ main(int argc, char **argv)
        FILE *fp = NULL;
        FILE *fp_out = NULL;
 
-       done = unlink_done;
+       atexit(unlink_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -139,17 +139,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] file", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case VERBSW:
                                verbosw++;
@@ -244,7 +245,7 @@ main(int argc, char **argv)
                unlink_outfile = 0;
 
                free_content(ct);
-               done(0);
+               exit(0);
        }
 
        /*
@@ -273,28 +274,28 @@ main(int argc, char **argv)
        if (rename(outfile, compfile) == NOTOK) {
                advise(compfile, "unable to rename output %s to", outfile);
                rename(buffer, compfile);
-               done(1);
+               /* sysexits.h EX_IOERR */
+               exit(1);
        }
        unlink_outfile = 0;
 
        free_content(ct);
-       done(0);
-       return 1;
+       return 0;
 }
 
 
 static void
-unlink_done(int status)
+unlink_done()
 {
        /*
        ** Check if we need to remove stray temporary files.
        */
-       if (unlink_infile)
+       if (unlink_infile) {
                unlink(infile);
-       if (unlink_outfile)
+       }
+       if (unlink_outfile) {
                unlink(outfile);
-
-       exit(status);
+       }
 }
 
 /*
@@ -419,8 +420,10 @@ finish_field:
        ** draft.  So create a multipart/mixed content to hold everything.
        ** We can remove this later, if it is not needed.
        */
-       if (get_ctinfo("multipart/mixed", ct, 0) == NOTOK)
-               done(1);
+       if (get_ctinfo("multipart/mixed", ct, 0) == NOTOK) {
+               /* sysexits.h EX_DATAERR */
+               exit(1);
+       }
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = MULTI_MIXED;
        ct->c_file = getcpy(infile);
@@ -707,7 +710,8 @@ rock_and_roll:
 
                /* parse content type */
                if (get_ctinfo(content, ct, inlineD) == NOTOK)
-                       done(1);
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
 
                for (s2i = str2cts; s2i->si_key; s2i++)
                        if (!mh_strcasecmp(ci->ci_type, s2i->si_key))
@@ -755,7 +759,8 @@ call_init:
 
        /* parse directive */
        if (get_ctinfo(buf+1, ct, 1) == NOTOK)
-               done(1);
+               /* sysexits.h EX_DATAERR */
+               exit(1);
 
        /* check directive against the list of MIME types */
        for (s2i = str2cts; s2i->si_key; s2i++)
@@ -826,7 +831,8 @@ use_forw:
                        if ((cp = context_find(buffer)) == NULL ||
                                        *cp == '\0') {
                                content_error(NULL, ct, "don't know how to compose content");
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        }
                }
                ci->ci_magic = getcpy(cp);
@@ -878,7 +884,8 @@ use_forw:
                        cp = *ap;
                        if (*cp != '+' && *cp != '@')
                                if (!m_convert(mp, cp))
-                                       done(1);
+                                       /* sysexits.h EX_USAGE */
+                                       exit(1);
                }
                free(folder);
                free_ctinfo(ct);
@@ -892,7 +899,8 @@ use_forw:
                if (mp->numsel > 1) {
                        /* we are forwarding multiple messages */
                        if (get_ctinfo("multipart/digest", ct, 0) == NOTOK)
-                               done(1);
+                               /* sysexits.h EX_DATAERR */
+                               exit(1);
                        ct->c_type = CT_MULTIPART;
                        ct->c_subtype = MULTI_DIGEST;
 
@@ -915,7 +923,8 @@ use_forw:
                                        pe = p->c_cefile;
                                        if (get_ctinfo("message/rfc822", p, 0)
                                                        == NOTOK)
-                                               done(1);
+                                               /* sysexits.h EX_DATAERR */
+                                               exit(1);
                                        p->c_type = CT_MESSAGE;
                                        p->c_subtype = MESSAGE_RFC822;
 
@@ -934,7 +943,8 @@ use_forw:
                } else {
                        /* we are forwarding one message */
                        if (get_ctinfo("message/rfc822", ct, 0) == NOTOK)
-                               done(1);
+                               /* sysexits.h EX_DATAERR */
+                               exit(1);
                        ct->c_type = CT_MESSAGE;
                        ct->c_subtype = MESSAGE_RFC822;
 
@@ -980,7 +990,8 @@ use_forw:
                free_ctinfo(ct);
                snprintf(buffer, sizeof(buffer), "multipart/%s", cp);
                if (get_ctinfo(buffer, ct, 0) == NOTOK)
-                       done(1);
+                       /* sysexits.h EX_DATAERR */
+                       exit(1);
                ct->c_type = CT_MULTIPART;
                ct->c_subtype = vrsn;
 
@@ -1211,7 +1222,8 @@ raw:
                        default:
                                fclose(out);
                                if (pidXwait(child_id, NULL))
-                                       done(1);
+                                       /* sysexits.h EX_SOFTWARE */
+                                       exit(1);
                                break;
                        }
                }
index bf3382c..c9a0418 100644 (file)
@@ -22,7 +22,7 @@ void free_content(CT);
 void free_header(CT);
 void free_ctinfo(CT);
 void free_encoding(CT, int);
-void freects_done(int);
+void freects_done();
 
 /*
 ** static prototypes
@@ -261,13 +261,13 @@ free_encoding(CT ct, int toplevel)
 
 
 void
-freects_done(int status)
+freects_done()
 {
        CT *ctp;
 
-       if ((ctp = cts))
-               for (; *ctp; ctp++)
+       if ((ctp = cts)) {
+               for (; *ctp; ctp++){
                        free_content(*ctp);
-
-       exit(status);
+               }
+       }
 }
index 8c2e4af..5403673 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -175,17 +175,11 @@ static int num_ignores = 0;
 static char *ignores[MAXARGS];
 
 static  jmp_buf env;
-static  jmp_buf mhlenv;
-
-static FILE *(*mhl_action) () = (FILE *(*) ()) 0;
-
 
 /*
 ** Redefine a couple of functions.
 ** These are undefined later in the code.
 */
-#define adios mhladios
-#define done  mhldone
 
 /*
 ** prototypes
@@ -208,8 +202,6 @@ static char *oneline(char *, long);
 static void putstr(char *);
 static void putch(char);
 static void intrser(int);
-static void mhladios(char *, char *, ...);
-static void mhldone(int);
 
 int sc_width(void);  /* from termsbr.c */
 
@@ -239,17 +231,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -575,8 +567,7 @@ process(char *fname, int ofilen, int ofilec)
 
        if (setjmp(env) == 0) {
                if (fname) {
-                       fp = mhl_action ? (*mhl_action) (fname) :
-                                       fopen(fname, "r");
+                       fp = fopen(fname, "r");
                        if (fp == NULL) {
                                advise(fname, "unable to open");
                                exitstat++;
@@ -591,7 +582,7 @@ process(char *fname, int ofilen, int ofilec)
        }
 
        SIGNAL(SIGINT, SIG_IGN);
-       if (mhl_action == NULL && fp != stdin)
+       if (fp != stdin)
                fclose(fp);
        if (holder.c_text) {
                free(holder.c_text);
@@ -1117,29 +1108,3 @@ intrser(int i)
        putchar('\n');
        longjmp(env, DONE);
 }
-
-
-#undef adios
-#undef done
-
-static void
-mhladios(char *what, char *fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       advertise(what, NULL, fmt, ap);
-       va_end(ap);
-       mhldone(1);
-}
-
-
-static void
-mhldone(int status)
-{
-       exitstat = status;
-       if (mhl_action)
-               longjmp(mhlenv, DONE);
-       else
-               done(exitstat);
-}
index afa67ce..8c7e51d 100644 (file)
@@ -73,7 +73,7 @@ void list_all_messages(CT *, int, int);
 /* mhfree.c */
 void free_content(CT);
 extern CT *cts;
-void freects_done(int) NORETURN;
+void freects_done();
 
 /*
 ** static prototypes
@@ -92,7 +92,7 @@ main(int argc, char **argv)
        struct msgs *mp = NULL;
        CT ct, *ctp;
 
-       done=freects_done;
+       atexit(freects_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -111,17 +111,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -219,9 +219,12 @@ main(int argc, char **argv)
                        adios(NULL, "no messages in %s", folder);
 
                /* parse all the message ranges/sequences and set SELECTED */
-               for (msgnum = 0; msgnum < msgs.size; msgnum++)
-                       if (!m_convert(mp, msgs.msgs[msgnum]))
-                               done(1);
+               for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+                       if (!m_convert(mp, msgs.msgs[msgnum])) {
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
+                       }
+               }
                seq_setprev(mp);  /* set the previous-sequence */
 
                if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
@@ -241,7 +244,7 @@ main(int argc, char **argv)
        }
 
        if (!*cts)
-               done(1);
+               exit(1);
 
        userrs = 1;
        SIGNAL(SIGQUIT, quitser);
@@ -282,8 +285,7 @@ main(int argc, char **argv)
                context_save();  /* save the context file  */
        }
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 
@@ -297,6 +299,6 @@ pipeser(int i)
                fflush(stderr);
        }
 
-       done(1);
+       exit(1);
        /* NOTREACHED */
 }
index e79d874..9936261 100644 (file)
@@ -65,7 +65,8 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -74,10 +75,10 @@ main(int argc, char **argv)
                                                "%s addrs... [switches]",
                                                invo_name);
                                print_help(buf, switches, 0);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FROMSW:
                                if (!(from = *argp++) || *from == '-')
@@ -168,7 +169,8 @@ main(int argc, char **argv)
                if (in == -1 || out == -1) {
                        fprintf(stderr, "Letter left at %s.\n",
                                        tmpfil);
-                       done(status ? 1 : 0);
+                       /* sysexits.h exit-status from spost */
+                       exit(status ? 1 : 0);
                }
                cpydata(in, out, tmpfil, "dead.letter");
                close(in);
@@ -176,8 +178,8 @@ main(int argc, char **argv)
                fprintf(stderr, "Letter saved in dead.letter\n");
        }
        unlink(tmpfil);
-       done(status ? 1 : 0);
-       return 0;  /* dead code to satisfy the compiler */
+       /* sysexits.h exit status from spost */
+       exit(status ? 1 : 0);
 }
 
 
@@ -185,6 +187,6 @@ static void
 intrser(int i)
 {
        unlink(tmpfil);
-       done(i != 0 ? 1 : 0);
+       exit(i != 0 ? 1 : 0);
 }
 
index dce2d75..1d95377 100644 (file)
@@ -140,17 +140,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /*sysexits.h EX_USAGE*/
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [profile-components] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case COMPSW:
                                components = 1;
@@ -218,8 +219,7 @@ main(int argc, char **argv)
                }
        }
 
-       done(missed);
-       return 1;
+       return missed;
 }
 
 
index e187f59..f4c26cc 100644 (file)
@@ -136,7 +136,7 @@ pidcheck(int status)
 
        fflush(stdout);
        fflush(stderr);
-       done(1);
+       exit(1);
        return 1;
 }
 
index a8de5cb..67408ed 100644 (file)
@@ -44,17 +44,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1); //sysexits.h EX_TEMPFAIL
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0); //sysexits.h EX_OK
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0); //sysexits.h EX_OK
                        }
                }
                if (*cp == '+' || *cp == '@') {
@@ -73,7 +73,7 @@ main(int argc, char **argv)
        /* If no messages are given, print folder pathname */
        if (!msgs.size) {
                printf("%s\n", maildir);
-               done(0);
+               exit(0); //sysexits.h EX_OK
        }
 
        if (chdir(maildir) == NOTOK)
@@ -108,9 +108,11 @@ main(int argc, char **argv)
        mp->msgflags |= ALLOW_BEYOND;  /* allow the beyond sequence */
 
        /* parse all the message ranges/sequences and set SELECTED */
-       for (i = 0; i < msgs.size; i++)
-               if (!m_convert(mp, msgs.msgs[i]))
-                       done(1);
+       for (i = 0; i < msgs.size; i++) {
+               if (!m_convert(mp, msgs.msgs[i])) {
+                       exit(1); //sysexits.h EX_USAGE
+               }
+       }
 
        seq_setprev(mp);  /* set the previous-sequence */
 
@@ -122,6 +124,5 @@ main(int argc, char **argv)
        seq_save(mp);  /* synchronize message sequences */
        context_save();  /* save the context file */
        folder_free(mp);  /* free folder/message structure */
-       done(0);
-       return 1;
+       return 0;
 }
index 0b49b7e..9bc7ed3 100644 (file)
@@ -75,7 +75,7 @@ void show_all_messages(CT *);
 /* mhfree.c */
 void free_content(CT);
 extern CT *cts;
-void freects_done(int) NORETURN;
+void freects_done();
 
 /*
 ** static prototypes
@@ -98,7 +98,7 @@ main(int argc, char **argv)
        FILE *fp;
        int ontty = 0;
 
-       done=freects_done;
+       atexit(freects_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -122,17 +122,18 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] %s[switches]", invo_name, mode==SHOW ? "[msgs] " : "");
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -284,7 +285,8 @@ main(int argc, char **argv)
                /* parse all the message ranges/sequences and set SELECTED */
                for (msgnum = 0; msgnum < msgs.size; msgnum++)
                        if (!m_convert(mp, msgs.msgs[msgnum]))
-                               done(1);
+                               /* sysexits.h EX_USAGE */
+                               exit(1);
 
                /*
                ** Set the SELECT_UNSEEN bit for all the SELECTED messages,
@@ -318,7 +320,7 @@ main(int argc, char **argv)
        }
 
        if (!*cts)
-               done(1);
+               exit(1);
 
        userrs = 1;
        SIGNAL(SIGQUIT, quitser);
@@ -367,8 +369,7 @@ main(int argc, char **argv)
                context_save();                    /* save the context file */
        }
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 
@@ -382,7 +383,7 @@ pipeser(int i)
                fflush(stderr);
        }
 
-       done(1);
+       exit(1);
        /* NOTREACHED */
 }
 
index f28d867..6a268f2 100644 (file)
@@ -63,7 +63,7 @@ void flush_errors(void);
 /* mhfree.c */
 void free_content(CT);
 extern CT *cts;  /* The list of top-level contents to display */
-void freects_done(int) NORETURN;
+void freects_done();
 
 /*
 ** static prototypes
@@ -129,7 +129,7 @@ main(int argc, char **argv)
        CT ct, *ctp;
        FILE *fp;
 
-       done=freects_done;
+       atexit(freects_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -148,17 +148,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case AUTOSW:
                                autosw++;
@@ -285,7 +285,7 @@ main(int argc, char **argv)
                /* parse all the message ranges/sequences and set SELECTED */
                for (msgnum = 0; msgnum < msgs.size; msgnum++)
                        if (!m_convert(mp, msgs.msgs[msgnum]))
-                               done(1);
+                               exit(1);
                seq_setprev(mp);  /* set the previous-sequence */
 
                if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
@@ -305,7 +305,7 @@ main(int argc, char **argv)
        }
 
        if (!*cts)
-               done(1);
+               exit(1);
 
        userrs = 1;
        SIGNAL(SIGQUIT, quitser);
@@ -346,8 +346,7 @@ main(int argc, char **argv)
                context_save();  /* save the context file  */
        }
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 
@@ -361,7 +360,7 @@ pipeser(int i)
                fflush(stderr);
        }
 
-       done(1);
+       exit(1);
        /* NOTREACHED */
 }
 
index 1c1684f..a1718db 100644 (file)
@@ -75,7 +75,7 @@ void flush_errors(void);
 /* mhfree.c */
 void free_content(CT);
 extern CT *cts;
-void freects_done(int) NORETURN;
+void freects_done();
 
 /*
 ** static prototypes
@@ -95,7 +95,7 @@ main(int argc, char **argv)
        struct msgs *mp = NULL;
        CT ct, *ctp;
 
-       done=freects_done;
+       atexit(freects_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -114,17 +114,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -233,7 +233,7 @@ main(int argc, char **argv)
                /* parse all the message ranges/sequences and set SELECTED */
                for (msgnum = 0; msgnum < msgs.size; msgnum++)
                        if (!m_convert(mp, msgs.msgs[msgnum]))
-                               done(1);
+                               exit(1);
                seq_setprev(mp);  /* set the previous-sequence */
 
                if (!(cts = (CT *) calloc((size_t) (mp->numsel + 1),
@@ -253,7 +253,7 @@ main(int argc, char **argv)
        }
 
        if (!*cts)
-               done(1);
+               exit(1);
 
        userrs = 1;
        SIGNAL(SIGQUIT, quitser);
@@ -294,8 +294,7 @@ main(int argc, char **argv)
                context_save();  /* save the context file  */
        }
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 
@@ -324,6 +323,6 @@ pipeser(int i)
                fflush(stderr);
        }
 
-       done(1);
+       exit(1);
        /* NOTREACHED */
 }
index 1ee95ff..04fb949 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -457,7 +457,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -466,10 +466,10 @@ main(int argc, char **argv)
                                                "%s [switches] [sequences]",
                                                invo_name);
                                print_help(help, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FOLDERSSW:
                                if (!(folders = *argp++) || *folders == '-')
@@ -526,7 +526,7 @@ main(int argc, char **argv)
 
        folder = doit(context_find(curfolder), folders, sequences);
        if (folder == NULL) {
-               done(0);
+               exit(0);
                return 1;
        }
 
@@ -550,6 +550,5 @@ main(int argc, char **argv)
 
        context_save();
 
-       done(0);
-       return 1;
+       return 0;
 }
index 763b6e7..f9d02e8 100644 (file)
@@ -47,17 +47,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
                        }
                }
                if (*cp == '+' || *cp == '@') {
@@ -90,7 +90,7 @@ main(int argc, char **argv)
        /* parse all the message ranges/sequences and set SELECTED */
        for (msgnum = 0; msgnum < msgs.size; msgnum++)
                if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+                       exit(1);
        seq_setprev(mp);  /* set the previous-sequence */
 
        /* copy all the SELECTED messages to stdout */
@@ -113,6 +113,5 @@ main(int argc, char **argv)
        seq_save(mp);
        context_save();
        folder_free(mp);
-       done(0);
-       return 1;
+       return 0;
 }
index 58c5969..6c59add 100644 (file)
@@ -76,7 +76,7 @@ static int pmatches(FILE *, int, long, long);
 
 static int listsw = -1;
 
-static void putzero_done(int) NORETURN;
+static void putzero_done();
 
 int
 main(int argc, char **argv)
@@ -91,7 +91,7 @@ main(int argc, char **argv)
        struct msgs *mp;
        register FILE *fp;
 
-       done=putzero_done;
+       atexit(putzero_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -112,7 +112,7 @@ main(int argc, char **argv)
                        case AMBIGSW:
                                ambigsw(cp, switches);
                                listsw = 0;  /* HACK */
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -120,11 +120,11 @@ main(int argc, char **argv)
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
                                listsw = 0;  /* HACK */
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
                                listsw = 0;  /* HACK */
-                               done(1);
+                               exit(0);
 
                        case CCSW:
                        case DATESW:
@@ -163,7 +163,7 @@ main(int argc, char **argv)
                                        adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
 
                                if (!seq_nameok(cp))
-                                       done(1);
+                                       exit(1);
 
                                seqs[seqp++] = cp;
                                continue;
@@ -223,7 +223,7 @@ main(int argc, char **argv)
        /* parse all the message ranges/sequences and set SELECTED */
        for (msgnum = 0; msgnum < msgs.size; msgnum++)
                if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+                       exit(1);
        seq_setprev(mp);  /* set the previous-sequence */
 
        /*
@@ -238,7 +238,7 @@ main(int argc, char **argv)
                                folder);
 
        if (!pcompile(vec, NULL))
-               done(1);
+               exit(1);
 
        lo = mp->lowsel;
        hi = mp->hghsel;
@@ -289,7 +289,7 @@ main(int argc, char **argv)
        */
        for (seqp = 0; seqs[seqp]; seqp++)
                if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
-                       done(1);
+                       exit(1);
 
        /*
        ** Print total matched if not printing each matched message number.
@@ -302,17 +302,16 @@ main(int argc, char **argv)
        seq_save(mp);  /* synchronize message sequences */
        context_save();  /* save the context file */
        folder_free(mp);  /* free folder/message structure */
-       done(0);
-       return 1;
+       listsw = 0; /* HACK */
+       return 0;
 }
 
 
 static void
-putzero_done(int status)
+putzero_done()
 {
-       if (listsw && status && !isatty(fileno(stdout)))
+       if (listsw && !isatty(fileno(stdout)))
                printf("0\n");
-       exit(status);
 }
 
 
index ef33db9..4d0ce86 100644 (file)
@@ -71,7 +71,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -80,10 +80,10 @@ main(int argc, char **argv)
                                                "%s [switches] file",
                                                invo_name);
                                print_help(buffer, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case PREPSW:
                                prepend++;
@@ -160,7 +160,8 @@ main(int argc, char **argv)
                                if (i == -1) {
 abort:
                                        unlink(tmpfil);
-                                       done(1);
+                                       /* sysexits.h EX_DATAERR */
+                                       exit(1);
                                }
                                if (i || (field[0]!='\n' && field[0]!='\0')) {
                                        fprintf(out, "%s:", name);
@@ -254,8 +255,7 @@ has_no_body:
        unlink(tmpfil);
 
        context_save();  /* save the context file */
-       done(0);
-       return 1;
+       return 0;
 }
 
 
index 2ba6097..d3e4100 100644 (file)
@@ -30,7 +30,7 @@ static char tmpfil[BUFSIZ] = "";
 ** prototypes
 */
 static void rcvdistout(FILE *, char *, char *);
-static void unlink_done(int) NORETURN;
+static void unlink_done();
 
 
 int
@@ -42,7 +42,7 @@ main(int argc, char **argv)
        FILE *fp;
        char *tfile = NULL;
 
-       done=unlink_done;
+       atexit(unlink_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -58,7 +58,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                vec[vecp++] = --cp;
                                continue;
@@ -66,10 +66,10 @@ main(int argc, char **argv)
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] [switches for spost] address ...", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-') {
@@ -103,7 +103,8 @@ main(int argc, char **argv)
        fclose(fp);
 
        if (distout(drft, tmpfil, backup) == NOTOK) {
-               done(1);
+               /* sysexits.h EX_DATAERR */
+               exit(1);
        }
 
        vec[0] = "spost";
@@ -275,7 +276,7 @@ finished: ;
 
 
 static void
-unlink_done(int status)
+unlink_done()
 {
        if (*backup) {
                unlink(backup);
@@ -286,5 +287,4 @@ unlink_done(int status)
        if (*tmpfil) {
                unlink(tmpfil);
        }
-       exit(status ? RCV_MBX : RCV_MOK);
 }
index 79c3450..352f785 100644 (file)
@@ -42,7 +42,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -51,10 +51,10 @@ main(int argc, char **argv)
                                                "%s [switches] file",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
                        }
                }
                if (file)
@@ -66,27 +66,27 @@ main(int argc, char **argv)
        /* copy stdin to stdout, converting rfc822 message to mbox */
        if (!file) {
                if (mbox_copy(fileno(stdout), fileno(stdin)) == NOTOK) {
-                       done(RCV_MBX);
+                       exit(RCV_MBX);
                }
-               done(RCV_MOK);
+               exit(RCV_MOK);
                return 1;
        }
 
        /* open and lock the file */
        if ((md = mbox_open(file, getuid(), getgid(), m_gmprot()))
                        == NOTOK)
-               done(RCV_MBX);
+               exit(RCV_MBX);
 
        /* append the message */
        if (mbox_copy(md, fileno(stdin)) == NOTOK) {
                mbox_close(file, md);
-               done(RCV_MBX);
+               exit(RCV_MBX);
        }
 
        /* close and unlock the file */
        if (mbox_close(file, md) == NOTOK)
-               done(RCV_MBX);
+               exit(RCV_MBX);
 
-       done(RCV_MOK);
+       exit(RCV_MOK);
        return 1;
 }
index bb14ed9..fbddda7 100644 (file)
@@ -44,7 +44,7 @@ static struct swit switches[] = {
 */
 static char *tmpfilenam = NULL;
 
-static void unlink_done(int) NORETURN;
+static void unlink_done();
 
 int
 main(int argc, char **argv)
@@ -58,7 +58,7 @@ main(int argc, char **argv)
        struct msgs *mp;
        struct stat st;
 
-       done=unlink_done;
+       atexit(unlink_done);
 
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
@@ -75,7 +75,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -84,10 +84,10 @@ main(int argc, char **argv)
                                                "%s [+folder] [switches]",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(1);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(1);
 
                        case SEQSW:
                                if (!(cp = *argp++) || *cp == '-')
@@ -186,7 +186,7 @@ main(int argc, char **argv)
        if (st.st_size == 0) {
                unlink(tmpfilenam);
                advise(NULL, "empty file");
-               done(0);
+               exit(0);
        }
 
        /*
@@ -201,7 +201,7 @@ main(int argc, char **argv)
        */
        if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, NULL))
                        == -1)
-               done(1);
+               exit(1);
 
        /*
        ** Add the message to any extra sequences
@@ -209,7 +209,7 @@ main(int argc, char **argv)
        */
        for (seqp = 0; seqs[seqp]; seqp++) {
                if (!seq_addmsg(mp, seqs[seqp], msgnum, publicsw, zerosw))
-                       done(1);
+                       exit(1);
        }
 
        seq_setunseen(mp, 1);  /* add new msgs to unseen sequences */
@@ -220,17 +220,16 @@ main(int argc, char **argv)
        unlink(tmpfilenam);  /* remove temporary file */
        tmpfilenam = NULL;
 
-       done(0);
-       return 1;
+       return 0;
 }
 
 /*
 ** Clean up and exit
 */
 static void
-unlink_done(int status)
+unlink_done()
 {
-       if (tmpfilenam && *tmpfilenam)
+       if (tmpfilenam && *tmpfilenam) {
                unlink(tmpfilenam);
-       exit(status);
+       }
 }
index b07c32d..96f355a 100644 (file)
@@ -73,17 +73,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [msgs] [switches] +folder ...", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case LINKSW:
                                linkf++;
@@ -132,7 +132,8 @@ main(int argc, char **argv)
                opnfolds(folders, foldp);
                for (i = 0; i < filep; i++)
                        if (m_file(files[i], folders, foldp, 0))
-                               done(1);
+                               /* sysexits.h EX_IOERR */
+                               exit(1);
                /* If -nolink, then unlink files */
                if (!linkf) {
                        int i;
@@ -144,7 +145,7 @@ main(int argc, char **argv)
                                        admonish(files[i], "unable to unlink");
                        }
                }
-               done(0);
+               exit(0);
        }
 
        if (!msgs.size)
@@ -167,7 +168,8 @@ main(int argc, char **argv)
        /* parse the message range/sequence/name and set SELECTED */
        for (msgnum = 0; msgnum < msgs.size; msgnum++)
                if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
        seq_setprev(mp);  /* set the previous-sequence */
 
        /* create folder structures for each destination folder */
@@ -183,7 +185,8 @@ main(int argc, char **argv)
                if (is_selected(mp, msgnum)) {
                        cp = getcpy(m_name(msgnum));
                        if (m_file(cp, folders, foldp, !linkf))
-                               done(1);
+                               /* sysexits.h EX_IOERR */
+                               exit(1);
                        free(cp);
                }
        }
@@ -208,8 +211,7 @@ main(int argc, char **argv)
        context_replace(curfolder, folder);
        context_save();
        folder_free(mp);
-       done(0);
-       return 1;
+       return 0;
 }
 
 
@@ -228,7 +230,7 @@ opnfolds(struct st_fold *folders, int nfolders)
                chdir(toabsdir("+"));
                strncpy(nmaildir, toabsdir(fp->f_name), sizeof(nmaildir));
 
-               create_folder(nmaildir, 0, done);
+               create_folder(nmaildir, 0, exit);
 
                if (chdir(nmaildir) == NOTOK)
                        adios(nmaildir, "unable to change directory to");
index e5fbc0f..42bcfdc 100644 (file)
@@ -157,17 +157,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s: [+folder] [msg] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(0);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case GROUPSW:
                                groupreply++;
@@ -315,7 +315,8 @@ main(int argc, char **argv)
 
                /* parse the message range/sequence/name and set SELECTED */
                if (!m_convert(mp, msg))
-                       done(1);
+                       /* sysexits.h EX_USAGE */
+                       exit(1);
                seq_setprev(mp);  /* set the previous-sequence */
 
                if (mp->numsel > 1)
@@ -344,9 +345,9 @@ main(int argc, char **argv)
        fclose(in);
 
        if (buildsw)
-               done(0);
+               exit(0);
        what_now(ed, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL, cwd);
-       done(1);
+       /* sysexits.h EX_SOFTWARE */
        return 1;
 }
 
@@ -356,7 +357,7 @@ docc(char *cp, int ccflag)
        switch (smatch(cp, ccswitches)) {
        case AMBIGSW:
                ambigsw(cp, ccswitches);
-               done(1);
+               exit(1);
        case UNKWNSW:
                adios(NULL, "-%scc %s unknown", ccflag ? "" : "no", cp);
 
@@ -771,7 +772,8 @@ replfilter(FILE *in, FILE *out, char *filter)
 
        default:
                if (pidXwait(pid, "mhl"))
-                       done(1);
+                       /* sysexits.h EX_SOFTWARE */
+                       exit(1);
                fseek(out, 0L, SEEK_END);
                break;
        }
index a0c68a3..164ec77 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -48,17 +48,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case INTRSW:
                                interactive = 1;
@@ -105,7 +105,7 @@ main(int argc, char **argv)
        if (interactive) {
                cp = concat("Remove folder \"", folder, "\"? ", NULL);
                if (!getanswer(cp))
-                       done(0);
+                       exit(0);
                free(cp);
        }
 
@@ -118,8 +118,7 @@ main(int argc, char **argv)
                }
        }
        context_save();  /* save the context file */
-       done(0);
-       return 1;
+       return 0;
 }
 
 static int
index 33ae9da..03d4568 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -46,17 +46,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case UNLINKSW:
                                unlink_msgs++;
@@ -103,7 +103,8 @@ main(int argc, char **argv)
        */
        for (msgnum = 0; msgnum < msgs.size; msgnum++) {
                if (!m_convert(mp, msgs.msgs[msgnum])) {
-                       done(1);
+                       /* sysexits EX_USAGE */
+                       exit(1);
                }
        }
 
@@ -116,8 +117,7 @@ main(int argc, char **argv)
                seq_setprev(mp);
                seq_save(mp);
                folder_free(mp);
-               done(0);
-               return 1;
+               return 0;
        }
 
        /* remove by refiling. */
@@ -139,7 +139,6 @@ main(int argc, char **argv)
                vec[vecp++] = msgs.msgs[msgnum];
        }
        vec[vecp] = NULL;
-       done(execprog(*vec, vec));
 
-       return 1;  /* just in case ... */
+       return execprog(*vec, vec);
 }
index ba90e40..29aea65 100644 (file)
@@ -58,17 +58,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -130,7 +130,7 @@ main(int argc, char **argv)
                                break;
                }
                fclose(in);
-               done(0);
+               exit(0);
        }
 
        /*
@@ -157,7 +157,7 @@ main(int argc, char **argv)
        /* parse all the message ranges/sequences and set SELECTED */
        for (msgnum = 0; msgnum < msgs.size; msgnum++)
                if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+                       exit(1);
        seq_setprev(mp);  /* set the Previous-Sequence */
 
        context_replace(curfolder, folder);  /* update current folder */
@@ -222,6 +222,5 @@ main(int argc, char **argv)
 
        folder_free(mp);  /* free folder/message structure */
 
-       done(0);
-       return 1;
+       return 0;
 }
index 13ae761..234dfb2 100644 (file)
@@ -11,7 +11,6 @@
 #include <errno.h>
 #include <signal.h>
 #include <h/signals.h>
-#include <setjmp.h>
 #include <h/mime.h>
 #include <h/tws.h>
 #include <h/utils.h>
@@ -28,8 +27,6 @@ char *altmsg = NULL;
 char *annotext = NULL;
 char *distfile = NULL;
 
-static jmp_buf env;
-
 /* name of temp file for body content */
 static char body_file_name[MAXPATHLEN + 1];
 /* name of mhbuild composition temporary file */
@@ -44,7 +41,6 @@ static FILE *composition_file;  /* composition file pointer */
 ** static prototypes
 */
 static int sendsbr(char **, int, char *, struct stat *);
-static void armed_done(int) NORETURN;
 static void anno(struct stat *);
 static int sendaux(char **, int, char *, struct stat *);
 static int attach(char *);
@@ -99,7 +95,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown\n", cp);
 
@@ -108,10 +104,10 @@ main(int argc, char **argv)
                                                "%s [file] [switches]",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case DEBUGSW:
                                debugsw++;
@@ -150,7 +146,7 @@ main(int argc, char **argv)
                /* parse all the msgranges/sequences and set SELECTED */
                for (msgnum = 0; msgnum < nmsgs; msgnum++) {
                        if (!m_convert(mp, msgs[msgnum])) {
-                               done(1);
+                               exit(1);
                        }
                }
                seq_setprev(mp);
@@ -217,7 +213,7 @@ main(int argc, char **argv)
        for (n = 0; n < nfiles; n++) {
                switch (sendsbr(vec, vecp, files[n], &st)) {
                case DONE:
-                       done(++status);
+                       exit(++status);
                case NOTOK:
                        status++;  /* fall */
                case OK:
@@ -226,8 +222,7 @@ main(int argc, char **argv)
        }
 
        context_save();
-       done(status);
-       return 1;
+       return status;
 }
 
 
@@ -288,27 +283,22 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st)
                break;
        }
 
-       done=armed_done;
-       if (setjmp(env) == 0) {
-               status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
-               if (status == OK) {
-                       /* move original draft to +trash folder */
-                       /* temporary close stdin, for refile not to ask */
-                       dupfd = dup(0);
-                       close(0);
-                       if (execprogl("refile", "refile", "-file",
-                                       original_draft, "+trash",
-                                       (char *)NULL) != 0) {
-                               advise(NULL, "unable to trash the draft");
-                       }
-                       dup2(dupfd, 0);
-                       close(dupfd);
+       if ((status = sendaux(vec, vecp, drft, st)) == OK) {
+               /* move original draft to +trash folder */
+               /* temporary close stdin, for refile not to ask */
+               dupfd = dup(0);
+               close(0);
+               if (execprogl("refile", "refile", "-file",
+                               original_draft, "+trash",
+                               (char *)NULL) != 0) {
+                       advise(NULL, "unable to trash the draft");
                }
+               dup2(dupfd, 0);
+               close(dupfd);
        } else {
                status = DONE;
        }
 
-       done=exit;
        if (distfile) {
                unlink(distfile);
        }
@@ -624,15 +614,15 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
 
        vec[vecp++] = drft;
        if (distfile && distout(drft, distfile, backup) == NOTOK) {
-               done(1);
+               return DONE;
        }
        vec[vecp] = NULL;
 
        switch (child_id = fork()) {
        case -1:
                /* oops -- fork error */
-               adios("fork", "unable to");
-               break;  /* NOT REACHED */
+               advise("fork", "unable to");
+               return DONE;
 
        case 0:
                /* child process -- send it */
@@ -663,7 +653,7 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
        }
 
 
-       return status;
+       return status ? NOTOK : status;
 }
 
 
@@ -745,12 +735,3 @@ strexit(int status)
                return "message not delivered to anyone";
        }
 }
-
-
-static void
-armed_done(int status)
-{
-       longjmp(env, status ? status : NOTOK);
-
-       exit(status);
-}
index 837f038..ff8df8c 100644 (file)
@@ -186,17 +186,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [switches] [address info sender]", invo_name);
                                print_help(buf, switches, 0);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case ADDRSW:
                                if (!(addr = *argp++)) {
@@ -397,8 +397,7 @@ main(int argc, char **argv)
        /* deliver the message */
        status = localmail(fd, mdlvr);
 
-       done(status != -1 ? RCV_MOK : RCV_MBX);
-       return 1;
+       return (status != -1 ? RCV_MOK : RCV_MBX);
 }
 
 
index ed09181..0230495 100644 (file)
@@ -90,17 +90,17 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
                                snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case DATESW:
                                if (datesw)
@@ -179,7 +179,7 @@ main(int argc, char **argv)
        /* parse all the message ranges/sequences and set SELECTED */
        for (msgnum = 0; msgnum < msgs.size; msgnum++)
                if (!m_convert(mp, msgs.msgs[msgnum]))
-                       done(1);
+                       exit(1);
        seq_setprev(mp);  /* set the previous sequence */
 
        if ((nmsgs = read_hdrs(mp, datesw)) <= 0)
@@ -274,8 +274,7 @@ main(int argc, char **argv)
        seq_save(mp);  /* synchronize message sequences */
        context_save();  /* save the context file */
        folder_free(mp);  /* free folder/message structure */
-       done(0);
-       return 1;
+       return 0;
 }
 
 static int
index b65e4c4..bfa8f4b 100644 (file)
@@ -149,7 +149,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -158,10 +158,10 @@ main(int argc, char **argv)
                                                "%s [switches] file",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case DEBUGSW:
                                debug++;
@@ -262,7 +262,7 @@ main(int argc, char **argv)
 
        if (debug) {
                /* stop here */
-               done(0);
+               exit(0);
        }
 
        fclose(out);
index 4f8d956..2969397 100644 (file)
@@ -110,7 +110,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -119,10 +119,10 @@ main(int argc, char **argv)
                                                "%s [switches] [file]",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case EDITRSW:
                                if (!(ed = *argp++) || *ed == '-')
@@ -161,14 +161,15 @@ main(int argc, char **argv)
                                unlink(drft);
                        }
                        advise(NULL, "Try again.");
-                       done(1);
+                       /* sysexits.h EX_SOFTWARE */
+                       exit(1);
                }
        }
 
        snprintf(prompt, sizeof(prompt), myprompt, invo_name);
        for (;;) {
                if (!(argp = getans(prompt, aleqs))) {
-                       done(1);
+                       exit(1);
                }
                switch (smatch(*argp, aleqs)) {
                case DISPSW:
@@ -199,12 +200,12 @@ main(int argc, char **argv)
                        if (stat(drft, &st) != NOTOK) {
                                advise(NULL, "draft left on %s", drft);
                        }
-                       done(1);
+                       exit(1);
 
                case DELETESW:
                        /* Delete draft and exit */
                        removefile(drft);
-                       done(1);
+                       exit(1);
 
                case SENDSW:
                        /* Send draft */
@@ -214,7 +215,7 @@ main(int argc, char **argv)
                case REFILEOPT:
                        /* Refile the draft */
                        if (refile(++argp, drft) == 0) {
-                               done(0);
+                               exit(0);
                        }
                        break;
 
index 57fddc8..fb77ab3 100644 (file)
@@ -85,7 +85,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
 
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
@@ -95,10 +95,10 @@ main(int argc, char **argv)
                                                "%s [switches] file ...",
                                                invo_name);
                                print_help(buf, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case TOCCSW:
                                toccsw = 1;