Xref: utzoo comp.binaries.ibm.pc.d:10057 comp.lang.postscript:6479 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!ncifcrf!fcs260c2!toms From: toms@fcs260c2.ncifcrf.gov (Tom Schneider) Newsgroups: comp.binaries.ibm.pc.d,comp.lang.postscript Subject: Re: Trying to chop long PS lines Summary: pascal program to wrap postscript Message-ID: <1916@fcs280s.ncifcrf.gov> Date: 23 Oct 90 16:03:16 GMT References: <11144.27239e63@ecs.umass.edu> Sender: news@ncifcrf.gov Followup-To: comp.binaries.ibm.pc.d Organization: NCI Supercomputer Facility, Frederick, MD Lines: 93 In article <11144.27239e63@ecs.umass.edu> ssircar@ecs.umass.edu (Santanu sircar) writes: >Does anyone know of an utility which would wrap very long lines in a file? It seems that in these modern times people still insist on making long file lines. The output of the f2ps program (which converts the fig program;s graphics to PostScript) is long lines, and these cause my LaserWriter ntxII to die. The general rule is to avoid lines being longer than 80 characers. Following is a filter, written in Pascal, that wraps lines between words that should work for you. It should compile on a VAX. > Santanu Sircar BITNET: ssircar@umaecs.bitnet > University of Massachusetts/Amherst INTERNET: ssircar@ecs.umass.edu Tom Schneider National Cancer Institute Laboratory of Mathematical Biology Frederick, Maryland 21702-1201 toms@ncifcrf.gov - snip - snip - snip - snip - snip - snip - snip - snip - snip - snip - snip program ww(input,output); (* ww: word wrap Tom Schneider, 1988 *) const (* begin module version *) version = 1.01; (* of ww 1988 September 14 origin 1988 aug 22 *) (* end module version *) (* begin module describe.ww *) (* name ww: word wrap synopsis ww(input: in, output: out) files input: text to be wrapped output: wrapped text description This Pascal program takes ASCII text and filters it. Lines longer than the constant maxline are altered by replacing the first space after position maxline with a carriage return. This has the effect of wrapping the lines between 'words'. The original purpose was to get around a design flaw in another program. The program fig produces graphics for X and NeWS windows. The graphics is converted to PostScript by another program, f2ps. Unfortunately f2ps was poorly designed: the PostScript produced has many lines longer than 70 characters. When this PostScript code is sent to the (latest as of 1988) Apple NTX LaserWriterII, the printer dies. By running this filter, the problem is bypassed. Moral: never make lines longer than 80 characters! author Thomas Dana Schneider bugs the constant maxline is fixed at compile time, of course. *) (* end module describe.ww *) maxline = 70; (* maximum width of output lines *) var c: char; (* a character in the input *) n: integer; (* number of characters written to output so far *) waitforspace: boolean; (* true if waiting for the next space to appear *) begin while not eof(input) do begin n := 0; (* no characters written out so far on this line *) waitforspace := false; while not eoln(input) do begin read(input,c); if n > maxline then waitforspace := true; if waitforspace and (c = ' ') then begin writeln(output); (* replace space with carriage return *) n := 0; (* no characters written out so far on this line *) waitforspace := false; end else begin write(output,c); n := n + 1; end end; readln(input); writeln(output); end end.