home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / isrcline.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  52 lines

  1. ############################################################################
  2. #
  3. #    File:     isrcline.icn
  4. #
  5. #    Subject:  Program to count code lines in Icon program
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 7, 1997
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program counts the number of lines in a Icon program that actually
  18. #  contain code, as opposed to being comments or blank lines.
  19. #
  20. #  Note:  preprocessor directives are counted as code lines.
  21. #
  22. ############################################################################
  23. #
  24. #  Links:  numbers
  25. #
  26. ############################################################################
  27.  
  28. link numbers
  29.  
  30. procedure main()
  31.    local total, chaff, code, line
  32.  
  33.    total := chaff := 0
  34.  
  35.    while line := read() do {
  36.       total +:= 1
  37.       line ? {
  38.          tab(many(' \t'))
  39.          if ="#" | pos(0) then chaff +:= 1
  40.          }
  41.       }
  42.  
  43.    code := total - chaff
  44.  
  45.    write(left("total lines:", 17), right(total, 6))
  46.    write(left("code lines:", 17), right(code, 6))
  47.    write(left("non-code lines:", 17), right(chaff, 6))
  48.    write()
  49.    write(left("percentage code:", 17), fix(100 * code, total, 7, 2))
  50.  
  51. end
  52.