Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/src/tt/tt.c

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


#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <bio.h>

void
main(int argc, char *argv[])
{
	Biobuf bout;
	char *s, *e, c;
	ulong l;

	Binit(&bout, 1, OWRITE);
	while(++argv, --argc){
		s = *argv;
		while(*s){
			switch(c = *s){
			case '^':
				s++;
				if(*s == '\0')
					sysfatal("bad control: %s", *argv);
				c = toupper(*s) - 0x40;	/* lazy */
				break;
			case '\\':
				s++;
				if(*s == '\0')
					sysfatal("bad escape: %s", *argv);
				switch(*s){
				case 'a':	c = '\a'; break;
				case 'b':	c = '\b'; break;
				case 'f':	c = '\f'; break;
				case 'n':	c = '\n'; break;
				case 'r':	c = '\r'; break;
				case 't':	c = '\t'; break;
				case 'v':	c = '\v'; break;
				case '\'':	c = '\''; break;
				case '\\':	c = '\\'; break;
				default:
					l = strtoul(s, &e, 0);
					if(e == s)
						break;
					c = (char)l;
					s = e-1;
				}
				break;
			}
			Bputc(&bout, c);
			s++;
		}
	}
	Bflush(&bout);
	exits(nil);
}

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].