comparison pyrect/template/grep.cbc @ 40:962ae4154724

add CbCGREPTranslator.
author Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp>
date Tue, 20 Jul 2010 17:26:54 +0900
parents
children ffbbdd33881d
comparison
equal deleted inserted replaced
39:43b277a00905 40:962ae4154724
1 void grep(char * regexp, FILE *f) {
2 goto next_line();
3 return;
4 }
5
6 void grepmain(int argc, char* argv[]) {
7 int i;
8
9 if (argc < 2) {
10 fprintf(stderr, "usage: grep regexp [file ...]");
11 exit(0);
12 }
13 if (argc == 2) {
14 grep(argv[1], stdin);
15 } else {
16 for (i = 2; i < argc; i++) {
17 filename = argv[i];
18 f = fopen(filename, "r");
19 if (f == NULL) {
20 fprintf(stderr, "can't open %s:", filename);
21 continue;
22 }
23 if (READBUFSIZE > 0)
24 setvbuf(f, readbuf, _IOFBF, READBUFSIZE);
25 grep(argv[1], f);
26 fclose(f);
27 }
28 }
29
30 return;
31 }