/sys/src/lib*: clean up
This commit is contained in:
parent
28f4567ba6
commit
ed76659c05
12 changed files with 7 additions and 360 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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; nb<f->nbox; nb++, b++){
|
||||
_frcklinewrap(f, &pt, b);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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++){
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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--){
|
||||
|
|
Loading…
Reference in a new issue