shithub: riscv

Download patch

ref: ed76659c054ce781ae6050e563de9ad40b3d25cd
parent: 28f4567ba615c4036c079021392825757ef2a008
author: ftrvxmtrx <[email protected]>
date: Thu Nov 17 17:58:16 EST 2016

/sys/src/lib*: clean up

--- a/sys/src/libavl/avl.c
+++ b/sys/src/libavl/avl.c
@@ -204,17 +204,6 @@
 	return -(ob != 0 && (*tp)->bal == 0);
 }
 
-static void
-checkparents(Avl *a, Avl *p)
-{
-	if(a == nil)
-		return;
-	if(a->p != p)
-		print("bad parent\n");
-	checkparents(a->n[0], a);
-	checkparents(a->n[1], a);
-}
-
 struct Avltree
 {
 	Avl	*root;
@@ -423,14 +412,4 @@
 		}
 	}
 	free(w);
-}
-
-static void
-walkavl(Avl *t, void (*f)(Avl*, void*), void *v)
-{
-	if(t == nil)
-		return;
-	walkavl(t->n[0], f, v);
-	f(t, v);
-	walkavl(t->n[1], f, v);
 }
--- a/sys/src/libcontrol/radiobutton.c
+++ b/sys/src/libcontrol/radiobutton.c
@@ -46,7 +46,6 @@
 };
 
 static void	radioshow(Radio*);
-static void	radiofree(Radio*);
 
 static void
 radiomouse(Control *c, Mouse *m)
@@ -60,11 +59,6 @@
 			(r->buttons[i]->mouse)(r->buttons[i], m);
 			break;
 		}
-}
-
-static void
-radiofree(Radio*)
-{
 }
 
 static void
--- a/sys/src/libcontrol/scribble.c
+++ b/sys/src/libcontrol/scribble.c
@@ -58,7 +58,6 @@
 static void scribchar(Scrib*, Rune);
 
 static void	resetstroke(Scrib *w);
-static void	displaystroke(Scrib *w);
 static void	displaylast(Scrib *w);
 static void	addpoint(Scrib *w, Point p);
 
@@ -245,15 +244,6 @@
 
 	s->ps.npts = 0;
 	scribshow(w);
-}
-
-static void
-displaystroke(Scrib *b)
-{
-	Scribble *s = b->scrib;
-
-	poly(b->screen, s->pt, s->ps.npts, Endsquare, Endsquare, 0, b->color->image, ZP);
-	flushimage(display, 1);
 }
 
 static void
--- a/sys/src/libframe/frdraw.c
+++ b/sys/src/libframe/frdraw.c
@@ -10,7 +10,6 @@
 {
 	Frbox *b;
 	int nb;
-	static int x;
 
 	for(nb=0,b=f->box; nb<f->nbox; nb++, b++){
 		_frcklinewrap(f, &pt, b);
--- a/sys/src/libhtml/build.c
+++ b/sys/src/libhtml/build.c
@@ -275,7 +275,7 @@
 static Area*		newarea(int shape, Rune* href, int target, Area* link);
 static DestAnchor*	newdestanchor(int index, Rune* name, Item* item, DestAnchor* link);
 static Docinfo*		newdocinfo(void);
-static Genattr*		newgenattr(Rune* id, Rune* class, Rune* style, Rune* title, Attr* events);
+static Genattr*		newgenattr(Rune* id, Rune* class, Rune* style, Rune* title, SEvent* events);
 static Form*		newform(int formid, Rune* name, Rune* action,
 					int target, int method, Form* link);
 static Formfield*	newformfield(int ftype, int fieldid, Form* form, Rune* name,
--- a/sys/src/libmach/2db.c
+++ b/sys/src/libmach/2db.c
@@ -94,7 +94,7 @@
 m68020ufix(Map *map)
 {
 	struct ftype *ft;
-	int i, size, vec;
+	int i, vec;
 	ulong efl[2];
 	uchar *ef=(uchar*)efl;
 	ulong l;
@@ -110,11 +110,6 @@
 
 	if (get4(map, mach->kbase, (&l)) < 0)
 		return -1;
-	if ((l&0xfc000000) == 0x04000000)	/* if NeXT */
-		size = 30*2;
-	else
-		size = 46*2;			/* 68020 */
-	USED(size);
 
 	stktop = mach->kbase+mach->pgsize;
 	for(i=3; i<100; i++){
--- a/sys/src/libndb/ndbipinfo.c
+++ b/sys/src/libndb/ndbipinfo.c
@@ -14,7 +14,6 @@
 static Ndbtuple*	filter(Ndb *db, Ndbtuple *t, Ndbtuple *f);
 static Ndbtuple*	mkfilter(int argc, char **argv);
 static int		filtercomplete(Ndbtuple *f);
-static Ndbtuple*	toipaddr(Ndb *db, Ndbtuple *t);
 static int		prefixlen(uchar *ip);
 static Ndbtuple*	subnet(Ndb *db, uchar *net, Ndbtuple *f, int prefix);
 
--- a/sys/src/libregexp/regcomp.c
+++ b/sys/src/libregexp/regcomp.c
@@ -156,17 +156,6 @@
 	return plex;
 }
 
-static int
-maxthreads(Renode *tree)
-{
-	tree = tree->left;
-	if(tree->op == TCAT)
-		tree = tree->left;
-	if(tree->op == TBOL)
-		return 2;
-	return -1;
-}
-
 static Reprog*
 regcomp1(char *regstr, int nl, int lit)
 {
@@ -190,7 +179,6 @@
 	maxthr = regstrlen;
 	parsetr = node(&plex, TSUB, e0(&plex), nil);
 
-//	prtree(parsetr, 0, 1);
 	reprog = malloc(sizeof(Reprog) +
 	                sizeof(Reinst) * plex.instrs +
 	                sizeof(Rethread) * maxthr);
@@ -514,66 +502,4 @@
 		n->nclass = i++;
 	}
 	return n;
-}
-
-static void
-prtree(Renode *tree, int d, int f)
-{
-	int i;
-
-	if(tree == nil)
-		return;
-	if(f)
-	for(i = 0; i < d; i++)
-		print("\t");
-	switch(tree->op) {
-	case TCAT:
-		prtree(tree->left, d, 0);
-		prtree(tree->right, d, 1);
-		break;
-	case TOR:
-		print("TOR\n");
-		prtree(tree->left, d+1, 1);
-		for(i = 0; i < d; i++)
-			print("\t");
-		print("|\n");
-		prtree(tree->right, d+1, 1);
-		break;
-	case TSTAR:
-		print("*\n");
-		prtree(tree->left, d+1, 1);
-		break;
-	case TPLUS:
-		print("+\n");
-		prtree(tree->left, d+1, 1);
-		break;
-	case TQUES:
-		print("?\n");
-		prtree(tree->left, d+1, 1);
-		break;
-	case TANY:
-		print(".\n");
-		prtree(tree->left, d+1, 1);
-		break;
-	case TBOL:
-		print("^\n");
-		break;
-	case TEOL:
-		print("$\n");
-		break;
-	case TSUB:
-		print("TSUB\n");
-		prtree(tree->left, d+1, 1);
-		break;
-	case TRUNE:
-		print("TRUNE: %C\n", tree->r);
-		break;
-	case TNOTNL:
-		print("TNOTNL: !\\n\n");
-		break;
-	case TCLASS:
-		print("CLASS: %C-%C\n", tree->r, tree->r1);
-		prtree(tree->left, d, 1);
-		break;
-	}
 }
--- a/sys/src/libscribble/hre_api.c
+++ b/sys/src/libscribble/hre_api.c
@@ -71,10 +71,8 @@
 
 /*Local functions*/
 
-static char* shared_library_name(char* directory,char* locale,char* name);
 static rec_info* make_rec_info(char* directory,char* name,char** subset);
 static void delete_rec_info(rec_info* ri);
-static int check_for_user_home(void);
 static void intl_initialize(void);
 
 static void cleanup_rec_element(rec_element* re,bool delete_points_p);
@@ -166,21 +164,6 @@
 
     rec->recognizer_info = rinf;
 
-    /*Check whether home directory is there for recognizer info.*/
-
-/*
- *  ari -- don't bother.  We're not going to load from each user's
- *  home directory at this point.  Instead, we'll use a stupid
- *  little a-b-c file because it loads FAST.
- *
- *    if( check_for_user_home() < 0 ) {
- *	recognizer_unload(rec);
- *	return((recognizer)nil);
- *   }
- */
-    /*We got it!*/
-/* fprint(2, "Done.\n"); */
-
     return(rec);
 }
 
@@ -616,46 +599,6 @@
 */
 
 /*
- * shared_library_name-Get the full pathname to the shared library,
- *    based on the recognizer name and the environment.
-*/
-
-
-static char* shared_library_name(char* directory,char* locale,char* name)
-{
-    char* ret;
-    int len = strlen(name);
-
-    /*If directory is there, it takes precedence.*/
-
-    if( directory != nil ) {
-		ret = (char*)safe_malloc(strlen(directory) + len + 2);
-		strcpy(ret,directory);
-		strcat(ret,"/");
-		strcat(ret,name);
-    } else {
-		char* dir;
-	
-		/*First try the environment variable.*/
-	
-		if( (dir = getenv(RECHOME)) == nil ) {
-		    dir = "REC_DEFAULT_HOME_DIR";
-	
-		  }
-	
-		ret = (char*)safe_malloc(strlen(dir) + strlen(locale) + len + 3);
-		/*Form the pathname.*/
-		strcpy(ret,dir);
-		strcat(ret,"/");
-		strcat(ret,locale);
-		strcat(ret,"/");
-		strcat(ret,name);
-	}
-
-    return(ret);
-}
-
-/*
  * intl_initialize-Initialize the internationaliztion of messages for
  * the recognition manager.
 */
@@ -755,49 +698,6 @@
 	}
 	free(ri);
     }
-}
-
-/*check_for_user_home-Check whether USERRECHOME has been created.*/
-
-static int check_for_user_home()
-{
-	char* homedir = getenv(HOME);
-	char* rechome;
-	Dir *dir;
-
-	if( homedir == nil ) {
-		the_last_error = "Home environment variable HOME not set.";
-		return(-1);
-	}
-
-    rechome = (char*)safe_malloc(strlen(homedir) + strlen(USERRECHOME) + 2);
-
-    /*Form name.*/
-
-    strcpy(rechome,homedir);
-    strcat(rechome,"/");
-    strcat(rechome,USERRECHOME);
-
-    /*Create directory.*/
-
-    dir = dirstat(rechome);
-    if (dir != nil) {
-		if (dir->mode & DMDIR) {
-			free(dir);
-			free(rechome);
-			return 0;
-		}
-		free(dir);
-	} else {
-		int fd;
-		if ((fd = create(rechome, OREAD, DMDIR|0755)) >= 0) {
-			close(fd);
-    		free(rechome);
-    		return(0);
-		}
-    }
-	free(rechome);
-	return(-1);
 }
 
 /*
--- a/sys/src/libstdio/dtoa.c
+++ b/sys/src/libstdio/dtoa.c
@@ -151,34 +151,6 @@
 	return b;
 }
 
-static Bigint *
-s2b(const char *s, int nd0, int nd, unsigned int y9)
-{
-	Bigint * b;
-	int	i, k;
-	int x, y;
-
-	x = (nd + 8) / 9;
-	for (k = 0, y = 1; x > y; y <<= 1, k++) 
-		;
-	b = Balloc(k);
-	b->x[0] = y9;
-	b->wds = 1;
-
-	i = 9;
-	if (9 < nd0) {
-		s += 9;
-		do 
-			b = multadd(b, 10, *s++ - '0');
-		while (++i < nd0);
-		s++;
-	} else
-		s += 10;
-	for (; i < nd; i++)
-		b = multadd(b, 10, *s++ - '0');
-	return b;
-}
-
 static int	
 hi0bits(register unsigned int x)
 {
@@ -483,18 +455,6 @@
 	return c;
 }
 
-static double	
-ulp(FPdbleword x)
-{
-	int L;
-	FPdbleword a;
-
-	L = (fpword0(x) & Exp_mask) - (P - 1) * Exp_msk1;
-	fpword0(a) = L;
-	fpword1(a) = 0;
-	return a.x;
-}
-
 static FPdbleword	
 b2d(Bigint *a, int *e)
 {
@@ -567,24 +527,6 @@
 #undef d0
 #undef d1
 
-static double	
-ratio(Bigint *a, Bigint *b)
-{
-	FPdbleword da, db;
-	int	k, ka, kb;
-
-	da = b2d(a, &ka);
-	db = b2d(b, &kb);
-	k = ka - kb + 32 * (a->wds - b->wds);
-	if (k > 0)
-		fpword0(da) += k * Exp_msk1;
-	else {
-		k = -k;
-		fpword0(db) += k * Exp_msk1;
-	}
-	return da.x / db.x;
-}
-
 static const double
 tens[] = {
 	1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
@@ -596,11 +538,6 @@
 bigtens[] = { 
 	1e16, 1e32, 1e64, 1e128, 1e256 };
 
-static const double tinytens[] = { 
-	1e-16, 1e-32, 1e-64, 1e-128,
-	9007199254740992.e-256
-};
-
 /* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
 /* flag unnecessarily.  It leads to a song and dance at the end of strtod. */
 #define Scale_Bit 0x10
@@ -609,67 +546,6 @@
 #define NAN_WORD0 0x7ff80000
 
 #define NAN_WORD1 0
-
-static int	
-match(const char **sp, char *t)
-{
-	int	c, d;
-	const char * s = *sp;
-
-	while (d = *t++) {
-		if ((c = *++s) >= 'A' && c <= 'Z')
-			c += 'a' - 'A';
-		if (c != d)
-			return 0;
-	}
-	*sp = s + 1;
-	return 1;
-}
-
-static void	
-gethex(FPdbleword *rvp, const char **sp)
-{
-	unsigned int c, x[2];
-	const char * s;
-	int	havedig, udx0, xshift;
-
-	x[0] = x[1] = 0;
-	havedig = xshift = 0;
-	udx0 = 1;
-	s = *sp;
-	while (c = *(const unsigned char * )++s) {
-		if (c >= '0' && c <= '9')
-			c -= '0';
-		else if (c >= 'a' && c <= 'f')
-			c += 10 - 'a';
-		else if (c >= 'A' && c <= 'F')
-			c += 10 - 'A';
-		else if (c <= ' ') {
-			if (udx0 && havedig) {
-				udx0 = 0;
-				xshift = 1;
-			}
-			continue;
-		} else if (/*(*/ c == ')') {
-			*sp = s + 1;
-			break;
-		} else
-			return;	/* invalid form: don't change *sp */
-		havedig = 1;
-		if (xshift) {
-			xshift = 0;
-			x[0] = x[1];
-			x[1] = 0;
-		}
-		if (udx0)
-			x[0] = (x[0] << 4) | (x[1] >> 28);
-		x[1] = (x[1] << 4) | c;
-	}
-	if ((x[0] &= 0xfffff) || x[1]) {
-		fpword0(*rvp) = Exp_mask | x[0];
-		fpword1(*rvp) = x[1];
-	}
-}
 
 static int	
 quorem(Bigint *b, Bigint *S)
--- a/sys/src/libstdio/setvbuf.c
+++ b/sys/src/libstdio/setvbuf.c
@@ -31,12 +31,6 @@
 	f->state=RDWR;
 	return 0;
 }
-int _IO_setvbuf(FILE *f){
-	static int isatty(int);
-	if(f==stderr || (f==stdout && isatty(1)))
-		return setvbuf(f, (char *)0, _IOLBF, BUFSIZ);
-	else return setvbuf(f, (char *)0, _IOFBF, BUFSIZ);
-}
 static int
 isatty(int fd)
 {
@@ -47,4 +41,9 @@
 
 	/* might be /mnt/term/dev/cons */
 	return strlen(buf) >= 9 && strcmp(buf+strlen(buf)-9, "/dev/cons") == 0;
+}
+int _IO_setvbuf(FILE *f){
+	if(f==stderr || (f==stdout && isatty(1)))
+		return setvbuf(f, (char *)0, _IOLBF, BUFSIZ);
+	else return setvbuf(f, (char *)0, _IOFBF, BUFSIZ);
 }
--- a/sys/src/libventi/file.c
+++ b/sys/src/libventi/file.c
@@ -503,7 +503,6 @@
 	VtBlock *b;
 	int type;
 	uchar *score;
-	VtEntry oe;
 
 	switch(p->type){
 	case VtDataType:
@@ -532,8 +531,6 @@
 	if(vtglobaltolocal(b->score) != NilBlock)
 		return b;
 
-	oe = *e;
-
 	/*
 	 * Copy on write.
 	 */
@@ -600,7 +597,6 @@
 shrinkdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth)
 {
 	VtBlock *b, *nb, *ob, *rb;
-	VtEntry oe;
 
 	assert(ISLOCKED(r));
 	assert(depth <= VtPointerDepth);
@@ -608,12 +604,6 @@
 	rb = vtcacheglobal(r->c, e->score, e->type);
 	if(rb == nil)
 		return -1;
-
-	/*
-	 * Walk down to the new root block.
-	 * We may stop early, but something is better than nothing.
-	 */
-	oe = *e;
 
 	ob = nil;
 	b = rb;