home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / mgrdemos.zoo / demo / sh / c_menu < prev    next >
Encoding:
Text File  |  1989-01-25  |  1.4 KB  |  49 lines

  1. #!/bin/sh
  2. #                        Copyright (c) 1988 Bellcore
  3. #                            All Rights Reserved
  4. #       Permission is granted to copy or use this program, EXCEPT that it
  5. #       may not be sold for profit, the copyright notice must be reproduced
  6. #       on copies, and credit should be given to Bellcore where it is due.
  7. #       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  8.  
  9. #    $Header: c_menu,v 1.1 88/07/07 14:34:11 sau Exp $
  10. #    $Source: /tmp/mgrsrc/demo/sh/RCS/c_menu,v $
  11.  
  12.  
  13. #    filter cc error messages into mgr menus
  14.  
  15. #    look for error messages of the form:
  16. #    "foo.c", line 19: word undefined
  17.  
  18. sed -n -e 's/^"\([^"]*\)", line \([0-9]*\): \(.*\)/\1@\2@\3/p' | \
  19.  
  20. #    turn the error message into menus
  21.  
  22. awk -F@ '
  23. BEGIN    {    SEP="❎"    # menu field seperator
  24.         ESC=""    # mgr escape char
  25.         MAX=15        # max errors per file
  26.         }
  27.  
  28.     { if (file == $1 && i++ <= MAX) {    # at error to current file name
  29.         item[menu] = item[menu] SEP $3 
  30.         action[menu] = action[menu] SEP $2 "G"
  31.         }
  32.     else if (file != $1) {            # get new file name
  33.         menu++;  i=0;  file=$1
  34.         main_item=main_item $1 SEP
  35.         main_action=main_action ":n " $1 "\\r" SEP
  36.         }
  37.     }
  38.  
  39. END    {    text = SEP main_item main_action
  40.         printf "%s%d,%dm%s",ESC,1,length(text),text    # main menu
  41.         for(i=1;i<=menu;i++) {
  42.             text=item[i] action[i] SEP
  43.             printf "%s%d,%dm%s",ESC,i+1,length(text),text # errors
  44.             printf "%s%d,%d,%d,15m",ESC,1,i-1,i+1    # menu links
  45.             }
  46.         printf "%s1m",ESC        # select menu
  47.     }
  48. '
  49.