home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / context / README < prev   
Encoding:
Text File  |  1986-11-30  |  2.1 KB  |  82 lines

  1. The following file is my context'' program for displaying the context of
  2. a message of the general form
  3.  
  4.     <garbage> filename <garbege> linenumber <garbage>
  5.  
  6. Sample usage:
  7.  
  8. Script started on Fri Jun  6 18:29:09 1986
  9. % grep range context.c
  10. int cxtrange = 3;
  11.         if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
  12.             cxtrange = 3;
  13.         lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
  14.         hilino = cxtln + cxtrange;
  15.  
  16. % grep -n range /dev/null context.c | context    # /dev/null forces filename
  17. **************
  18. * context.c:6:int cxtrange = 3;
  19. *****
  20.   
  21.   char curfile[512];
  22.   FILE *curfp = NULL;
  23. * int cxtrange = 3;
  24.   
  25.   char *gets();
  26.   
  27.  
  28. **************
  29. * context.c:20:        if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
  30. *****
  31.           exit(1);
  32.       }
  33.       if (argc == 2)
  34. *         if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
  35.               cxtrange = 3;
  36.       while (gets(context) != (char *) 0) {
  37.           for (cp = context; *cp != '.' && *cp != '/' && *cp != '-' && *cp != '_' && !isalnum(*cp); cp++)
  38.  
  39. **************
  40. * context.c:21:            cxtrange = 3;
  41. *****
  42.       }
  43.       if (argc == 2)
  44.           if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
  45. *             cxtrange = 3;
  46.       while (gets(context) != (char *) 0) {
  47.           for (cp = context; *cp != '.' && *cp != '/' && *cp != '-' && *cp != '_' && !isalnum(*cp); cp++)
  48.               if (*cp == '\0')
  49.  
  50. **************
  51. * context.c:49:        lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
  52. *****
  53.           if (*fcp == '\0')
  54.               continue;
  55.           cxtln = atol(fcp);
  56. *         lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
  57.           hilino = cxtln + cxtrange;
  58.           if (lolino < curln) {
  59.               fseek(curfp, 0L, 0);
  60.  
  61. **************
  62. * context.c:50:        hilino = cxtln + cxtrange;
  63. *****
  64.               continue;
  65.           cxtln = atol(fcp);
  66.           lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
  67. *         hilino = cxtln + cxtrange;
  68.           if (lolino < curln) {
  69.               fseek(curfp, 0L, 0);
  70.               curln = 0;
  71.  
  72. script done on Fri Jun  6 18:29:55 1986
  73.  
  74. Also useful for examining the causes of C errors (although I've received mixed
  75. reviews on that; seems that BSD4.2 has a smarter'' program callederrors'').
  76.  
  77. Simply compile context.c -- there are no V7/S5/BSD dependencies that I know
  78. of.  Then enjoy.
  79.  
  80.                     --Brandon
  81.