static char *sccsid
= "@(#)pr.c 4.5 (Berkeley) %G%";
* print file with headings
/* Making putcp a macro sped things up by 14%. */
#define putcp(c) if (page >= fpage) putchar(c)
#define BUFS 9000 /* at least 66 * 132 */
char buffer
[BUFS
]; /* for multi-column output */
if (signal(SIGINT
, SIG_IGN
) != SIG_IGN
)
for (nfdone
=0; argc
>1; argc
--) {
case 'h': /* define page header */
case 't': /* don't print page headers */
case 'f': /* use form feeds */
case 'l': /* length of page */
case 'w': /* width of page */
case 's': /* col separator */
case 'm': /* all files at once */
if (numeric(*argv
)) { /* # of cols */
if ((ncol
= atoi(*argv
)) == 0) {
fprintf(stderr
, "can't print 0 cols, using 1 instead.\n");
fprintf(stderr
, "pr: bad key %s\n", *argv
);
} else if (**argv
== '+') { /* start at page ++*argv */
print((char *)0, (char **)0);
/* numeric -- returns 1 if str is numeric, elsewise 0 */
if (*str
> '9' || *str
< '0') {
mode
= sbuf
.st_mode
&0777;
/* print -- print file */
if (ncol
>72 || ncol
>width
) {
fprintf(stderr
, "pr: No room for columns.\n");
colw
= width
/(ncol
==0? 1 : ncol
);
if((file
=fopen(fp
, "r"))==NULL
) {
cbuf
= ctime(&sbuf
.st_mtime
);
colp
[ncol
] = bufp
= buffer
;
while (mflg
&&nofile
|| (!mflg
)&&tpgetc(ncol
)>0) {
colp
[ncol
] = &buffer
[BUFS
];
/* Assume a ff takes two blank lines at the
sprintf(linebuf
, "%s %s %s Page %d\n\n\n",
cbuf
+4, cbuf
+20, header
, page
);
sprintf(linebuf
, "\n\n%s %s %s Page %d\n\n\n",
cbuf
+4, cbuf
+20, header
, page
);
for(cp
=linebuf
;*cp
;) put(*cp
++);
while((p1
= *p
) && p
++ <= lastarg
) {
if((ifile
[nofile
]=fopen(p1
, "r")) == NULL
){
fprintf(stderr
, "pr: Too many args\n");
register int lastcol
, i
, c
;
while((c
= tpgetc(0)) && c
!='\n' && c
!=FF
)
if (mflg
==0) for (i
=1; i
<=ncol
; i
++) {
for (j
= margin
; j
<length
; j
++)
while((c
=tpgetc(i
))!='\n')
while ((c
=pgetc(i
)) && c
!='\n')
if (col
<lastcol
|| tabc
!=0)
while ((c
= pgetc(ncol
)) && c
!='\n')
n
= &buffer
[BUFS
] - rbufp
;
if((n
=fread(rbufp
,1,n
,file
)) <= 0){
if (rbufp
>= &buffer
[BUFS
])
if((c
=getc(ifile
[i
])) == EOF
) {
c
= **(p
= &colp
[i
]) & 0377;
if (nspace
>2 && col
> (ns
=((col
-nspace
)|07))) {