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 / itrcfltr.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  70 lines

  1. ############################################################################
  2. #
  3. #    File:     itrcfltr.icn
  4. #
  5. #    Subject:  Program to filter trace output
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     July 14, 1997
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program filters trace output.  If there are command-line arguments,
  18. #  they are taken as procedure names, and only those lines with those
  19. #  names are written.  If there are no command-line arguments, all lines
  20. #  are written.
  21. #
  22. #  The names of procedures to pass through can be given in a "response"
  23. #  file as accepted by options(), as in
  24. #
  25. #    itrcfltr @names <trace_file
  26. #
  27. #  where names is a file containing the names to be passed through.
  28. #
  29. #  The following option is supported:
  30. #
  31. #    -a    list all trace messages; overrides any procedure names
  32. #          given
  33. #
  34. ############################################################################
  35. #
  36. #  See also:  options.icn
  37. #
  38. ############################################################################
  39. #
  40. #  Links: itrcline, options
  41. #
  42. ############################################################################
  43.  
  44. link itrcline
  45. link options
  46.  
  47. $define CountWidth 10
  48.  
  49. procedure main(args)
  50.    local line, name, selected, opts
  51.  
  52.    opts := options(args, "a")
  53.    
  54.    selected := set(args)
  55.  
  56.    if (*selected = 0) | \opts["a"] then        # if -a or no names produce all
  57.       every write(itrcline(&input))
  58.    else {
  59.       every line := itrcline(&input) do {
  60.          line ? {
  61.             move(21) | break            # line after trace output?
  62.             tab(many('| '))            # depth bars
  63.             name := tab(upto('( '))        # procedure name
  64.             if member(selected, name) then write(line)
  65.             }
  66.          }
  67.       }
  68.  
  69. end
  70.