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

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


#include <runetype.c>
#include <bio.h>

Rune
strtorune(char *s)
{
	char *r;
	ulong u;

	u = strtoul(s, &r, 0x10);
	if(*r != 0 || u > Runemax)
		return Runeerror;
	return (Rune)u;
}

void
usage(void)
{
	fprint(2, "usage: trunetype [cp] ...\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	int i;
	Rune r;
	Biobuf b;

	ARGBEGIN{
	default:
		usage();
	}ARGEND
	Binit(&b, 1, OWRITE);
	for(i = 0; i < argc; i++){
		r = strtorune(argv[i]);
		if(r == Runeerror){
			Bflush(&b);
			fprint(2, "bad rune\n");
			continue;
		}
		print("%.4ux ", r);
		if(isalpharune(r))
			Bprint(&b, "alpha ");
		if(istitlerune(r))
			Bprint(&b, "title ");
		if(isspacerune(r))
			Bprint(&b, "space ");
		if(islowerrune(r))
			Bprint(&b, "lower %C(%.4ux) ", toupperrune(r), toupperrune(r));
		if(isupperrune(r))
			Bprint(&b, "upper %C(%.4ux) ", tolowerrune(r), tolowerrune(r));
		if(isdigitrune(r))
			Bprint(&b, "digit %d\n", digitrunevalue(r));
		Bprint(&b, "\n");
	}
	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 webmaster@9p.io.