Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/src/runetype/compose.c

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


#include "runecompose.c"
#include <bio.h>

void
compose(Biobuf *o, Biobuf *b)
{
	int r0, r1, c;

	r0 = Bgetrune(o);
	r1 = Bgetrune(o);
	for(;;){
		if((c = runecompose(r0, r1)) != -1)
			r0 = c;		/* allow recomposition */
		else{
			Bputrune(b, r0);
			r0 = r1;
		}
		r1 = Bgetrune(o);
		if(r1 == -1)
			break;
	}
	if(r0 != -1)
		Bputrune(b, r0);
}

void
usage(void)
{
	fprint(2, "usage: compose ...\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	int i, fd;
	Biobuf b, o;

	ARGBEGIN{
	default:
		usage();
	}ARGEND
	Binit(&b, 1, OWRITE);
	for(i = 0; i < argc; i++){
		fd = open(argv[i], OREAD);
		if(fd == -1)
			sysfatal("open: %r");
		Binit(&o, fd, OREAD);
		compose(&o, &b);
		close(fd);
	}
	if(argc == 0){
		Binit(&o, 0, OREAD);
		compose(&o, &b);
	}
	Bterm(&o);
	Bterm(&b);
	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 [email protected].