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