~foura/wired

1abb9736d43ec046c91975abedadce884ecc98a6 — james palmer 1 year, 2 months ago 783a075
fix strange behaviour on control-d
1 files changed, 18 insertions(+), 7 deletions(-)

M main.c
M main.c => main.c +18 -7
@@ 58,9 58,9 @@ wineventproc(void *aux)
				
			break;
		case 'I':
			if(strcmp(ev.text, "") == 0)
			if(strchr(ev.text, '') != 0)
				sendp(ctl, "send");
				

			break;
		case 'l':
		case 'L':


@@ 73,25 73,36 @@ char *
readbody(AWin *w)
{
	Biobuf *fd;
	int addr;
	char *buf;
	int i;
	
	fd = awinfsbopen(w, "body", OREAD);
	buf = Brdstr(fd, '\0', 0);
	Bterm(fd);
	sleep(10);
	
	awinclear(w);
	addr = awinfsopen(w, "addr", OWRITE);
	fd = awinfsbopen(w, "data", OREAD);

	fprint(addr, ",");
	buf = Brdstr(fd, '\0', 0);
	
	if(!buf)
		return nil;
	
	for(i = strlen(buf)-1; i > 0; i--) {
	for(i = strlen(buf)-1; i >= 0; i--) {
		if(buf[i] == '' || buf[i] == '\n')
			buf[i] = '\0';
		else
			break;
	}
	
	if(buf[0] == '\0') {
		awinclear(w);
		return nil;
	}
	
	awinclear(w);
	Bterm(fd);
	close(addr);
	return buf;
}