#include <u.h>
#include <libc.h>
#include <bio.h>
void
main(int argc, char *argv[])
{
ulong index, oindex, wlen;
char w[1024];
char n, o;
int wflag;
Biobuf bin;
USED(argc, argv);
Binit(&bin, 0, OREAD);
wlen = 0;
index = 0;
oindex = 0;
wflag = 0;
while((n = Bgetc(&bin)) != Beof) {
index++;
switch(n) {
case '\n':
if(o == '\n') {
w[wlen] = '\0';
print("%s\t%uld\n", w, oindex);
wlen = 0;
wflag = 0;
oindex = index;
} else {
wflag = 1;
}
break;
default:
if(!wflag)
w[wlen++] = n;
break;
}
o = n;
}
Bterm(&bin);
exits("");
}
|