From ed76659c054ce781ae6050e563de9ad40b3d25cd Mon Sep 17 00:00:00 2001 From: ftrvxmtrx Date: Thu, 17 Nov 2016 22:58:16 +0100 Subject: [PATCH] /sys/src/lib*: clean up --- sys/src/libavl/avl.c | 21 ------ sys/src/libcontrol/radiobutton.c | 6 -- sys/src/libcontrol/scribble.c | 10 --- sys/src/libframe/frdraw.c | 1 - sys/src/libhtml/build.c | 2 +- sys/src/libmach/2db.c | 7 +- sys/src/libndb/ndbipinfo.c | 1 - sys/src/libregexp/regcomp.c | 74 ------------------ sys/src/libscribble/hre_api.c | 100 ------------------------- sys/src/libstdio/dtoa.c | 124 ------------------------------- sys/src/libstdio/setvbuf.c | 11 ++- sys/src/libventi/file.c | 10 --- 12 files changed, 7 insertions(+), 360 deletions(-) diff --git a/sys/src/libavl/avl.c b/sys/src/libavl/avl.c index 59266d36d..ec60df209 100644 --- a/sys/src/libavl/avl.c +++ b/sys/src/libavl/avl.c @@ -204,17 +204,6 @@ _deleteavl(Avl **tp, Avl *p, Avl *rx, int(*cmp)(Avl*,Avl*), Avl **del, 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; @@ -424,13 +413,3 @@ endwalk(Avlwalk *w) } 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); -} diff --git a/sys/src/libcontrol/radiobutton.c b/sys/src/libcontrol/radiobutton.c index 133730a50..d3089cda0 100644 --- a/sys/src/libcontrol/radiobutton.c +++ b/sys/src/libcontrol/radiobutton.c @@ -46,7 +46,6 @@ static char *cmds[] = { }; static void radioshow(Radio*); -static void radiofree(Radio*); static void radiomouse(Control *c, Mouse *m) @@ -62,11 +61,6 @@ radiomouse(Control *c, Mouse *m) } } -static void -radiofree(Radio*) -{ -} - static void radioshow(Radio *r) { diff --git a/sys/src/libcontrol/scribble.c b/sys/src/libcontrol/scribble.c index 4e10ab68f..ad1f8d312 100644 --- a/sys/src/libcontrol/scribble.c +++ b/sys/src/libcontrol/scribble.c @@ -58,7 +58,6 @@ static void scribshow(Scrib*); 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); @@ -247,15 +246,6 @@ resetstroke(Scrib *w) 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 displaylast(Scrib *w) { diff --git a/sys/src/libframe/frdraw.c b/sys/src/libframe/frdraw.c index b1bcf7d52..57412a8d5 100644 --- a/sys/src/libframe/frdraw.c +++ b/sys/src/libframe/frdraw.c @@ -10,7 +10,6 @@ _frdrawtext(Frame *f, Point pt, Image *text, Image *back) { Frbox *b; int nb; - static int x; for(nb=0,b=f->box; nbnbox; nb++, b++){ _frcklinewrap(f, &pt, b); diff --git a/sys/src/libhtml/build.c b/sys/src/libhtml/build.c index 7b99d64a1..54bf61f65 100644 --- a/sys/src/libhtml/build.c +++ b/sys/src/libhtml/build.c @@ -275,7 +275,7 @@ static Anchor* newanchor(int index, Rune* name, Rune* href, int target, Anchor* 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, diff --git a/sys/src/libmach/2db.c b/sys/src/libmach/2db.c index d7ee77f65..c91ccb7fe 100644 --- a/sys/src/libmach/2db.c +++ b/sys/src/libmach/2db.c @@ -94,7 +94,7 @@ static int 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 @@ m68020ufix(Map *map) 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++){ diff --git a/sys/src/libndb/ndbipinfo.c b/sys/src/libndb/ndbipinfo.c index f01335543..2e491d1d3 100644 --- a/sys/src/libndb/ndbipinfo.c +++ b/sys/src/libndb/ndbipinfo.c @@ -14,7 +14,6 @@ enum 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); diff --git a/sys/src/libregexp/regcomp.c b/sys/src/libregexp/regcomp.c index ad3b8cd96..61f9683a6 100644 --- a/sys/src/libregexp/regcomp.c +++ b/sys/src/libregexp/regcomp.c @@ -156,17 +156,6 @@ initplex(Parselex *plex, char *regstr, int lit) 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 @@ regcomp1(char *regstr, int nl, int lit) maxthr = regstrlen; parsetr = node(&plex, TSUB, e0(&plex), nil); -// prtree(parsetr, 0, 1); reprog = malloc(sizeof(Reprog) + sizeof(Reinst) * plex.instrs + sizeof(Rethread) * maxthr); @@ -515,65 +503,3 @@ buildclass(Parselex *l) } 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; - } -} diff --git a/sys/src/libscribble/hre_api.c b/sys/src/libscribble/hre_api.c index 240dcdcb2..0809ddc91 100644 --- a/sys/src/libscribble/hre_api.c +++ b/sys/src/libscribble/hre_api.c @@ -71,10 +71,8 @@ static char rif_name[] = "__recognizer_internal_finalize"; */ /*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 @@ recognizer_load(char* directory, char* name, char** subset) 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); } @@ -615,46 +598,6 @@ recognizer_train_gestures(recognizer rec,char* name,xgesture fn,void* wsinfo) * Local functions. */ -/* - * 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. @@ -757,49 +700,6 @@ static void delete_rec_info(rec_info* 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); -} - /* * Constructor functions for making structures. * diff --git a/sys/src/libstdio/dtoa.c b/sys/src/libstdio/dtoa.c index f8de75dbe..80fd3c73e 100644 --- a/sys/src/libstdio/dtoa.c +++ b/sys/src/libstdio/dtoa.c @@ -151,34 +151,6 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */ 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 @@ diff(Bigint *a, Bigint *b) 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 @@ d2b(FPdbleword d, int *e, int *bits) #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 @@ static const double 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 @@ -610,67 +547,6 @@ static const double tinytens[] = { #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) { diff --git a/sys/src/libstdio/setvbuf.c b/sys/src/libstdio/setvbuf.c index 34c3bf7c8..e63e8db9d 100644 --- a/sys/src/libstdio/setvbuf.c +++ b/sys/src/libstdio/setvbuf.c @@ -31,12 +31,6 @@ int setvbuf(FILE *f, char *buf, int mode, long size){ 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) { @@ -48,3 +42,8 @@ isatty(int fd) /* 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); +} diff --git a/sys/src/libventi/file.c b/sys/src/libventi/file.c index b6887dec7..bad30a567 100644 --- a/sys/src/libventi/file.c +++ b/sys/src/libventi/file.c @@ -503,7 +503,6 @@ blockwalk(VtBlock *p, int index, VtCache *c, int mode, VtEntry *e) VtBlock *b; int type; uchar *score; - VtEntry oe; switch(p->type){ case VtDataType: @@ -532,8 +531,6 @@ blockwalk(VtBlock *p, int index, VtCache *c, int mode, VtEntry *e) if(vtglobaltolocal(b->score) != NilBlock) return b; - oe = *e; - /* * Copy on write. */ @@ -600,7 +597,6 @@ static int shrinkdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth) { VtBlock *b, *nb, *ob, *rb; - VtEntry oe; assert(ISLOCKED(r)); assert(depth <= VtPointerDepth); @@ -609,12 +605,6 @@ shrinkdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth) 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; for(; DEPTH(e->type) > depth; e->type--){ -- 2.44.0