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 / what.icn < prev    next >
Text File  |  2001-05-02  |  2KB  |  70 lines

  1. ############################################################################
  2. #
  3. #    File:     what.icn
  4. #
  5. #    Subject:  Program to identify source-code information
  6. #
  7. #    Author:   Phillip Lee Thomas
  8. #
  9. #    Date:     May 2, 2001
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. # Writes all strings beginning with "@" followed by "(#)"
  18. #     and ending with null, newline, quotes, greater-than
  19. #     or backslash. Follows UNIX what conventions.
  20. #
  21. ############################################################################
  22. #
  23. #  Requires:  Tested with DOS, AIX UNIX
  24. #
  25. ############################################################################
  26. #
  27. #  Links:    basename
  28. #
  29. ############################################################################
  30.  
  31. link basename
  32.  
  33. procedure main(args)
  34.    local ID, line, terminator, key, f, fin, here
  35.  
  36.    ID := "@(#)what.icn (1.0) - plt - 2 May, 96"
  37.    ID := "@(#)-- Identify source code information."
  38.  
  39.    line := ""
  40.    terminator := '\0\n\">\\' # ++ char(10)
  41.    key := "@" || "(#)"
  42.  
  43.    if *args = 0 then  {
  44.       write("Usage: ", basename(&progname, ".EXE"),
  45.          " file1 [file2 [file3]]")
  46.       exit(1)
  47.       }
  48.  
  49.    while f := pop(args) do  {
  50.       fin := open(f, "ru") | next
  51.       write(f, ":")
  52.  
  53.       while line ||:= reads(fin, 32768)  do {
  54.          line ? {
  55.             here := 1
  56.             every (tab(here := upto('@')) | next) do {
  57.                if match(key) then  {
  58.                   move(4)
  59.                   write('\t', tab(here := upto(terminator)))
  60.                   }
  61.                }
  62.             line := line[here:0]
  63.             }  # line
  64.          } # while
  65.       close(fin)
  66.       }  # while files
  67.    write("[Time: ", &time / 1000.0, " seconds.]")
  68.    exit(0)
  69. end
  70.