/* expand.c Compile with: gcc -g expand.c -lm -o expand Example run: cluster infocon.hs2.a0.226.l5.list > infocon.hs2.a0.226.l5.c expand infocon.hs2.a0.226.l5.c > infocon.hs2.a0.226.l5.graph Performs point-to-point expansion of a "cluster" file (file of integer intervals). Used to produce the block-graphs in Fig4 A,B,C, representing the regions reported by each of the methods along horizontal lines. */ #include #include #include #include #define Usage "%s \n" #define LARGE_NUMBER 99999999 void fatalf(char *msg, char *val); FILE *ckopen(char *name, char *mode); void *ckalloc(size_t amount); int main(int argc, char *argv[]) { char buffer[1000]; int k, i, from, to; FILE *fp; if (argc!=2) fatalf(Usage,argv[0]); fp = ckopen(argv[1],"r"); while (fgets(buffer,1000,fp)!=NULL) { if (!isdigit(buffer[0])) continue; sscanf(buffer, "%d %d", &from, &to); for (i=from; i<=to; i++) printf("%d\n", i); } fclose(fp); return 0; } void fatal(char *msg) { (void)fprintf(stderr, "%s\n", msg); exit(1); } void fatalf(char *msg, char *val) { (void)fprintf(stderr, msg, val); (void)putc('\n', stderr); exit(1); } FILE *ckopen(char *name, char *mode) { FILE *fp; if ((fp = fopen(name, mode)) == NULL) fatalf("Cannot open %s.", name); return fp; } void *ckalloc(size_t amount) { void *p; if ((p = malloc(amount)) == NULL) fatal("Ran out of memory."); return p; }