Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/misc/undos.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[])
{
	int c1, c2;
	Biobuf b[2], *bi = &b[0], *bo = &b[1];

	if(argc == 1)
		Binit(bi, 0, OREAD);
	else
	if((bi = Bopen(argv[1], OREAD)) == nil)
		sysfatal("%s cannot open file - %r\n", argv[1]);
	Binit(bo, 1, OWRITE);
		

	c1 = Bgetc(bi);
	while ((c2 = Bgetc(bi)) >= 0){
		if (c1 != '\r' || c2 != '\n')
			Bputc(bo, c1);
		c1 = c2;
	}
	if (c1 >= 0)
		Bputc(bo, c1);
	Bterm(bi);
	Bterm(bo);
	exits(0);
}

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.