History

tests2: fix and enable 46_grep test.

minux committed 12 years ago

Commit aa255f31 parent 0a513863 files · +13 −8Browse files

Unified · Split

3 files
  1. tests/tests2/46_grep.c +8 −5
  2. tests/tests2/46_grep.expect +3 −0
  3. tests/tests2/Makefile +2 −3
tests/tests2/46_grep.c+8−5
@@ -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 * grep21 * 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
29char *documentation[] = {29char *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 51274#define LMAX 512
76#define PMAX 25675#define PMAX 256
@@ -97,6 +96,10 @@ char *pp, lbuf[LMAX], pbuf[PMAX]; · 20 unmodified lines
97 96
98char *cclass();97char *cclass();
99char *pmatch();98char *pmatch();
99void store(int);
100void error(char *);
101void badpat(char *, char *, char *);
102int 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 ***/
341void match()344int 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
tests/tests2/46_grep.expect+3−0
@@ -0,0 +1,3 @@
1File 46_grep.c:
2/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
3
tests/tests2/Makefile+2−3
@@ -84,11 +84,9 @@ TESTS = \ · 83 unmodified lines
84 66_macro_concat_end.test \84 66_macro_concat_end.test \
85 67_macro_concat.test85 67_macro_concat.test
86 86
87# 30_hanoi.test -- seg fault in the code, gcc as well
88# 34_array_assignment.test -- array assignment is not in C standard87# 34_array_assignment.test -- array assignment is not in C standard
89# 46_grep.test -- does not compile even with gcc
90 88
91SKIP = 34_array_assignment.test 46_grep.test89SKIP = 34_array_assignment.test
92 90
93# some tests do not pass on all platforms, remove them for now91# some tests do not pass on all platforms, remove them for now
94ifeq ($(TARGETOS),Darwin)92ifeq ($(TARGETOS),Darwin)
@@ -102,6 +100,7 @@ endif · 7 unmodified lines
102# Some tests might need arguments100# Some tests might need arguments
103ARGS =101ARGS =
10431_args.test : ARGS = arg1 arg2 arg3 arg4 arg510231_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
10346_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c
105 104
106all test: $(filter-out $(SKIP),$(TESTS))105all test: $(filter-out $(SKIP),$(TESTS))
107 106

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t