projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Run the tests in defined (i.e. sorted) order
[mmh]
/
uip
/
ap.c
diff --git
a/uip/ap.c
b/uip/ap.c
index
3bb2bf0
..
8156517
100644
(file)
--- a/
uip/ap.c
+++ b/
uip/ap.c
@@
-9,6
+9,9
@@
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
+#include <h/utils.h>
+#include <locale.h>
+#include <sysexits.h>
#define NADDRS 100
#define NADDRS 100
@@
-20,7
+23,7
@@
static struct swit switches[] = {
#define NORMSW 1
{ "normalize", 0 },
#define NNORMSW 2
#define NORMSW 1
{ "normalize", 0 },
#define NNORMSW 2
- { "nonormalize", 0 },
+ { "nonormalize", 2 },
#define VERSIONSW 3
{ "Version", 0 },
#define HELPSW 4
#define VERSIONSW 3
{ "Version", 0 },
#define HELPSW 4
@@
-47,9
+50,7
@@
main(int argc, char **argv)
char buf[BUFSIZ], **argp;
char **arguments, *addrs[NADDRS];
char buf[BUFSIZ], **argp;
char **arguments, *addrs[NADDRS];
-#ifdef LOCALE
setlocale(LC_ALL, "");
setlocale(LC_ALL, "");
-#endif
invo_name = mhbasename(argv[0]);
/* read user profile/context */
invo_name = mhbasename(argv[0]);
/* read user profile/context */
@@
-63,22
+64,22
@@
main(int argc, char **argv)
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(1);
+ exit(EX_USAGE);
case UNKWNSW:
case UNKWNSW:
- adios(NULL, "-%s unknown", cp);
+ adios(EX_USAGE, NULL, "-%s unknown", cp);
case HELPSW:
snprintf(buf, sizeof(buf), "%s [switches] addrs ...", invo_name);
print_help(buf, switches, 1);
case HELPSW:
snprintf(buf, sizeof(buf), "%s [switches] addrs ...", invo_name);
print_help(buf, switches, 1);
- done(1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
case VERSIONSW:
print_version(invo_name);
case VERSIONSW:
print_version(invo_name);
- done(1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
case FORMSW:
if (!(form = *argp++) || *form == '-')
case FORMSW:
if (!(form = *argp++) || *form == '-')
- adios(NULL, "missing argument to %s", argp[-2]);
+ adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]);
continue;
case NORMSW:
continue;
case NORMSW:
@@
-90,14
+91,14
@@
main(int argc, char **argv)
}
}
if (addrp > NADDRS)
}
}
if (addrp > NADDRS)
- adios(NULL, "more than %d addresses", NADDRS);
+ adios(EX_USAGE, NULL, "more than %d addresses", NADDRS);
else
addrs[addrp++] = cp;
}
addrs[addrp] = NULL;
if (addrp == 0)
else
addrs[addrp++] = cp;
}
addrs[addrp] = NULL;
if (addrp == 0)
- adios(NULL, "usage: %s [switches] addrs ...", invo_name);
+ adios(EX_USAGE, NULL, "usage: %s [switches] addrs ...", invo_name);
/* get new format string */
fmtstr = new_fs(form, FORMAT);
/* get new format string */
fmtstr = new_fs(form, FORMAT);
@@
-114,8
+115,7
@@
main(int argc, char **argv)
for (addrp = 0; addrs[addrp]; addrp++)
status += process(addrs[addrp], normalize);
for (addrp = 0; addrs[addrp]; addrp++)
status += process(addrs[addrp], normalize);
- done(status);
- return 1;
+ return status;
}
struct pqpair {
}
struct pqpair {
@@
-129,18
+129,18
@@
static int
process(char *arg, int norm)
{
int status = 0;
process(char *arg, int norm)
{
int status = 0;
- register char *cp;
+ char *cp;
char buffer[BUFSIZ + 1], error[BUFSIZ];
char buffer[BUFSIZ + 1], error[BUFSIZ];
- register struct comp *cptr;
- register struct pqpair *p, *q;
+ struct comp *cptr;
+ struct pqpair *p, *q;
struct pqpair pq;
struct pqpair pq;
- register struct mailname *mp;
+ struct mailname *mp;
(q = &pq)->pq_next = NULL;
while ((cp = getname(arg))) {
if ((p = (struct pqpair *)
(q = &pq)->pq_next = NULL;
while ((cp = getname(arg))) {
if ((p = (struct pqpair *)
- calloc((size_t) 1, sizeof(*p))) == NULL)
- adios(NULL, "unable to allocate pqpair memory");
+ mh_xcalloc((size_t) 1, sizeof(*p))) == NULL)
+ adios(EX_OSERR, NULL, "unable to allocate pqpair memory");
if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
p->pq_text = getcpy(cp);
p->pq_error = getcpy(error);
if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
p->pq_text = getcpy(cp);
p->pq_error = getcpy(error);