* complete copyright information.
*/
-#include <h/mh.h>
-#include <h/addrsbr.h>
-#include <h/fmt_scan.h>
-#include <h/scansbr.h>
-#include <h/tws.h>
-#include <h/utils.h>
+#include "h/mh.h"
+#include "sbr/error.h"
+#include "h/addrsbr.h"
+#include "h/fmt_scan.h"
+#include "h/scansbr.h"
+#include "h/tws.h"
+#include "h/utils.h"
+#include "sbr/terminal.h"
static struct format *fmt;
static struct comp *datecomp; /* pntr to "date" comp */
scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
int unseen, char *folder, long size, int noisy, charstring_t *scanl)
{
+ static bool deja_vu;
+ static int tty_width;
int i, compnum, encrypted, state;
char *cp, *tmpbuf, *startbody, **nxtbuf;
char *saved_c_text = NULL;
scanl used to be a global. */
if (! *scanl) {
if (width == -1) {
- /* Default: width of the terminal, but at least WIDTH/2. */
- if ((width = sc_width ()) < WIDTH/2)
- width = WIDTH/2;
+ if (!deja_vu) {
+ deja_vu = true;
+ tty_width = sc_width();
+ }
+
+ width = max(tty_width, WIDTH / 2);
} else if (width == 0) {
/* Unlimited width. */
width = INT_MAX;
goto finished;
default:
- adios (NULL, "getfld() returned %d", state);
+ die("getfld() returned %d", state);
}
}
if (scnout && (ferror(scnout) || fclose (scnout) == EOF))
DIEWRERR();
- return (state != FILEEOF ? SCNERR : encrypted ? SCNENC : SCNMSG);
+ return state != FILEEOF ? SCNERR : encrypted ? SCNENC : SCNMSG;
}
/* The following two functions allow access to the global gstate above. */
void
-scan_finished(void) {
+scan_finished(void)
+{
m_getfld_state_destroy (&gstate);
}
void
-scan_detect_mbox_style (FILE *f) {
+scan_detect_mbox_style (FILE *f)
+{
m_unknown (&gstate, f);
}