1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

'#if 0' cleanup

This removes various blocks of uncommented experimental code that
was disabled using '#if 0' or '#if 1 ... #else' directives. It's
hard or impossible to figure out what the thoughts behind them
might have been, and we can really do without those distractions.
This commit is contained in:
Martijn Dekker 2020-08-30 03:59:12 +01:00
parent f8feed1bd2
commit 42301639d6
17 changed files with 4 additions and 227 deletions

View file

@ -70,11 +70,6 @@ USAGE_LICENSE
"with the \bfunction\b reserved word, the specified variables "
"will have function static scope. Otherwise, the variable is "
"unset prior to processing the assignment list.]"
#if 0
"[p?Causes the output to be in a form of \b\f?\f\b commands that can be "
"used as input to the shell to recreate the current type of "
"these variables.]"
#endif
"\n"
"\n[name[=value]...]\n"
"\n"
@ -103,11 +98,7 @@ static int enuminfo(Opt_t* op, Sfio_t *out, const char *str, Optdisc_t *fp)
np = *(Namval_t**)(fp+1);
ep = (struct Enum*)np->nvfun;
if(strcmp(str,"default")==0)
#if 0
sfprintf(out,"\b%s\b%c",ep->values[0],0);
#else
sfprintf(out,"\b%s\b",ep->values[0]);
#endif
else if(strcmp(str,"case")==0)
{
if(ep->iflag)

View file

@ -227,10 +227,8 @@ static int waitnotify(int fd, long timeout, int rw)
if(service_list[file_list[i]])
*pstream++ = sh_fd2sfio(file_list[i]);
}
#if 1
for(i=0; i < pstream-poll_list; i++)
sfset(poll_list[i],SF_WRITE,0);
#endif
nready = ready = 0;
errno = 0;
#ifdef DEBUG
@ -246,10 +244,8 @@ static int waitnotify(int fd, long timeout, int rw)
sfprintf(sfstderr," %d",sffileno(poll_list[i]));
sfputc(sfstderr,'\n');
#endif
#if 1
for(i=0; i < pstream-poll_list; i++)
sfset(poll_list[i],SF_WRITE,1);
#endif
if(nready<=0)
return(errno? -1: 0);
if(special && poll_list[0]==special)

View file

@ -538,11 +538,7 @@ static char *fmthtml(const char *string, int flags)
return(stakptr(offset));
}
#if 1
static ssize_t fmtbase64(Sfio_t *iop, char *string, int alt)
#else
static void *fmtbase64(char *string, ssize_t *sz, int alt)
#endif
{
char *cp;
Sfdouble_t d;
@ -595,16 +591,9 @@ static void *fmtbase64(char *string, ssize_t *sz, int alt)
number.i = (int)d;
}
}
#if 1
return(sfwrite(iop, (void*)&number, size));
#else
if(sz)
*sz = size;
return((void*)&number);
#endif
}
if(nv_isattr(np,NV_BINARY))
#if 1
{
Namfun_t *fp;
for(fp=np->nvfun; fp;fp=fp->next)
@ -651,17 +640,6 @@ static void *fmtbase64(char *string, ssize_t *sz, int alt)
size = strlen(cp);
return(sfwrite(iop,cp,size));
}
#else
nv_onattr(np,NV_RAW);
cp = nv_getval(np);
if(nv_isattr(np,NV_BINARY))
nv_offattr(np,NV_RAW);
if((size = nv_size(np))==0)
size = strlen(cp);
if(sz)
*sz = size;
return((void*)cp);
#endif
}
static int varname(const char *str, int n)

View file

@ -1784,12 +1784,8 @@ USAGE_LICENSE
"[+?\btypeset\b is built in to the shell as a declaration command so that "
"field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]"
#if 1
"[a]:?[type?Indexed array. This is the default. If \b[\b\atype\a\b]]\b is "
"specified, each subscript is interpreted as a value of type \atype\a.]"
#else
"[a?Indexed array. this is the default.]"
#endif
"[b?Each \aname\a may contain binary data. Its value is the mime "
"base64 encoding of the data. It can be used with \b-Z\b, "
"to specify fixed sized fields.]"

View file

@ -133,17 +133,6 @@ typedef struct _shlex_
#define SH_COMPASSIGN 010 /* allow compound assignments only */
#if 0
typedef struct _shlex_
{
struct shlex_t _shlex;
#ifdef _SHLEX_PRIVATE
_SHLEX_PRIVATE
#endif
} Lex_t;
#define shlex (((Lex_t*)(sh.lex_context))->_shlex)
#endif
extern const char e_unexpected[];
extern const char e_unmatched[];
extern const char e_endoffile[];

View file

@ -490,11 +490,6 @@ static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdoubl
case MESSAGE:
sfsync(NIL(Sfio_t*));
#if 0
if(warn)
errormsg(SH_DICT,ERROR_warn(0),lvalue->value,*ptr);
else
#endif
if(lvalue->emode&ARITH_COMP)
return(-1);

View file

@ -1207,22 +1207,6 @@ Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
}
ap->header.nelem &= ~ARRAY_UNDEF;
ap->header.nelem |= (mode&(ARRAY_SCAN|ARRAY_NOCHILD|ARRAY_UNDEF|ARRAY_NOSCOPE));
#if 0
if(array_isbit(ap->bits,oldsize,ARRAY_CHILD))
mp = ap->val[oldsize].np;
if(size != oldsize && mp->nvalue.cp)
{
Namfun_t *nfp;
for(nfp=np->nvfun; nfp; nfp=nfp->next)
{
if(nfp->disc && nfp->disc->readf)
{
(*nfp->disc->readf)(mp,(Sfio_t*)0,0,nfp);
break;
}
}
}
#endif
ap->cur = size;
if((mode&ARRAY_SCAN) && (ap->cur--,!nv_nextsub(np)))
np = 0;

View file

@ -348,10 +348,6 @@ static void put_restricted(register Namval_t* np,const char *val,int flags,Namfu
if(mp && (val=nv_getval(mp)))
nv_putval(mp,val,NV_RDONLY);
}
#if 0
sfprintf(sfstderr,"%d: name=%s val=%s\n",getpid(),name,val);
path_dump((Pathcomp_t*)shp->pathlist);
#endif
}
}

View file

@ -812,9 +812,6 @@ static void copyto(register Mac_t *mp,int endch, int newquote)
if(n==S_COLON && mp->assign==2 && *cp=='~' && endch==0 && !mp->quote &&!mp->lit)
tilde = stktell(stkp)+(c+1);
else if(n==S_SLASH && mp->pattern==2)
#if 0
goto pattern;
#else
{
if(mp->quote || mp->lit)
goto pattern;
@ -827,7 +824,6 @@ static void copyto(register Mac_t *mp,int endch, int newquote)
sfwrite(stkp,first,cp-first);
first=cp;
}
#endif
break;
case S_DOT:
if(*cp=='.' && mp->subcopy==1)

View file

@ -1052,9 +1052,6 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
#if SHOPT_FIXEDARRAY
Namarr_t *ap = nv_arrayptr(np);
#endif /* SHOPT_FIXEDARRAY */
#if 0
int scan = ap?(ap->nelem&ARRAY_SCAN):0;
#endif
n = mode|nv_isarray(np);
if(!mode && (flags&NV_ARRAY) && ((c=sp[1])=='*' || c=='@') && sp[2]==']')
{
@ -1078,10 +1075,6 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
flags &= ~NV_ARRAY;
#endif /* SHOPT_FIXEDARRAY */
#if 0
if(scan)
nv_putsub(np,NIL(char*),ARRAY_SCAN);
#endif
}
else
cp = sp;
@ -1307,13 +1300,6 @@ void nv_delete(Namval_t* np, Dt_t *root, int flags)
free((void*)np);
}
}
#if 0
else
{
sfprintf(sfstderr,"%s not deleted\n",nv_name(np));
sfsync(sfstderr);
}
#endif
}
}
@ -2644,7 +2630,6 @@ Namval_t *sh_scoped(Shell_t *shp, register Namval_t *np)
return(dtsearch(shp->var_tree,np));
}
#if 1
/*
* return space separated list of names of variables in given tree
*/
@ -2674,7 +2659,6 @@ static char *tableval(Dt_t *root)
dtview(root,base);
return((char*)out->_data);
}
#endif
#if SHOPT_OPTIMIZE
struct optimize
@ -3164,12 +3148,7 @@ char *sh_getenv(const char *name)
Shell_t *shp = sh_getinterp();
register Namval_t *np;
if(!shp->var_tree)
{
#if 0
if(name[0] == 'P' && name[1] == 'A' && name[2] == 'T' && name[3] == 'H' && name[4] == 0 || name[0] == 'L' && ((name[1] == 'C' || name[1] == 'D') && name[2] == '_' || name[1] == 'A' && name[1] == 'N') || name[0] == 'V' && name[1] == 'P' && name[2] == 'A' && name[3] == 'T' && name[4] == 'H' && name[5] == 0 || name[0] == '_' && name[1] == 'R' && name[2] == 'L' && name[3] == 'D' || name[0] == '_' && name[1] == 'A' && name[2] == 'S' && name[3] == 'T' && name[4] == '_')
#endif
return(oldgetenv(name));
}
else if((np = nv_search(name,shp->var_tree,0)) && nv_isattr(np,NV_EXPORT))
return(nv_getval(np));
return(0);
@ -3655,11 +3634,7 @@ char *nv_name(register Namval_t *np)
return(sfstruse(shp->strbuf));
}
if(nv_istable(np))
#if 1
shp->last_table = nv_parent(np);
#else
shp->last_table = nv_create(np,0, NV_LAST,(Namfun_t*)0);
#endif
else if(!nv_isref(np))
{
for(fp= np->nvfun ; fp; fp=fp->next)

View file

@ -1415,16 +1415,8 @@ Dt_t *nv_dict(Namval_t* np)
if(tp)
return(tp->dict);
np = shp->last_table;
while(np)
{
if(tp = (struct table*)nv_hasdisc(np,&table_disc))
if(np && (tp = (struct table*)nv_hasdisc(np,&table_disc)))
return(tp->dict);
#if 0
np = nv_create(np,(const char*)0, NV_FIRST, (Namfun_t*)0);
#else
break;
#endif
}
return(shp->var_tree);
}

View file

@ -159,7 +159,6 @@ void *nv_diropen(Namval_t *np,const char *name)
dp->data[len] = 0;
dp->len = len;
dp->root = sh.last_root?sh.last_root:sh.var_tree;
#if 1
while(1)
{
dp->table = sh.last_table;
@ -176,11 +175,6 @@ void *nv_diropen(Namval_t *np,const char *name)
dp->root = nv_dict(np);
name = next+1;
}
#else
dp->table = sh.last_table;
sh.last_table = 0;
last = dp->data;
#endif
if(*name)
{
fake.nvname = (char*)name;
@ -282,28 +276,14 @@ char *nv_dirnext(void *dir)
{
while(np=dp->hp)
{
#if 0
char *sptr;
#endif
if(nv_isarray(np))
nv_putsub(np,(char*)0, ARRAY_UNDEF);
dp->hp = nextnode(dp);
if(nv_isnull(np) && !nv_isarray(np) && !nv_isattr(np,NV_INTEGER))
continue;
last_table = sh.last_table;
#if 0
if(dp->table && dp->otable && !nv_isattr(dp->table,NV_MINIMAL))
{
sptr = dp->table->nvenv;
dp->table->nvenv = (char*)dp->otable;
}
#endif
sh.last_table = dp->table;
cp = nv_name(np);
#if 0
if(dp->table && dp->otable && !nv_isattr(dp->table,NV_MINIMAL))
dp->table->nvenv = sptr;
#endif
if(dp->nextnode && !dp->hp && (nq = (Namval_t*)dp->table))
{
Namarr_t *ap = nv_arrayptr(nq);
@ -342,11 +322,6 @@ char *nv_dirnext(void *dir)
memcpy(dp->data,cp,len+1);
if(nfp && np->nvfun)
{
#if 0
Namarr_t *ap = nv_arrayptr(np);
if(ap && (ap->nelem&ARRAY_UNDEF))
nv_putsub(np,(char*)0,ARRAY_SCAN);
#endif
dp->nextnode = nfp->disc->nextf;
dp->otable = dp->table;
dp->table = np;

View file

@ -99,16 +99,6 @@ struct Namtype
unsigned short nref;
};
#if 0
struct type
{
Namtype_t hdr;
unsigned short ndisc;
unsigned short current;
unsigned short nref;
};
#endif
typedef struct
{
char _cSfdouble_t;
@ -148,9 +138,6 @@ static const Namdisc_t type_disc =
0,
next_type,
0,
#if 0
read_type
#endif
};
size_t nv_datasize(Namval_t *np, size_t *offset)
@ -329,13 +316,8 @@ static int fixnode(Namtype_t *dp, Namtype_t *pp, int i, struct Namref *nrp,int f
if(fp)
nv_disc(np, fp, NV_LAST);
}
#if 0
if(nq->nvalue.cp >= pp->data && nq->nvalue.cp < (char*)pp +pp->fun.dsize)
nq->nvalue.cp = dp->data + (nq->nvalue.cp-pp->data);
#else
if(data >= pp->data && data < (char*)pp +pp->fun.dsize)
nq->nvalue.cp = dp->data + (data-pp->data);
#endif
else if(!nq->nvfun && pp->childfun.ttype!=pp->childfun.ptype)
{
Namval_t *nr = nv_namptr( pp->childfun.ttype->nodes,i);
@ -390,17 +372,10 @@ static Namfun_t *clone_type(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
memset((void*)nrp,0,pp->nref*sizeof(struct Namref));
}
memcpy((void*)dp,(void*)pp,size);
#if 0
dp->parent = nv_lastdict();
#else
dp->parent = mp;
#endif
dp->fun.nofree = (flags&NV_RDONLY?1:0);
dp->np = mp;
dp->childfun.ptype = dp;
#if 0
dp->childfun.ttype = (Namtype_t*)nv_hasdisc(dp->fun.type,&type_disc);
#endif
dp->nodes = (char*)(dp+1);
dp->data = (char*)dp + (pp->data - (char*)pp);
for(i=dp->numnodes; --i >= 0; )
@ -1097,7 +1072,6 @@ Namval_t *nv_mktype(Namval_t **nodes, int numnodes)
nv_disc(nq, &pp->childfun.fun, NV_LAST);
if(tp = (Namtype_t*)nv_hasdisc(nq, &type_disc))
tp->strsize = -tp->strsize;
else sfprintf(sfstderr,"tp==NULL\n");
for(r=0; r < dp->numnodes; r++)
{
Namval_t *nr = nv_namptr(dp->nodes,r);
@ -1182,11 +1156,7 @@ else sfprintf(sfstderr,"tp==NULL\n");
if(!nq->nvalue.cp && nq->nvfun== &pp->childfun.fun)
nq->nvalue.cp = Empty;
np->nvalue.cp = 0;
#if 0
offset += dsize;
#else
offset += (dsize?dsize:4);
#endif
}
k++;
skip:
@ -1426,10 +1396,6 @@ Fields_t foo[]=
FIELD(time,a),
FIELD(time,m),
FIELD(time,c),
#if 0
FIELD(blksize,),
FIELD(blocks,),
#endif
0
};

View file

@ -1572,10 +1572,6 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
writedefs(lexp,argp,line,0,NIL(struct argnod*));
else if(argp && strcmp(argp->argval,"read")==0)
writedefs(lexp,argp,line,0,NIL(struct argnod*));
#if 0
else if(argp && strcmp(argp->argval,"unset")==0)
writedefs(lexp,argp,line,'u',NIL(struct argnod*));
#endif
else if(argp && *argp->argval=='.' && argp->argval[1]==0 && (argp=argp->argnxt.ap))
{
r = kiaentity(lexp,sh_argstr(argp),-1,'p',0,0,lexp->script,'d',0,"");

View file

@ -355,19 +355,6 @@ static char *path_lib(Shell_t *shp,Pathcomp_t *pp, char *path)
return(0);
}
#if 0
void path_dump(register Pathcomp_t *pp)
{
sfprintf(sfstderr,"dump\n");
while(pp)
{
sfprintf(sfstderr,"pp=%x dev=%d ino=%d len=%d flags=%o name=%.*s\n",
pp,pp->dev,pp->ino,pp->len,pp->flags,pp->len,pp->name);
pp = pp->next;
}
}
#endif
/*
* check for duplicate directories on PATH
*/
@ -1705,9 +1692,6 @@ void path_newdir(Shell_t *shp,Pathcomp_t *first)
pp->next = next;
}
}
#if 0
path_dump(first);
#endif
}
Pathcomp_t *path_unsetfpath(Shell_t *shp)

View file

@ -194,23 +194,6 @@ static struct argnod *r_arg(Shell_t *shp)
ap->argval[l] = 0;
ap->argchn.cp = 0;
ap->argflag = sfgetc(infile);
#if 0
if((ap->argflag&ARG_MESSAGE) && *ap->argval)
{
/* replace international messages */
sh_endword(shp,1);
ap->argflag &= ~ARG_MESSAGE;
if(!(ap->argflag&(ARG_MAC|ARG_EXP)))
ap = sh_endword(shp,0);
else
{
ap = (struct argnod*)stkfreeze(stkp,0);
if(ap->argflag==0)
ap->argflag = ARG_RAW;
}
}
else
#endif
ap = (struct argnod*)stkfreeze(stkp,0);
if(*ap->argval==0 && (ap->argflag&ARG_EXP))
ap->argchn.ap = (struct argnod*)r_tree(shp);

View file

@ -1143,10 +1143,6 @@ int sh_exec(register const Shnode_t *t, int flags)
flgs |= NV_IDENT;
else
flgs |= NV_VARNAME;
#if 0
if(OPTIMIZE)
flgs |= NV_TAGGED;
#endif
nv_setlist(argp,flgs,tp);
if(np==shp->typeinit)
shp->typeinit = 0;
@ -1414,10 +1410,6 @@ int sh_exec(register const Shnode_t *t, int flags)
shp->redir0 = 0;
if(jmpval)
siglongjmp(*shp->jmplist,jmpval);
#if 0
if(flgs&NV_STATIC)
((Shnode_t*)t)->com.comset = 0;
#endif
if(shp->exitval >=0)
goto setexit;
np = 0;
@ -3060,9 +3052,6 @@ int sh_funscope(int argn, char *argv[],int(*fun)(void*),void *arg,int execflg)
shp->glob_options = shp->options;
else
shp->options = shp->glob_options;
#if 0
shp->st.lineno = error_info.line;
#endif
*prevscope = shp->st;
sh_offoption(SH_ERREXIT);
shp->st.prevst = prevscope;
@ -3240,11 +3229,7 @@ static void sh_funct(Shell_t *shp,Namval_t *np,int argn, char *argv[],struct arg
SH_LEVELNOD->nvalue.s = lp->maxlevel;
shp->last_root = nv_dict(DOTSHNOD);
shp->comsub = comsub;
#if 0
nv_putval(SH_FUNNAMENOD,shp->st.funname,NV_NOFREE);
#else
nv_putval(SH_FUNNAMENOD,fname,NV_NOFREE);
#endif
nv_putval(SH_PATHNAMENOD,shp->st.filename,NV_NOFREE);
shp->pipepid = pipepid;
np->nvalue.rp->running -= 2;