Lines Matching +full:data +full:- +full:lines

1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * output. By default, input is separated into 66-line pages, each
72 static int colwd; /* column data width - multiple columns */
83 static int lines; /* number of lines per page */ variable
90 static int sflag; /* -s option for multiple columns */
162 int cnt = -1; in onecol()
207 nbuf[--num] = nmchar; in onecol()
221 if (inskip(inf, pgnm, lines)) in onecol()
243 while (linecnt < lines) { in onecol()
284 if (linecnt && prtail(lines-linecnt-lrgln, lrgln)) in onecol()
318 int cnt = -1; in vertcol()
328 int mclcnt = clcnt - 1; in vertcol()
348 if ((buf = malloc((unsigned)lines*mxlen*sizeof(char))) == NULL) { in vertcol()
367 mvc = lines * clcnt; in vertcol()
375 * pointer into page where last data per line is located in vertcol()
377 if ((lstdat = (char **)malloc((unsigned)lines*sizeof(char *))) == NULL){ in vertcol()
383 * fast index lookups to locate start of lines in vertcol()
385 if ((indy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) { in vertcol()
389 if ((lindy = (int *)malloc((unsigned)lines*sizeof(int))) == NULL) { in vertcol()
402 for (j = 0; j < lines; ++j) { in vertcol()
422 if (inskip(inf, pgnm, lines)) in vertcol()
489 else if ((pln = col-cnt) > 0) { in vertcol()
499 if (++j >= lines) in vertcol()
507 * when -t (no header) is specified the spec requires in vertcol()
508 * the min number of lines. The last page may not have in vertcol()
511 * only used under limited conditions. Without -t, the in vertcol()
518 --cvc; in vertcol()
523 if ((cnt < 0) && cvc && ((mvc-cvc) >= clcnt)){ in vertcol()
577 if (prtail((lines - pln), 0)) in vertcol()
586 * determine how many lines to output in vertcol()
589 pln = lines; in vertcol()
604 if ((j = lstdat[i] - ptbf) <= offst) in vertcol()
613 if (pln && prtail((lines - pln), 0)) in vertcol()
647 int cnt = -1; in horzcol()
688 if (inskip(inf, pgnm, lines)) in horzcol()
704 for (i = 0; i < lines; ++i) { in horzcol()
740 else if ((pln = col - cnt) > 0) { in horzcol()
749 if ((j = lstdat - buf) <= offst) in horzcol()
764 if (i && prtail(lines-i, 0)) in horzcol()
838 * of the merge operation (-m) in relation to unsuccessful file opens in mulfile()
845 if (pgnm && (inskip(fbuf[j], pgnm, lines))) in mulfile()
861 colwd = (pgwd - clcnt - nmwd)/clcnt; in mulfile()
862 pgwd = ((colwd + 1) * clcnt) - nmwd - 2; in mulfile()
864 colwd = (pgwd + 1 - clcnt)/clcnt; in mulfile()
865 pgwd = ((colwd + 1) * clcnt) - 1; in mulfile()
893 * continue to loop while any file still has data in mulfile()
901 for (i = 0; i < lines; ++i) { in mulfile()
927 * EOF hit; no data in mulfile()
932 --actf; in mulfile()
936 * process file data in mulfile()
954 } else if ((pln = col - cnt) > 0) { in mulfile()
961 * calculate data in line in mulfile()
963 if ((j = lstdat - buf) <= offst) in mulfile()
987 if (i && prtail(lines-i, 0)) in mulfile()
1002 * inln(): input a line of data (unlimited length lines supported)
1009 * trnc: throw away data more than lim up to \n
1010 * mor: set if more data in line (not truncated)
1027 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) { in inln()
1035 col = (ptbuf - buf) + *cps; in inln()
1036 col = gap - (col % gap); in inln()
1047 while ((--col >= 0) && (--lim >= 0)) in inln()
1059 while ((--lim >= 0) && ((ch = getc(inf)) != EOF)) { in inln()
1065 col = ptbuf - buf; in inln()
1070 return(-1); in inln()
1107 * otln(): output a line of data. (Supports unlimited length lines)
1110 * buf: output buffer with data
1111 * cnt: number of chars of valid data in buf
1112 * svips: buffer input column position (for large lines)
1113 * svops: buffer output column position (for large lines)
1114 * mor: output line not complete in this buf; more data to come.
1115 * 1 is more, 0 is complete, -1 is no \n's
1147 ips += gap - (ips % gap); in otln()
1155 while (ips - ops > 1) { in otln()
1159 if ((tbps = ops + gap - (ops % gap)) > ips) in otln()
1200 while (ips - ops > 1) { in otln()
1204 if ((tbps = ops + gap - (ops % gap)) > ips) in otln()
1247 * inskip(): skip over pgcnt pages with lncnt lines per page
1252 * lncnt number of lines per page
1260 while(--pgcnt > 0) { in inskip()
1263 if ((c == '\n') && (--cnt == 0)) in inskip()
1280 * dt if set skips the date processing (used with -m)
1289 static int twice = -1; in nxtfile()
1306 if ((tv_sec = time(NULL)) == -1) { in nxtfile()
1310 eoptind = argc - 1; in nxtfile()
1316 if (strcmp(argv[eoptind], "-") == 0) { in nxtfile()
1318 * process a "-" for filename in nxtfile()
1329 if ((tv_sec = time(NULL)) == -1) { in nxtfile()
1360 if ((tv_sec = time(NULL)) == -1) { in nxtfile()
1409 * spec does not specify if -i processing should or should not
1420 *--pt = digs[line % 10]; in addnum()
1428 *--pt = ' '; in addnum()
1461 if (offst && otln(buf, offst, &ips, &ops, -1)) in prhead()
1468 * prtail(): pad page with empty lines (if required) and print page trailer
1471 * cnt number of lines of padding needed
1505 * if an odd number of lines per page, add an extra \n in prtail()
1522 while (--cnt >= 0) { in prtail()
1576 "usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n", in usage()
1579 " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err); in usage()
1581 " [-L locale] [-s[ch]] [-w width] [-] [file ...]\n", err); in usage()
1610 while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) { in setup()
1619 case '-': in setup()
1621 (void)fputs("pr: -columns must be 1 or more\n",err); in setup()
1642 "pr: -e gap must be 0 or more\n", err); in setup()
1649 "pr: invalid value for -e %s\n", eoptarg); in setup()
1672 "pr: -i gap must be 0 or more\n", err); in setup()
1679 "pr: invalid value for -i %s\n", eoptarg); in setup()
1688 if (!isdigit((unsigned char)*eoptarg) || ((lines=atoi(eoptarg)) < 1)) { in setup()
1690 "pr: number of lines must be 1 or more\n",err); in setup()
1705 "pr: -n width must be 1 or more\n",err); in setup()
1710 "pr: invalid value for -n %s\n", eoptarg); in setup()
1717 (void)fputs("pr: -o offset must be 1 or more\n", in setup()
1736 "pr: invalid value for -s %s\n", in setup()
1751 "pr: -w width must be 1 or more \n",err); in setup()
1766 if ((clcnt = argc - eoptind) <= 1) { in setup()
1775 (void)fputs("pr: -a flag requires multiple columns\n", in setup()
1780 (void)fputs("pr: -m cannot be used with -a\n", err); in setup()
1803 "pr: -m cannot be used with multiple columns\n", err); in setup()
1807 colwd = (pgwd + 1 - (clcnt * (nmwd + 2)))/clcnt; in setup()
1808 pgwd = ((colwd + nmwd + 2) * clcnt) - 1; in setup()
1810 colwd = (pgwd + 1 - clcnt)/clcnt; in setup()
1811 pgwd = ((colwd + 1) * clcnt) - 1; in setup()
1819 if (!lines) in setup()
1820 lines = LINES; in setup()
1825 if (lines <= HEADLEN + TAILLEN) in setup()
1828 lines -= HEADLEN + TAILLEN; in setup()
1834 if (lines == 1) in setup()
1837 if (lines & 1) in setup()
1839 lines /= 2; in setup()