summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6f9f1b0)
SCCS-vsn: old/pr/pr.c 4.2
-static char *sccsid = "@(#)pr.c 4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)pr.c 4.2 (Berkeley) %G%";
+
/*
* print file with headings
* 2+head+2+page[56]+5
/*
* print file with headings
* 2+head+2+page[56]+5
argv++;
if (**argv == '-') {
switch (*++*argv) {
argv++;
if (**argv == '-') {
switch (*++*argv) {
+ case 'h': /* define page header */
if (argc>=2) {
header = *++argv;
argc--;
}
continue;
if (argc>=2) {
header = *++argv;
argc--;
}
continue;
+ case 't': /* don't print page headers */
+ case 'f': /* use form feeds */
fflg++;
plength = 60;
continue;
fflg++;
plength = 60;
continue;
+ case 'l': /* length of page */
length = atoi(++*argv);
continue;
length = atoi(++*argv);
continue;
+ case 'w': /* width of page */
width = atoi(++*argv);
continue;
width = atoi(++*argv);
continue;
+ case 's': /* col separator */
if (*++*argv)
tabc = **argv;
else
tabc = '\t';
continue;
if (*++*argv)
tabc = **argv;
else
tabc = '\t';
continue;
+ case 'm': /* all files at once */
mflg++;
continue;
default:
mflg++;
continue;
default:
+ if (numeric(*argv)) { /* # of cols */
+ if ((ncol = atoi(*argv)) == 0) {
+ fprintf(stderr, "can't print 0 cols, using 1 instead.\n");
+ ncol = 1;
+ }
+ } else {
+ fprintf(stderr, "pr: bad key %s\n", *argv);
+ exit(1);
+ }
- } else if (**argv == '+') {
+ } else if (**argv == '+') { /* start at page ++*argv */
fpage = atoi(++*argv);
} else {
print(*argv, argv);
fpage = atoi(++*argv);
} else {
print(*argv, argv);
+/* numeric -- returns 1 if str is numeric, elsewise 0 */
+numeric(str)
+ char *str;
+{
+ for (; *str ; str++) {
+ if (*str > '9' || *str < '0') {
+ return(0);
+ }
+ }
+ return(1);
+}
+
+/* print -- print file */
print(fp, argp)
char *fp;
char **argp;
print(fp, argp)
char *fp;
char **argp;