| @@ -15,6 +15,7 @@ · 14 unmodified lines |
| 15 | * privileges were granted by DECUS. | 15 | * privileges were granted by DECUS. |
| 16 | */ | 16 | */ |
| 17 | #include <stdio.h> | 17 | #include <stdio.h> |
| | 18 | #include <stdlib.h> |
| 18 | | 19 | |
| 19 | /* | 20 | /* |
| 20 | * grep | 21 | * grep |
| @@ -25,7 +26,6 @@ · 4 unmodified lines |
| 25 | * See below for more information. | 26 | * See below for more information. |
| 26 | */ | 27 | */ |
| 27 | | 28 | |
| 28 | #if 0 | | |
| 29 | char *documentation[] = { | 29 | char *documentation[] = { |
| 30 | "grep searches a file for a given pattern. Execute by", | 30 | "grep searches a file for a given pattern. Execute by", |
| 31 | " grep [flags] regular_expression file_list\n", | 31 | " grep [flags] regular_expression file_list\n", |
| @@ -70,7 +70,6 @@ char *patdoc[] = { · 38 unmodified lines |
| 70 | " [a-z] matches alphabetics, while [z-a] never matches.", | 70 | " [a-z] matches alphabetics, while [z-a] never matches.", |
| 71 | "The concatenation of regular expressions is a regular expression.", | 71 | "The concatenation of regular expressions is a regular expression.", |
| 72 | 0}; | 72 | 0}; |
| 73 | #endif | | |
| 74 | | 73 | |
| 75 | #define LMAX 512 | 74 | #define LMAX 512 |
| 76 | #define PMAX 256 | 75 | #define PMAX 256 |
| @@ -97,6 +96,10 @@ char *pp, lbuf[LMAX], pbuf[PMAX]; · 20 unmodified lines |
| 97 | | 96 | |
| 98 | char *cclass(); | 97 | char *cclass(); |
| 99 | char *pmatch(); | 98 | char *pmatch(); |
| | 99 | void store(int); |
| | 100 | void error(char *); |
| | 101 | void badpat(char *, char *, char *); |
| | 102 | int match(void); |
| 100 | | 103 | |
| 101 | | 104 | |
| 102 | /*** Display a file name *******************************/ | 105 | /*** Display a file name *******************************/ |
| @@ -300,7 +303,7 @@ void badpat(char *message, char *source, char *stop) · 197 unmodified lines |
| 300 | /* char *stop; // Pattern end */ | 303 | /* char *stop; // Pattern end */ |
| 301 | { | 304 | { |
| 302 | fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); | 305 | fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); |
| 303 | fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", | 306 | fprintf(stderr, "-GREP-E-Stopped at byte %ld, '%c'\n", |
| 304 | stop-source, stop[-1]); | 307 | stop-source, stop[-1]); |
| 305 | error("?GREP-E-Bad pattern\n"); | 308 | error("?GREP-E-Bad pattern\n"); |
| 306 | } | 309 | } |
| @@ -338,7 +341,7 @@ void grep(FILE *fp, char *fn) · 31 unmodified lines |
| 338 | } | 341 | } |
| 339 | | 342 | |
| 340 | /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ | 343 | /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ |
| 341 | void match() | 344 | int match() |
| 342 | { | 345 | { |
| 343 | char *l; /* Line pointer */ | 346 | char *l; /* Line pointer */ |
| 344 | | 347 | |
| @@ -368,7 +371,7 @@ char *pmatch(char *line, char *pattern) · 23 unmodified lines |
| 368 | p = pattern; | 371 | p = pattern; |
| 369 | while ((op = *p++) != ENDPAT) { | 372 | while ((op = *p++) != ENDPAT) { |
| 370 | if (debug > 1) | 373 | if (debug > 1) |
| 371 | printf("byte[%d] = 0%o, '%c', op = 0%o\n", | 374 | printf("byte[%ld] = 0%o, '%c', op = 0%o\n", |
| 372 | l-line, *l, *l, op); | 375 | l-line, *l, *l, op); |
| 373 | switch(op) { | 376 | switch(op) { |
| 374 | | 377 | |