diff options
| author | minux <minux.ma@gmail.com> | 2014-04-12 14:04:10 -0400 |
|---|---|---|
| committer | minux <minux.ma@gmail.com> | 2014-04-12 14:04:10 -0400 |
| commit | aa255f37f24abc320b1101fb85f7e9f4d9e21cff (patch) | |
| tree | 078c0a79728e6d8add3c157d1ad894528b67fde7 /tests/tests2/46_grep.c | |
| parent | 0a51386960bcf116cce03fe61e21effd875cd792 (diff) | |
| download | tinycc-aa255f37f24abc320b1101fb85f7e9f4d9e21cff.tar.gz tinycc-aa255f37f24abc320b1101fb85f7e9f4d9e21cff.tar.bz2 | |
tests2: fix and enable 46_grep test.
Diffstat (limited to 'tests/tests2/46_grep.c')
| -rw-r--r-- | tests/tests2/46_grep.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/tests2/46_grep.c b/tests/tests2/46_grep.c index 27589a4..3123bc3 100644 --- a/tests/tests2/46_grep.c +++ b/tests/tests2/46_grep.c @@ -15,6 +15,7 @@ * privileges were granted by DECUS. */ #include <stdio.h> +#include <stdlib.h> /* * grep @@ -25,7 +26,6 @@ * See below for more information. */ -#if 0 char *documentation[] = { "grep searches a file for a given pattern. Execute by", " grep [flags] regular_expression file_list\n", @@ -70,7 +70,6 @@ char *patdoc[] = { " [a-z] matches alphabetics, while [z-a] never matches.", "The concatenation of regular expressions is a regular expression.", 0}; -#endif #define LMAX 512 #define PMAX 256 @@ -97,6 +96,10 @@ char *pp, lbuf[LMAX], pbuf[PMAX]; char *cclass(); char *pmatch(); +void store(int); +void error(char *); +void badpat(char *, char *, char *); +int match(void); /*** Display a file name *******************************/ @@ -300,7 +303,7 @@ void badpat(char *message, char *source, char *stop) /* char *stop; // Pattern end */ { fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); - fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", + fprintf(stderr, "-GREP-E-Stopped at byte %ld, '%c'\n", stop-source, stop[-1]); error("?GREP-E-Bad pattern\n"); } @@ -338,7 +341,7 @@ void grep(FILE *fp, char *fn) } /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ -void match() +int match() { char *l; /* Line pointer */ @@ -368,7 +371,7 @@ char *pmatch(char *line, char *pattern) p = pattern; while ((op = *p++) != ENDPAT) { if (debug > 1) - printf("byte[%d] = 0%o, '%c', op = 0%o\n", + printf("byte[%ld] = 0%o, '%c', op = 0%o\n", l-line, *l, *l, op); switch(op) { |
