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

@ -64,7 +64,7 @@
/* entry point for shell special builtins */
#if _BLD_shell && defined(__EXPORT__)
#if defined(__EXPORT__)
# define extern __EXPORT__
#endif

View file

@ -32,13 +32,6 @@
#include "FEATURE/options"
#include "FEATURE/locale"
#if !KSHELL
# include <setjmp.h>
# include <sig.h>
# include <ctype.h>
#endif /* KSHELL */
#include "FEATURE/setjmp"
#include "terminal.h"
@ -130,12 +123,8 @@ typedef struct edit
int *e_globals; /* global variables */
genchar *e_window; /* display window image */
char e_inmacro; /* processing macro expansion */
#if KSHELL
char e_vi_insert[2]; /* for sh_keytrap */
int32_t e_col; /* for sh_keytrap */
#else
char e_prbuff[PRSIZE]; /* prompt buffer */
#endif /* KSHELL */
struct termios e_ttyparm; /* initial tty parameters */
struct termios e_nttyparm; /* raw tty parameters */
struct termios e_savetty; /* saved terminal state */
@ -185,23 +174,6 @@ typedef struct edit
(c<'J'?c+1-'A':(c+10-'J'))))))))))))))))
#endif
#if !KSHELL
# define STRIP 0377
# define GMACS 1
# define EMACS 2
# define VIRAW 4
# define EDITVI 8
# define NOHIST 16
# define EDITMASK 15
# define is_option(m) (opt_flag&(m))
extern char opt_flag;
# ifdef SYSCALL
# define read(fd,buff,n) syscall(3,fd,buff,n)
# else
# define read(fd,buff,n) rEAd(fd,buff,n)
# endif /* SYSCALL */
#endif /* KSHELL */
extern void ed_crlf(Edit_t*);
extern void ed_putchar(Edit_t*, int);
extern void ed_ringbell(void);
@ -216,19 +188,17 @@ extern int ed_read(void*, int, char*, int, int);
extern int ed_emacsread(void*, int, char*, int, int);
extern Edpos_t ed_curpos(Edit_t*, genchar*, int, int, Edpos_t);
extern int ed_setcursor(Edit_t*, genchar*, int, int, int);
#if KSHELL
extern int ed_macro(Edit_t*,int);
extern int ed_expand(Edit_t*, char[],int*,int*,int,int);
extern int ed_fulledit(Edit_t*);
extern void *ed_open(Shell_t*);
#endif /* KSHELL */
# if SHOPT_MULTIBYTE
extern int ed_macro(Edit_t*,int);
extern int ed_expand(Edit_t*, char[],int*,int*,int,int);
extern int ed_fulledit(Edit_t*);
extern void *ed_open(Shell_t*);
#if SHOPT_MULTIBYTE
extern int ed_internal(const char*, genchar*);
extern int ed_external(const genchar*, char*);
extern void ed_gencpy(genchar*,const genchar*);
extern void ed_genncpy(genchar*,const genchar*,int);
extern int ed_genlen(const genchar*);
# endif /* SHOPT_MULTIBYTE */
#endif /* SHOPT_MULTIBYTE */
#if SHOPT_EDPREDICT
extern int ed_histgen(Edit_t*, const char*);
# if SHOPT_ESH || SHOPT_VSH
@ -237,9 +207,6 @@ extern int ed_setcursor(Edit_t*, genchar*, int, int, int);
#endif /* SHOPT_EDPREDICT */
extern const char e_runvi[];
#if !KSHELL
extern const char e_version[];
#endif /* KSHELL */
#if SHOPT_HISTEXPAND

View file

@ -49,12 +49,6 @@
#define IOPICKFD 0x10000 /* file descriptor number was selected automatically */
#define IOHERESTRING 0x20000 /* allow here documents to be string streams */
/*
* The remainder of this file is only used when compiled with shell
*/
#if KSHELL
#ifndef ARG_RAW
struct ionod;
#endif /* !ARG_RAW */
@ -66,7 +60,7 @@ extern int sh_iorenumber(Shell_t*,int,int);
extern void sh_pclose(int[]);
extern int sh_rpipe(int[]);
extern void sh_iorestore(Shell_t*,int,int);
#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
#if defined(__EXPORT__) && defined(_BLD_DLL)
__EXPORT__
#endif
extern Sfio_t *sh_iostream(Shell_t*,int);
@ -113,4 +107,3 @@ extern const char e_sysrc[];
extern const char e_stdprompt[];
extern const char e_supprompt[];
extern const char e_ambiguous[];
#endif /* KSHELL */

View file

@ -237,11 +237,7 @@ struct Namval
#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
#if defined(__EXPORT__) && defined(_DLL)
# ifdef _BLD_shell
# define extern __EXPORT__
# else
# define extern __IMPORT__
# endif /* _BLD_shell */
#endif /* _DLL */
/* prototype for array interface */
extern Namarr_t *nv_arrayptr(Namval_t*);

View file

@ -85,7 +85,7 @@ extern char *path_fullname(Shell_t*,const char*);
extern int path_expand(Shell_t*,const char*, struct argnod**);
extern noreturn void path_exec(Shell_t*,const char*,char*[],struct argnod*);
extern pid_t path_spawn(Shell_t*,const char*,char*[],char*[],Pathcomp_t*,int);
#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
#if defined(__EXPORT__) && defined(_BLD_DLL)
# define extern __EXPORT__
#endif
extern int path_open(Shell_t*,const char*,Pathcomp_t*);

View file

@ -219,9 +219,7 @@ extern Libcomp_t *liblist;
#undef getenv /* -lshell provides its own */
#if defined(__EXPORT__) && defined(_DLL)
# ifdef _BLD_shell
# define extern __EXPORT__
# endif /* _BLD_shell */
#endif /* _DLL */
extern Dt_t *sh_bltin_tree(void);
@ -273,11 +271,7 @@ extern int sh_exec(const Shnode_t*,int);
/*
* direct access to sh is obsolete, use sh_getinterp() instead
*/
#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
extern __IMPORT__ Shell_t sh;
#else
extern Shell_t sh;
#endif
extern Shell_t sh;
#ifdef _DLL
# undef extern

View file

@ -213,7 +213,7 @@ union Shnode_u
extern void sh_freeup(Shell_t*);
extern void sh_funstaks(struct slnod*,int);
extern Sfio_t *sh_subshell(Shell_t*,Shnode_t*, volatile int, int);
#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
#if defined(__EXPORT__) && defined(_BLD_DLL)
__EXPORT__
#endif
extern int sh_tdump(Sfio_t*, const Shnode_t*);