git: 9front

Download patch

ref: d00ae56ec8400a24b92787a449a0e526387376cb
parent: f3594897909571c9bdea99f9293c71def3850916
parent: 1cf26d72e2734aad1b39fae3a008b1360aec34e3
author: cinap_lenrek <cinap_lenrek@localhost>
date: Tue Jul 12 16:24:55 EDT 2011

merge

--- a/sys/games/lib/fortunes
+++ b/sys/games/lib/fortunes
@@ -4519,3 +4519,8 @@
 This is awesome. I feel the same way and have for years.
 what is going to happen to everybodys computers?
 rockets are like bootloaders, they have multiple stages and explode half of the time -- aiju
+The gun is good. The penis is evil. The penis shoots seeds, and makes new life to poison the Earth with a plague of men, as once it was, but the gun shoots death, and purifies the Earth of the filth of brutals. Go forth ... and kill!
+ERROR: If you can see this, then YouTube is down or you don't have Flash installed.
+The probe, which criticized the US Army for turning a blind eye to Blackwater abuses, found that in one incident a US officer signed over hundreds of AK-47s intended for Afghan forces to an individual from Blackwater's Counter Narcotics Training Unit who signed for them as "Eric Cartman."
+Finding your own problem is where everything interesting starts. -- Momus
+Stanford CS101 Adopts JavaScript
--- a/sys/include/bio.h
+++ b/sys/include/bio.h
@@ -32,6 +32,7 @@
 	uchar*	bbuf;		/* pointer to beginning of buffer */
 	uchar*	ebuf;		/* pointer to end of buffer */
 	uchar*	gbuf;		/* pointer to good data in buf */
+	void	(*errorf)(char *);	/* called on error if not nil */
 };
 
 struct	Biobuf
@@ -70,5 +71,7 @@
 int	Bungetc(Biobufhdr*);
 int	Bungetrune(Biobufhdr*);
 long	Bwrite(Biobufhdr*, void*, long);
+void	Blethal(Biobufhdr*, void(*)(char*));
+void	Berror(Biobufhdr*, char*, ...);
 
 #pragma	varargck	argpos	Bprint	2
--- a/sys/src/cmd/8c/swt.c
+++ b/sys/src/cmd/8c/swt.c
@@ -199,6 +199,7 @@
 		return;
 	}
 	Binit(&b, f, OWRITE);
+	Blethal(&b, nil);
 	Bseek(&b, 0L, 2);
 	outhist(&b);
 	for(sym=0; sym<NSYM; sym++) {
--- a/sys/src/cmd/cc/lex.c
+++ b/sys/src/cmd/cc/lex.c
@@ -1262,7 +1262,9 @@
 	if(i->f < 0)
 		goto pop;
 	fi.c = read(i->f, i->b, BUFSIZ) - 1;
-	if(fi.c < 0) {
+	if(fi.c < -1)
+		sysfatal("read error: %r");
+	if(fi.c == -1) {
 		close(i->f);
 		linehist(0, 0);
 		goto pop;
--- a/sys/src/libbio/bflush.c
+++ b/sys/src/libbio/bflush.c
@@ -20,6 +20,7 @@
 		}
 		bp->state = Binactive;
 		bp->ocount = 0;
+		Berror(bp, "write error: %r");
 		break;
 
 	case Bracteof:
--- a/sys/src/libbio/bgetc.c
+++ b/sys/src/libbio/bgetc.c
@@ -28,8 +28,10 @@
 	bp->gbuf = bp->bbuf;
 	if(i <= 0) {
 		bp->state = Bracteof;
-		if(i < 0)
+		if(i < 0) {
 			bp->state = Binactive;
+			Berror(bp, "read error: %r");
+		}
 		return Beof;
 	}
 	if(i < bp->bsize) {
--- a/sys/src/libbio/binit.c
+++ b/sys/src/libbio/binit.c
@@ -83,6 +83,7 @@
 	bp->rdline = 0;
 	bp->offset = 0;
 	bp->runesize = 0;
+	bp->errorf = nil;
 	return 0;
 }
 
--- a/sys/src/libbio/brdline.c
+++ b/sys/src/libbio/brdline.c
@@ -47,6 +47,8 @@
 	ip = (char*)bp->bbuf + i;
 	while(i < bp->bsize) {
 		j = read(bp->fid, ip, bp->bsize-i);
+		if(j < 0)
+			Berror(bp, "read error: %r");
 		if(j <= 0) {
 			/*
 			 * end of file with no delim
--- a/sys/src/libbio/brdstr.c
+++ b/sys/src/libbio/brdstr.c
@@ -67,6 +67,8 @@
 		ip = (char*)bp->bbuf + i;
 		while(i < bp->bsize) {
 			j = read(bp->fid, ip, bp->bsize-i);
+			if(j < 0)
+				Berror(bp, "read error: %r");
 			if(j <= 0 && i == 0)
 				return p;
 			if(j <= 0 && i > 0){
--- a/sys/src/libbio/bread.c
+++ b/sys/src/libbio/bread.c
@@ -23,8 +23,10 @@
 			i = read(bp->fid, bp->bbuf, bp->bsize);
 			if(i <= 0) {
 				bp->state = Bracteof;
-				if(i < 0)
+				if(i < 0) {
+					Berror(bp, "read error: %r");
 					bp->state = Binactive;
+				}
 				break;
 			}
 			bp->gbuf = bp->bbuf;
--- a/sys/src/libbio/bwrite.c
+++ b/sys/src/libbio/bwrite.c
@@ -24,8 +24,10 @@
 			i = write(bp->fid, bp->bbuf, bp->bsize);
 			if(i != bp->bsize) {
 				errstr(errbuf, sizeof errbuf);
-				if(strstr(errbuf, "interrupt") == nil)
+				if(strstr(errbuf, "interrupt") == nil) {
 					bp->state = Binactive;
+					Berror(bp, "write error: %s", errbuf);
+				}
 				errstr(errbuf, sizeof errbuf);
 				return Beof;
 			}
--- a/sys/src/libbio/mkfile
+++ b/sys/src/libbio/mkfile
@@ -9,6 +9,7 @@
 	bgetc.$O\
 	bgetd.$O\
 	binit.$O\
+	blethal.$O\
 	boffset.$O\
 	bprint.$O\
 	bputrune.$O\
--