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

Remove SHOPT_ENV dead code and sh.env variable (re: 8d7f616e)

As so often with SHOPT_* compile-time options, not all the relevant
code was actually conditional on the option macro. After removing
SHOPT_ENV, the arguments to sh_putenv() and env_delete() macro
calls are dead code and, after removing that, the sh.env variable
is unused.
This commit is contained in:
Martijn Dekker 2022-02-14 14:40:21 +00:00
parent 5bd18322e0
commit 82ff91e9d9
5 changed files with 9 additions and 12 deletions

View file

@ -136,7 +136,7 @@ int b_exec(int argc,char *argv[], Shbltin_t *context)
(*cp=0,np=nv_search(arg->argval,sh.var_tree,0))) (*cp=0,np=nv_search(arg->argval,sh.var_tree,0)))
{ {
nv_onattr(np,NV_EXPORT); nv_onattr(np,NV_EXPORT);
sh_envput(sh.env,np); env_change();
} }
if(cp) if(cp)
*cp = '='; *cp = '=';

View file

@ -62,8 +62,6 @@
#define Empty ((char*)(e_sptbnl+3)) #define Empty ((char*)(e_sptbnl+3))
#define env_change() (++ast.env_serial) #define env_change() (++ast.env_serial)
#define sh_envput(e,p) env_change()
#define env_delete(e,p) env_change()
extern char* sh_getenv(const char*); extern char* sh_getenv(const char*);
extern char* sh_setenviron(const char*); extern char* sh_setenviron(const char*);

View file

@ -343,7 +343,6 @@ struct Shell_s
int xargexit; int xargexit;
int nenv; int nenv;
mode_t mask; mode_t mask;
void *env; /* environment */
void *init_context; void *init_context;
void *mac_context; void *mac_context;
void *lex_context; void *lex_context;

View file

@ -1604,7 +1604,7 @@ void nv_putval(register Namval_t *np, const char *string, int flags)
nv_local=1; nv_local=1;
nv_putv(np,sp,flags,np->nvfun); nv_putv(np,sp,flags,np->nvfun);
if(sp && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT))) if(sp && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)))
sh_envput(sh.env,np); env_change();
return; return;
} }
/* called from disc, assign the actual value */ /* called from disc, assign the actual value */
@ -2012,7 +2012,7 @@ void nv_putval(register Namval_t *np, const char *string, int flags)
free((void*)tofree); free((void*)tofree);
} }
if(!was_local && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT))) if(!was_local && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)))
sh_envput(sh.env,np); env_change();
return; return;
} }
@ -2409,7 +2409,7 @@ static void table_unset(register Dt_t *root, int flags, Dt_t *oroot)
np->nvfun = 0; np->nvfun = 0;
} }
if(nv_isattr(nq,NV_EXPORT)) if(nv_isattr(nq,NV_EXPORT))
sh_envput(sh.env,nq); env_change();
} }
sh.last_root = root; sh.last_root = root;
sh.last_table = 0; sh.last_table = 0;
@ -2556,7 +2556,7 @@ done:
if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(np,NV_EXPORT)) if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(np,NV_EXPORT))
{ {
if(nv_isattr(np,NV_EXPORT) && !strchr(np->nvname,'[')) if(nv_isattr(np,NV_EXPORT) && !strchr(np->nvname,'['))
env_delete(sh.env,nv_name(np)); env_change();
if(!(flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)) if(!(flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT))
np->nvenv = 0; np->nvenv = 0;
nv_setattr(np,0); nv_setattr(np,0);
@ -2942,13 +2942,13 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size)
{ {
/* EXPORT exists on old attributes therefore not on new */ /* EXPORT exists on old attributes therefore not on new */
nv_offattr(np,NV_EXPORT); nv_offattr(np,NV_EXPORT);
env_delete(sh.env,nv_name(np)); env_change();
} }
else else
{ {
/* EXPORT is now turned on for new attributes */ /* EXPORT is now turned on for new attributes */
nv_onattr(np,NV_EXPORT); nv_onattr(np,NV_EXPORT);
sh_envput(sh.env,np); env_change();
} }
if((n^newatts)==NV_EXPORT && !trans) if((n^newatts)==NV_EXPORT && !trans)
/* Only EXPORT attribute has changed and thus all work has been done. */ /* Only EXPORT attribute has changed and thus all work has been done. */

View file

@ -381,12 +381,12 @@ static void nv_restore(struct subshell *sp)
if(nv_isattr(mp,NV_EXPORT)) if(nv_isattr(mp,NV_EXPORT))
{ {
char *name = nv_name(mp); char *name = nv_name(mp);
sh_envput(sh.env,mp); env_change();
if(*name=='_' && strcmp(name,"_AST_FEATURES")==0) if(*name=='_' && strcmp(name,"_AST_FEATURES")==0)
astconf(NiL, NiL, NiL); astconf(NiL, NiL, NiL);
} }
else if(nv_isattr(np,NV_EXPORT)) else if(nv_isattr(np,NV_EXPORT))
env_delete(sh.env,nv_name(mp)); env_change();
nv_onattr(mp,flags); nv_onattr(mp,flags);
skip: skip:
for(mp=lp->child; mp; mp=mpnext) for(mp=lp->child; mp; mp=mpnext)