home *** CD-ROM | disk | FTP | other *** search
- The following file is my context'' program for displaying the context of
- a message of the general form
-
- <garbage> filename <garbege> linenumber <garbage>
-
- Sample usage:
-
- Script started on Fri Jun 6 18:29:09 1986
- % grep range context.c
- int cxtrange = 3;
- if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
- cxtrange = 3;
- lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
- hilino = cxtln + cxtrange;
-
- % grep -n range /dev/null context.c | context # /dev/null forces filename
- **************
- * context.c:6:int cxtrange = 3;
- *****
-
- char curfile[512];
- FILE *curfp = NULL;
- * int cxtrange = 3;
-
- char *gets();
-
-
- **************
- * context.c:20: if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
- *****
- exit(1);
- }
- if (argc == 2)
- * if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
- cxtrange = 3;
- while (gets(context) != (char *) 0) {
- for (cp = context; *cp != '.' && *cp != '/' && *cp != '-' && *cp != '_' && !isalnum(*cp); cp++)
-
- **************
- * context.c:21: cxtrange = 3;
- *****
- }
- if (argc == 2)
- if ((cxtrange = atol(argv[1])) < 1 || cxtrange > 25)
- * cxtrange = 3;
- while (gets(context) != (char *) 0) {
- for (cp = context; *cp != '.' && *cp != '/' && *cp != '-' && *cp != '_' && !isalnum(*cp); cp++)
- if (*cp == '\0')
-
- **************
- * context.c:49: lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
- *****
- if (*fcp == '\0')
- continue;
- cxtln = atol(fcp);
- * lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
- hilino = cxtln + cxtrange;
- if (lolino < curln) {
- fseek(curfp, 0L, 0);
-
- **************
- * context.c:50: hilino = cxtln + cxtrange;
- *****
- continue;
- cxtln = atol(fcp);
- lolino = (cxtln < cxtrange - 1? 1: cxtln - cxtrange);
- * hilino = cxtln + cxtrange;
- if (lolino < curln) {
- fseek(curfp, 0L, 0);
- curln = 0;
-
- %
- script done on Fri Jun 6 18:29:55 1986
-
- Also useful for examining the causes of C errors (although I've received mixed
- reviews on that; seems that BSD4.2 has a smarter'' program callederrors'').
-
- Simply compile context.c -- there are no V7/S5/BSD dependencies that I know
- of. Then enjoy.
-
- --Brandon
-