mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
cleanup: get rid of KSHELL and _BLD_shell preprocessor macros
Once upon a time it might have been possible to build certain parts of ksh, such as the emacs and vi editors and possibly even the name/value library (nval(3)) as independent libraries. But given the depressing amount of bit rot in the code that we inherited, I am certain that disabling either of these macros had been resulting in a broken build for many years before AT&T abandoned this code base. These are certainly not going to be useful now. Meanwhile the KSHELL macro got in the way of me today, because the Mamfile did not define it for all the .c files, but some headers declared some functionality conditionally upon that macro. So including <io.h> in, e.g., nvdisc.c did not declare the same functions as including that header in files with KSHELL defined. This inconsistency is now gone as well, for various files. I'm currently working on making it possible once again to build libshell as a dynamic library; that should be good enough. And that never involved disabling either of these macros.
This commit is contained in:
parent
2b8eaa6609
commit
aa3048880b
18 changed files with 102 additions and 285 deletions
|
|
@ -27,15 +27,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#if KSHELL
|
||||
# include "defs.h"
|
||||
# include "variables.h"
|
||||
# include "test.h"
|
||||
#else
|
||||
# include <ast.h>
|
||||
# include <ctype.h>
|
||||
# include <setjmp.h>
|
||||
#endif /* KSHELL */
|
||||
#include "defs.h"
|
||||
#include "variables.h"
|
||||
#include "test.h"
|
||||
#include <glob.h>
|
||||
#include <ls.h>
|
||||
#include <stak.h>
|
||||
|
|
@ -43,23 +37,16 @@
|
|||
#include "io.h"
|
||||
#include "path.h"
|
||||
|
||||
#if KSHELL
|
||||
# define argbegin argnxt.cp
|
||||
static const char *sufstr;
|
||||
static int suflen;
|
||||
static int scantree(Dt_t*,const char*, struct argnod**);
|
||||
#else
|
||||
# define sh_sigcheck(sig) (0)
|
||||
# define sh_access access
|
||||
# define suflen 0
|
||||
#endif /* KSHELL */
|
||||
#define argbegin argnxt.cp
|
||||
static const char *sufstr;
|
||||
static int suflen;
|
||||
static int scantree(Dt_t*,const char*, struct argnod**);
|
||||
|
||||
|
||||
/*
|
||||
* This routine builds a list of files that match a given pathname
|
||||
* Uses external routine strgrpmatch() to match each component
|
||||
* A leading . must match explicitly
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLOB_AUGMENTED
|
||||
|
|
@ -99,11 +86,9 @@ int path_expand(Shell_t *shp,const char *pattern, struct argnod **arghead)
|
|||
#endif
|
||||
if(sh_isstate(SH_COMPLETE))
|
||||
{
|
||||
#if KSHELL
|
||||
extra += scantree(shp->alias_tree,pattern,arghead);
|
||||
extra += scantree(shp->fun_tree,pattern,arghead);
|
||||
gp->gl_nextdir = nextdir;
|
||||
#endif /* KSHELL */
|
||||
flags |= GLOB_COMPLETE;
|
||||
flags &= ~GLOB_NOCHECK;
|
||||
}
|
||||
|
|
@ -127,8 +112,6 @@ int path_expand(Shell_t *shp,const char *pattern, struct argnod **arghead)
|
|||
return(gp->gl_pathc+extra);
|
||||
}
|
||||
|
||||
#if KSHELL
|
||||
|
||||
/*
|
||||
* scan tree and add each name that matches the given pattern
|
||||
*/
|
||||
|
|
@ -169,8 +152,6 @@ int path_complete(Shell_t *shp,const char *name,register const char *suffix, str
|
|||
return(path_expand(shp,name,arghead));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if SHOPT_BRACEPAT
|
||||
|
||||
static int checkfmt(Sfio_t* sp, void* vp, Sffmt_t* fp)
|
||||
|
|
|
|||
|
|
@ -32,15 +32,7 @@
|
|||
#include <fcin.h>
|
||||
#include <nval.h>
|
||||
#include "FEATURE/options"
|
||||
|
||||
#if KSHELL
|
||||
# include "defs.h"
|
||||
#else
|
||||
# include <shell.h>
|
||||
# define nv_getval(np) ((np)->nvalue)
|
||||
Shell_t sh = {1};
|
||||
#endif /* KSHELL */
|
||||
|
||||
#include "defs.h"
|
||||
#include "argnod.h"
|
||||
#include "test.h"
|
||||
#include "lexstates.h"
|
||||
|
|
@ -136,7 +128,6 @@ static void lex_advance(Sfio_t *iop, const char *buff, register int size, void *
|
|||
register Shell_t *shp = lp->sh;
|
||||
register Sfio_t *log= shp->funlog;
|
||||
Stk_t *stkp = shp->stk;
|
||||
#if KSHELL
|
||||
/* write to history file and to stderr if necessary */
|
||||
if(iop && !sfstacked(iop))
|
||||
{
|
||||
|
|
@ -146,7 +137,6 @@ static void lex_advance(Sfio_t *iop, const char *buff, register int size, void *
|
|||
if(sh_isstate(SH_VERBOSE))
|
||||
sfwrite(sfstderr, buff, size);
|
||||
}
|
||||
#endif
|
||||
if(lp->lexd.nocopy)
|
||||
return;
|
||||
if(lp->lexd.dolparen && lp->lexd.docword && lp->lexd.docend)
|
||||
|
|
@ -1498,10 +1488,8 @@ breakloop:
|
|||
if(!lp->lex.incase && !assignment && fcpeek(0)!=LPAREN &&
|
||||
(np=nv_search(state,shp->alias_tree,HASH_SCOPE))
|
||||
&& !nv_isattr(np,NV_NOEXPAND)
|
||||
#if KSHELL
|
||||
&& (lp->aliasok!=2 || nv_isattr(np,BLT_DCL))
|
||||
&& (!sh_isstate(SH_NOALIAS) || nv_isattr(np,NV_NOFREE))
|
||||
#endif /* KSHELL */
|
||||
&& (state=nv_getval(np)))
|
||||
{
|
||||
setupalias(lp,state,np);
|
||||
|
|
@ -2118,11 +2106,7 @@ noreturn void sh_syntax(Lex_t *lp)
|
|||
fcclose();
|
||||
shp->inlineno = lp->inlineno;
|
||||
shp->st.firstline = lp->firstline;
|
||||
#if KSHELL
|
||||
if(!sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_PROFILE))
|
||||
#else
|
||||
if(shp->inlineno!=1)
|
||||
#endif
|
||||
errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax1,lp->lastline,tokstr,cp);
|
||||
else
|
||||
errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax2,tokstr,cp);
|
||||
|
|
|
|||
|
|
@ -2152,7 +2152,6 @@ static void comsubst(Mac_t *mp,register Shnode_t* t, int type)
|
|||
mp->shp->inlineno = c;
|
||||
type = 1;
|
||||
}
|
||||
#if KSHELL
|
||||
if(t)
|
||||
{
|
||||
fcsave(&save);
|
||||
|
|
@ -2203,9 +2202,6 @@ static void comsubst(Mac_t *mp,register Shnode_t* t, int type)
|
|||
sh_onstate(SH_HISTORY);
|
||||
if(was_verbose)
|
||||
sh_onstate(SH_VERBOSE);
|
||||
#else
|
||||
sp = sfpopen(NIL(Sfio_t*),str,"r");
|
||||
#endif
|
||||
*mp = savemac;
|
||||
np = sh_scoped(mp->shp,IFSNOD);
|
||||
nv_putval(np,mp->ifsp,NV_RDONLY);
|
||||
|
|
|
|||
|
|
@ -29,12 +29,7 @@
|
|||
* This is the parser for a shell language
|
||||
*/
|
||||
|
||||
#if KSHELL
|
||||
#include "defs.h"
|
||||
#else
|
||||
#include <shell.h>
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <fcin.h>
|
||||
#include <error.h>
|
||||
#include "shlex.h"
|
||||
|
|
@ -72,15 +67,6 @@ static Shnode_t *test_primary(Lex_t*);
|
|||
#endif /* NIL */
|
||||
#define CNTL(x) ((x)&037)
|
||||
|
||||
|
||||
#if !KSHELL
|
||||
static struct stdata
|
||||
{
|
||||
struct slnod *staklist;
|
||||
int cmdline;
|
||||
} st;
|
||||
#endif
|
||||
|
||||
static int opt_get;
|
||||
static int loop_level;
|
||||
static struct argnod *label_list;
|
||||
|
|
@ -396,9 +382,7 @@ void *sh_parse(Shell_t *shp, Sfio_t *iop, int flag)
|
|||
flag &= ~SH_FUNEVAL;
|
||||
if((flag&SH_NL) && (shp->inlineno=error_info.line+shp->st.firstline)==0)
|
||||
shp->inlineno=1;
|
||||
#if KSHELL
|
||||
shp->nextprompt = 2;
|
||||
#endif
|
||||
t = sh_cmd(lexp,(flag&SH_EOF)?EOFSYM:'\n',SH_SEMI|SH_EMPTY|(flag&SH_NL));
|
||||
fcclose();
|
||||
fcrestore(&sav_input);
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ Sfdouble_t strval(Shell_t *shp,const char *s,char **end,Sfdouble_t(*conv)(const
|
|||
|
||||
#undef error
|
||||
|
||||
#if _BLD_shell && defined(__EXPORT__)
|
||||
#if defined(__EXPORT__)
|
||||
#define extern __EXPORT__
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue