X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/b56c88e2847c582f9b18ae5bbda44f033cd49c42..2fc70e8bf64ead869fce76abb74f04bf1af94923:/uip/scan.c diff --git a/uip/scan.c b/uip/scan.c index 20668691..d9d8ca9d 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -1,6 +1,4 @@ - -/* - * scan.c -- display a one-line "scan" listing of folder or messages +/* scan.c -- display a one-line "scan" listing of folder or messages * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -13,6 +11,7 @@ #include #include #include +#include "../sbr/m_maildir.h" #define SCAN_SWITCHES \ X("clear", 0, CLRSW) \ @@ -41,7 +40,7 @@ int main (int argc, char **argv) { int clearflag = 0, hdrflag = 0, ontty; - int width = 0, revflag = 0; + int width = -1, revflag = 0; int i, state, msgnum; ivector_t seqnum = ivector_create (0); int unseen, num_unseen_seq = 0; @@ -54,7 +53,7 @@ main (int argc, char **argv) if (nmh_init(argv[0], 1)) { return 1; } - mts_init (invo_name); + mts_init (); arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -127,10 +126,9 @@ main (int argc, char **argv) if (*cp == '+' || *cp == '@') { if (folder) adios (NULL, "only one folder at a time!"); - else - folder = pluspath (cp); + folder = pluspath (cp); } else - app_msgarg(&msgs, cp); + app_msgarg(&msgs, cp); } if (!context_find ("path")) @@ -165,8 +163,11 @@ main (int argc, char **argv) scan_detect_mbox_style (in); for (msgnum = 1; ; ++msgnum) { + charstring_t scanl = NULL; + state = scan (in, msgnum, -1, nfs, width, 0, 0, - hdrflag ? file : NULL, 0L, 1); + hdrflag ? file : NULL, 0L, 1, &scanl); + charstring_free (scanl); if (state != SCNMSG && state != SCNENC) break; } @@ -213,14 +214,13 @@ main (int argc, char **argv) if ((cp = context_find (usequence)) && *cp) { char **ap, *dp; - dp = getcpy(cp); + dp = mh_xstrdup(cp); ap = brkstring (dp, " ", "\n"); for (i = 0; ap && *ap; i++, ap++) ivector_push_back (seqnum, seq_getnum (mp, *ap)); num_unseen_seq = i; - if (dp) - free(dp); + mh_xfree(dp); } ontty = isatty (fileno (stdout)); @@ -229,6 +229,8 @@ main (int argc, char **argv) (revflag ? msgnum >= mp->lowsel : msgnum <= mp->hghsel); msgnum += (revflag ? -1 : 1)) { if (is_selected(mp, msgnum)) { + charstring_t scanl = NULL; + if ((in = fopen (cp = m_name (msgnum), "r")) == NULL) { admonish (cp, "unable to open message"); continue; @@ -252,7 +254,7 @@ main (int argc, char **argv) switch (state = scan (in, msgnum, 0, nfs, width, msgnum == mp->curmsg, unseen, - folder, 0L, 1)) { + folder, 0L, 1, &scanl)) { case SCNMSG: case SCNENC: case SCNERR: @@ -262,9 +264,10 @@ main (int argc, char **argv) adios (NULL, "scan() botch (%d)", state); case SCNEOF: - advise (NULL, "message %d: empty", msgnum); + inform("message %d: empty", msgnum); break; } + charstring_free (scanl); scan_finished (); hdrflag = 0; fclose (in);