#define NDATES 100
#define WIDTH 78
-#define WBUFSIZ BUFSIZ
#define FORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
int
main (int argc, char **argv)
{
- int datep = 0, width = 0, status = 0;
+ int datep = 0, width = -1, status = 0;
char *cp, *form = NULL, *format = NULL, *nfs;
char buf[BUFSIZ], **argp, **arguments;
char *dates[NDATES];
/* get new format string */
nfs = new_fs (form, format, FORMAT);
- if (width == 0) {
- if ((width = sc_width ()) < WIDTH / 2)
+ if (width == -1) {
+ if ((width = sc_width ()) < WIDTH / 2) {
+ /* Default: width of the terminal, but at least WIDTH/2. */
width = WIDTH / 2;
+ }
width -= 2;
+ } else if (width == 0) {
+ /* Unlimited width. */
+ width = INT_MAX;
}
- if (width > WBUFSIZ)
- width = WBUFSIZ;
fmt_compile (nfs, &fmt, 1);
dat[0] = 0;
process (char *date, int length)
{
int status = 0;
- charstring_t scanl = charstring_create (length);
+ charstring_t scanl =
+ charstring_create (length < NMH_BUFSIZ ? length : NMH_BUFSIZ);
register struct comp *cptr;
cptr = fmt_findcomp ("text");