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

Accumulated fixes for minor issues (#442)

This commit applies various accumulated bugfixes:

- Applied some fixes for compiler warnings based off of the
  following pull requests (with whitespace changes excluded to
  avoid inflating the size of the diff):

  https://github.com/att/ast/pull/281
  https://github.com/att/ast/pull/283
  https://github.com/att/ast/pull/303
  https://github.com/att/ast/pull/304

- clone_type(): Two separate variables in this function share the
  same name. A bugfix from ksh93v- 2013-05-24 was backported to
  avoid conflict issues.

- Backported a minor error message improvement from ksh2020 for
  when the user attempts to run too many coprocesses.

- Backported a ksh2020 bugfix for a file descriptor leak:
  58bc8b56

- Backported ksh2020 bugfixes for unused variable and pointless
  assignment lint warnings:
  47650fe0
  df209c0d
  5e417b00

- Applied a few minor improvements to libast from graphviz:
  e7c03541
  969a7cde

- dtmemory(): Mark unused parameters with NOT_USED(). Based on:
  6ac3ad99

- Applied a few documentation/comment tweaks for the NEWS file,
  printf -v and spawnveg.

- Added a missing regression test for using the rm builtin's -f
  option without additional arguments (this was fixed in
  ksh93u+ 2012-02-14).
This commit is contained in:
Johnothan King 2022-01-30 12:09:14 -08:00 committed by Martijn Dekker
parent e3a1dda93a
commit ad9f9ff13e
23 changed files with 78 additions and 59 deletions

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2014 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -21,7 +21,7 @@
/*
* echo [arg...]
* print [-enprsvC] [-f format] [-u fd] [string ...]
* printf format [string ...]
* printf [-v var] format [string ...]
*
* David Korn
* AT&T Labs

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -699,13 +699,15 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
np = sh_fsearch(name,HASH_NOSCOPE);
if(!np)
#endif /* SHOPT_NAMESPACE */
if(np=nv_search(name,troot,0))
{
if(!is_afunction(np))
np = 0;
if(np=nv_search(name,troot,0))
{
if(!is_afunction(np))
np = 0;
}
else if(memcmp(name,".sh.math.",9)==0 && sh_mathstd(name+9))
continue;
}
else if(memcmp(name,".sh.math.",9)==0 && sh_mathstd(name+9))
continue;
}
if(np && ((flag&NV_LTOU) || !nv_isnull(np) || nv_isattr(np,NV_LTOU)))
{
@ -1090,12 +1092,9 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
struct tdata tdata;
Shbltin_f addr;
Stk_t *stkp;
void *library=0;
char *errmsg;
#if SHOPT_DYNAMIC
unsigned long ver;
int list = 0;
char path[1024];
#endif
NOT_USED(argc);
memset(&tdata,0,sizeof(tdata));
@ -1156,6 +1155,9 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
#if SHOPT_DYNAMIC
if(arg)
{
unsigned long ver;
char path[PATH_MAX];
void *library;
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));
@ -1354,8 +1356,8 @@ static int unall(int argc, char **argv, register Dt_t *troot)
isfun = is_afunction(np);
if(troot==sh.var_tree)
{
Namarr_t *ap;
#if SHOPT_FIXEDARRAY
Namarr_t *ap;
if((ap=nv_arrayptr(np)) && !ap->fixed && name[strlen(name)-1]==']' && !nv_getsub(np))
#else
if(nv_isarray(np) && name[strlen(name)-1]==']' && !nv_getsub(np))

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -70,7 +70,7 @@ const char e_restricted[] = "%s: restricted";
#if SHOPT_PFSH
const char e_pfsh[] = "%s: disabled in profile shell";
#endif
const char e_pexists[] = "process already exists";
const char e_copexists[] = "coprocess is running; cannot create a new coprocess";
const char e_exists[] = "%s: file already exists";
const char e_pipe[] = "cannot create pipe";
const char e_alarm[] = "cannot set alarm";

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -2737,10 +2737,12 @@ yankeol:
#if SHOPT_MULTIBYTE
if((c&~STRIP)==0)
#endif /* SHOPT_MULTIBYTE */
if( isupper(c) )
c = tolower(c);
else if( islower(c) )
c = toupper(c);
{
if( isupper(c) )
c = tolower(c);
else if( islower(c) )
c = toupper(c);
}
replace(vp,c, 1);
}
return(GOOD);

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -76,7 +76,7 @@ extern int sh_devtofd(const char*);
extern int sh_isdevfd(const char*);
/* the following are readonly */
extern const char e_pexists[];
extern const char e_copexists[];
extern const char e_query[];
extern const char e_history[];
extern const char e_argtype[];

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -29,7 +29,7 @@
#if defined(_sys_resource) && defined(_lib_getrlimit)
# include <sys/resource.h>
# if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
/* This handles hp/ux problem */
/* This handles HP-UX problem */
# include <sys/vlimit.h>
# define RLIMIT_FSIZE (LIM_FSIZE-1)
# define RLIMIT_DATA (LIM_DATA-1)

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -2268,10 +2268,8 @@ static void comsubst(Mac_t *mp,register Shnode_t* t, int type)
str[c] = 0;
else
{
ssize_t len = 1;
/* can't write past buffer so save last character */
c -= len;
c -= 1;
lastc = str[c];
str[c] = 0;
}

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -744,7 +744,9 @@ static void outval(char *name, const char *vname, struct Walk *wp)
{
if(*name!='.')
{
#if SHOPT_FIXEDARRAY
Namarr_t *ap;
#endif
nv_attribute(np,wp->out,"typeset",'=');
#if SHOPT_FIXEDARRAY
if((ap=nv_arrayptr(np)) && ap->fixed)

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
@ -430,11 +430,11 @@ static Namfun_t *clone_type(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
nv_putsub(nq,cp,ARRAY_ADD|ARRAY_NOSCOPE);
if(array_assoc(ap))
{
Namval_t *mp = (Namval_t*)((*ap->fun)(nr,NIL(char*),NV_ACURRENT));
Namval_t *mr = (Namval_t*)((*ap->fun)(nr,NIL(char*),NV_ACURRENT));
Namval_t *mq = (Namval_t*)((*ap->fun)(nq,NIL(char*),NV_ACURRENT));
nv_clone(mp,mq,NV_MOVE);
nv_clone(mr,mq,NV_MOVE);
ap->nelem--;
nv_delete(mp,ap->table,0);
nv_delete(mr,ap->table,0);
}
else
{

View file

@ -770,7 +770,9 @@ Pathcomp_t *path_absolute(register const char *name, Pathcomp_t *pp, int flag)
Pathcomp_t *oldpp;
Namval_t *np;
char *cp;
#if SHOPT_DYNAMIC
char *bp;
#endif
sh.path_err = ENOENT;
if(!pp && !(pp=path_get(Empty)))
return(0);
@ -885,7 +887,10 @@ Pathcomp_t *path_absolute(register const char *name, Pathcomp_t *pp, int flag)
{
*cp = 0;
if(nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE))
{
sh_close(f);
f = -1;
}
*cp = '.';
}
if(isfun && f>=0)
@ -895,7 +900,7 @@ Pathcomp_t *path_absolute(register const char *name, Pathcomp_t *pp, int flag)
nv_onattr(nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE),NV_LTOU|NV_FUNCTION);
funload(f,name);
}
close(f);
sh_close(f);
return(0);
}
else if(f>=0 && (oldpp->flags & PATH_STD_DIR))

View file

@ -3401,7 +3401,7 @@ static void coproc_init(int pipes[])
int outfd;
if(sh.coutpipe>=0 && sh.cpid)
{
errormsg(SH_DICT,ERROR_exit(1),e_pexists);
errormsg(SH_DICT,ERROR_exit(1),e_copexists);
UNREACHABLE();
}
sh.cpid = 0;

View file

@ -2,7 +2,7 @@
# #
# This software is part of the ast package #
# Copyright (c) 1982-2012 AT&T Intellectual Property #
# Copyright (c) 2020-2021 Contributors to ksh 93u+m #
# Copyright (c) 2020-2022 Contributors to ksh 93u+m #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
@ -239,9 +239,9 @@ if rm -rf "$file" && ln -s / "$file"
then [[ -L "$file" ]] || err_exit '-L not working'
[[ -L "$file"/ ]] && err_exit '-L with file/ not working'
fi
$SHELL -c 't=1234567890; [[ $t == @({10}(\d)) ]]' 2> /dev/null || err_exit ' @({10}(\d)) pattern not working'
$SHELL -c '[[ att_ == ~(E)(att|cus)_.* ]]' 2> /dev/null || err_exit ' ~(E)(att|cus)_* pattern not working'
$SHELL -c '[[ att_ =~ (att|cus)_.* ]]' 2> /dev/null || err_exit ' =~ ere not working'
$SHELL -c 't=1234567890; [[ $t == @({10}(\d)) ]]' 2> /dev/null || err_exit '@({10}(\d)) pattern not working'
$SHELL -c '[[ att_ == ~(E)(att|cus)_.* ]]' 2> /dev/null || err_exit '~(E)(att|cus)_* pattern not working'
$SHELL -c '[[ att_ =~ (att|cus)_.* ]]' 2> /dev/null || err_exit '=~ ere not working'
$SHELL -c '[[ abc =~ a(b)c ]]' 2> /dev/null || err_exit '[[ abc =~ a(b)c ]] fails'
$SHELL -xc '[[ abc =~ \babc\b ]]' 2> /dev/null || err_exit '[[ abc =~ \babc\b ]] fails'
[[ abc == ~(E)\babc\b ]] || err_exit '\b not preserved for ere when not in ()'

View file

@ -1454,6 +1454,14 @@ if builtin rm 2> /dev/null; then
[[ $? == 0 ]] || err_exit 'rm builtin fails to remove non-empty directory and file with -rd options' \
"(got $(printf %q "$got"))"
[[ -f $tmp/nonemptydir2/shouldexist || -d $tmp/nonemptydir2 ]] && err_exit 'rm builtin fails to remove all folders and files with -rd options'
# Additional test: 'rm -f' without additional arguments should act
# as a no-op command. This bug was fixed in ksh93u+ 2012-02-14.
got=$(rm -f 2>&1)
if (($? != 0)) || [[ ! -z $got ]]
then err_exit 'rm -f without additional arguments does not work correctly' \
"(got $(printf %q "$got"))"
fi
fi
# ======