home *** CD-ROM | disk | FTP | other *** search
- Path: wupost!sdd.hp.com!mips!pacbell.com!jcwasik
- From: jcwasik@PacBell.COM (Joe Wasik)
- Newsgroups: alt.sources
- Subject: LINEL -- PREDICT PAPER-SPACE FOR PRINT FILE, part 1/1
- Message-ID: <1991Sep5.163807.21279@PacBell.COM>
- Date: 5 Sep 91 16:38:07 GMT
- Sender: news@PacBell.COM (Pacific Bell Netnews)
- Organization: Pacific * Bell
- Lines: 834
-
- This program "linel" tries to predict paper-space that a file expects
- to use. It takes linewraps, formfeeds, backspaces, etc into account
- and tells you number of lines, pages, etc.
-
- See the manpage for options. Linel assumes somethings that you may need
- to override.
- --- cut here ---
- # This is a shell archive. Remove anything before this line,
- # then unpack it by saving it in a file and typing "sh file".
- #
- # Contents: README linel.1 linel.c
-
- echo x - README
- sed 's/^@//' > "README" <<'@//E*O*F README//'
- Linel is a program to predict the appearance and paper space needed by
- a print file.
-
- There is no make file, but make's default rules will work. So, either
- type "make linel" or "cc -O linel.c -o linel". See the manpage for runtime
- instructions.
-
- If you have any comments, constructive or otherwise, send them to
- jcwasik@clib.pacbell.com
- @//E*O*F README//
- chmod u=rw,g=rw,o=r README
-
- echo x - linel.1
- sed 's/^@//' > "linel.1" <<'@//E*O*F linel.1//'
- @.TH LINEL 1
- @.SH NAME
- linel - predict line count and page count of file without printing it
- @.SH SYNOPSIS
- @.B "linel"
- [
- @.B "\-h"
- (help) ] [
- @.B "\-b"
- ] [
- @.B "\-f"
- ] [
- @.B "\-o"
- offset ] [
- @.B "\-t"
- tabs ] [
- @.B "\-v"
- ] [
- @.B "\-w"
- wrap position ]
- @.P
- [
- @.B "\-p"
- lines on page ] [ file1... filex | - (stdin) ]"
- @.SH DESCRIPTION
- \fILinel\fP tries to predict the paper space to print a file, i.e.
- \fIlinel\fP expands all tabs, takes margins and line wrap into account, and
- then delivers a number of statistics. These are:
- @.IP
- Number of pages.
- @.br
- Number of print lines.
- @.br
- Number of raw characters.
- @.br
- Number of print positions.
- @.br
- Number of binary characters.
- @.br
- Number of print positions in longest line.
- @.P
- The output of \fIlinel\fP appears similar to that of the \fIwc(1)\fP command,
- i.e. all numbers are on one line with the file's name at the right end. By
- giving it more than one file, an additional line of totals appears.
- \fILinel\fP can also take input from stdin. Either a \- (dash) on the command
- line or by omitting the filename you can force \fIlinel\fP to take input from
- stdin. The dash may be interspersed with file names.
- @.P
- \fILinel\fP is most useful with printers that cannot find top of form once a
- line has wrapped. \fILinel\fP warns a potential problem by indicating how
- many print characters are in the longest line.
- @.SH Options
- @.IP "\-h" 8
- Display help-screen and exit without processing any files or other command
- line options.
- @.IP "\-b"
- Printer cannot act upon backspace, treat the backspace as a binary character,
- i.e. do nothing. By default, when it finds a backspace, \fIlinel\fP retreats
- the logical printhead one position.
- @.IP "\-f"
- Printer cannot act upon formfeed. Like the backspace, treat the formfeed as a
- binary character. By default, when it finds a formfeed, \fIlinel\fP advances
- a logical page.
- @.IP "\-v"
- Verbose output. Now, \fIlinel\fP's output does not look like \fIwc(1)\fP's
- output.
- @.IP "\-o \fIn\fP"
- Assume a margin of \fIn\fP characters. Works like the \fIpr(1)\fP command. The
- default margin is zero.
- @.IP "\-t \fIn\fP"
- A tab character expands into spaces so that the next character position is
- a whole multiple of \fIn\fP. If \fIn\fP is zero, treat the tab character as
- a binary character. By default, \fIn\fP is \fB8\fP.
- @.IP "\-w \fIn\fP"
- Wrap line after \fIn\fP characters. If \fIn\fP is zero, no line ever wraps. The
- report of \fIprint positions in longest line\fP won't ever exceed this value.
- @.IP "\-p \fIn\fP"
- Advance page count when lines per page passes \fIn\fP. If set to zero, page
- count advances only when formfeeds are found and recognized. By default,
- \fIlinel\fP thinks a logical page should have \fB55\fP lines.
- @.P
- \fILionel\fP always counts at least one page. Therefore, a file with one
- recognized formfeed will report at least two pages.
- @.P
- A line that gets wrapped will still wrap around to position 1, not the right
- margin as specified with the \fI-o n\fP option. This is the way that
- \fIpr(1)\fP works.
- @.P
- \fILinel\fP tries to act like most printers and copies behaviors from other
- Unix commands. Specifically \fIlinel\fP looks at:
- @.P
- When run on a DOS file that sits on a Unix system, \fIlinel\fP reports one
- binary character for each end-of-line. Unix systems use a different scheme to
- terminate lines. Take a look at the \fIflip(1)\fP command.
- @.IP Tabs 14
- Expands all tabs to spaces. The number of spaces depends on the position of
- the printhead when it sees the tab. A tab found on the wrapped part of a line
- acts as if the second line started at position 1 (not at the margin!). A tab
- that causes a line to wrap, generates as many spaces as if the line didn't
- wrap. The tab value can be adjusted with a command line option.
- @.IP Binary
- Binary characters are ignored. It is not predictable what a binary
- character's effect on a page would be. \fILinel\fP counts the binary
- characters that it finds and, at end, the total is displayed. By using
- command line options, \fIlinel\fP can treat backspaces, formfeeds, and tabs as
- binary characters.
- @.IP Backspace
- If the printer knows the backspace, the logical printhead moves back one
- position -- unless it is already at the first position. If a line has
- wrapped, a backspace at the first position of the new line will not move the
- printhead up to the previous line. If a line has backspaces immediately
- preceding a newline, those backspaces are ignored, i.e. if printed they would
- have no effect on the page.
- @.IP Formfeed
- If the printer knows formfeeds and one is found, a new line is started and a
- new page is counted. If \fIlinel\fP finds a formfeed after data but before a
- newline than the formfeed also acts as a new line.
- @.SH WARNING
- Compile time options may change \fIlinel\fP's default behavior.
- @.P
- \fILinel\fP cannot interpret escape sequences. It will instead read them
- as binary and printable characters.
- @.SH "SEE ALSO"
- flip(by Rahul Dhesi), pr(1), wc(1)
- @//E*O*F linel.1//
- chmod u=rw,g=rw,o=r linel.1
-
- echo x - linel.c
- sed 's/^@//' > "linel.c" <<'@//E*O*F linel.c//'
- /*
- ** Source name: linel.c
- **
- ** Written and tested on System V 3.1.1
- **
- ** Input args (command line):
- ** command line options
- ** file names
- **
- ** Output args:
- ** return code, < 0 if error, 0 if ok
- **
- ** Synopsis:
- ** Program analysis input, which may come from files or from
- ** standard-input. Program counts line lengths in order to allow
- ** prediction of what print-outs of these files might look like.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
-
- /*
- ** COMPILE-TIME DEFAULTS:
- */
-
- /*
- ** Number of characters normally in a tab (Override with -t option)
- */
-
- #ifndef TABNUM
- #define TABNUM 8L
- #endif
-
- /*
- ** Buffer size of name of input file
- ** (You may get this from /usr/include/limits.h)
- */
-
- #ifndef PATH_MAX
- #define PATH_MAX 1024
- #endif
-
- /*
- ** Left hand margin size (offset, override with -o option)
- ** (Always gets added to count of printable chars for each line)
- */
-
- #ifndef MARGIN
- #define MARGIN 0L
- #endif
-
- /*
- ** Default at verbose or not (-v toggles this)
- */
-
- #ifndef VERBOSE
- #define VERBOSE 0
- #endif
-
- /*
- ** Default at formfeed or not (-f toggles this)
- ** (On: formfeed is printable, starts a new line)
- ** (Off: formfeed is binary char -- printer doesn't know it)
- */
-
- #ifndef FORMFEED
- #define FORMFEED 1
- #endif
-
- /*
- **
- ** Default at backspace or not (-b toggles this)
- ** (On: backspace is printable, moves printhead back on position)
- ** (Off: backspace is binary char -- printer doesn't know it)
- ** (Note, backspace never moves to previous line)
- */
-
- #ifndef BACKSPACE
- #define BACKSPACE 1
- #endif
-
- /*
- ** Wrap value (Override with -w)
- ** Leave at zero if printer discards what's past right margin
- ** Otherwise this should be where printer breaks line
- */
-
- #ifndef WRAPPOS
- #define WRAPPOS 0L
- #endif
-
- /*
- ** Number of printing lines on page (Override with -p)
- */
-
- #ifndef PAGELEN
- #define PAGELEN 55L
- #endif
-
- /*
- ** end of COMPILE-TIME DEFAULTS
- */
-
- #define USAGE "Usage %s: [-h (help)] [-b] [-f] [-o offset] [-t tabs] [-v]\n\t [-w wrap position] [-p lines on page] [file1... filex | stdin ]\n"
-
- #define EOLFLAG -99L
- #define BINFLAG -98L
- #define BCKFLAG -97L
- #define FFFLAG -96L
-
- /*
- ** Debug mode not at startup, -d toggles this
- */
-
- #ifndef DEBUG
- #define DEBUG 0
- #else
- #define DEBUG 1
- #endif
-
- char *pname; /* this program's name */
- int debug = DEBUG; /* cmdline opt, debug needed */
- long tabnum = TABNUM; /* cmdline opt, chars in tab */
- long margin = MARGIN; /* cmdline opt, margin size */
- int verbose = VERBOSE; /* cmdline opt, verbose flag */
- int formfeed = FORMFEED; /* cmdline opt, formfeed flag */
- int backspace = BACKSPACE; /* cmdline opt, backspace flg */
- long wrappos = WRAPPOS; /* cmdline opt, wrap position */
- long pagelen = PAGELEN; /* cmdline opt, lines on page */
- int helptext = 0; /* cmdline opt, help screen */
-
- /* define this structure for use by functions */
- struct counter {
- long file_page_cnt; /* count pages */
- long file_line_cnt; /* count all lines */
- long file_raw_cnt; /* count all chars as 1 */
- long file_prnt_cnt; /* count printing chars */
- long file_bin_cnt; /* count binary chars */
- long line_prnt_cnt; /* count printing chars */
- };
-
- int
- main(argc,argv)
- int argc;
- char **argv;
- {
- int next; /* really optind of getopt() */
- int status = 0; /* return code to caller */
- int i; /* loop var */
- struct counter totals; /* if more than one file */
- void do_help(); /* help function */
-
- /* store pointer to this program's name */
- pname = *argv;
-
- /*
- ** go get command line options
- ** if an error was found, tell user and exit
- */
- if ((next = options(argc, argv)) == -1) {
- (void) Usage();
- return(-1);
- }
-
- /* if requested display help -- always exit */
- if (helptext) {
- (void) do_help();
- return(0);
- }
-
- /* initialize counters for totals */
- totals.file_page_cnt = 0L;
- totals.file_line_cnt = 0L;
- totals.file_raw_cnt = 0L;
- totals.file_prnt_cnt = 0L;
- totals.file_bin_cnt = 0L;
- totals.line_prnt_cnt = 0L;
-
- /*
- ** if next=argc, all args were options, so no file names, process stdin
- ** if file names, then loop through them, processing each one
- ** accumulate status so that good file doesn't hide result from bad one
- */
- if (next == argc) {
- status = do_file("-", &totals);
- } else {
- for (i = next; i < argc; i++) {
- status += do_file(argv[i], &totals);
- }
- }
-
- /*
- ** print totals stats
- ** but only if not stdin and and more than 1 file
- */
- if (next != argc && argc - next > 1) {
- (void) print_stats(&totals, "total");
- }
-
- if (debug) {
- (void) fprintf(stderr, "debug: exit status: %d\n", status);
- }
-
- /* exit with return value */
- return(status);
- }
-
- /*
- ** Function name: Usage()
- **
- ** Synopsis:
- ** Print usage message and ensure buffers are flushed
- */
-
- int
- Usage()
- {
- (void) fflush(stdout);
- (void) fprintf(stderr, USAGE, pname);
- (void) fflush(stderr);
- return(0);
- }
-
- /*
- ** Function name: options()
- **
- ** Input args:
- ** The same are as a main would usually get
- **
- ** Output args:
- ** Optind, integer, argc of next argument which should be a file name
- **
- ** Synopsis:
- ** This function scans the command line and sets a bunch of global flags
- ** based on what it finds.
- */
-
- int
- options(argc, argv)
- int argc;
- char **argv;
- {
- int i; /* temp or loop variable */
- extern int optind; /* see getopt(3C) */
- extern char *optarg; /* see getopt(3C) */
- long atol(); /* see strtol(3C) */
-
- /*
- ** analize the command line
- ** note that some options are toggles
- */
- while ((i = getopt(argc, argv, "?bdfho:p:t:vw:")) != EOF) {
- switch(i) {
- case 'b': backspace = (backspace ? 0 : 1);
- break;
- case 'd': debug = (debug ? 0 : 1);
- break;
- case 'f': formfeed = (formfeed ? 0 : 1);
- break;
- case 'h': helptext++;
- break;
- case 'o': margin = atol(optarg);
- break;
- case 'p': pagelen = atol(optarg);
- break;
- case 't': tabnum = atol(optarg);
- break;
- case 'v': verbose = (verbose ? 0 : 1);
- break;
- case 'w': wrappos = atol(optarg);
- break;
- default: return(-1);
- }
- }
-
- if (debug) {
- (void) fprintf(stderr,
- "debug: -d:%d -f:%d, -b:%d, -v:%d, -p:%ld, -t:%ld, -o:%ld -w:%ld\n",
- debug, formfeed, backspace, verbose, pagelen,
- tabnum, margin, wrappos);
- }
-
- /*
- ** if this printer wraps, the indicated position cannot precede margin
- */
- if (wrappos && margin >= wrappos) {
- (void) fprintf(stderr, "%s: offset & wrap position conflict\n", pname);
- return(-1);
- }
-
- /* send the pos of next arg (a filename) to caller */
- return(optind);
- }
-
- /*
- ** Function name: do_help()
- **
- ** Synopsis:
- ** Just display help
- */
-
- void
- do_help()
- {
- (void) fputs("\n", stdout);
- (void) fputs("linel: version 1.1\n", stdout);
- (void) fputs("\n", stdout);
- (void) Usage();
- (void) fputs("\n", stdout);
- (void) fputs("-h Help screen\n", stdout);
- (void) fputs("-b Print device does not know backspace\n", stdout);
- (void) fputs("-f Print device does not know formfeed\n", stdout);
- (void) fputs("-v Provide verbose output, not like wc(1)\n", stdout);
- (void) fputs("-o n Left margin (offset) at printer is n\n", stdout);
- (void) fputs("-p n Number of printing lines per page is n\n", stdout);
- (void) fputs("-t n Tab causes move to next multiple of n\n", stdout);
- (void) fputs("-w n Printer wraps line after n characters\n", stdout);
- (void) fputs("\n", stdout);
- }
-
- /*
- ** Function name: do_file()
- **
- ** Input args:
- ** argv, char pointer, name of a file or "-" if stdin
- ** totals, struct pointer, where to put program totals
- **
- ** Output args:
- ** status, integer, could come from another module
- ** 0 if OK, -1 if bad
- **
- ** Synopsis:
- ** Take filename, open it, then process it
- */
-
- int
- do_file(argv, totals)
- char *argv; /* file name */
- struct counter *totals; /* totals for all files */
- {
- char infile[PATH_MAX]; /* buffer for input file name */
- FILE *ifp; /* input file pointer */
- void perror(); /* avoid lint problems */
- long rc; /* return code */
- long do_char(); /* check char function */
- struct counter tmpcount; /* create accumulate buffer */
- struct counter count; /* create counter buffer */
- char c; /* char being examined */
- long backspace_cnt; /* count trailing backspaces */
- long pageline_cnt; /* count lines on one page */
-
- /*
- ** determine input
- ** if a dash, then assume stdin, so set flags and save stdin string
- /* if no dash, then save file name and open the file
- */
- if (!strcmp(argv, "-")) {
- ifp = stdin;
- (void) strcpy(infile, "stdin");
- } else {
- (void) strcpy(infile, argv);
- if ((ifp = fopen(argv, "r")) == NULL) {
- (void) perror(pname);
- return(-1);
- }
- }
-
- if (debug) {
- (void) fprintf(stderr, "debug: opening \"%s\"\n", infile);
- }
-
- /* purge the buffers before we begin */
- (void) fflush(stdout);
- (void) fflush(stderr);
-
- /* initialize counters */
- tmpcount.file_page_cnt = 1L;
- tmpcount.file_line_cnt = 0L;
- tmpcount.file_raw_cnt = 0L;
- tmpcount.file_prnt_cnt = 0L;
- tmpcount.file_bin_cnt = 0L;
- tmpcount.line_prnt_cnt = margin;
- count.file_page_cnt = 0L;
- count.file_line_cnt = 0L;
- count.file_raw_cnt = 0L;
- count.file_prnt_cnt = 0L;
- count.file_bin_cnt = 0L;
- count.line_prnt_cnt = 0L;
- pageline_cnt = 0L;
-
- /* clearout error code (macro) */
- clearerr(ifp);
-
- /*
- ** loop through the input file -- one character at a time
- ** if end-of-file then exit loop
- ** if error then report it, close file, and exit to next file
- ** always count raw characters for file
- ** go examine character
- ** if eol (end-of-line) then
- ** add trailing backspaces back to printable count
- ** (the printhead was past the current position)
- ** see if this line has most printable chars so far?
- ** if more than previous high, save new high
- ** add printable count for line to file
- ** count the line
- ** reset print counter for line to margin size
- ** reset backspace counter for next line
- ** if we're doing pages and we just filled one
- ** reset page-line count to 1 (first one)
- ** count the page
- ** else (not eol) if ff (formfeed) char then
- ** add trailing backspaces back to printable count
- ** (the printhead was past the current position)
- ** if print-count says something's on this line besides margin then
- ** see if this line has most printable chars so far?
- ** if more than previous high, save new high
- ** add printable count for line to file
- ** count the line
- ** reset print counter for line to margin size
- ** reset backspace counter for next line
- ** reset page-line count to 1 (first one)
- ** count the page
- ** else (not eol and not ff ) if backspace char then
- ** if there are print positions?
- ** yes, so move back one print position
- ** (move even if this means going into the margin)
- ** else (not eol and not ff and not backspace) if binary char then
- ** accumulate countert for binary chars
- ** else (not eol and not ff and not backspace and not binary char) then
- ** accumulate printable counters for line
- ** if this printer wraps and we've exceeded line's capacity then
- ** (this is a new line, see above)
- ** calculate new print position by removing 1st part of line
- ** add same value to file-print-cnt
- ** add one to line count
- ** discard counted, trailing backspaces
- ** if we're doing pages and we just filled one
- ** reset line count to 1 (first one)
- ** count the page
- ** else (we did not need to wrap line)
- ** if there are trailing backspace chars?
- ** remove one (it just got printed over)
- ** this way we only count TRAILING backspace chars
- */
- while (1) {
- c = getc(ifp);
- if (feof(ifp)) break;
- if (ferror(ifp)) {
- (void) perror(pname);
- (void) close(ifp);
- return(-1);
- }
- tmpcount.file_raw_cnt++;
- rc = do_char(c, tmpcount.line_prnt_cnt);
- if (rc == EOLFLAG) {
- tmpcount.line_prnt_cnt += backspace_cnt;
- if (tmpcount.line_prnt_cnt > count.line_prnt_cnt) {
- count.line_prnt_cnt = tmpcount.line_prnt_cnt;
- }
- tmpcount.file_prnt_cnt += tmpcount.line_prnt_cnt;
- tmpcount.file_line_cnt++;
- tmpcount.line_prnt_cnt = margin;
- backspace_cnt = 0L;
- if (pagelen && ++pageline_cnt > pagelen) {
- pageline_cnt = 1L;
- tmpcount.file_page_cnt++;
- }
- } else if (rc == FFFLAG) {
- tmpcount.line_prnt_cnt += backspace_cnt;
- if (tmpcount.line_prnt_cnt > margin) {
- if (tmpcount.line_prnt_cnt > count.line_prnt_cnt) {
- count.line_prnt_cnt = tmpcount.line_prnt_cnt;
- }
- tmpcount.file_prnt_cnt += tmpcount.line_prnt_cnt;
- tmpcount.file_line_cnt++;
- tmpcount.line_prnt_cnt = margin;
- }
- backspace_cnt = 0L;
- pageline_cnt = 1L;
- tmpcount.file_page_cnt++;
- } else if (rc == BCKFLAG) {
- if (tmpcount.line_prnt_cnt > 0L) {
- backspace_cnt++;
- tmpcount.line_prnt_cnt--;
- }
- } else if (rc == BINFLAG) {
- tmpcount.file_bin_cnt++;
- } else {
- tmpcount.line_prnt_cnt += rc;
- if (wrappos && tmpcount.line_prnt_cnt > wrappos) {
- count.line_prnt_cnt = wrappos;
- tmpcount.file_prnt_cnt += wrappos;
- tmpcount.line_prnt_cnt -= wrappos;
- tmpcount.file_line_cnt++;
- backspace_cnt = 0L;
- if (pagelen && ++pageline_cnt > pagelen) {
- pageline_cnt = 1L;
- tmpcount.file_page_cnt++;
- }
- } else {
- if (backspace_cnt) backspace_cnt--;
- }
- }
- } /* end while */
-
- /* move these values to their permanent locations */
- count.file_page_cnt = tmpcount.file_page_cnt;
- count.file_line_cnt = tmpcount.file_line_cnt;
- count.file_raw_cnt = tmpcount.file_raw_cnt;
- count.file_prnt_cnt = tmpcount.file_prnt_cnt;
- count.file_bin_cnt = tmpcount.file_bin_cnt;
-
- /* accumulate file totals in case we have > 1 file */
- totals->file_page_cnt += count.file_page_cnt;
- totals->file_line_cnt += count.file_line_cnt;
- totals->file_raw_cnt += count.file_raw_cnt;
- totals->file_prnt_cnt += count.file_prnt_cnt;
- totals->file_bin_cnt += count.file_bin_cnt;
-
- /* file totals again, look for largest at that level */
- if (count.line_prnt_cnt > totals->line_prnt_cnt) {
- totals->line_prnt_cnt = count.line_prnt_cnt;
- }
-
- /* print stats for one file */
- (void) print_stats(&count, infile);
-
- /* if not stdin, then close the input file */
- if (ifp != stdin) {
- (void) fclose(ifp);
- }
-
- return(0);
- }
-
- /*
- ** Function name: do_char()
- **
- ** Input args:
- ** c, integer, the character being examine
- ** p, long, the current print position
- **
- ** Output args:
- ** char count, long, the number of positions to move print head
- ** (could be set to EOLFLAG if end-of-line was found)
- **
- ** Synopsis:
- ** Identify the character being read
- */
-
- long
- do_char(c,p)
- int c; /* character being examined */
- long p; /* current print position */
- {
- long remainder; /* intermediate computed vaue */
-
- /*
- ** examine the character
- ** if tab
- ** if we have a tab value, compute using remainder and number of pos
- ** if no tab value, then return bin flag (printer must not know tab!)
- ** if backspace
- ** if backspace flag then return backspace else return binary char
- ** if newline
- ** return flag
- ** if formfeed
- ** if formfeed flag then return newline else return binary char
- */
- switch(c) {
- case '\t':
- if (tabnum) {
- remainder = ((++p)+tabnum)%tabnum;
- if (remainder == 0) {
- return(1L);
- } else {
- return(1L + tabnum - remainder);
- }
- } else {
- return(BINFLAG);
- }
- case '\b':
- if (backspace) {
- return(BCKFLAG);
- } else {
- return(BINFLAG);
- }
- case '\n':
- return(EOLFLAG);
- case '\f':
- if (formfeed) {
- return(FFFLAG);
- } else {
- return(BINFLAG);
- }
- }
-
- /*
- ** if none of the above then return whether this char
- ** was binary or, if not, the advance one space
- */
- if (isprint(c)) {
- return(1L);
- } else {
- return(BINFLAG);
- }
- }
-
- /*
- ** Function: prnt_stats()
- **
- ** Input args:
- ** count, struct pointer, contains numbers that need printing
- ** filename, string, name of file being processed
- **
- ** Synopsys:
- ** Just print what we're passed
- */
-
- int
- print_stats(count, filename)
- struct counter *count; /* where numbers to print are */
- char *filename; /* file name */
- {
- /*
- ** print format depends on commandline flag
- ** ensure order is the same regardless of format
- ** short format modeled after wc(1) command
- */
- if (verbose) {
- (void) fprintf(stdout,
- "results for: %s\n", filename);
- (void) fprintf(stdout,
- "total pages in file: %ld\n", count->file_page_cnt);
- (void) fprintf(stdout,
- "total lines in file: %ld\n", count->file_line_cnt);
- (void) fprintf(stdout,
- "total characters in file: %ld\n", count->file_raw_cnt);
- (void) fprintf(stdout,
- "total printing positions in file: %ld\n", count->file_prnt_cnt);
- (void) fprintf(stdout,
- "total binary characters in file: %ld\n", count->file_bin_cnt);
- (void) fprintf(stdout,
- "most printing positions in line: %ld\n", count->line_prnt_cnt);
- } else {
- (void) fprintf(stdout, "%7ld%7ld%7ld%7ld%7ld%7ld %s\n",
- count->file_page_cnt,
- count->file_line_cnt,
- count->file_raw_cnt,
- count->file_prnt_cnt,
- count->file_bin_cnt,
- count->line_prnt_cnt,
- filename);
- }
- return(0);
- }
- /* eof */
- @//E*O*F linel.c//
- chmod u=rw,g=rw,o=r linel.c
-
- echo Inspecting for damage in transit...
- temp=/tmp/shar$$; dtemp=/tmp/.shar$$
- trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
- cat > $temp <<\!!!
- 9 56 339 README
- 124 846 4911 linel.1
- 659 2561 17601 linel.c
- 792 3463 22851 total
- !!!
- wc README linel.1 linel.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
- if [ -s $dtemp ]
- then echo "Ouch [diff of wc output]:" ; cat $dtemp
- else echo "No problems found."
- fi
- exit 0
-