File: sagrep.c

package info (click to toggle)
sufary 2.1.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,236 kB
  • ctags: 782
  • sloc: ansic: 4,122; perl: 1,378; makefile: 726; sh: 664; tcl: 441; cpp: 192
file content (22 lines) | stat: -rw-r--r-- 470 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <stdlib.h>
#include "sufary.h"

main(int argc, char *argv[])
{
  char *s;
  SUFARY *ary;
  long i, pos;
  
  if ((ary = sa_openfiles(argv[2],NULL)) == NULL) fprintf(stderr,"Error\n");

  if (sa_sel(ary, argv[1]) == CONT){
    for (i = sa_left(ary); i <= sa_right(ary) ; i++){
      pos = sa_aryidx2txtidx(ary, i);
      s = sa_getline(ary, pos);
      printf("%s:%ld: %s\n", argv[1], pos, s);
      free(s);
    }
  }
  sa_closefiles(ary);
}