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
1515 * privileges were granted by DECUS.
1616 */
1717 #include <stdio.h>
18+#include <stdlib.h>
1819
1920 /*
2021 * grep
@@ -25,7 +26,6 @@ · 4 unmodified lines
2526 * See below for more information.
2627 */
2728
28−#if 0
2929 char *documentation[] = {
3030 "grep searches a file for a given pattern. Execute by",
3131 " grep [flags] regular_expression file_list\n",
@@ -70,7 +70,6 @@ char *patdoc[] = { · 38 unmodified lines
7070 " [a-z] matches alphabetics, while [z-a] never matches.",
7171 "The concatenation of regular expressions is a regular expression.",
7272 0};
73−#endif
7473
7574 #define LMAX 512
7675 #define PMAX 256
@@ -97,6 +96,10 @@ char *pp, lbuf[LMAX], pbuf[PMAX]; · 20 unmodified lines
9796
9897 char *cclass();
9998 char *pmatch();
99+void store(int);
100+void error(char *);
101+void badpat(char *, char *, char *);
102+int match(void);
100103
101104
102105 /*** Display a file name *******************************/
@@ -300,7 +303,7 @@ void badpat(char *message, char *source, char *stop) · 197 unmodified lines
300303 /* char *stop; // Pattern end */
301304 {
302305 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",
304307 stop-source, stop[-1]);
305308 error("?GREP-E-Bad pattern\n");
306309 }
@@ -338,7 +341,7 @@ void grep(FILE *fp, char *fn) · 31 unmodified lines
338341 }
339342
340343 /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/
341−void match()
344+int match()
342345 {
343346 char *l; /* Line pointer */
344347
@@ -368,7 +371,7 @@ char *pmatch(char *line, char *pattern) · 23 unmodified lines
368371 p = pattern;
369372 while ((op = *p++) != ENDPAT) {
370373 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",
372375 l-line, *l, *l, op);
373376 switch(op) {
374377
tests/tests2/46_grep.expect+3−0
@@ -0,0 +1,3 @@
1+File 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
8484 66_macro_concat_end.test \
8585 67_macro_concat.test
8686
87−# 30_hanoi.test -- seg fault in the code, gcc as well
8887 # 34_array_assignment.test -- array assignment is not in C standard
89−# 46_grep.test -- does not compile even with gcc
9088
91−SKIP = 34_array_assignment.test 46_grep.test
89+SKIP = 34_array_assignment.test
9290
9391 # some tests do not pass on all platforms, remove them for now
9492 ifeq ($(TARGETOS),Darwin)
@@ -102,6 +100,7 @@ endif · 7 unmodified lines
102100 # Some tests might need arguments
103101 ARGS =
104102 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
103+46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c
105104
106105 all test: $(filter-out $(SKIP),$(TESTS))
107106

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