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

Another round of minor tweaks and cleanups

Notable changes:
- The typeset builtin's usage and error messages for incompatible
  options used with -f has been corrected to show that -t and -u
  can be used with -f.
- In name.c, get rid of misleaadingly named Null static which is
  actually the empty string, not the null value. Replace with a new
  AltEmpty macro that is defined similarly to Empty. This is now
  also used in nvtype.c (re: de037b6e).
This commit is contained in:
Martijn Dekker 2022-06-09 02:53:33 +01:00
parent 0602177646
commit 89cec81b32
17 changed files with 29 additions and 128 deletions

View file

@ -473,7 +473,7 @@ endargs:
}
if(troot==sh.fun_tree && ((isfloat || flag&~(NV_FUNCT|NV_TAGGED|NV_EXPORT|NV_LTOU))))
{
errormsg(SH_DICT,2,e_optincompat1,"-f");
errormsg(SH_DICT,2,e_optincompat2,"-f","other options except -t and -u");
error_info.errors++;
}
if(sflag && troot==sh.fun_tree)

View file

@ -73,7 +73,7 @@ const struct shtable3 shtab_builtins[] =
"[", NV_BLTIN|BLT_ENV, bltin(test),
"let", NV_BLTIN|BLT_ENV, bltin(let),
"export", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly),
".", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(dot_cmd),
e_dot, NV_BLTIN|BLT_ENV|BLT_SPC, bltin(dot_cmd),
"source", NV_BLTIN|BLT_ENV, bltin(dot_cmd),
"return", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
"enum", NV_BLTIN|BLT_ENV|BLT_DCL, bltin(enum),
@ -1898,7 +1898,7 @@ const char sh_opttypeset[] =
"[Z]#?[n?Zero fill. If \an\a is given it represents the field width.]"
"\n"
"\n[name[=value]...]\n"
" -f [name...]\n"
" -f [-tu] [name...]\n"
" -m [name=name...]\n"
" -n [-g] [name=name...]\n"
" -T [tname[=(type definition)]...]\n"
@ -1911,6 +1911,7 @@ const char sh_opttypeset[] =
"[+SEE ALSO?\breadonly\b(1), \bexport\b(1)]"
;
#ifndef _no_ulimit
const char sh_optulimit[] =
"[-1c?@(#)$Id: ulimit (ksh 93u+m) 2021-12-28 $\n]"
"[--catalog?" SH_DICT "]"
@ -1946,6 +1947,7 @@ const char sh_optulimit[] =
"[+SEE ALSO?\bulimit\b(2), \bgetrlimit\b(2)]"
;
#endif /* !_no_ulimit */
const char sh_opttimes[] =
"[-1c?@(#)$Id: times (ksh 93u+m) 2020-07-14 $\n]"

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 *

View file

@ -133,7 +133,6 @@ extern int sh_argopts(int,char*[]);
extern const char e_heading[];
extern const char e_sptbnl[];
extern const char e_subst[];
extern const char e_option[];
extern const char e_exec[];

View file

@ -60,6 +60,7 @@
#endif
#define Empty ((char*)(e_sptbnl+3))
#define AltEmpty ((char*)(e_dot+1)) /* alternative pointer to empty string */
#define env_change() (++ast.env_serial)
@ -198,7 +199,9 @@ extern char *sh_getcwd(void);
#define sh_sigcheck() do { if(sh.trapnote & SH_SIGSET) sh_exit(SH_EXITSIG); } while(0)
extern int32_t sh_mailchk;
extern const char e_dict[];
extern const char e_dict[]; /* error message catalog */
extern const char e_sptbnl[]; /* default IFS: " \t\n" */
extern const char e_dot[]; /* default path & name of dot command: "." */
/* sh_printopts() mode flags -- set --[no]option by default */

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 *

View file

@ -107,7 +107,6 @@ extern Shbltin_f sh_getlib(char*,Pathcomp_t*);
/* constant strings needed for whence */
extern const char e_timeformat[];
extern const char e_badtformat[];
extern const char e_dot[];
extern const char e_funload[];
extern const char e_pwd[];
extern const char e_logout[];

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 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 *
@ -18,6 +18,8 @@
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma clang diagnostic ignored "-Wdeprecated-register"
#pragma clang diagnostic ignored "-Wparentheses"
/*
* AT&T Bell Laboratories
* make abstract machine file state support
@ -34,12 +36,11 @@ static char id[] = "\n@(#)$Id: mamstate (AT&T Bell Laboratories) 1989-06-26 $\0\
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
main(argc, argv)
int argc;
register char** argv;
int main(int argc, char **argv)
{
register char* s;
register int c;

View file

@ -36,7 +36,6 @@
#define ATTR_TO_EXPORT (NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER)
#define NVCACHE 8 /* must be a power of 2 */
static char *savesub = 0;
static char Null[1];
static Namval_t NullNode;
static Dt_t *Refdict;
static Dtdisc_t _Refdisc =
@ -1971,12 +1970,12 @@ void nv_putval(register Namval_t *np, const char *string, int flags)
{
if(dot==0 && !nv_isattr(np,NV_LJUST|NV_RJUST))
{
cp = Null;
cp = AltEmpty;
nv_onattr(np,NV_NOFREE);
}
else
{
if(tofree && tofree!=Empty && tofree!=Null)
if(tofree && tofree!=Empty && tofree!=AltEmpty)
{
cp = (char*)sh_realloc((void*)tofree, dot+append+1);
tofree = 0;
@ -2013,7 +2012,7 @@ void nv_putval(register Namval_t *np, const char *string, int flags)
}
if(flags&NV_APPEND)
stakseek(offset);
if(tofree && tofree!=Empty && tofree!=Null)
if(tofree && tofree!=Empty && tofree!=AltEmpty)
free((void*)tofree);
}
if(!was_local && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)))
@ -2548,7 +2547,7 @@ void _nv_unset(register Namval_t *np,int flags)
up = &np->nvalue;
if(up && up->cp)
{
if(up->cp!=Empty && up->cp!=Null && !nv_isattr(np, NV_NOFREE))
if(up->cp!=Empty && up->cp!=AltEmpty && !nv_isattr(np, NV_NOFREE))
free((void*)up->cp);
up->cp = 0;
}

View file

@ -926,7 +926,7 @@ static char **genvalue(char **argv, const char *prefix, int n, struct Walk *wp)
cp = (char*)prefix;
if(c=='.')
cp[m-1] = 0;
outval(".",prefix-n,wp);
outval((char*)e_dot,prefix-n,wp);
if(c=='.')
cp[m-1] = c;
if(wp->indent>0)

View file

@ -139,8 +139,6 @@ static const Namdisc_t type_disc =
0,
};
static char *AltEmpty = "";
size_t nv_datasize(Namval_t *np, size_t *offset)
{
size_t s=0, a=0;

View file

@ -1373,7 +1373,7 @@ static noreturn void exscript(register char *path,register char *argv[],char **e
static struct tms buffer;
static clock_t before;
static char *SHACCT; /* set to value of SHACCT environment variable */
static shaccton; /* non-zero causes accounting record to be written */
static int shaccton; /* non-zero causes accounting record to be written */
static int compress(time_t);
/*
* initialize accounting, i.e., see if SHACCT variable set
@ -1388,9 +1388,6 @@ static noreturn void exscript(register char *path,register char *argv[],char **e
void sh_accsusp(void)
{
shaccton=0;
#ifdef AEXPAND
sabuf.ac_flag |= AEXPND;
#endif /* AEXPAND */
}
/*

View file

@ -325,15 +325,15 @@ x=abc
[[ -v x[0] ]] || err_exit 'x[0] should be set'
[[ ${x[0]+x} ]] || err_exit print '${x[0]+x} should be x'
[[ -v x[3] ]] && err_exit 'x[3] should not be set'
[[ ${x[3]+x} ]] && err_exit '${x[0]+x} should be Empty'
[[ ${x[3]+x} ]] && err_exit '${x[0]+x} should be empty'
unset x
[[ ${x[@]+x} ]] && err_exit '${x[@]+x} should be Empty'
[[ ${x[@]+x} ]] && err_exit '${x[@]+x} should be empty'
unset x y z foo bar
{ x=$($SHELL -c '[[ (( $# -eq 0 )) ]] && print ok') 2> /dev/null;}
[[ $x == ok ]] || err_exit '((...)) inside [[ ... ]] not treated as nested ()'
[[ -e /dev/fd/ ]] || err_exit '/dev/fd/ does not exits'
[[ -e /dev/fd/ ]] || err_exit '/dev/fd/ does not exist'
[[ -e /dev/tcp/ ]] || err_exit '/dev/tcp/ does not exist'
[[ -e /dev/udp/ ]] || err_exit '/dev/udp/ does not exist'
[[ -e /dev/xxx/ ]] && err_exit '/dev/xxx/ exists'

View file

@ -317,6 +317,7 @@ rtests=(
typeset -i i n
n=${#rtests[@]}
ulimit --cpu 3 2>/dev/null
unset arr
for ((i=0; i<n; i++))
do
got=$(