1
0
Fork 0
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:
Martijn Dekker 2021-12-08 22:16:11 +01:00
parent 2b8eaa6609
commit aa3048880b
18 changed files with 102 additions and 285 deletions

View file

@ -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)