home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / cmplngmg / cl_jun89.arc / AWK210.ARC / FMT.AWK < prev    next >
Text File  |  1988-03-01  |  426b  |  21 lines

  1. # fmt - format
  2. #    input:  text
  3. #    output: text formatted into lines of <= 60 characters
  4.  
  5. /./  { for (i = 1; i <= NF; i++) addword($i) }
  6. /^$/ { printline(); print "" }
  7. END  { printline() }
  8.  
  9. function addword(w) {
  10.     if (length(line) + length(w) > 60)
  11.         printline()
  12.     line = line " " w
  13. }
  14.  
  15. function printline() {
  16.     if (length(line) > 0) {
  17.         print substr(line, 2)
  18.         line = ""
  19.     }
  20. }
  21.