Last change
on this file since 3a2ae91 was
9e0afb5,
checked in by Mateusz Hromada <ruanda@…>, 15 years ago
|
Migration to new build system.
|
-
Property mode set to
100644
|
File size:
917 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <string.h> |
---|
4 | #include <regex.h> |
---|
5 | |
---|
6 | char buf[5000]; |
---|
7 | |
---|
8 | int main(int argc, char **argv) |
---|
9 | { |
---|
10 | |
---|
11 | char *pattern; |
---|
12 | char eoln; |
---|
13 | regex_t re; |
---|
14 | |
---|
15 | int firstline = 1; |
---|
16 | |
---|
17 | if( argc < 2 ) |
---|
18 | { |
---|
19 | /* pattern="[ \t]*([0-9]+[ \t]+){2}EOS([ \t].*)?"; */ |
---|
20 | pattern = "[ \t]*BOS([ \t].*)?"; |
---|
21 | } |
---|
22 | else |
---|
23 | { |
---|
24 | pattern = argv[1]; |
---|
25 | } |
---|
26 | |
---|
27 | if( argc < 3 ) |
---|
28 | { |
---|
29 | eoln = '\f'; |
---|
30 | } |
---|
31 | else |
---|
32 | { |
---|
33 | eoln = atoi(argv[2]); |
---|
34 | } |
---|
35 | |
---|
36 | if( 0 != regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) ) |
---|
37 | { |
---|
38 | fprintf(stderr, "Invalid pattern.\n"); |
---|
39 | return 1; |
---|
40 | } |
---|
41 | |
---|
42 | while( fgets(buf, 5000, stdin) ) |
---|
43 | { |
---|
44 | buf[strlen(buf)-1] = '\0'; |
---|
45 | if( firstline ) |
---|
46 | { |
---|
47 | firstline = 0; |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | if( 0 == regexec(&re, buf, (size_t)0, NULL, 0) ) |
---|
52 | { |
---|
53 | putchar('\n'); |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | putchar(eoln); |
---|
58 | } |
---|
59 | } |
---|
60 | fputs(buf, stdout); |
---|
61 | } |
---|
62 | |
---|
63 | putchar('\n'); |
---|
64 | |
---|
65 | return 0; |
---|
66 | |
---|
67 | } |
---|
68 | |
---|
Note: See
TracBrowser
for help on using the repository browser.