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

Remove more legacy libast code (re: f9c127e3, 651bbd56)

This removes #ifdefs checking for the existence of
SH_PLUGIN_VERSION (version check for dynamically loaded builtins)
and the SFIO identifiers SF_BUFCONST, SF_CLOSING, SF_APPENDWR,
SF_ATEXIT, all of which are defined by the bundled libast.
This commit is contained in:
Martijn Dekker 2021-03-21 04:17:05 +00:00
parent c7242de16f
commit 0b814b53bd
8 changed files with 18 additions and 80 deletions

View file

@ -1027,7 +1027,7 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
Stk_t *stkp; Stk_t *stkp;
void *library=0; void *library=0;
char *errmsg; char *errmsg;
#ifdef SH_PLUGIN_VERSION #if SHOPT_DYNAMIC
unsigned long ver; unsigned long ver;
int list = 0; int list = 0;
char path[1024]; char path[1024];
@ -1055,7 +1055,7 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
#endif /* SHOPT_DYNAMIC */ #endif /* SHOPT_DYNAMIC */
break; break;
case 'l': case 'l':
#ifdef SH_PLUGIN_VERSION #if SHOPT_DYNAMIC
list = 1; list = 1;
#endif #endif
break; break;
@ -1083,7 +1083,6 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
#if SHOPT_DYNAMIC #if SHOPT_DYNAMIC
if(arg) if(arg)
{ {
#ifdef SH_PLUGIN_VERSION
if(!(library = dllplugin(SH_ID, arg, NiL, SH_PLUGIN_VERSION, &ver, RTLD_LAZY, path, sizeof(path)))) if(!(library = dllplugin(SH_ID, arg, NiL, SH_PLUGIN_VERSION, &ver, RTLD_LAZY, path, sizeof(path))))
{ {
errormsg(SH_DICT,ERROR_exit(0),"%s: %s",arg,dllerror(0)); errormsg(SH_DICT,ERROR_exit(0),"%s: %s",arg,dllerror(0));
@ -1091,13 +1090,6 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
} }
if(list) if(list)
sfprintf(sfstdout, "%s %08lu %s\n", arg, ver, path); sfprintf(sfstdout, "%s %08lu %s\n", arg, ver, path);
#else
if(!(library = dllplug(SH_ID,arg,NIL(char*),RTLD_LAZY,NIL(char*),0)))
{
errormsg(SH_DICT,ERROR_exit(0),"%s: %s",arg,dlerror());
return(1);
}
#endif
sh_addlib(tdata.sh,library,arg,NiL); sh_addlib(tdata.sh,library,arg,NiL);
} }
else else

View file

@ -110,14 +110,8 @@ static History_t* hist_trim(History_t*, int);
static int hist_nearend(History_t*,Sfio_t*, off_t); static int hist_nearend(History_t*,Sfio_t*, off_t);
static int hist_check(int); static int hist_check(int);
static int hist_clean(int); static int hist_clean(int);
#ifdef SF_BUFCONST
static ssize_t hist_write(Sfio_t*, const void*, size_t, Sfdisc_t*); static ssize_t hist_write(Sfio_t*, const void*, size_t, Sfdisc_t*);
static int hist_exceptf(Sfio_t*, int, void*, Sfdisc_t*); static int hist_exceptf(Sfio_t*, int, void*, Sfdisc_t*);
#else
static int hist_write(Sfio_t*, const void*, int, Sfdisc_t*);
static int hist_exceptf(Sfio_t*, int, Sfdisc_t*);
#endif
static int histinit; static int histinit;
static mode_t histmode; static mode_t histmode;
@ -788,11 +782,7 @@ void hist_flush(register History_t *hp)
* a zero byte. Line sequencing is added as required * a zero byte. Line sequencing is added as required
*/ */
#ifdef SF_BUFCONST
static ssize_t hist_write(Sfio_t *iop,const void *buff,register size_t insize,Sfdisc_t* handle) static ssize_t hist_write(Sfio_t *iop,const void *buff,register size_t insize,Sfdisc_t* handle)
#else
static int hist_write(Sfio_t *iop,const void *buff,register int insize,Sfdisc_t* handle)
#endif
{ {
register History_t *hp = (History_t*)handle; register History_t *hp = (History_t*)handle;
register char *bufptr = ((char*)buff)+insize; register char *bufptr = ((char*)buff)+insize;
@ -1174,14 +1164,11 @@ done:
/* /*
* Handle history file exceptions * Handle history file exceptions
*/ */
#ifdef SF_BUFCONST
static int hist_exceptf(Sfio_t* fp, int type, void *data, Sfdisc_t *handle) static int hist_exceptf(Sfio_t* fp, int type, void *data, Sfdisc_t *handle)
#else
static int hist_exceptf(Sfio_t* fp, int type, Sfdisc_t *handle)
#endif
{ {
register int newfd,oldfd; register int newfd,oldfd;
History_t *hp = (History_t*)handle; History_t *hp = (History_t*)handle;
NOT_USED(data);
if(type==SF_WRITE) if(type==SF_WRITE)
{ {
if(errno==ENOSPC || hp->histwfail++ >= 10) if(errno==ENOSPC || hp->histwfail++ >= 10)

View file

@ -32,13 +32,6 @@
#endif /* IOBSIZE */ #endif /* IOBSIZE */
#define IOMAXTRY 20 #define IOMAXTRY 20
#ifndef SF_CLOSING
#define SF_CLOSING SF_CLOSE
#endif
#ifndef SF_APPENDWR
#define SF_APPENDWR SF_APPEND
#endif
/* used for output of shell errors */ /* used for output of shell errors */
#define ERRIO 2 #define ERRIO 2

View file

@ -2386,13 +2386,11 @@ static int subexcept(Sfio_t* sp,register int mode, void *data, Sfdisc_t* handle)
free((void*)disp); free((void*)disp);
return(0); return(0);
} }
#ifdef SF_ATEXIT
else if (mode==SF_ATEXIT) else if (mode==SF_ATEXIT)
{ {
sfdisc(sp, SF_POPDISC); sfdisc(sp, SF_POPDISC);
return(0); return(0);
} }
#endif
else if(mode==SF_READ) else if(mode==SF_READ)
return(0); return(0);
return(-1); return(-1);

View file

@ -123,11 +123,7 @@ struct lexdata
#define poplevel(lp) (lp->lexd.lastc=lp->lexd.lex_match[--lp->lexd.level]) #define poplevel(lp) (lp->lexd.lastc=lp->lexd.lex_match[--lp->lexd.level])
static char *fmttoken(Lex_t*, int, char*); static char *fmttoken(Lex_t*, int, char*);
#ifdef SF_BUFCONST
static int alias_exceptf(Sfio_t*, int, void*, Sfdisc_t*); static int alias_exceptf(Sfio_t*, int, void*, Sfdisc_t*);
#else
static int alias_exceptf(Sfio_t*, int, Sfdisc_t*);
#endif
static void setupalias(Lex_t*,const char*, Namval_t*); static void setupalias(Lex_t*,const char*, Namval_t*);
static int comsub(Lex_t*,int); static int comsub(Lex_t*,int);
static void nested_here(Lex_t*); static void nested_here(Lex_t*);
@ -2414,22 +2410,12 @@ struct alias
/* /*
* This code gets called whenever an end of string is found with alias * This code gets called whenever an end of string is found with alias
*/ */
#ifndef SF_ATEXIT
# define SF_ATEXIT 0
#endif
/*
* This code gets called whenever an end of string is found with alias
*/
#ifdef SF_BUFCONST
static int alias_exceptf(Sfio_t *iop,int type,void *data, Sfdisc_t *handle) static int alias_exceptf(Sfio_t *iop,int type,void *data, Sfdisc_t *handle)
#else
static int alias_exceptf(Sfio_t *iop,int type,Sfdisc_t *handle)
#endif
{ {
register struct alias *ap = (struct alias*)handle; register struct alias *ap = (struct alias*)handle;
register Namval_t *np; register Namval_t *np;
register Lex_t *lp; register Lex_t *lp;
NOT_USED(data);
if(type==0 || type==SF_ATEXIT || !ap) if(type==0 || type==SF_ATEXIT || !ap)
return(0); return(0);
lp = ap->lp; lp = ap->lp;
@ -2448,7 +2434,7 @@ static int alias_exceptf(Sfio_t *iop,int type,Sfdisc_t *handle)
} }
if(ap->nextc) if(ap->nextc)
{ {
/* if last character is a blank, then next work can be alias */ /* if last character is a blank, then next word can be alias */
register int c = fcpeek(-1); register int c = fcpeek(-1);
if(isblank(c)) if(isblank(c))
lp->aliasok = 1; lp->aliasok = 1;

View file

@ -108,10 +108,6 @@ struct adata
char nv_local = 0; char nv_local = 0;
static void(*nullscan)(Namval_t*,void*); static void(*nullscan)(Namval_t*,void*);
#if ( SFIO_VERSION <= 20010201L )
# define _data data
#endif
/* ======== name value pair routines ======== */ /* ======== name value pair routines ======== */
#include "shnodes.h" #include "shnodes.h"

View file

@ -46,12 +46,6 @@
#define HERE_MEM SF_BUFSIZE /* size of here-docs kept in memory */ #define HERE_MEM SF_BUFSIZE /* size of here-docs kept in memory */
#if CDT_VERSION < 20111111L
#define hash nvlink.hl._hash
#else
#define hash nvlink.lh.__hash
#endif
/* These routines are local to this module */ /* These routines are local to this module */
static Shnode_t *makeparent(Lex_t*, int, Shnode_t*); static Shnode_t *makeparent(Lex_t*, int, Shnode_t*);
@ -1999,6 +1993,15 @@ static Shnode_t *test_primary(Lex_t *lexp)
} }
#if SHOPT_KIA #if SHOPT_KIA
/*
* ksh is currently compiled with -D_API_ast=20100309, which sets CDT_VERSION to 20100309 in src/lib/libast/include/cdt.h
* which enables a legacy Cdt API also used elsewhere in ksh. Do not remove this version check as it is not yet obsolete.
*/
#if CDT_VERSION < 20111111L
#define hash nvlink.hl._hash
#else
#define hash nvlink.lh.__hash
#endif
/* /*
* return an entity checksum * return an entity checksum
* The entity is created if it doesn't exist * The entity is created if it doesn't exist
@ -2035,6 +2038,7 @@ unsigned long kiaentity(Lex_t *lexp,const char *name,int len,int type,int first,
} }
return(np->hash); return(np->hash);
} }
#undef hash
static void kia_add(register Namval_t *np, void *data) static void kia_add(register Namval_t *np, void *data)
{ {

View file

@ -851,26 +851,8 @@ Pathcomp_t *path_absolute(Shell_t *shp,register const char *name, Pathcomp_t *pp
shp->bltin_dir = 0; shp->bltin_dir = 0;
return(oldpp); return(oldpp);
} }
#ifdef SH_PLUGIN_VERSION
if (dll = dllplugin(SH_ID, stakptr(m), NiL, SH_PLUGIN_VERSION, NiL, RTLD_LAZY, NiL, 0)) if (dll = dllplugin(SH_ID, stakptr(m), NiL, SH_PLUGIN_VERSION, NiL, RTLD_LAZY, NiL, 0))
sh_addlib(shp,dll,stakptr(m),oldpp); sh_addlib(shp,dll,stakptr(m),oldpp);
#else
if (dll = dllplug(SH_ID, stakptr(m), NiL, RTLD_LAZY, NiL, 0))
{
/*
* this detects the 2007-05-11 builtin context change and also
* the 2008-03-30 opt_info.num change that hit libcmd::b_head
*/
if (libcmd && !dlllook(dll, "b_pids"))
{
dlclose(dll);
dll = 0;
}
else
sh_addlib(shp,dll,stakptr(m),oldpp);
}
#endif
if(dll && if(dll &&
(addr=(Shbltin_f)dlllook(dll,stakptr(n))) && (addr=(Shbltin_f)dlllook(dll,stakptr(n))) &&
(!(np = sh_addbuiltin(stakptr(PATH_OFFSET),NiL,NiL)) || np->nvalue.bfp!=(Nambfp_f)addr) && (!(np = sh_addbuiltin(stakptr(PATH_OFFSET),NiL,NiL)) || np->nvalue.bfp!=(Nambfp_f)addr) &&