Plan 9 from Bell Labs’s /usr/web/sources/contrib/akumar/dict/src/mkdictd.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#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("");
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.