2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 1991 Keith Muller.
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Keith Muller of the University of California, San Diego.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 static const char copyright[] =
42 "@(#) Copyright (c) 1993\n\
43 The Regents of the University of California. All rights reserved.\n";
48 static char sccsid[] = "@(#)pr.c 8.2 (Berkeley) 4/16/94";
52 #include <sys/cdefs.h>
53 __FBSDID("$FreeBSD$");
55 #include <sys/types.h>
73 * pr: a printing and pagination filter. If multiple input files
74 * are specified, each is read, formatted, and written to standard
75 * output. By default, input is separated into 66-line pages, each
76 * with a header that includes the page number, date, time and the
79 * Complies with posix P1003.2/D11
85 static int pgnm; /* starting page number */
86 static int clcnt; /* number of columns */
87 static int colwd; /* column data width - multiple columns */
88 static int across; /* mult col flag; write across page */
89 static int dspace; /* double space flag */
90 static char inchar; /* expand input char */
91 static int ingap; /* expand input gap */
92 static int pausefst; /* Pause before first page */
93 static int pauseall; /* Pause before each page */
94 static int formfeed; /* use formfeed as trailer */
95 static char *header; /* header name instead of file name */
96 static char ochar; /* contract output char */
97 static int ogap; /* contract output gap */
98 static int lines; /* number of lines per page */
99 static int merge; /* merge multiple files in output */
100 static char nmchar; /* line numbering append char */
101 static int nmwd; /* width of line number field */
102 static int offst; /* number of page offset spaces */
103 static int nodiag; /* do not report file open errors */
104 static char schar; /* text column separation character */
105 static int sflag; /* -s option for multiple columns */
106 static int nohead; /* do not write head and trailer */
107 static int pgwd; /* page width with multiple col output */
108 static char *timefrmt; /* time conversion string */
113 static FILE *err; /* error message file pointer */
114 static int addone; /* page length is odd with double space */
115 static int errcnt; /* error count on file processing */
116 static char digs[] = "0123456789"; /* page number translation map */
118 static char fnamedefault[] = FNAME;
121 main(int argc, char *argv[])
125 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
126 (void)signal(SIGINT, terminate);
127 ret_val = setup(argc, argv);
130 * select the output format based on options
133 ret_val = mulfile(argc, argv);
135 ret_val = onecol(argc, argv);
137 ret_val = horzcol(argc, argv);
139 ret_val = vertcol(argc, argv);
144 if (errcnt || ret_val)
150 * Check if we should pause and write an alert character and wait for a
151 * carriage return on /dev/tty.
154 ttypause(int pagecnt)
159 if ((pauseall || (pausefst && pagecnt == 1)) &&
160 isatty(STDOUT_FILENO)) {
161 if ((ttyfp = fopen("/dev/tty", "r")) != NULL) {
162 (void)putc('\a', stderr);
163 while ((pch = getc(ttyfp)) != '\n' && pch != EOF)
171 * onecol: print files with only one column of output.
172 * Line length is unlimited.
175 onecol(int argc, char *argv[])
203 * allocate line buffer
205 if ((obuf = malloc((unsigned)(LBUF + off)*sizeof(char))) == NULL) {
210 * allocate header buffer
212 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
218 ohbuf = hbuf + offst;
222 nbuf[--num] = nmchar;
224 (void)memset(obuf, (int)' ', offst);
225 (void)memset(hbuf, (int)' ', offst);
231 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
234 * skip to specified page
236 if (inskip(inf, pgnm, lines))
258 while (linecnt < lines) {
262 if ((cnt = inln(inf,lbuf,LBUF,&cps,0,&mor)) < 0)
264 if (!linecnt && !nohead &&
265 prhead(hbuf, fname, pagecnt))
273 addnum(nbuf, num, ++lncnt);
274 if (otln(obuf,cnt+off, &ips, &ops, mor))
276 } else if (otln(lbuf, cnt, &ips, &ops, mor))
280 * if line bigger than buffer, get more
288 * whole line rcvd. reset tab proc. state
297 * fill to end of page
299 if (linecnt && prtail(lines-linecnt-lrgln, lrgln))
303 * On EOF go to next file
324 * vertcol: print files with more than one column of output down a page
327 vertcol(int argc, char *argv[])
330 char **lstdat = NULL;
342 int mxlen = pgwd + offst + 1;
343 int mclcnt = clcnt - 1;
344 struct vcol *vc = NULL;
361 * allocate page buffer
363 if ((buf = malloc((unsigned)lines*mxlen*sizeof(char))) == NULL) {
369 * allocate page header
371 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
375 ohbuf = hbuf + offst;
377 (void)memset(hbuf, (int)' ', offst);
380 * col pointers when no headers
384 (struct vcol *)malloc((unsigned)mvc*sizeof(struct vcol))) == NULL) {
390 * pointer into page where last data per line is located
392 if ((lstdat = (char **)malloc((unsigned)lines*sizeof(char *))) == NULL){
398 * fast index lookups to locate start of lines
400 if ((indy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
404 if ((lindy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) {
415 * initialize buffer lookup indexes and offset area
417 for (j = 0; j < lines; ++j) {
418 lindy[j] = j * mxlen;
419 indy[j] = lindy[j] + offst;
421 ptbf = buf + lindy[j];
422 (void)memset(ptbf, (int)' ', offst);
425 ptbf = buf + indy[j];
432 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
435 * skip to requested page
437 if (inskip(inf, pgnm, lines))
454 for (i = 0; i < clcnt; ++i) {
457 * if last column, do not pad
468 * is this first column
471 ptbf = buf + indy[j];
481 addnum(ptbf, nmwd, ++lncnt);
489 cnt = inln(inf,ptbf,colwd,&cps,1,&mor);
496 * pad all but last column on page
500 * pad to end of column
504 else if ((pln = col-cnt) > 0) {
511 * remember last char in line
522 * when -t (no header) is specified the spec requires
523 * the min number of lines. The last page may not have
524 * balanced length columns. To fix this we must reorder
525 * the columns. This is a very slow technique so it is
526 * only used under limited conditions. Without -t, the
527 * balancing of text columns is unspecified. To NOT
528 * balance the last page, add the global variable
529 * nohead to the if statement below e.g.
531 * if ((cnt < 0) && nohead && cvc ......
536 * check to see if last page needs to be reordered
538 if ((cnt < 0) && cvc && ((mvc-cvc) >= clcnt)){
546 if (!nohead && prhead(hbuf, fname, pagecnt))
548 for (i = 0; i < pln; ++i) {
552 otln(buf,offst,&ips,&ops,1))
556 for (j = 0; j < clcnt; ++j) {
558 * determine column length
571 cnt = vc[tvc].cnt + 1;
576 if (otln(vc[tvc].pt, cnt, &ips,
586 if (otln(buf, 0, &ips, &ops, 0))
592 if (prtail((lines - pln), 0))
595 * done with output, go to next file
601 * determine how many lines to output
611 if (pln && !nohead && prhead(hbuf, fname, pagecnt))
617 for (i = 0; i < pln; ++i) {
618 ptbf = buf + lindy[i];
619 if ((j = lstdat[i] - ptbf) <= offst)
621 if (otln(ptbf, j, &ips, &ops, 0))
628 if (pln && prtail((lines - pln), 0))
632 * if EOF go to next file
655 * horzcol: print files with more than one column of output across a page
658 horzcol(int argc, char *argv[])
679 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
687 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
692 ohbuf = hbuf + offst;
694 (void)memset(buf, (int)' ', offst);
695 (void)memset(hbuf, (int)' ', offst);
701 while ((inf = nxtfile(argc, argv, &fname, ohbuf, 0)) != NULL) {
703 if (inskip(inf, pgnm, lines))
719 for (i = 0; i < lines; ++i) {
729 * add number to column
731 addnum(ptbf, nmwd, ++lncnt);
738 if ((cnt = inln(inf,ptbf,colwd,&cps,1,
745 * if last line skip padding
751 * pad to end of column
755 else if ((pln = col - cnt) > 0) {
756 (void)memset(ptbf,(int)' ',pln);
762 * determine line length
764 if ((j = lstdat - buf) <= offst)
767 prhead(hbuf, fname, pagecnt))
772 if (otln(buf, j, &ips, &ops, 0))
779 if (i && prtail(lines-i, 0))
783 * if EOF go to next file
804 * mulfile: print files with more than one column of output and
805 * more than one file concurrently
808 mulfile(int argc, char *argv[])
833 * array of FILE *, one for each operand
835 if ((fbuf = (FILE **)malloc((unsigned)clcnt*sizeof(FILE *))) == NULL) {
843 if ((hbuf = malloc((unsigned)(HDBUF + offst)*sizeof(char))) == NULL) {
847 ohbuf = hbuf + offst;
850 * do not know how many columns yet. The number of operands provide an
851 * upper bound on the number of columns. We use the number of files
852 * we can open successfully to set the number of columns. The operation
853 * of the merge operation (-m) in relation to unsuccessful file opens
854 * is unspecified by posix.
858 if ((fbuf[j] = nxtfile(argc, argv, &fname, ohbuf, 1)) == NULL)
860 if (pgnm && (inskip(fbuf[j], pgnm, lines)))
872 * calculate page boundaries based on open file count
876 colwd = (pgwd - clcnt - nmwd)/clcnt;
877 pgwd = ((colwd + 1) * clcnt) - nmwd - 2;
879 colwd = (pgwd + 1 - clcnt)/clcnt;
880 pgwd = ((colwd + 1) * clcnt) - 1;
884 "pr: page width too small for %d columns\n", clcnt);
893 if ((buf = malloc((unsigned)(pgwd+offst+1)*sizeof(char))) == NULL) {
898 (void)memset(buf, (int)' ', offst);
899 (void)memset(hbuf, (int)' ', offst);
908 * continue to loop while any file still has data
916 for (i = 0; i < lines; ++i) {
921 * add line number to line
923 addnum(ptbf, nmwd, ++lncnt);
933 for (j = 0; j < clcnt; ++j) {
934 if (fbuf[j] == NULL) {
939 } else if ((cnt = inln(fbuf[j], ptbf, colwd,
940 &cps, 1, &mor)) < 0) {
944 if (fbuf[j] != stdin)
945 (void)fclose(fbuf[j]);
959 * if last ACTIVE column, done with line
965 * pad to end of column
969 } else if ((pln = col - cnt) > 0) {
970 (void)memset(ptbf, (int)' ', pln);
976 * calculate data in line
978 if ((j = lstdat - buf) <= offst)
981 if (!i && !nohead && prhead(hbuf, fname, pagecnt))
987 if (otln(buf, j, &ips, &ops, 0))
991 * if no more active files, done
1000 * pad to end of page
1002 if (i && prtail(lines-i, 0))
1017 * inln(): input a line of data (unlimited length lines supported)
1018 * Input is optionally expanded to spaces
1022 * lim: buffer length
1023 * cps: column position 1st char in buffer (large line support)
1024 * trnc: throw away data more than lim up to \n
1025 * mor: set if more data in line (not truncated)
1028 inln(FILE *inf, char *buf, int lim, int *cps, int trnc, int *mor)
1034 int chk = (int)inchar;
1040 * expanding input option
1042 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
1044 * is this the input "tab" char
1048 * expand to number of spaces
1050 col = (ptbuf - buf) + *cps;
1051 col = gap - (col % gap);
1054 * if more than this line, push back
1056 if ((col > lim) && (ungetc(ch, inf) == EOF))
1062 while ((--col >= 0) && (--lim >= 0))
1074 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) {
1090 * entire line processed
1098 * line was larger than limit
1102 * throw away rest of line
1104 while ((ch = getc(inf)) != EOF) {
1112 * save column offset if not truncated
1122 * otln(): output a line of data. (Supports unlimited length lines)
1123 * output is optionally contracted to tabs
1125 * buf: output buffer with data
1126 * cnt: number of chars of valid data in buf
1127 * svips: buffer input column position (for large lines)
1128 * svops: buffer output column position (for large lines)
1129 * mor: output line not complete in this buf; more data to come.
1130 * 1 is more, 0 is complete, -1 is no \n's
1133 otln(char *buf, int cnt, int *svips, int *svops, int mor)
1135 int ops; /* last col output */
1136 int ips; /* last col in buf examined */
1143 * contracting on output
1148 while (buf < endbuf) {
1150 * count number of spaces and ochar in buffer
1159 * simulate ochar processing
1161 if (*buf == ochar) {
1162 ips += gap - (ips % gap);
1168 * got a non space char; contract out spaces
1170 while (ips - ops > 1) {
1172 * use as many ochar as will fit
1174 if ((tbps = ops + gap - (ops % gap)) > ips)
1176 if (putchar(ochar) == EOF) {
1185 * finish off with spaces
1187 if (putchar(' ') == EOF) {
1195 * output non space char
1197 if (putchar(*buf++) == EOF) {
1207 * if incomplete line, save position counts
1215 while (ips - ops > 1) {
1217 * use as many ochar as will fit
1219 if ((tbps = ops + gap - (ops % gap)) > ips)
1221 if (putchar(ochar) == EOF) {
1229 * finish off with spaces
1231 if (putchar(' ') == EOF) {
1241 * output is not contracted
1243 if (cnt && (fwrite(buf, sizeof(char), cnt, stdout) <= 0)) {
1252 * process line end and double space as required
1254 if ((putchar('\n') == EOF) || (dspace && (putchar('\n') == EOF))) {
1262 * inskip(): skip over pgcnt pages with lncnt lines per page
1263 * file is closed at EOF (if not stdin).
1265 * inf FILE * to read from
1266 * pgcnt number of pages to skip
1267 * lncnt number of lines per page
1270 inskip(FILE *inf, int pgcnt, int lncnt)
1275 while(--pgcnt > 0) {
1277 while ((c = getc(inf)) != EOF) {
1278 if ((c == '\n') && (--cnt == 0))
1291 * nxtfile: returns a FILE * to next file in arg list and sets the
1292 * time field for this file (or current date).
1294 * buf array to store proper date for the header.
1295 * dt if set skips the date processing (used with -m)
1298 nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
1302 struct tm *timeptr = NULL;
1303 struct stat statbuf;
1304 static int twice = -1;
1307 if (eoptind >= argc) {
1309 * no file listed; default, use standard input
1318 *fname = fnamedefault;
1321 if ((tv_sec = time(NULL)) == -1) {
1323 (void)fprintf(err, "pr: cannot get time of day, %s\n",
1328 timeptr = localtime(&tv_sec);
1330 for (; eoptind < argc; ++eoptind) {
1331 if (strcmp(argv[eoptind], "-") == 0) {
1333 * process a "-" for filename
1340 *fname = fnamedefault;
1342 if (nohead || (dt && twice))
1344 if ((tv_sec = time(NULL)) == -1) {
1347 "pr: cannot get time of day, %s\n",
1351 timeptr = localtime(&tv_sec);
1354 * normal file processing
1356 if ((inf = fopen(argv[eoptind], "r")) == NULL) {
1360 (void)fprintf(err, "pr: cannot open %s, %s\n",
1361 argv[eoptind], strerror(errno));
1367 *fname = fnamedefault;
1369 *fname = argv[eoptind];
1371 if (nohead || (dt && twice))
1375 if ((tv_sec = time(NULL)) == -1) {
1378 "pr: cannot get time of day, %s\n",
1383 timeptr = localtime(&tv_sec);
1385 if (fstat(fileno(inf), &statbuf) < 0) {
1389 "pr: cannot stat %s, %s\n",
1390 argv[eoptind], strerror(errno));
1393 timeptr = localtime(&(statbuf.st_mtime));
1402 * set up time field used in header
1404 if (strftime(buf, HDBUF, timefrmt, timeptr) <= 0) {
1408 (void)fputs("pr: time conversion failed\n", err);
1415 * addnum(): adds the line number to the column
1416 * Truncates from the front or pads with spaces as required.
1417 * Numbers are right justified.
1419 * buf buffer to store the number
1420 * wdth width of buffer to fill
1423 * NOTE: numbers occupy part of the column. The posix
1424 * spec does not specify if -i processing should or should not
1425 * occur on number padding. The spec does say it occupies
1426 * part of the column. The usage of addnum currently treats
1427 * numbers as part of the column so spaces may be replaced.
1430 addnum(char *buf, int wdth, int line)
1432 char *pt = buf + wdth;
1435 *--pt = digs[line % 10];
1437 } while (line && (pt > buf));
1440 * pad with space as required
1447 * prhead(): prints the top of page header
1449 * buf buffer with time field (and offset)
1450 * cnt number of chars in buf
1451 * fname fname field for header
1452 * pagcnt page number
1455 prhead(char *buf, const char *fname, int pagcnt)
1460 if ((putchar('\n') == EOF) || (putchar('\n') == EOF)) {
1465 * posix is not clear if the header is subject to line length
1466 * restrictions. The specification for header line format
1467 * in the spec clearly does not limit length. No pr currently
1468 * restricts header length. However if we need to truncate in
1469 * a reasonable way, adjust the length of the printf by
1470 * changing HDFMT to allow a length max as an argument to printf.
1471 * buf (which contains the offset spaces and time field could
1474 * note only the offset (if any) is processed for tab expansion
1476 if (offst && otln(buf, offst, &ips, &ops, -1))
1478 (void)printf(HDFMT,buf+offst, fname, pagcnt);
1483 * prtail(): pad page with empty lines (if required) and print page trailer
1486 * cnt number of lines of padding needed
1487 * incomp was a '\n' missing from last line output
1490 prtail(int cnt, int incomp)
1494 * only pad with no headers when incomplete last line
1497 ((dspace && (putchar('\n') == EOF)) ||
1498 (putchar('\n') == EOF))) {
1503 * but honor the formfeed request
1506 if (putchar('\f') == EOF) {
1514 * if double space output two \n
1520 * if an odd number of lines per page, add an extra \n
1529 if ((incomp && (putchar('\n') == EOF)) ||
1530 (putchar('\f') == EOF)) {
1537 while (--cnt >= 0) {
1538 if (putchar('\n') == EOF) {
1547 * terminate(): when a SIGINT is recvd
1550 terminate(int which_sig __unused)
1558 * flsh_errs(): output saved up diagnostic messages after all normal
1559 * processing has completed
1566 (void)fflush(stdout);
1571 while (fgets(buf, BUFSIZ, err) != NULL)
1572 (void)fputs(buf, stderr);
1578 (void)fputs("pr: memory allocation failed\n", err);
1584 (void)fprintf(err, "pr: write failure, %s\n", strerror(errno));
1591 "usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n",
1594 " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err);
1596 " [-L locale] [-s[ch]] [-w width] [-] [file ...]\n", err);
1600 * setup: Validate command args, initialize and perform sanity
1604 setup(int argc, char *argv[])
1614 if (isatty(fileno(stdout))) {
1616 * defer diagnostics until processing is done
1618 if ((err = tmpfile()) == NULL) {
1620 (void)fputs("Cannot defer diagnostic messages\n",stderr);
1625 while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) {
1628 if ((pgnm = atoi(eoptarg)) < 1) {
1629 (void)fputs("pr: +page number must be 1 or more\n",
1635 if ((clcnt = atoi(eoptarg)) < 1) {
1636 (void)fputs("pr: -columns must be 1 or more\n",err);
1650 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1651 inchar = *eoptarg++;
1654 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1655 if ((ingap = atoi(eoptarg)) < 0) {
1657 "pr: -e gap must be 0 or more\n", err);
1662 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1664 "pr: invalid value for -e %s\n", eoptarg);
1680 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1684 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1685 if ((ogap = atoi(eoptarg)) < 0) {
1687 "pr: -i gap must be 0 or more\n", err);
1692 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1694 "pr: invalid value for -i %s\n", eoptarg);
1703 if (!isdigit((unsigned char)*eoptarg) || ((lines=atoi(eoptarg)) < 1)) {
1705 "pr: number of lines must be 1 or more\n",err);
1713 if ((eoptarg != NULL) && !isdigit((unsigned char)*eoptarg))
1714 nmchar = *eoptarg++;
1717 if ((eoptarg != NULL) && isdigit((unsigned char)*eoptarg)) {
1718 if ((nmwd = atoi(eoptarg)) < 1) {
1720 "pr: -n width must be 1 or more\n",err);
1723 } else if ((eoptarg != NULL) && (*eoptarg != '\0')) {
1725 "pr: invalid value for -n %s\n", eoptarg);
1731 if (!isdigit((unsigned char)*eoptarg) || ((offst = atoi(eoptarg))< 1)){
1732 (void)fputs("pr: -o offset must be 1 or more\n",
1745 if (eoptarg == NULL)
1749 if (*eoptarg != '\0') {
1751 "pr: invalid value for -s %s\n",
1762 if ((eoptarg == NULL ) ||
1763 !isdigit((unsigned char)*eoptarg) ||
1764 ((pgwd = atoi(eoptarg)) < 1)){
1766 "pr: -w width must be 1 or more \n",err);
1777 * default and sanity checks
1781 if ((clcnt = argc - eoptind) <= 1) {
1790 (void)fputs("pr: -a flag requires multiple columns\n",
1795 (void)fputs("pr: -m cannot be used with -a\n", err);
1805 if (cflag || merge) {
1818 "pr: -m cannot be used with multiple columns\n", err);
1822 colwd = (pgwd + 1 - (clcnt * (nmwd + 2)))/clcnt;
1823 pgwd = ((colwd + nmwd + 2) * clcnt) - 1;
1825 colwd = (pgwd + 1 - clcnt)/clcnt;
1826 pgwd = ((colwd + 1) * clcnt) - 1;
1830 "pr: page width is too small for %d columns\n",clcnt);
1838 * make sure long enough for headers. if not disable
1840 if (lines <= HEADLEN + TAILLEN)
1843 lines -= HEADLEN + TAILLEN;
1846 * adjust for double space on odd length pages
1858 (void) setlocale(LC_TIME, (Lflag != NULL) ? Lflag : "");
1860 d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
1861 timefrmt = strdup(d_first ? TIMEFMTD : TIMEFMTM);