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
|
|
@ -40,14 +40,8 @@
|
|||
# include <ls.h>
|
||||
#endif
|
||||
|
||||
#if KSHELL
|
||||
# include "defs.h"
|
||||
# include "variables.h"
|
||||
#else
|
||||
# include <ctype.h>
|
||||
extern char ed_errbuf[];
|
||||
char e_version[] = "\n@(#)$Id: Editlib version 1993-12-28 r $\0\n";
|
||||
#endif /* KSHELL */
|
||||
#include "defs.h"
|
||||
#include "variables.h"
|
||||
#include "io.h"
|
||||
#include "terminal.h"
|
||||
#include "history.h"
|
||||
|
|
@ -138,12 +132,7 @@ static Lex_t *savelex;
|
|||
# endif /* TIOCGETP */
|
||||
#endif /* _hdr_sgtty */
|
||||
|
||||
#if KSHELL
|
||||
static int keytrap(Edit_t *,char*, int, int, int);
|
||||
#else
|
||||
Edit_t editb;
|
||||
#endif /* KSHELL */
|
||||
|
||||
static int keytrap(Edit_t *,char*, int, int, int);
|
||||
|
||||
#ifndef _POSIX_DISABLE
|
||||
# define _POSIX_DISABLE 0
|
||||
|
|
@ -618,15 +607,11 @@ void ed_setup(register Edit_t *ep, int fd, int reedit)
|
|||
ep->nhlist = 0;
|
||||
ep->hoff = 0;
|
||||
#endif /* SHOPT_EDPREDICT */
|
||||
#if KSHELL
|
||||
ep->e_stkoff = staktell();
|
||||
ep->e_stkptr = stakfreeze(0);
|
||||
if(!(last = shp->prompt))
|
||||
last = "";
|
||||
shp->prompt = 0;
|
||||
#else
|
||||
last = ep->e_prbuff;
|
||||
#endif /* KSHELL */
|
||||
if(shp->gd->hist_ptr)
|
||||
{
|
||||
register History_t *hp = shp->gd->hist_ptr;
|
||||
|
|
@ -1033,10 +1018,8 @@ static int putstack(Edit_t *ep,char string[], register int nbyte, int type)
|
|||
{
|
||||
/*** user break key ***/
|
||||
ep->e_lookahead = 0;
|
||||
# if KSHELL
|
||||
sh_fault(SIGINT);
|
||||
siglongjmp(ep->e_env, UINTR);
|
||||
# endif /* KSHELL */
|
||||
}
|
||||
# endif /* CBREAK */
|
||||
|
||||
|
|
@ -1091,10 +1074,8 @@ static int putstack(Edit_t *ep,char string[], register int nbyte, int type)
|
|||
{
|
||||
/*** user break key ***/
|
||||
ep->e_lookahead = 0;
|
||||
# if KSHELL
|
||||
sh_fault(SIGINT);
|
||||
siglongjmp(ep->e_env, UINTR);
|
||||
# endif /* KSHELL */
|
||||
}
|
||||
# endif /* CBREAK */
|
||||
}
|
||||
|
|
@ -1638,7 +1619,6 @@ int tcsetattr(int fd,int mode,struct termios *tt)
|
|||
}
|
||||
#endif /* SHOPT_OLDTERMIO */
|
||||
|
||||
#if KSHELL
|
||||
/*
|
||||
* Execute keyboard trap on given buffer <inbuff> of given size <isize>
|
||||
* <mode> < 0 for vi insert mode
|
||||
|
|
@ -1683,7 +1663,6 @@ static int keytrap(Edit_t *ep,char *inbuff,register int insize, int bufsize, int
|
|||
nv_unset(ED_TXTNOD);
|
||||
return(insize);
|
||||
}
|
||||
#endif /* KSHELL */
|
||||
|
||||
#if SHOPT_EDPREDICT
|
||||
static int ed_sortdata(const char *s1, const char *s2)
|
||||
|
|
|
|||
|
|
@ -66,13 +66,8 @@ One line screen editor for any program
|
|||
|
||||
#include <ast.h>
|
||||
#include "FEATURE/cmds"
|
||||
#if KSHELL
|
||||
# include "defs.h"
|
||||
#else
|
||||
# include <ctype.h>
|
||||
#endif /* KSHELL */
|
||||
#include "defs.h"
|
||||
#include "io.h"
|
||||
|
||||
#include "history.h"
|
||||
#include "edit.h"
|
||||
#include "terminal.h"
|
||||
|
|
@ -976,7 +971,6 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
|
|||
draw(ep,UPDATE);
|
||||
return(-1);
|
||||
}
|
||||
#if KSHELL
|
||||
|
||||
#if SHOPT_EDPREDICT
|
||||
case '\n': case '\t':
|
||||
|
|
@ -1168,18 +1162,9 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
|
|||
# else
|
||||
return(-1);
|
||||
# endif /* ESH_BETTER */
|
||||
#else
|
||||
update:
|
||||
cur = i;
|
||||
draw(ep,UPDATE);
|
||||
beep();
|
||||
return(-1);
|
||||
|
||||
default:
|
||||
#endif /* KSHELL */
|
||||
beep();
|
||||
return(-1);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1202,8 +1187,7 @@ static void xcommands(register Emacs_t *ep,int count)
|
|||
draw(ep,UPDATE);
|
||||
return;
|
||||
|
||||
#if KSHELL
|
||||
# ifdef ESH_BETTER
|
||||
#ifdef ESH_BETTER
|
||||
case cntl('E'): /* invoke emacs on current command */
|
||||
if(ed_fulledit(ep->ed)==-1)
|
||||
beep();
|
||||
|
|
@ -1267,8 +1251,7 @@ static void xcommands(register Emacs_t *ep,int count)
|
|||
return;
|
||||
}
|
||||
# endif /* debugging code */
|
||||
# endif /* ESH_BETTER */
|
||||
#endif /* KSHELL */
|
||||
#endif /* ESH_BETTER */
|
||||
|
||||
default:
|
||||
beep();
|
||||
|
|
|
|||
|
|
@ -77,30 +77,12 @@
|
|||
#include <error.h>
|
||||
#include <ls.h>
|
||||
#include "defs.h"
|
||||
#if KSHELL
|
||||
# include "variables.h"
|
||||
# include "path.h"
|
||||
# include "builtins.h"
|
||||
# include "io.h"
|
||||
#else
|
||||
# include <ctype.h>
|
||||
#endif /* KSHELL */
|
||||
#include "variables.h"
|
||||
#include "path.h"
|
||||
#include "builtins.h"
|
||||
#include "io.h"
|
||||
#include "history.h"
|
||||
|
||||
#if !KSHELL
|
||||
# define NIL(type) ((type)0)
|
||||
# define path_relative(s,x) (s,x)
|
||||
# ifdef __STDC__
|
||||
# define nv_getval(s) getenv(#s)
|
||||
# else
|
||||
# define nv_getval(s) getenv("s")
|
||||
# endif /* __STDC__ */
|
||||
# define e_unknown "unknown"
|
||||
# define sh_translate(x) (x)
|
||||
char login_sh = 0;
|
||||
const char hist_fname[] = "/.history";
|
||||
#endif /* KSHELL */
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif /* O_BINARY */
|
||||
|
|
@ -268,10 +250,8 @@ retry:
|
|||
}
|
||||
if(fd < 0)
|
||||
{
|
||||
#if KSHELL
|
||||
/* don't allow root a history_file in /tmp */
|
||||
if(shgd->userid)
|
||||
#endif /* KSHELL */
|
||||
{
|
||||
if(!(fname = pathtmp(NIL(char*),0,0,NIL(int*))))
|
||||
return(0);
|
||||
|
|
@ -346,9 +326,7 @@ retry:
|
|||
hp = hist_trim(hp,(int)hp->histind-maxlines);
|
||||
}
|
||||
sfdisc(hp->histfp,&hp->histdisc);
|
||||
#if KSHELL
|
||||
(HISTCUR)->nvalue.lp = (&hp->histind);
|
||||
#endif /* KSHELL */
|
||||
sh_timeradd(1000L*(HIST_RECENT-30), 1, hist_touch, (void*)hp->histname);
|
||||
#if SHOPT_ACCTFILE
|
||||
if(sh_isstate(SH_INTERACTIVE))
|
||||
|
|
@ -955,11 +933,9 @@ Histloc_t hist_find(register History_t*hp,char *string,register int index1,int f
|
|||
location.hist_command = index1;
|
||||
return(location);
|
||||
}
|
||||
#if KSHELL
|
||||
/* allow a search to be aborted */
|
||||
if(((Shell_t*)hp->histshell)->trapnote&SH_SIGSET)
|
||||
break;
|
||||
#endif /* KSHELL */
|
||||
}
|
||||
return(location);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,13 +31,7 @@
|
|||
|
||||
#if SHOPT_VSH
|
||||
|
||||
#if KSHELL
|
||||
# include "defs.h"
|
||||
#else
|
||||
# include <ast.h>
|
||||
# include "FEATURE/options"
|
||||
# include <ctype.h>
|
||||
#endif /* KSHELL */
|
||||
#include "defs.h"
|
||||
#include "io.h"
|
||||
|
||||
#include "history.h"
|
||||
|
|
@ -258,14 +252,14 @@ int ed_viread(void *context, int fd, register char *shbuf, int nchar, int reedit
|
|||
/* time the current line to determine typeahead */
|
||||
oldtime = times(&dummy);
|
||||
#endif /* FIORDCHK */
|
||||
#if KSHELL
|
||||
/* abort of interrupt has occurred */
|
||||
if(ed->sh->trapnote&SH_SIGSET)
|
||||
i = -1;
|
||||
else
|
||||
#endif /* KSHELL */
|
||||
/*** Read the line ***/
|
||||
i = ed_read(context, fd, shbuf, nchar, 0);
|
||||
{
|
||||
/*** Read the line ***/
|
||||
i = ed_read(context, fd, shbuf, nchar, 0);
|
||||
}
|
||||
#ifndef FIORDCHK
|
||||
newtime = times(&dummy);
|
||||
vp->typeahead = ((newtime-oldtime) < NTICKS);
|
||||
|
|
@ -953,11 +947,9 @@ static int cntlmode(Vi_t *vp)
|
|||
}
|
||||
break;
|
||||
|
||||
#if KSHELL
|
||||
case 'v':
|
||||
if(vp->repeat_set==0)
|
||||
goto vcommand;
|
||||
#endif /* KSHELL */
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 'G': /** goto command repeat **/
|
||||
|
|
@ -975,13 +967,11 @@ static int cntlmode(Vi_t *vp)
|
|||
goto newhist;
|
||||
}
|
||||
|
||||
#if KSHELL
|
||||
vcommand:
|
||||
if(ed_fulledit(vp->ed)==GOOD)
|
||||
return(BIGVI);
|
||||
else
|
||||
goto ringbell;
|
||||
#endif /* KSHELL */
|
||||
|
||||
case '#': /** insert(delete) # to (no)comment command **/
|
||||
if( cur_virt != INVALID )
|
||||
|
|
@ -2448,7 +2438,6 @@ addin:
|
|||
{
|
||||
/***** Input commands *****/
|
||||
|
||||
#if KSHELL
|
||||
case '\t':
|
||||
if(vp->ed->e_tabcount!=1)
|
||||
return(BAD);
|
||||
|
|
@ -2514,7 +2503,6 @@ addin:
|
|||
ed_ringbell();
|
||||
return(BAD);
|
||||
|
||||
#endif /* KSHELL */
|
||||
case '_': /** append last argument of prev command **/
|
||||
save_v(vp);
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue