2 ** mhl.c -- the nmh message listing program
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
10 #include <h/signals.h>
11 #include <h/addrsbr.h>
12 #include <h/fmt_scan.h>
23 ** for a component containing addresses, ADDRFMT, if COMPRESS is also
24 ** set, then addresses get split wrong (not at the spaces between commas).
25 ** To fix this correctly, putstr() should know about "atomic" strings that
26 ** must NOT be broken across lines. That's too difficult for right now
27 ** (it turns out that there are a number of degernate cases), so in
28 ** oneline(), instead of
30 ** (*onelp == '\n' && !onelp[1])
32 ** being a terminating condition,
34 ** (*onelp == '\n' && (!onelp[1] || (flags & ADDRFMT)))
36 ** is used instead. This cuts the line prematurely, and gives us a much
37 ** better chance of getting things right.
46 static struct swit switches[] = {
48 { "form formfile", 0 },
50 { "width columns", 0 },
64 char *version=VERSION;
66 #define NOCOMPONENT 0x000001 /* don't show component name */
67 #define UPPERCASE 0x000002 /* display in all upper case */
68 #define CENTER 0x000004 /* center line */
69 #define CLEARTEXT 0x000008 /* cleartext */
70 #define EXTRA 0x000010 /* an "extra" component */
71 #define HDROUTPUT 0x000020 /* already output */
72 #define LEFTADJUST 0x000040 /* left justify multiple lines */
73 #define COMPRESS 0x000080 /* compress text */
74 #define ADDRFMT 0x000100 /* contains addresses */
75 #define DATEFMT 0x000200 /* contains dates */
76 #define FORMAT 0x000400 /* parse address/date/RFC-2047 field */
77 #define INIT 0x000800 /* initialize component */
78 #define SPLIT 0x001000 /* split headers (don't concatenate) */
79 #define NONEWLINE 0x002000 /* don't write trailing newline */
80 #define RTRIM 0x004000 /* trim trailing whitespace */
81 #define RAW 0x008000 /* print the raw input */
82 #define LBITS "\020\01NOCOMPONENT\02UPPERCASE\03CENTER\04CLEARTEXT\05EXTRA\06HDROUTPUT\07LEFTADJUST\010COMPRESS\011ADDRFMT\012DATEFMT\013FORMAT\014INIT\015SPLIT\016NONEWLINE\017RTRIM\020RAW"
83 #define GFLAGS (NOCOMPONENT | UPPERCASE | CENTER | LEFTADJUST | COMPRESS | SPLIT)
86 char *c_name; /* component name */
87 char *c_text; /* component text */
88 char *c_ovtxt; /* text overflow indicator */
89 char *c_fstr; /* iff FORMAT */
90 struct format *c_fmt; /* .. */
91 int c_offset; /* left margin indentation */
92 int c_ovoff; /* overflow indentation */
93 int c_width; /* width of field */
94 int c_cwidth; /* width of component */
99 static struct mcomp *msghd = NULL;
100 static struct mcomp *msgtl = NULL;
101 static struct mcomp *fmthd = NULL;
102 static struct mcomp *fmttl = NULL;
104 static struct mcomp global = {
105 NULL, NULL, NULL, NULL, NULL, 0, -1, 80, -1, 0, NULL
108 static struct mcomp holder = {
109 NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, NOCOMPONENT, NULL
117 static struct pair pairs[] = {
120 { "Sender", ADDRFMT },
121 { "Reply-To", ADDRFMT },
125 { "Resent-Date", DATEFMT },
126 { "Resent-From", ADDRFMT },
127 { "Resent-Sender", ADDRFMT },
128 { "Resent-Reply-To", ADDRFMT },
129 { "Resent-To", ADDRFMT },
130 { "Resent-Cc", ADDRFMT },
131 { "Resent-Bcc", ADDRFMT },
141 static struct triple triples[] = {
142 { "nocomponent", NOCOMPONENT, 0 },
143 { "uppercase", UPPERCASE, RAW },
144 { "nouppercase", 0, UPPERCASE },
145 { "center", CENTER, RAW },
146 { "nocenter", 0, CENTER },
147 { "leftadjust", LEFTADJUST, RAW },
148 { "noleftadjust", 0, LEFTADJUST },
149 { "compress", COMPRESS, RAW },
150 { "nocompress", 0, COMPRESS },
151 { "split", SPLIT, 0 },
152 { "nosplit", 0, SPLIT },
153 { "rtrim", RTRIM, RAW },
154 { "nortrim", 0, RTRIM },
155 { "raw", RAW|SPLIT|NOCOMPONENT|NONEWLINE, UPPERCASE|CENTER|LEFTADJUST|COMPRESS|DATEFMT|ADDRFMT },
156 { "addrfield", ADDRFMT, DATEFMT|RAW },
157 { "datefield", DATEFMT, ADDRFMT|RAW },
158 { "newline", 0, NONEWLINE|RAW },
159 { "nonewline", NONEWLINE, 0 },
164 static int dobody = 1;
165 static int forwflg = 0;
166 static int forwall = 0;
168 static int exitstat = 0;
169 static int mhldebug = 0;
171 static unsigned int column;
176 static unsigned int wid;
180 static unsigned char *onelp;
184 static int num_ignores = 0;
185 static char *ignores[MAXARGS];
187 volatile sig_atomic_t eflag = 0;
190 ** Redefine a couple of functions.
191 ** These are undefined later in the code.
197 static void mhl_format(char *, int);
198 static int evalvar(struct mcomp *);
199 static int ptoi(char *, int *);
200 static int ptos(char *, char **);
201 static char *parse(void);
202 static void process(char *, int, int);
203 static void mhlfile(FILE *, char *, int, int);
204 static int mcomp_flags(char *);
205 static char *mcomp_add(long, char *, char *);
206 static void mcomp_format(struct mcomp *, struct mcomp *);
207 static struct mcomp *add_queue(struct mcomp **, struct mcomp **,
208 char *, char *, int);
209 static void free_queue(struct mcomp **, struct mcomp **);
210 static void putcomp(struct mcomp *, struct mcomp *, int);
211 static char *oneline(char *, long);
212 static void putstr(char *);
213 static void putch(char);
214 static void intrser(int);
216 int sc_width(void); /* from termsbr.c */
220 main(int argc, char **argv)
222 int i, width = 0, vecp = 0;
223 char *cp, *form = NULL;
224 char buf[BUFSIZ], *files[MAXARGS];
225 char **argp, **arguments;
227 setlocale(LC_ALL, "");
228 invo_name = mhbasename(argv[0]);
230 /* read user profile/context */
233 arguments = getarguments(invo_name, argc, argv, 1);
236 if ((cp = getenv("MHLDEBUG")) && *cp)
239 while ((cp = *argp++)) {
241 switch (smatch(++cp, switches)) {
243 ambigsw(cp, switches);
246 adios(EX_USAGE, NULL, "-%s unknown\n", cp);
249 snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
250 print_help(buf, switches, 1);
251 exit(argc == 2 ? EX_OK : EX_USAGE);
253 print_version(invo_name);
254 exit(argc == 2 ? EX_OK : EX_USAGE);
257 if (!(form = *argp++) || *form == '-')
258 adios(EX_USAGE, NULL, "missing argument to %s",
263 if (!(cp = *argp++) || *cp == '-')
264 adios(EX_USAGE, NULL, "missing argument to %s",
266 if ((width = atoi(cp)) < 1)
267 adios(EX_USAGE, NULL, "bad argument %s %s",
272 forwall++; /* fall */
285 mhl_format(form ? form : mhlformat, width);
288 process(NULL, 1, vecp = 1);
290 for (i = 0; i < vecp; i++)
291 process(files[i], i + 1, vecp);
295 printf("\n------- End of Forwarded Message%s\n\n",
296 vecp > 1 ? "s" : "");
300 if (ferror(stdout)) {
301 adios(EX_IOERR, "output", "error writing");
309 mhl_format(char *file, int width)
313 char *ap, buffer[BUFSIZ], name[NAMESZ];
317 static dev_t dev = 0;
318 static ino_t ino = 0;
319 static time_t mtime = 0;
322 if (stat(etcpath(file), &st) != NOTOK
323 && mtime == st.st_mtime
328 free_queue(&fmthd, &fmttl);
331 if ((fp = fopen(etcpath(file), "r")) == NULL)
332 adios(EX_IOERR, file, "unable to open format file");
334 if (fstat(fileno(fp), &st) != NOTOK) {
340 global.c_ovtxt = global.c_fstr = NULL;
344 if ((i = sc_width()) > 5)
346 global.c_cwidth = -1;
350 while (vfgets(fp, &ap) == OK) {
355 if ((cp = strchr(bp, '\n')))
359 c1 = add_queue(&fmthd, &fmttl, NULL, bp + 1,
365 strncpy(name, parse(), sizeof(name));
371 ** Split this list of fields to ignore, and copy
372 ** it to the end of the current "ignores" list.
374 if (!mh_strcasecmp(name, "ignores")) {
378 /* split the fields */
379 tmparray = brkstring(mh_xstrdup(++parptr), ",",
382 ** copy pointers to split fields
385 while (tmparray[n] && num_ignores<MAXARGS-1) {
386 ignores[num_ignores++] = tmparray[n++];
388 ignores[num_ignores] = NULL;
393 if (evalvar(&global))
394 adios(EX_CONFIG, NULL, "format file syntax error: %s", bp);
401 c1 = add_queue(&fmthd, &fmttl, name, NULL, INIT);
402 while (*parptr == ':' || *parptr == ',') {
405 adios(EX_CONFIG, NULL, "format file syntax error: %s", bp);
407 if (!c1->c_fstr && global.c_fstr) {
408 if ((c1->c_flags & DATEFMT) &&
409 (global.c_flags & DATEFMT)) {
410 c1->c_fstr = mh_xstrdup(global.c_fstr);
411 } else if ((c1->c_flags & ADDRFMT) &&
412 (global.c_flags & ADDRFMT)) {
413 c1->c_fstr = mh_xstrdup(global.c_fstr);
419 adios(EX_CONFIG, NULL, "format file syntax error: %s", bp);
425 for (c1 = fmthd; c1; c1 = c1->c_next) {
426 fprintf(stderr, "c1: name=\"%s\" text=\"%s\" ovtxt=\"%s\"\n", c1->c_name, c1->c_text, c1->c_ovtxt);
427 fprintf(stderr, "\tfstr=0x%x fmt=0x%x\n", (unsigned int)(unsigned long) c1->c_fstr, (unsigned int)(unsigned long) c1->c_fmt);
428 fprintf(stderr, "\toffset=%d ovoff=%d width=%d cwidth=%d\n", c1->c_offset, c1->c_ovoff, c1->c_width, c1->c_cwidth);
429 fprintf (stderr, "\tflags=%s\n", snprintb(buffer, sizeof(buffer), (unsigned) c1->c_flags, LBITS));
435 global.c_width = width;
436 if (global.c_width < 5)
437 global.c_width = 10000;
442 evalvar(struct mcomp *c1)
444 char *cp, name[NAMESZ];
449 strncpy(name, parse(), sizeof(name));
451 if (!mh_strcasecmp(name, "component")) {
452 if (ptos(name, &c1->c_text))
454 c1->c_flags &= ~NOCOMPONENT;
458 if (!mh_strcasecmp(name, "overflowtext"))
459 return ptos(name, &c1->c_ovtxt);
461 if (!mh_strcasecmp(name, "formatfield")) {
466 cp = concat("=", cp, NULL);
467 fmtstr = new_fs(cp, NULL);
469 c1->c_fstr = mh_xstrdup(fmtstr);
470 c1->c_flags |= FORMAT;
474 if (!mh_strcasecmp(name, "decode")) {
477 fmtstr = new_fs("=%(decode{text})", NULL);
478 c1->c_fstr = mh_xstrdup(fmtstr);
479 c1->c_flags |= FORMAT;
483 if (!mh_strcasecmp(name, "offset"))
484 return ptoi(name, &c1->c_offset);
485 if (!mh_strcasecmp(name, "overflowoffset"))
486 return ptoi(name, &c1->c_ovoff);
487 if (!mh_strcasecmp(name, "width"))
488 return ptoi(name, &c1->c_width);
489 if (!mh_strcasecmp(name, "compwidth"))
490 return ptoi(name, &c1->c_cwidth);
492 for (ap = triples; ap->t_name; ap++)
493 if (!mh_strcasecmp(ap->t_name, name)) {
494 c1->c_flags |= ap->t_on;
495 c1->c_flags &= ~ap->t_off;
504 ptoi(char *name, int *i)
508 if (*parptr++ != '=' || !*(cp = parse())) {
509 advise(NULL, "missing argument to variable %s", name);
519 ptos(char *name, char **s)
523 if (*parptr++ != '=') {
524 advise(NULL, "missing argument to variable %s", name);
528 if (*parptr != '"') {
529 for (cp = parptr; *parptr && *parptr != ':' && *parptr != ',';
533 for (cp = ++parptr; *parptr && *parptr != '"'; parptr++)
534 if (*parptr == QUOTE)
541 if ((*parptr = c) == '"')
552 static char result[NAMESZ];
554 for (cp = result; *parptr && (cp - result < NAMESZ); parptr++) {
573 process(char *fname, int ofilen, int ofilec)
579 fp = fopen(fname, "r");
581 advise(fname, "unable to open");
589 SIGNAL(SIGINT, intrser);
590 mhlfile(fp, fname, ofilen, ofilec);
592 SIGNAL(SIGINT, SIG_IGN);
596 mh_free0(&(holder.c_text));
598 free_queue(&msghd, &msgtl);
599 for (c1 = fmthd; c1; c1 = c1->c_next)
600 c1->c_flags &= ~HDROUTPUT;
604 simplematch(char *pattern, char *b)
606 char *match = strrchr(pattern, '*');
610 /* check if pattern ends with a * and is not escaped witch a \ */
611 if (!match || match[1] || (match > pattern && match[-1] == '\\')) {
612 if (!match || match[1]) {
613 return mh_strcasecmp(pattern, b) == 0;
617 ret = mh_strcasecmp(pattern, b)==0;
623 repl = b[match-pattern];
624 b[match-pattern] = '\0';
626 ret = (mh_strcasecmp(pattern, b) == 0);
627 b[match-pattern] = repl;
633 mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
636 struct field f = {{0}};
637 struct mcomp *c1, *c2, *c3;
643 printf(" Forwarded Message%s", ofilec > 1 ? "s" : "");
645 printf(" Message %d", ofilen);
648 } else if (ofilec > 1) {
652 printf(">>> %s\n\n", mname);
655 for (state = FLD2; !eflag; ) {
656 switch (state = m_getfld2(state, &f, fp)) {
658 for (ip = ignores; *ip; ip++)
659 if (simplematch(*ip, f.name)) {
666 for (c2 = fmthd; c2; c2 = c2->c_next)
667 if (mh_strcasecmp(c2->c_name, f.name)==0) {
671 if (!((c3 = c2 ? c2 : &global)->c_flags & SPLIT))
672 for (c1 = msghd; c1; c1 = c1->c_next)
673 if (mh_strcasecmp(c1->c_name,
675 c1->c_text = mcomp_add(c1->c_flags, f.value, c1->c_text);
679 c1 = add_queue(&msghd, &msgtl, f.name, f.value, 0);
682 c1->c_flags |= EXTRA;
689 for (c1 = fmthd; c1; c1 = c1->c_next) {
690 if (c1->c_flags & CLEARTEXT) {
691 putcomp(c1, c1, ONECOMP);
694 if (mh_strcasecmp(c1->c_name, "messagename")==0) {
695 holder.c_text = concat("(Message ",
697 putcomp(c1, &holder, ONECOMP);
698 mh_free0(&(holder.c_text));
701 if (mh_strcasecmp(c1->c_name, "extras")==0) {
702 for (c2 = msghd; c2; c2 = c2->c_next) {
703 if (c2->c_flags & EXTRA) {
704 putcomp(c1, c2, TWOCOMP);
709 if (dobody && mh_strcasecmp(c1->c_name, "body")==0) {
710 holder.c_text = mh_xstrdup(f.value);
711 while (state == BODY2) {
712 putcomp(c1, &holder, BODYCOMP);
713 state = m_getfld2(state, &f, fp);
715 holder.c_text = mh_xstrdup(f.value);
717 mh_free0(&(holder.c_text));
720 for (c2 = msghd; c2; c2 = c2->c_next) {
721 if (mh_strcasecmp(c2->c_name,
723 putcomp(c1, c2, ONECOMP);
724 if (!(c1->c_flags & SPLIT)) {
735 advise(NULL, "format error in message %s", mname);
740 adios(EX_SOFTWARE, NULL, "getfld() returned %d", state);
747 mcomp_flags(char *name)
751 for (ap = pairs; ap->p_name; ap++)
752 if (!mh_strcasecmp(ap->p_name, name))
753 return (ap->p_flags);
760 mcomp_add(long flags, char *s1, char *s2)
764 if (!(flags & ADDRFMT))
767 if (s2 && *(dp = s2 + strlen(s2) - 1) == '\n')
770 return add(s1, add(",\n", s2));
777 struct pqpair *pq_next;
782 mcomp_format(struct mcomp *c1, struct mcomp *c2)
786 char buffer[BUFSIZ], error[BUFSIZ];
788 struct pqpair *p, *q;
797 dat[3] = sizeof(buffer) - 1;
799 fmt_compile(c1->c_fstr, &c1->c_fmt);
801 if (!(c1->c_flags & ADDRFMT)) {
802 FINDCOMP(cptr, "text");
805 if ((cp = strrchr(ap, '\n'))) /* drop ending newline */
809 fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
810 /* Don't need to append a newline, dctime() already did */
811 c2->c_text = mh_xstrdup(buffer);
817 (q = &pq)->pq_next = NULL;
818 while ((cp = getname(ap))) {
819 p = mh_xcalloc(1, sizeof(*p));
821 if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
822 p->pq_text = mh_xstrdup(cp);
823 p->pq_error = mh_xstrdup(error);
825 p->pq_text = mh_xstrdup(mp->m_text);
828 q = (q->pq_next = p);
831 for (p = pq.pq_next; p; p = q) {
832 FINDCOMP(cptr, "text");
834 cptr->c_text = p->pq_text;
835 FINDCOMP(cptr, "error");
837 cptr->c_text = p->pq_error;
839 fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
842 c2->c_text = add(",\n", c2->c_text);
843 if (*(cp = buffer + strlen(buffer) - 1) == '\n')
845 c2->c_text = add(buffer, c2->c_text);
848 mh_free0(&(p->pq_text));
850 mh_free0(&(p->pq_error));
855 c2->c_text = add("\n", c2->c_text);
860 static struct mcomp *
861 add_queue(struct mcomp **head, struct mcomp **tail, char *name,
862 char *text, int flags)
866 c1 = mh_xcalloc(1, sizeof(*c1));
868 c1->c_flags = flags & ~INIT;
869 if ((c1->c_name = name ? mh_xstrdup(name) : NULL))
870 c1->c_flags |= mcomp_flags(c1->c_name);
871 c1->c_text = text ? mh_xstrdup(text) : NULL;
874 c1->c_ovtxt = mh_xstrdup(global.c_ovtxt);
875 c1->c_offset = global.c_offset;
876 c1->c_ovoff = global. c_ovoff;
878 c1->c_cwidth = global.c_cwidth;
879 c1->c_flags |= global.c_flags & GFLAGS;
884 (*tail)->c_next = c1;
892 free_queue(struct mcomp **head, struct mcomp **tail)
894 struct mcomp *c1, *c2;
896 for (c1 = *head; c1; c1 = c2) {
899 mh_free0(&(c1->c_name));
901 mh_free0(&(c1->c_text));
903 mh_free0(&(c1->c_ovtxt));
905 mh_free0(&(c1->c_fstr));
907 mh_free0(&(c1->c_fmt));
911 *head = *tail = NULL;
915 putcomp(struct mcomp *c1, struct mcomp *c2, int flag)
919 char trimmed_prefix[BUFSIZ];
921 strncpy(trimmed_prefix, c1->c_text ? c1->c_text : c1->c_name, sizeof(trimmed_prefix) - 1);
922 rtrim(trimmed_prefix);
925 wid = c1->c_width ? c1->c_width : global.c_width;
926 ovoff = (c1->c_ovoff >= 0 ? c1->c_ovoff : global.c_ovoff)
928 if ((ovtxt = c1->c_ovtxt ? c1->c_ovtxt : global.c_ovtxt) == NULL)
930 if (wid < ovoff + strlen(ovtxt) + 5)
931 adios(EX_SOFTWARE, NULL, "component: %s width(%d) too small for overflow(%d)", c1->c_name, wid, ovoff + strlen(ovtxt) + 5);
934 if (c1->c_flags & CLEARTEXT) {
935 putstr((c1->c_flags & RTRIM) ? rtrim(c1->c_text) : c1->c_text);
940 if (c1->c_flags & RAW) {
943 printf("%s:%s", c1->c_name, c1->c_text);
946 printf("%s:%s", c2->c_name, c2->c_text);
949 fputs(c2->c_text, stdout);
952 adios(EX_SOFTWARE, NULL, "BUG: putcomp() is called with a unknown flag");
957 if (c1->c_fstr && (c1->c_flags & (ADDRFMT | DATEFMT | FORMAT)))
958 mcomp_format(c1, c2);
960 if (c1->c_flags & CENTER) {
961 count = (c1->c_width ? c1->c_width : global.c_width)
962 - c1->c_offset - strlen(c2->c_text);
963 if (!(c1->c_flags & HDROUTPUT) && !(c1->c_flags & NOCOMPONENT))
964 count -= strlen(c1->c_text ? c1->c_text : c1->c_name)
966 lm = c1->c_offset + (count / 2);
972 if (!(c1->c_flags & HDROUTPUT) && !(c1->c_flags & NOCOMPONENT)) {
973 if (c1->c_flags & UPPERCASE) /* uppercase component also */
974 for (cp = (c1->c_text ? c1->c_text : c1->c_name); *cp; cp++)
977 if (*c2->c_text && *c2->c_text != '\n' && *c2->c_text != '\r') {
978 putstr(c1->c_text ? c1->c_text : c1->c_name);
980 putstr(trimmed_prefix);
982 if (flag != BODYCOMP) {
984 if (!(c1->c_flags & SPLIT))
985 c1->c_flags |= HDROUTPUT;
988 if ((count = c1->c_cwidth -
989 strlen(c1->c_text ? c1->c_text : c1->c_name) - 2) > 0)
993 c1->c_flags |= HDROUTPUT; /* for BODYCOMP */
996 if (flag == TWOCOMP && !(c2->c_flags & HDROUTPUT)
997 && !(c2->c_flags & NOCOMPONENT)) {
998 if (c1->c_flags & UPPERCASE)
999 for (cp = c2->c_name; *cp; cp++)
1004 if (!(c1->c_flags & SPLIT))
1005 c2->c_flags |= HDROUTPUT;
1008 if ((count = c1->c_cwidth - strlen(c2->c_name) - 2) > 0)
1012 if (c1->c_flags & UPPERCASE)
1013 for (cp = c2->c_text; *cp; cp++)
1019 if (flag == TWOCOMP)
1020 count = (c1->c_cwidth >= 0) ? c1->c_cwidth :
1021 (int)strlen(c2->c_name) + 2;
1023 count = (c1->c_cwidth >= 0) ? (size_t)c1->c_cwidth :
1025 c1->c_text : c1->c_name) + 2;
1027 count += c1->c_offset;
1029 if ((cp = oneline(c2->c_text, c1->c_flags))) {
1030 putstr((c1->c_flags & RTRIM) ? rtrim(cp) : cp);
1034 while ((cp = oneline(c2->c_text, c1->c_flags))) {
1036 if (flag == BODYCOMP && !(c1->c_flags & NOCOMPONENT)) {
1038 putstr(c1->c_text ? c1->c_text : c1->c_name);
1040 putstr(trimmed_prefix);
1044 putstr((c1->c_flags & RTRIM) ? rtrim(cp) : cp);
1049 if (flag == BODYCOMP && term == '\n')
1050 c1->c_flags &= ~HDROUTPUT; /* Buffer ended on a newline */
1054 oneline(char *stuff, long flags)
1062 return (onelp = NULL);
1066 if (flags & COMPRESS) {
1067 for (spc = 1, cp = ret; *onelp; onelp++)
1068 if (isspace(*onelp)) {
1069 if (*onelp == '\n' &&
1071 (flags & ADDRFMT))) {
1086 while (*onelp && *onelp != '\n')
1088 if (*onelp == '\n') {
1092 if (flags & LEFTADJUST)
1093 while (*ret == ' ' || *ret == '\t')
1096 if (*onelp == 0 && term == '\n' && (flags & NONEWLINE))
1103 putstr(char *string)
1105 if (!column && lm > 0) {
1141 ** If we are forwarding this message, and the first
1142 ** column contains a dash, then add a dash and a space.
1144 if (column == 0 && forwflg && ch == '-') {
1153 if (column >= wid) {
1157 putstr(ovtxt ? ovtxt : "");