shithub: drawterm-fdroid

Download patch

ref: 7f51f90cb36b248269cea2f6ac8f3da918fa834f
parent: d1b585cfe24c6fd89865a1301ec933597c4de5e6
author: Russ Cox <[email protected]>
date: Fri Jun 22 18:06:34 EDT 2007

various fixes

--- a/Make.unix
+++ b/Make.unix
@@ -19,5 +19,5 @@
 all: default
 
 libmachdep.a:
-	arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/'`; \
+	arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/; s/x86_64/amd64/'`; \
 	(cd posix-$$arch &&  make)
--- a/cpu.c
+++ b/cpu.c
@@ -548,7 +548,7 @@
 	char tbuf[TICKETLEN+TICKETLEN+AUTHENTLEN], trbuf[TICKREQLEN];
 	char authkey[DESKEYLEN];
 	Authenticator auth;
-	int afd, i, v2;
+	int afd, i, n, v2;
 	Ticketreq tr;
 	Ticket t;
 	AuthInfo *ai;
@@ -623,11 +623,26 @@
 	auth.id = 0;
 	convA2M(&auth, tbuf+TICKETLEN, t.key);
 
-	if(write(fd, tbuf, TICKETLEN+AUTHENTLEN) != TICKETLEN+AUTHENTLEN)
+	if(write(fd, tbuf+1, TICKETLEN+AUTHENTLEN) != TICKETLEN+AUTHENTLEN)
 		fatal(1, "cannot send ticket and authenticator back in p9sk1");
 
-	if(readn(fd, tbuf, AUTHENTLEN) != AUTHENTLEN)
-		fatal(1, "cannot read authenticator in p9sk1");
+	if((n=readn(fd, tbuf, AUTHENTLEN)) != AUTHENTLEN ||
+			memcmp(tbuf, "cpu:", 4) == 0){
+		if(n <= 4)
+			fatal(1, "cannot read authenticator in p9sk1");
+
+		/*
+		 * didn't send back authenticator:
+		 * sent back fatal error message.
+		 */
+		memmove(buf, tbuf, n);
+		i = readn(fd, buf+n, sizeof buf-n-1);
+		if(i > 0)
+			n += i;
+		buf[n] = 0;
+		werrstr("");
+		fatal(0, "server says: %s", buf);
+	}
 	
 	convM2A(tbuf, &auth, t.key);
 	if(auth.num != AuthAs
@@ -635,7 +650,7 @@
 	|| auth.id != 0){
 		print("?you and auth server agree about password.\n");
 		print("?server is confused.\n");
-		fatal(1, "server lies got %llux.%d want %llux.%d", *(vlong*)auth.chal, auth.id, *(vlong*)cchal, 0);
+		fatal(0, "server lies got %llux.%d want %llux.%d", *(vlong*)auth.chal, auth.id, *(vlong*)cchal, 0);
 	}
 	//print("i am %s there.\n", t.suid);
 	ai = mallocz(sizeof(AuthInfo), 1);
--- a/gui-x11/screen.c
+++ b/gui-x11/screen.c
@@ -1126,6 +1126,7 @@
 		XChangeProperty(xd, xe->requestor, xe->property, xe->target,
 			8, PropModeReplace, (uchar*)a, sizeof a);
 	}else if(xe->target == XA_STRING || xe->target == utf8string || xe->target == text || xe->target == compoundtext){
+	text:
 		/* if the target is STRING we're supposed to reply with Latin1 XXX */
 		qlock(&clip.lk);
 		XChangeProperty(xd, xe->requestor, xe->property, xe->target,
@@ -1132,12 +1133,21 @@
 			8, PropModeReplace, (uchar*)clip.buf, strlen(clip.buf));
 		qunlock(&clip.lk);
 	}else{
-		iprint("get %d\n", xe->target);
 		name = XGetAtomName(xd, xe->target);
 		if(name == nil)
-			iprint("XGetAtomName failed\n");
-		else if(strcmp(name, "TIMESTAMP") != 0)
-			iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target);
+			iprint("XGetAtomName %d failed\n", xe->target);
+		if(name){
+			if(strcmp(name, "TIMESTAMP") == 0){
+				/* nothing */
+			}else if(strncmp(name, "image/", 6) == 0){
+				/* nothing */
+			}else if(strcmp(name, "text/html") == 0){
+				/* nothing */
+			}else if(strcmp(name, "text/plain") == 0 || strcmp(name, "text/plain;charset=UTF-8") == 0){
+				goto text;
+			}else
+				iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target);
+		}
 		r.xselection.property = None;
 	}
 
--- a/include/unix.h
+++ b/include/unix.h
@@ -1,3 +1,15 @@
+#define __BSD_VISIBLE 1 /* FreeBSD 5.x */
+#define _BSD_SOURCE 1
+#define _NETBSD_SOURCE 1	/* NetBSD */
+#define _SVID_SOURCE 1
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
+#	define _XOPEN_SOURCE 1000
+#	define _XOPEN_SOURCE_EXTENDED 1
+#endif
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -4,6 +16,7 @@
 #include <math.h>
 #include <fcntl.h>
 #include <setjmp.h>
+#include <stddef.h>
 #include <time.h>
 #include <assert.h>
 #include <unistd.h>