source: app/src/fla/fla.c @ 389de9a

help
Last change on this file since 389de9a was 25ae32e, checked in by obrebski <obrebski@…>, 17 years ago

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@4 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 757 bytes
Line 
1#include <stdio.h>
2#include <string.h>
3#include <regex.h>
4
5char buf[5001];
6
7main(int argc, char **argv)
8{
9
10  char *pattern;
11  char eoln;
12  regex_t re;
13
14  int firstline=1;
15
16  if(argc < 2)
17/*     pattern="[ \t]*([0-9]+[ \t]+){2}EOS([ \t].*)?"; */
18    pattern="[ \t]*BOS([ \t].*)?";
19  else
20    pattern=argv[1];
21
22  if(argc < 3)
23    eoln='\f';
24  else
25    eoln=atoi(argv[2]);
26
27  if(regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) !=0)
28  {
29    fprintf(stderr,"Invalid pattern.\n");
30    exit(1);
31  }
32
33  while(fgets(buf,5000,stdin))
34  {
35    buf[strlen(buf)-1]='\0';
36    if(firstline)
37      firstline=0;
38    else
39      if(regexec(&re, buf, (size_t)0, NULL, 0) == 0)
40        putchar('\n');
41      else
42        putchar(eoln);
43    fputs(buf,stdout);
44  }
45  putchar('\n');
46}
Note: See TracBrowser for help on using the repository browser.