code: drawterm

Download patch

ref: 537f761602734ebd5b131ad469280249888dd63b
parent: 494adeed0b1e2afdf696baeff995ee80e0f37e8b
author: Russ Cox <rsc@swtch.com>
date: Mon Nov 7 12:34:39 EST 2005

mac warnings

--- a/Make.unix
+++ b/Make.unix
@@ -1,14 +1,16 @@
 # Unix
+PTHREAD=
+#PTHREAD=-pthread
 AR=ar
 AS=as
-CC=gcc -Wall -Wno-missing-braces
 RANLIB=ranlib
-CFLAGS=-I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -ggdb -D_THREAD_SAFE -pthread # not ready for this yet: -Wall
+CC=gcc
+CFLAGS=-Wall -Wno-missing-braces -ggdb -I$(ROOT) -I$(ROOT)/include -I$(ROOT)/kern -c -D_THREAD_SAFE $(PTHREAD)
 O=o
 OS=posix
 GUI=x11
 LDADD=-L/usr/X11R6/lib -lX11 -ggdb
-LDFLAGS=-pthread
+LDFLAGS=$(PTHREAD)
 TARG=drawterm
 
 all: default
--- a/README
+++ b/README
@@ -27,9 +27,6 @@
 TO DO:
 ------
 
-- Should clean up the code so that gcc -Wall doesn't print
-any warnings.
-
 - Should import latest /dev/draw to allow resize of window
 
 - Should copy 9term code and make console window a real
--- a/gui-x11/screen.c
+++ b/gui-x11/screen.c
@@ -191,8 +191,8 @@
 	drawqlock();
 	fg = map[0];
 	bg = map[255];
-	xsrc = XCreateBitmapFromData(xdisplay, xdrawable, src, 16, 16);
-	xmask = XCreateBitmapFromData(xdisplay, xdrawable, mask, 16, 16);
+	xsrc = XCreateBitmapFromData(xdisplay, xdrawable, (char*)src, 16, 16);
+	xmask = XCreateBitmapFromData(xdisplay, xdrawable, (char*)mask, 16, 16);
 	xc = XCreatePixmapCursor(xdisplay, xsrc, xmask, &fg, &bg, -cursor.offset.x, -cursor.offset.y);
 	if(xc != 0) {
 		XDefineCursor(xdisplay, xdrawable, xc);
@@ -403,7 +403,7 @@
 	name.value = (uchar*)"drawterm";
 	name.encoding = XA_STRING;
 	name.format = 8;
-	name.nitems = strlen(name.value);
+	name.nitems = strlen((char*)name.value);
 	normalhints.flags = USSize|PMaxSize;
 	normalhints.max_width = Dx(r);
 	normalhints.max_height = Dy(r);
--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -13,7 +13,7 @@
 Queue*	lineq;			/* processed console input */
 Queue*	serialoq;		/* serial console output */
 Queue*	kprintoq;		/* console output, for /dev/kprint */
-ulong	kprintinuse;		/* test and set whether /dev/kprint is open */
+long	kprintinuse;		/* test and set whether /dev/kprint is open */
 int	iprintscreenputs = 0;
 
 int	panicking;
--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -585,7 +585,7 @@
 		d.length = stbuf.st_size;
 		d.type = 'U';
 		d.dev = c->dev;
-		n = convD2M(&d, (char*)va+i, count-i);
+		n = convD2M(&d, (uchar*)va+i, count-i);
 		if(n == BIT16SZ){
 			strcpy(uif->nextname, de);
 			break;
--- a/kern/devip-posix.c
+++ b/kern/devip-posix.c
@@ -72,7 +72,7 @@
 void
 so_getsockname(int fd, unsigned long *laddr, unsigned short *lport)
 {
-	int len;
+	uint len;
 	struct sockaddr_in sin;
 
 	len = sizeof(sin);
@@ -96,7 +96,8 @@
 int
 so_accept(int fd, unsigned long *raddr, unsigned short *rport)
 {
-	int nfd, len;
+	int nfd;
+	uint len;
 	struct sockaddr_in sin;
 
 	len = sizeof(sin);
--- a/libdraw/chan.c
+++ b/libdraw/chan.c
@@ -31,7 +31,7 @@
 
 /* avoid pulling in ctype when using with drawterm etc. */
 static int
-isspace(char c)
+xisspace(char c)
 {
 	return c==' ' || c== '\t' || c=='\r' || c=='\n';
 }
@@ -45,10 +45,10 @@
 
 	c = 0;
 	p=s;
-	while(*p && isspace(*p))
+	while(*p && xisspace(*p))
 		p++;
 
-	while(*p && !isspace(*p)){
+	while(*p && !xisspace(*p)){
 		if((q = strchr(channames, p[0])) == nil) 
 			return 0;
 		t = q-channames;
--- a/posix-power/md5block.c
+++ b/posix-power/md5block.c
@@ -1,4 +1,5 @@
-#include "os.h"
+#include <u.h>
+#include <libc.h>
 #include <libsec.h>
 
 /*
--- a/posix-power/sha1block.c
+++ b/posix-power/sha1block.c
@@ -1,4 +1,6 @@
-#include "os.h"
+#include <u.h>
+#include <libc.h>
+#include <libsec.h>
 
 void
 _sha1block(uchar *p, ulong len, u32int *s)