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 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * $FreeBSD: src/usr.bin/pr/pr.c,v 1.9.2.4 2002/04/15 17:16:57 jmallett Exp $
34 * $DragonFly: src/usr.bin/pr/pr.c,v 1.4 2008/10/16 01:52:32 swildner Exp $
36 * @(#) Copyright (c) 1993 The Regents of the University of California. All rights reserved.
37 * @(#)pr.c 8.2 (Berkeley) 4/16/94
40 #include <sys/types.h>
58 * pr: a printing and pagination filter. If multiple input files
59 * are specified, each is read, formatted, and written to standard
60 * output. By default, input is separated into 66-line pages, each
61 * with a header that includes the page number, date, time and the
64 * Complies with posix P1003.2/D11
70 int pgnm; /* starting page number */
71 int clcnt; /* number of columns */
72 int colwd; /* column data width - multiple columns */
73 int across; /* mult col flag; write across page */
74 int dspace; /* double space flag */
75 char inchar; /* expand input char */
76 int ingap; /* expand input gap */
77 int pausefst; /* Pause before first page */
78 int pauseall; /* Pause before each page */
79 int formfeed; /* use formfeed as trailer */
80 char *header; /* header name instead of file name */
81 char ochar; /* contract output char */
82 int ogap; /* contract output gap */
83 int lines; /* number of lines per page */
84 int merge; /* merge multiple files in output */
85 char nmchar; /* line numbering append char */
86 int nmwd; /* width of line number field */
87 int offst; /* number of page offset spaces */
88 int nodiag; /* do not report file open errors */
89 char schar; /* text column separation character */
90 int sflag; /* -s option for multiple columns */
91 int nohead; /* do not write head and trailer */
92 int pgwd; /* page width with multiple col output */
93 char *timefrmt; /* time conversion string */
98 FILE *err; /* error message file pointer */
99 int addone; /* page length is odd with double space */
100 int errcnt; /* error count on file processing */
101 char digs[] = "0123456789"; /* page number translation map */
104 main(int argc, char **argv)
108 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
109 (void)signal(SIGINT, terminate);
110 ret_val = setup(argc, argv);
113 * select the output format based on options
116 ret_val = mulfile(argc, argv);
118 ret_val = onecol(argc, argv);
120 ret_val = horzcol(argc, argv);
122 ret_val = vertcol(argc, argv);
126 if (errcnt || ret_val)
132 * Check if we should pause and write an alert character and wait for a
133 * carriage return on /dev/tty.
136 ttypause(int pagecnt)
141 if ((pauseall || (pausefst && pagecnt == 1)) &&
142 isatty(STDOUT_FILENO)) {
143 if ((ttyfp = fopen("/dev/tty", "r")) != NULL) {
144 (void)putc('\a', stderr);
145 while ((pch = getc(ttyfp)) != '\n' && pch != EOF)
153 * onecol: print files with only one column of output.
154 * Line length is unlimited.
157 onecol(int argc, char **argv)
185 * allocate line buffer
187 if ((obuf = malloc((unsigned)(LBUF + off)*sizeof(char))) == NULL) {
192 * allocate header buffer
194 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
199 ohbuf = hbuf + offst;
203 nbuf[--num] = nmchar;
205 (void)memset(obuf, (int)' ', offst);
206 (void)memset(hbuf, (int)' ', offst);
212 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
215 * skip to specified page
217 if (inskip(inf, pgnm, lines))
239 while (linecnt < lines) {
243 if ((cnt = inln(inf,lbuf,LBUF,&cps,0,&mor)) < 0)
245 if (!linecnt && !nohead &&
246 prhead(hbuf, fname, pagecnt))
254 addnum(nbuf, num, ++lncnt);
255 if (otln(obuf,cnt+off, &ips, &ops, mor))
257 } else if (otln(lbuf, cnt, &ips, &ops, mor))
261 * if line bigger than buffer, get more
269 * whole line rcvd. reset tab proc. state
278 * fill to end of page
280 if (linecnt && prtail(lines-linecnt-lrgln, lrgln))
284 * On EOF go to next file
299 * vertcol: print files with more than one column of output down a page
302 vertcol(int argc, char **argv)
317 int mxlen = pgwd + offst + 1;
318 int mclcnt = clcnt - 1;
335 * allocate page buffer
337 if ((buf = malloc((unsigned)lines*mxlen*sizeof(char))) == NULL) {
343 * allocate page header
345 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
349 ohbuf = hbuf + offst;
351 (void)memset(hbuf, (int)' ', offst);
354 * col pointers when no headers
358 (struct vcol *)malloc((unsigned)mvc*sizeof(struct vcol))) == NULL) {
364 * pointer into page where last data per line is located
366 if ((lstdat = (char **)malloc((unsigned)lines*sizeof(char *))) == NULL){
372 * fast index lookups to locate start of lines
374 if ((indy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
378 if ((lindy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
389 * initialize buffer lookup indexes and offset area
391 for (j = 0; j < lines; ++j) {
392 lindy[j] = j * mxlen;
393 indy[j] = lindy[j] + offst;
395 ptbf = buf + lindy[j];
396 (void)memset(ptbf, (int)' ', offst);
399 ptbf = buf + indy[j];
406 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
409 * skip to requested page
411 if (inskip(inf, pgnm, lines))
428 for (i = 0; i < clcnt; ++i) {
431 * if last column, do not pad
442 * is this first column
445 ptbf = buf + indy[j];
455 addnum(ptbf, nmwd, ++lncnt);
463 cnt = inln(inf,ptbf,colwd,&cps,1,&mor);
470 * pad all but last column on page
474 * pad to end of column
478 else if ((pln = col-cnt) > 0) {
485 * remember last char in line
496 * when -t (no header) is specified the spec requires
497 * the min number of lines. The last page may not have
498 * balanced length columns. To fix this we must reorder
499 * the columns. This is a very slow technique so it is
500 * only used under limited conditions. Without -t, the
501 * balancing of text columns is unspecified. To NOT
502 * balance the last page, add the global variable
503 * nohead to the if statement below e.g.
505 * if ((cnt < 0) && nohead && cvc ......
510 * check to see if last page needs to be reordered
512 if ((cnt < 0) && cvc && ((mvc-cvc) >= clcnt)){
520 if (!nohead && prhead(hbuf, fname, pagecnt))
522 for (i = 0; i < pln; ++i) {
525 if (offst&& otln(buf,offst,&ips,&ops,1))
529 for (j = 0; j < clcnt; ++j) {
531 * determine column length
544 cnt = vc[tvc].cnt + 1;
549 if (otln(vc[tvc].pt, cnt, &ips,
559 if (otln(buf, 0, &ips, &ops, 0))
565 if (prtail((lines - pln), 0))
568 * done with output, go to next file
574 * determine how many lines to output
584 if (pln && !nohead && prhead(hbuf, fname, pagecnt))
590 for (i = 0; i < pln; ++i) {
591 ptbf = buf + lindy[i];
592 if ((j = lstdat[i] - ptbf) <= offst)
594 if (otln(ptbf, j, &ips, &ops, 0))
601 if (pln && prtail((lines - pln), 0))
605 * if EOF go to next file
620 * horzcol: print files with more than one column of output across a page
623 horzcol(int argc, char **argv)
644 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
652 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
656 ohbuf = hbuf + offst;
658 (void)memset(buf, (int)' ', offst);
659 (void)memset(hbuf, (int)' ', offst);
665 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
667 if (inskip(inf, pgnm, lines))
683 for (i = 0; i < lines; ++i) {
693 * add number to column
695 addnum(ptbf, nmwd, ++lncnt);
702 if ((cnt = inln(inf,ptbf,colwd,&cps,1,
709 * if last line skip padding
715 * pad to end of column
719 else if ((pln = col - cnt) > 0) {
720 (void)memset(ptbf,(int)' ',pln);
726 * determine line length
728 if ((j = lstdat - buf) <= offst)
731 prhead(hbuf, fname, pagecnt))
736 if (otln(buf, j, &ips, &ops, 0))
743 if (i && prtail(lines-i, 0))
747 * if EOF go to next file
762 * mulfile: print files with more than one column of output and
763 * more than one file concurrently
766 mulfile(int argc, char **argv)
790 * array of FILE *, one for each operand
792 if ((fbuf = (FILE **)malloc((unsigned)clcnt*sizeof(FILE *))) == NULL) {
800 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
804 ohbuf = hbuf + offst;
807 * do not know how many columns yet. The number of operands provide an
808 * upper bound on the number of columns. We use the number of files
809 * we can open successfully to set the number of columns. The operation
810 * of the merge operation (-m) in relation to unsuccesful file opens
811 * is unspecified by posix.
815 if ((fbuf[j] = nxtfile(argc, argv, &fname, ohbuf, 1)) == NULL)
817 if (pgnm && (inskip(fbuf[j], pgnm, lines)))
829 * calculate page boundries based on open file count
833 colwd = (pgwd - clcnt - nmwd)/clcnt;
834 pgwd = ((colwd + 1) * clcnt) - nmwd - 2;
836 colwd = (pgwd + 1 - clcnt)/clcnt;
837 pgwd = ((colwd + 1) * clcnt) - 1;
841 "pr: page width too small for %d columns\n", clcnt);
850 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
855 (void)memset(buf, (int)' ', offst);
856 (void)memset(hbuf, (int)' ', offst);
865 * continue to loop while any file still has data
873 for (i = 0; i < lines; ++i) {
878 * add line number to line
880 addnum(ptbf, nmwd, ++lncnt);
890 for (j = 0; j < clcnt; ++j) {
891 if (fbuf[j] == NULL) {
896 } else if ((cnt = inln(fbuf[j], ptbf, colwd,
897 &cps, 1, &mor)) < 0) {
901 if (fbuf[j] != stdin)
902 (void)fclose(fbuf[j]);
916 * if last ACTIVE column, done with line
922 * pad to end of column
926 } else if ((pln = col - cnt) > 0) {
927 (void)memset(ptbf, (int)' ', pln);
933 * calculate data in line
935 if ((j = lstdat - buf) <= offst)
938 if (!i && !nohead && prhead(hbuf, fname, pagecnt))
944 if (otln(buf, j, &ips, &ops, 0))
948 * if no more active files, done
959 if (i && prtail(lines-i, 0))
969 * inln(): input a line of data (unlimited length lines supported)
970 * Input is optionally expanded to spaces
975 * cps: column positon 1st char in buffer (large line support)
976 * trnc: throw away data more than lim up to \n
977 * mor: set if more data in line (not truncated)
980 inln(FILE *inf, char *buf, int lim, int *cps, int trnc, int *mor)
986 int chk = (int)inchar;
992 * expanding input option
994 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
996 * is this the input "tab" char
1000 * expand to number of spaces
1002 col = (ptbuf - buf) + *cps;
1003 col = gap - (col % gap);
1006 * if more than this line, push back
1008 if ((col > lim) && (ungetc(ch, inf) == EOF))
1014 while ((--col >= 0) && (--lim >= 0))
1026 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
1042 * entire line processed
1050 * line was larger than limit
1054 * throw away rest of line
1056 while ((ch = getc(inf)) != EOF) {
1064 * save column offset if not truncated
1074 * otln(): output a line of data. (Supports unlimited length lines)
1075 * output is optionally contracted to tabs
1077 * buf: output buffer with data
1078 * cnt: number of chars of valid data in buf
1079 * svips: buffer input column position (for large lines)
1080 * svops: buffer output column position (for large lines)
1081 * mor: output line not complete in this buf; more data to come.
1082 * 1 is more, 0 is complete, -1 is no \n's
1085 otln(char *buf, int cnt, int *svips, int *svops, int mor)
1087 int ops; /* last col output */
1088 int ips; /* last col in buf examined */
1095 * contracting on output
1100 while (buf < endbuf) {
1102 * count number of spaces and ochar in buffer
1111 * simulate ochar processing
1113 if (*buf == ochar) {
1114 ips += gap - (ips % gap);
1120 * got a non space char; contract out spaces
1124 * use as many ochar as will fit
1126 if ((tbps = ops + gap - (ops % gap)) > ips)
1128 if (putchar(ochar) == EOF) {
1137 * finish off with spaces
1139 if (putchar(' ') == EOF) {
1147 * output non space char
1149 if (putchar(*buf++) == EOF) {
1159 * if incomplete line, save position counts
1169 * use as many ochar as will fit
1171 if ((tbps = ops + gap - (ops % gap)) > ips)
1173 if (putchar(ochar) == EOF) {
1181 * finish off with spaces
1183 if (putchar(' ') == EOF) {
1193 * output is not contracted
1195 if (cnt && (fwrite(buf, sizeof(char), cnt, stdout) <= 0)) {
1204 * process line end and double space as required
1206 if ((putchar('\n') == EOF) || (dspace && (putchar('\n') == EOF))) {
1214 * inskip(): skip over pgcnt pages with lncnt lines per page
1215 * file is closed at EOF (if not stdin).
1217 * inf FILE * to read from
1218 * pgcnt number of pages to skip
1219 * lncnt number of lines per page
1222 inskip(FILE *inf, int pgcnt, int lncnt)
1227 while(--pgcnt > 0) {
1229 while ((c = getc(inf)) != EOF) {
1230 if ((c == '\n') && (--cnt == 0))
1243 * nxtfile: returns a FILE * to next file in arg list and sets the
1244 * time field for this file (or current date).
1246 * buf array to store proper date for the header.
1247 * dt if set skips the date processing (used with -m)
1250 nxtfile(int argc, char **argv, char **fname, char *buf, int dt)
1256 struct tm *timeptr = NULL;
1257 struct stat statbuf;
1258 static int twice = -1;
1261 if (eoptind >= argc) {
1263 * no file listed; default, use standard input
1275 if (gettimeofday(&tv, &tz) < 0) {
1277 (void)fprintf(err, "pr: cannot get time of day, %s\n",
1283 timeptr = localtime(&tv_sec);
1285 for (; eoptind < argc; ++eoptind) {
1286 if (strcmp(argv[eoptind], "-") == 0) {
1288 * process a "-" for filename
1297 if (nohead || (dt && twice))
1299 if (gettimeofday(&tv, &tz) < 0) {
1302 "pr: cannot get time of day, %s\n",
1307 timeptr = localtime(&tv_sec);
1310 * normal file processing
1312 if ((inf = fopen(argv[eoptind], "r")) == NULL) {
1316 (void)fprintf(err, "pr: Cannot open %s, %s\n",
1317 argv[eoptind], strerror(errno));
1325 *fname = argv[eoptind];
1327 if (nohead || (dt && twice))
1331 if (gettimeofday(&tv, &tz) < 0) {
1334 "pr: cannot get time of day, %s\n",
1339 timeptr = localtime(&tv_sec);
1341 if (fstat(fileno(inf), &statbuf) < 0) {
1345 "pr: Cannot stat %s, %s\n",
1346 argv[eoptind], strerror(errno));
1349 timeptr = localtime(&(statbuf.st_mtime));
1358 * set up time field used in header
1360 if (strftime(buf, HDBUF, timefrmt, timeptr) <= 0) {
1364 (void)fputs("pr: time conversion failed\n", err);
1371 * addnum(): adds the line number to the column
1372 * Truncates from the front or pads with spaces as required.
1373 * Numbers are right justified.
1375 * buf buffer to store the number
1376 * wdth width of buffer to fill
1379 * NOTE: numbers occupy part of the column. The posix
1380 * spec does not specify if -i processing should or should not
1381 * occur on number padding. The spec does say it occupies
1382 * part of the column. The usage of addnum currently treats
1383 * numbers as part of the column so spaces may be replaced.
1386 addnum(char *buf, int wdth, int line)
1388 char *pt = buf + wdth;
1391 *--pt = digs[line % 10];
1393 } while (line && (pt > buf));
1396 * pad with space as required
1403 * prhead(): prints the top of page header
1405 * buf buffer with time field (and offset)
1406 * cnt number of chars in buf
1407 * fname fname field for header
1408 * pagcnt page number
1411 prhead(char *buf, char *fname, int pagcnt)
1416 if ((putchar('\n') == EOF) || (putchar('\n') == EOF)) {
1421 * posix is not clear if the header is subject to line length
1422 * restrictions. The specification for header line format
1423 * in the spec clearly does not limit length. No pr currently
1424 * restricts header length. However if we need to truncate in
1425 * an reasonable way, adjust the length of the printf by
1426 * changing HDFMT to allow a length max as an arguement printf.
1427 * buf (which contains the offset spaces and time field could
1430 * note only the offset (if any) is processed for tab expansion
1432 if (offst && otln(buf, offst, &ips, &ops, -1))
1434 (void)printf(HDFMT,buf+offst, fname, pagcnt);
1439 * prtail(): pad page with empty lines (if required) and print page trailer
1442 * cnt number of lines of padding needed
1443 * incomp was a '\n' missing from last line output
1446 prtail(int cnt, int incomp)
1450 * only pad with no headers when incomplete last line
1453 ((dspace && (putchar('\n') == EOF)) ||
1454 (putchar('\n') == EOF))) {
1459 * but honor the formfeed request
1462 if (putchar('\f') == EOF) {
1470 * if double space output two \n
1476 * if an odd number of lines per page, add an extra \n
1485 if ((incomp && (putchar('\n') == EOF)) ||
1486 (putchar('\f') == EOF)) {
1493 while (--cnt >= 0) {
1494 if (putchar('\n') == EOF) {
1503 * terminate(): when a SIGINT is recvd
1506 terminate(int which_sig)
1514 * flsh_errs(): output saved up diagnostic messages after all normal
1515 * processing has completed
1522 (void)fflush(stdout);
1527 while (fgets(buf, BUFSIZ, err) != NULL)
1528 (void)fputs(buf, stderr);
1534 (void)fputs("pr: memory allocation failed\n", err);
1540 (void)fprintf(err, "pr: write failure, %s\n", strerror(errno));
1547 "usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n",
1550 " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err);
1552 " [-L locale] [-s[ch]] [-w width] [-] [file ...]\n", err);
1556 * setup: Validate command args, initialize and perform sanity
1560 setup(int argc, char **argv)
1570 if (isatty(fileno(stdout))) {
1572 * defer diagnostics until processing is done
1574 if ((err = tmpfile()) == NULL) {
1576 (void)fputs("Cannot defer diagnostic messages\n",stderr);
1581 while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) {
1584 if ((pgnm = atoi(eoptarg)) < 1) {
1585 (void)fputs("pr: +page number must be 1 or more\n",
1591 if ((clcnt = atoi(eoptarg)) < 1) {
1592 (void)fputs("pr: -columns must be 1 or more\n",err);
1606 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1607 inchar = *eoptarg++;
1610 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1611 if ((ingap = atoi(eoptarg)) < 0) {
1613 "pr: -e gap must be 0 or more\n", err);
1618 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1620 "pr: invalid value for -e %s\n", eoptarg);
1636 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1640 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1641 if ((ogap = atoi(eoptarg)) < 0) {
1643 "pr: -i gap must be 0 or more\n", err);
1648 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1650 "pr: invalid value for -i %s\n", eoptarg);
1659 if (!isdigit((unsigned char)*eoptarg) || ((lines=atoi(eoptarg)) < 1)) {
1661 "pr: Number of lines must be 1 or more\n",err);
1669 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1670 nmchar = *eoptarg++;
1673 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1674 if ((nmwd = atoi(eoptarg)) < 1) {
1676 "pr: -n width must be 1 or more\n",err);
1679 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1681 "pr: invalid value for -n %s\n", eoptarg);
1687 if (!isdigit((unsigned char)*eoptarg) || ((offst = atoi(eoptarg))< 1)){
1688 (void)fputs("pr: -o offset must be 1 or more\n",
1701 if (eoptarg == NULL)
1705 if (*eoptarg != '\0') {
1707 "pr: invalid value for -s %s\n",
1718 if (!isdigit((unsigned char)*eoptarg) || ((pgwd = atoi(eoptarg)) < 1)){
1720 "pr: -w width must be 1 or more \n",err);
1731 * default and sanity checks
1735 if ((clcnt = argc - eoptind) <= 1) {
1744 (void)fputs("pr: -a flag requires multiple columns\n",
1749 (void)fputs("pr: -m cannot be used with -a\n", err);
1759 if (cflag || merge) {
1772 "pr: -m cannot be used with multiple columns\n", err);
1776 colwd = (pgwd + 1 - (clcnt * (nmwd + 2)))/clcnt;
1777 pgwd = ((colwd + nmwd + 2) * clcnt) - 1;
1779 colwd = (pgwd + 1 - clcnt)/clcnt;
1780 pgwd = ((colwd + 1) * clcnt) - 1;
1784 "pr: page width is too small for %d columns\n",clcnt);
1792 * make sure long enough for headers. if not disable
1794 if (lines <= HEADLEN + TAILLEN)
1797 lines -= HEADLEN + TAILLEN;
1800 * adjust for double space on odd length pages
1812 (void) setlocale(LC_TIME, (Lflag != NULL) ? Lflag : "");
1814 d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
1815 timefrmt = d_first ? TIMEFMTD : TIMEFMTM;