2 * Copyright (c) 1991 Keith Muller.
4 * The Regents of the University of California. All rights reserved.
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * $FreeBSD: src/usr.bin/pr/pr.c,v 1.9.2.4 2002/04/15 17:16:57 jmallett Exp $
41 static char copyright[] =
42 "@(#) Copyright (c) 1993\n\
43 The Regents of the University of California. All rights reserved.\n";
47 static char sccsid[] = "@(#)pr.c 8.2 (Berkeley) 4/16/94";
50 #include <sys/types.h>
68 * pr: a printing and pagination filter. If multiple input files
69 * are specified, each is read, formatted, and written to standard
70 * output. By default, input is separated into 66-line pages, each
71 * with a header that includes the page number, date, time and the
74 * Complies with posix P1003.2/D11
80 int pgnm; /* starting page number */
81 int clcnt; /* number of columns */
82 int colwd; /* column data width - multiple columns */
83 int across; /* mult col flag; write across page */
84 int dspace; /* double space flag */
85 char inchar; /* expand input char */
86 int ingap; /* expand input gap */
87 int pausefst; /* Pause before first page */
88 int pauseall; /* Pause before each page */
89 int formfeed; /* use formfeed as trailer */
90 char *header; /* header name instead of file name */
91 char ochar; /* contract output char */
92 int ogap; /* contract output gap */
93 int lines; /* number of lines per page */
94 int merge; /* merge multiple files in output */
95 char nmchar; /* line numbering append char */
96 int nmwd; /* width of line number field */
97 int offst; /* number of page offset spaces */
98 int nodiag; /* do not report file open errors */
99 char schar; /* text column separation character */
100 int sflag; /* -s option for multiple columns */
101 int nohead; /* do not write head and trailer */
102 int pgwd; /* page width with multiple col output */
103 char *timefrmt; /* time conversion string */
108 FILE *err; /* error message file pointer */
109 int addone; /* page length is odd with double space */
110 int errcnt; /* error count on file processing */
111 char digs[] = "0123456789"; /* page number translation map */
120 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
121 (void)signal(SIGINT, terminate);
122 ret_val = setup(argc, argv);
125 * select the output format based on options
128 ret_val = mulfile(argc, argv);
130 ret_val = onecol(argc, argv);
132 ret_val = horzcol(argc, argv);
134 ret_val = vertcol(argc, argv);
138 if (errcnt || ret_val)
144 * Check if we should pause and write an alert character and wait for a
145 * carriage return on /dev/tty.
154 if ((pauseall || (pausefst && pagecnt == 1)) &&
155 isatty(STDOUT_FILENO)) {
156 if ((ttyfp = fopen("/dev/tty", "r")) != NULL) {
157 (void)putc('\a', stderr);
158 while ((pch = getc(ttyfp)) != '\n' && pch != EOF)
166 * onecol: print files with only one column of output.
167 * Line length is unlimited.
174 register int cnt = -1;
177 register int linecnt;
200 * allocate line buffer
202 if ((obuf = malloc((unsigned)(LBUF + off)*sizeof(char))) == NULL) {
207 * allocate header buffer
209 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
214 ohbuf = hbuf + offst;
218 nbuf[--num] = nmchar;
220 (void)memset(obuf, (int)' ', offst);
221 (void)memset(hbuf, (int)' ', offst);
227 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
230 * skip to specified page
232 if (inskip(inf, pgnm, lines))
254 while (linecnt < lines) {
258 if ((cnt = inln(inf,lbuf,LBUF,&cps,0,&mor)) < 0)
260 if (!linecnt && !nohead &&
261 prhead(hbuf, fname, pagecnt))
269 addnum(nbuf, num, ++lncnt);
270 if (otln(obuf,cnt+off, &ips, &ops, mor))
272 } else if (otln(lbuf, cnt, &ips, &ops, mor))
276 * if line bigger than buffer, get more
284 * whole line rcvd. reset tab proc. state
293 * fill to end of page
295 if (linecnt && prtail(lines-linecnt-lrgln, lrgln))
299 * On EOF go to next file
314 * vertcol: print files with more than one column of output down a page
322 register char **lstdat;
325 register int cnt = -1;
334 int mxlen = pgwd + offst + 1;
335 int mclcnt = clcnt - 1;
352 * allocate page buffer
354 if ((buf = malloc((unsigned)lines*mxlen*sizeof(char))) == NULL) {
360 * allocate page header
362 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
366 ohbuf = hbuf + offst;
368 (void)memset(hbuf, (int)' ', offst);
371 * col pointers when no headers
375 (struct vcol *)malloc((unsigned)mvc*sizeof(struct vcol))) == NULL) {
381 * pointer into page where last data per line is located
383 if ((lstdat = (char **)malloc((unsigned)lines*sizeof(char *))) == NULL){
389 * fast index lookups to locate start of lines
391 if ((indy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
395 if ((lindy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
406 * initialize buffer lookup indexes and offset area
408 for (j = 0; j < lines; ++j) {
409 lindy[j] = j * mxlen;
410 indy[j] = lindy[j] + offst;
412 ptbf = buf + lindy[j];
413 (void)memset(ptbf, (int)' ', offst);
416 ptbf = buf + indy[j];
423 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
426 * skip to requested page
428 if (inskip(inf, pgnm, lines))
445 for (i = 0; i < clcnt; ++i) {
448 * if last column, do not pad
459 * is this first column
462 ptbf = buf + indy[j];
472 addnum(ptbf, nmwd, ++lncnt);
480 cnt = inln(inf,ptbf,colwd,&cps,1,&mor);
487 * pad all but last column on page
491 * pad to end of column
495 else if ((pln = col-cnt) > 0) {
502 * remember last char in line
513 * when -t (no header) is specified the spec requires
514 * the min number of lines. The last page may not have
515 * balanced length columns. To fix this we must reorder
516 * the columns. This is a very slow technique so it is
517 * only used under limited conditions. Without -t, the
518 * balancing of text columns is unspecified. To NOT
519 * balance the last page, add the global variable
520 * nohead to the if statement below e.g.
522 * if ((cnt < 0) && nohead && cvc ......
527 * check to see if last page needs to be reordered
529 if ((cnt < 0) && cvc && ((mvc-cvc) >= clcnt)){
537 if (!nohead && prhead(hbuf, fname, pagecnt))
539 for (i = 0; i < pln; ++i) {
542 if (offst&& otln(buf,offst,&ips,&ops,1))
546 for (j = 0; j < clcnt; ++j) {
548 * determine column length
561 cnt = vc[tvc].cnt + 1;
566 if (otln(vc[tvc].pt, cnt, &ips,
576 if (otln(buf, 0, &ips, &ops, 0))
582 if (prtail((lines - pln), 0))
585 * done with output, go to next file
591 * determine how many lines to output
601 if (pln && !nohead && prhead(hbuf, fname, pagecnt))
607 for (i = 0; i < pln; ++i) {
608 ptbf = buf + lindy[i];
609 if ((j = lstdat[i] - ptbf) <= offst)
611 if (otln(ptbf, j, &ips, &ops, 0))
618 if (pln && prtail((lines - pln), 0))
622 * if EOF go to next file
637 * horzcol: print files with more than one column of output across a page
646 register int cnt = -1;
647 register char *lstdat;
648 register int col = colwd + 1;
663 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
671 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
675 ohbuf = hbuf + offst;
677 (void)memset(buf, (int)' ', offst);
678 (void)memset(hbuf, (int)' ', offst);
684 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
686 if (inskip(inf, pgnm, lines))
702 for (i = 0; i < lines; ++i) {
712 * add number to column
714 addnum(ptbf, nmwd, ++lncnt);
721 if ((cnt = inln(inf,ptbf,colwd,&cps,1,
728 * if last line skip padding
734 * pad to end of column
738 else if ((pln = col - cnt) > 0) {
739 (void)memset(ptbf,(int)' ',pln);
745 * determine line length
747 if ((j = lstdat - buf) <= offst)
750 prhead(hbuf, fname, pagecnt))
755 if (otln(buf, j, &ips, &ops, 0))
762 if (i && prtail(lines-i, 0))
766 * if EOF go to next file
781 * mulfile: print files with more than one column of output and
782 * more than one file concurrently
793 register char *lstdat;
811 * array of FILE *, one for each operand
813 if ((fbuf = (FILE **)malloc((unsigned)clcnt*sizeof(FILE *))) == NULL) {
821 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
825 ohbuf = hbuf + offst;
828 * do not know how many columns yet. The number of operands provide an
829 * upper bound on the number of columns. We use the number of files
830 * we can open successfully to set the number of columns. The operation
831 * of the merge operation (-m) in relation to unsuccesful file opens
832 * is unspecified by posix.
836 if ((fbuf[j] = nxtfile(argc, argv, &fname, ohbuf, 1)) == NULL)
838 if (pgnm && (inskip(fbuf[j], pgnm, lines)))
850 * calculate page boundries based on open file count
854 colwd = (pgwd - clcnt - nmwd)/clcnt;
855 pgwd = ((colwd + 1) * clcnt) - nmwd - 2;
857 colwd = (pgwd + 1 - clcnt)/clcnt;
858 pgwd = ((colwd + 1) * clcnt) - 1;
862 "pr: page width too small for %d columns\n", clcnt);
871 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
876 (void)memset(buf, (int)' ', offst);
877 (void)memset(hbuf, (int)' ', offst);
886 * continue to loop while any file still has data
894 for (i = 0; i < lines; ++i) {
899 * add line number to line
901 addnum(ptbf, nmwd, ++lncnt);
911 for (j = 0; j < clcnt; ++j) {
912 if (fbuf[j] == NULL) {
917 } else if ((cnt = inln(fbuf[j], ptbf, colwd,
918 &cps, 1, &mor)) < 0) {
922 if (fbuf[j] != stdin)
923 (void)fclose(fbuf[j]);
937 * if last ACTIVE column, done with line
943 * pad to end of column
947 } else if ((pln = col - cnt) > 0) {
948 (void)memset(ptbf, (int)' ', pln);
954 * calculate data in line
956 if ((j = lstdat - buf) <= offst)
959 if (!i && !nohead && prhead(hbuf, fname, pagecnt))
965 if (otln(buf, j, &ips, &ops, 0))
969 * if no more active files, done
980 if (i && prtail(lines-i, 0))
990 * inln(): input a line of data (unlimited length lines supported)
991 * Input is optionally expanded to spaces
996 * cps: column positon 1st char in buffer (large line support)
997 * trnc: throw away data more than lim up to \n
998 * mor: set if more data in line (not truncated)
1001 inln(inf, buf, lim, cps, trnc, mor)
1010 register int gap = ingap;
1011 register int ch = EOF;
1012 register char *ptbuf;
1013 register int chk = (int)inchar;
1019 * expanding input option
1021 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
1023 * is this the input "tab" char
1027 * expand to number of spaces
1029 col = (ptbuf - buf) + *cps;
1030 col = gap - (col % gap);
1033 * if more than this line, push back
1035 if ((col > lim) && (ungetc(ch, inf) == EOF))
1041 while ((--col >= 0) && (--lim >= 0))
1053 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
1069 * entire line processed
1077 * line was larger than limit
1081 * throw away rest of line
1083 while ((ch = getc(inf)) != EOF) {
1091 * save column offset if not truncated
1101 * otln(): output a line of data. (Supports unlimited length lines)
1102 * output is optionally contracted to tabs
1104 * buf: output buffer with data
1105 * cnt: number of chars of valid data in buf
1106 * svips: buffer input column position (for large lines)
1107 * svops: buffer output column position (for large lines)
1108 * mor: output line not complete in this buf; more data to come.
1109 * 1 is more, 0 is complete, -1 is no \n's
1112 otln(buf, cnt, svips, svops, mor)
1119 register int ops; /* last col output */
1120 register int ips; /* last col in buf examined */
1121 register int gap = ogap;
1123 register char *endbuf;
1127 * contracting on output
1132 while (buf < endbuf) {
1134 * count number of spaces and ochar in buffer
1143 * simulate ochar processing
1145 if (*buf == ochar) {
1146 ips += gap - (ips % gap);
1152 * got a non space char; contract out spaces
1156 * use as many ochar as will fit
1158 if ((tbps = ops + gap - (ops % gap)) > ips)
1160 if (putchar(ochar) == EOF) {
1169 * finish off with spaces
1171 if (putchar(' ') == EOF) {
1179 * output non space char
1181 if (putchar(*buf++) == EOF) {
1191 * if incomplete line, save position counts
1201 * use as many ochar as will fit
1203 if ((tbps = ops + gap - (ops % gap)) > ips)
1205 if (putchar(ochar) == EOF) {
1213 * finish off with spaces
1215 if (putchar(' ') == EOF) {
1225 * output is not contracted
1227 if (cnt && (fwrite(buf, sizeof(char), cnt, stdout) <= 0)) {
1236 * process line end and double space as required
1238 if ((putchar('\n') == EOF) || (dspace && (putchar('\n') == EOF))) {
1246 * inskip(): skip over pgcnt pages with lncnt lines per page
1247 * file is closed at EOF (if not stdin).
1249 * inf FILE * to read from
1250 * pgcnt number of pages to skip
1251 * lncnt number of lines per page
1254 inskip(inf, pgcnt, lncnt)
1262 while(--pgcnt > 0) {
1264 while ((c = getc(inf)) != EOF) {
1265 if ((c == '\n') && (--cnt == 0))
1278 * nxtfile: returns a FILE * to next file in arg list and sets the
1279 * time field for this file (or current date).
1281 * buf array to store proper date for the header.
1282 * dt if set skips the date processing (used with -m)
1285 nxtfile(argc, argv, fname, buf, dt)
1296 struct tm *timeptr = NULL;
1297 struct stat statbuf;
1298 static int twice = -1;
1301 if (eoptind >= argc) {
1303 * no file listed; default, use standard input
1315 if (gettimeofday(&tv, &tz) < 0) {
1317 (void)fprintf(err, "pr: cannot get time of day, %s\n",
1323 timeptr = localtime(&tv_sec);
1325 for (; eoptind < argc; ++eoptind) {
1326 if (strcmp(argv[eoptind], "-") == 0) {
1328 * process a "-" for filename
1337 if (nohead || (dt && twice))
1339 if (gettimeofday(&tv, &tz) < 0) {
1342 "pr: cannot get time of day, %s\n",
1347 timeptr = localtime(&tv_sec);
1350 * normal file processing
1352 if ((inf = fopen(argv[eoptind], "r")) == NULL) {
1356 (void)fprintf(err, "pr: Cannot open %s, %s\n",
1357 argv[eoptind], strerror(errno));
1365 *fname = argv[eoptind];
1367 if (nohead || (dt && twice))
1371 if (gettimeofday(&tv, &tz) < 0) {
1374 "pr: cannot get time of day, %s\n",
1379 timeptr = localtime(&tv_sec);
1381 if (fstat(fileno(inf), &statbuf) < 0) {
1385 "pr: Cannot stat %s, %s\n",
1386 argv[eoptind], strerror(errno));
1389 timeptr = localtime(&(statbuf.st_mtime));
1398 * set up time field used in header
1400 if (strftime(buf, HDBUF, timefrmt, timeptr) <= 0) {
1404 (void)fputs("pr: time conversion failed\n", err);
1411 * addnum(): adds the line number to the column
1412 * Truncates from the front or pads with spaces as required.
1413 * Numbers are right justified.
1415 * buf buffer to store the number
1416 * wdth width of buffer to fill
1419 * NOTE: numbers occupy part of the column. The posix
1420 * spec does not specify if -i processing should or should not
1421 * occur on number padding. The spec does say it occupies
1422 * part of the column. The usage of addnum currently treats
1423 * numbers as part of the column so spaces may be replaced.
1426 addnum(buf, wdth, line)
1431 register char *pt = buf + wdth;
1434 *--pt = digs[line % 10];
1436 } while (line && (pt > buf));
1439 * pad with space as required
1446 * prhead(): prints the top of page header
1448 * buf buffer with time field (and offset)
1449 * cnt number of chars in buf
1450 * fname fname field for header
1451 * pagcnt page number
1454 prhead(buf, fname, pagcnt)
1462 if ((putchar('\n') == EOF) || (putchar('\n') == EOF)) {
1467 * posix is not clear if the header is subject to line length
1468 * restrictions. The specification for header line format
1469 * in the spec clearly does not limit length. No pr currently
1470 * restricts header length. However if we need to truncate in
1471 * an reasonable way, adjust the length of the printf by
1472 * changing HDFMT to allow a length max as an arguement printf.
1473 * buf (which contains the offset spaces and time field could
1476 * note only the offset (if any) is processed for tab expansion
1478 if (offst && otln(buf, offst, &ips, &ops, -1))
1480 (void)printf(HDFMT,buf+offst, fname, pagcnt);
1485 * prtail(): pad page with empty lines (if required) and print page trailer
1488 * cnt number of lines of padding needed
1489 * incomp was a '\n' missing from last line output
1498 * only pad with no headers when incomplete last line
1501 ((dspace && (putchar('\n') == EOF)) ||
1502 (putchar('\n') == EOF))) {
1507 * but honor the formfeed request
1510 if (putchar('\f') == EOF) {
1518 * if double space output two \n
1524 * if an odd number of lines per page, add an extra \n
1533 if ((incomp && (putchar('\n') == EOF)) ||
1534 (putchar('\f') == EOF)) {
1541 while (--cnt >= 0) {
1542 if (putchar('\n') == EOF) {
1551 * terminate(): when a SIGINT is recvd
1554 terminate(which_sig)
1563 * flsh_errs(): output saved up diagnostic messages after all normal
1564 * processing has completed
1571 (void)fflush(stdout);
1576 while (fgets(buf, BUFSIZ, err) != NULL)
1577 (void)fputs(buf, stderr);
1583 (void)fputs("pr: memory allocation failed\n", err);
1589 (void)fprintf(err, "pr: write failure, %s\n", strerror(errno));
1596 "usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n",
1599 " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err);
1601 " [-L locale] [-s[ch]] [-w width] [-] [file ...]\n", err);
1605 * setup: Validate command args, initialize and perform sanity
1611 register char **argv;
1621 if (isatty(fileno(stdout))) {
1623 * defer diagnostics until processing is done
1625 if ((err = tmpfile()) == NULL) {
1627 (void)fputs("Cannot defer diagnostic messages\n",stderr);
1632 while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) {
1635 if ((pgnm = atoi(eoptarg)) < 1) {
1636 (void)fputs("pr: +page number must be 1 or more\n",
1642 if ((clcnt = atoi(eoptarg)) < 1) {
1643 (void)fputs("pr: -columns must be 1 or more\n",err);
1657 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1658 inchar = *eoptarg++;
1661 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1662 if ((ingap = atoi(eoptarg)) < 0) {
1664 "pr: -e gap must be 0 or more\n", err);
1669 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1671 "pr: invalid value for -e %s\n", eoptarg);
1687 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1691 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1692 if ((ogap = atoi(eoptarg)) < 0) {
1694 "pr: -i gap must be 0 or more\n", err);
1699 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1701 "pr: invalid value for -i %s\n", eoptarg);
1710 if (!isdigit((unsigned char)*eoptarg) || ((lines=atoi(eoptarg)) < 1)) {
1712 "pr: Number of lines must be 1 or more\n",err);
1720 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1721 nmchar = *eoptarg++;
1724 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1725 if ((nmwd = atoi(eoptarg)) < 1) {
1727 "pr: -n width must be 1 or more\n",err);
1730 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1732 "pr: invalid value for -n %s\n", eoptarg);
1738 if (!isdigit((unsigned char)*eoptarg) || ((offst = atoi(eoptarg))< 1)){
1739 (void)fputs("pr: -o offset must be 1 or more\n",
1752 if (eoptarg == NULL)
1756 if (*eoptarg != '\0') {
1758 "pr: invalid value for -s %s\n",
1769 if (!isdigit((unsigned char)*eoptarg) || ((pgwd = atoi(eoptarg)) < 1)){
1771 "pr: -w width must be 1 or more \n",err);
1782 * default and sanity checks
1786 if ((clcnt = argc - eoptind) <= 1) {
1795 (void)fputs("pr: -a flag requires multiple columns\n",
1800 (void)fputs("pr: -m cannot be used with -a\n", err);
1810 if (cflag || merge) {
1823 "pr: -m cannot be used with multiple columns\n", err);
1827 colwd = (pgwd + 1 - (clcnt * (nmwd + 2)))/clcnt;
1828 pgwd = ((colwd + nmwd + 2) * clcnt) - 1;
1830 colwd = (pgwd + 1 - clcnt)/clcnt;
1831 pgwd = ((colwd + 1) * clcnt) - 1;
1835 "pr: page width is too small for %d columns\n",clcnt);
1843 * make sure long enough for headers. if not disable
1845 if (lines <= HEADLEN + TAILLEN)
1848 lines -= HEADLEN + TAILLEN;
1851 * adjust for double space on odd length pages
1863 (void) setlocale(LC_TIME, (Lflag != NULL) ? Lflag : "");
1865 d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
1866 timefrmt = d_first ? TIMEFMTD : TIMEFMTM;