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