1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

Fix more compiler warnings, typos and other minor issues (#260)

Many of these changes are minor typo fixes. The other changes
(which are mostly compiler warning fixes) are:

NEWS:
- The --globcasedetect shell option works on older Linux kernels
  when used with FAT32/VFAT file systems, so remove the note about
  it only working with 5.2+ kernels.

src/cmd/ksh93/COMPATIBILITY:
- Update the documentation on function scoping with an addition
  from ksh93v- (this does apply to ksh93u+).

src/cmd/ksh93/edit/emacs.c:
- Check for '_AST_ksh_release', not 'AST_ksh_release'.

src/cmd/INIT/mamake.c,
src/cmd/INIT/ratz.c,
src/cmd/INIT/release.c,
src/cmd/builtin/pty.c:
- Add more uses of UNREACHABLE() and noreturn, this time for the
  build system and pty.

src/cmd/builtin/pty.c,
src/cmd/builtin/array.c,
src/cmd/ksh93/sh/name.c,
src/cmd/ksh93/sh/nvtype.c,
src/cmd/ksh93/sh/suid_exec.c:
- Fix six -Wunused-variable warnings (the name.c nv_arrayptr()
  fixes are also in ksh93v-).
- Remove the unused 'tableval' function to fix a -Wunused-function
  warning.

src/cmd/ksh93/sh/lex.c:
- Remove unused 'SHOPT_DOS' code, which isn't enabled anywhere.
  https://github.com/att/ast/issues/272#issuecomment-354363112

src/cmd/ksh93/bltins/misc.c,
src/cmd/ksh93/bltins/trap.c,
src/cmd/ksh93/bltins/typeset.c:
- Add dictionary generator function declarations for former
  aliases that are now builtins (re: 1fbbeaa1, ef1621c1, 3ba4900e).
- For consistency with the rest of the codebase, use '(void)'
  instead of '()' for print_cpu_times.

src/cmd/ksh93/sh/init.c,
src/lib/libast/path/pathshell.c:
- Move the otherwise unused EXE macro to pathshell() and only
  search for 'sh.exe' on Windows.

src/cmd/ksh93/sh/xec.c,
src/lib/libast/include/ast.h:
- Add an empty definition for inline when compiling with C89.
  This allows the timeval_to_double() function to be inlined.

src/cmd/ksh93/include/shlex.h:
- Remove the unused 'PIPESYM2' macro.

src/cmd/ksh93/tests/pty.sh:
- Add '# err_exit #' to count the regression test added in
  commit 113a9392.

src/lib/libast/disc/sfdcdio.c:
- Move diordwr, dioread, diowrite and dioexcept behind
  '#ifdef F_DIOINFO' to fix one -Wunused-variable warning and
  multiple -Wunused-function warnings (sfdcdio() only uses these
  functions when F_DIOINFO is defined).

src/lib/libast/string/fmtdev.c:
- Fix two -Wimplicit-function-declaration warnings on Linux by
  including sys/sysmacros.h in fmtdev().
This commit is contained in:
Johnothan King 2021-04-08 11:58:07 -07:00 committed by GitHub
parent ecf260c282
commit a065558291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 299 additions and 282 deletions

2
NEWS
View file

@ -72,7 +72,7 @@ Any uppercase BUG_* names are modernish shell bug IDs.
- A new --globcasedetect shell option is added to ksh on OSs where we can check
for a case-insensitive file system (currently macOS, Windows/Cygwin, Linux
5.2+, and QNX 7.0+). When this option is turned on, file name generation
and QNX 7.0+). When this option is turned on, file name generation
(globbing), as well as file name tab completion on interactive shells,
automatically become case-insensitive on file systems where the difference
between upper- and lowercase is ignored for file names. This is transparently

View file

@ -31,7 +31,7 @@ To see what's left to fix, see [the issue tracker](https://github.com/ksh93/ksh/
7. Code style varies somewhat in this historic code base.
Your changes should match the style of the code surrounding it.
Indent with tabs, assuming an 8-space tab width.
Opening braces are on a line of their own, at the same identation level
Opening braces are on a line of their own, at the same indentation level
as their corresponding closing brace.
Comments always use `/*`...`*/`.
8. Good judgment may override this policy.

View file

@ -771,7 +771,7 @@ or indexed, use ${!var[@]}.
<DT>How do I do global substitutions on the contents of shell variables?<DD>
Use // instead of / for global substitution, ${var//aa/bb} will
expand to the value of with each "aa" replace by "bb".
expand to the value of var with each "aa" replaced by "bb".
<DT>How can I convert %XX values to ascii?<DD>

View file

@ -450,7 +450,7 @@ All recorded changes follow.
regress.sh: INPUT and OUTPUT handle -f for printf instead of print
04-06-11 package.sh: make sure $INSTALLROOT/bin is in front of $PATH
package.sh: skip nmake if older than 2000-10-31
04-05-20 package.sh: fix arg vs. package parse with - or '' to disambuguate
04-05-20 package.sh: fix arg vs. package parse with - or '' to disambiguate
04-05-11 package.sh: package verbose update lists closure for package setup
package.sh: add src/lib/libardir to nmake proto bootstrap
regress.sh: probe for rm -u vs. chmod -R u+rwx
@ -518,7 +518,7 @@ All recorded changes follow.
03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks
regress.sh: add COPY from to, like MOVE but comprison still done
regress.sh: add COPY from to, like MOVE but comparison still done
regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation
@ -617,7 +617,7 @@ All recorded changes follow.
make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check
02-10-24 WWW.mk: fix bug that required a :WWWBIN: assertion to post
02-10-23 mamake.c: fix unuinitialized time in make()
02-10-23 mamake.c: fix uninitialized time in make()
ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw
@ -699,7 +699,7 @@ All recorded changes follow.
package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include
iffe.sh,package.sh: remove vaibale from sccs,cvs ident strings -- duh
iffe.sh,package.sh: remove variable from sccs,cvs ident strings -- duh
02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results
@ -950,7 +950,7 @@ All recorded changes follow.
98-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe
Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first

View file

@ -412,7 +412,7 @@ All recorded changes follow.
regress.sh: INPUT and OUTPUT handle -f for printf instead of print
04-06-11 package.sh: make sure $INSTALLROOT/bin is in front of $PATH
package.sh: skip nmake if older than 2000-10-31
04-05-20 package.sh: fix arg vs. package parse with - or '' to disambuguate
04-05-20 package.sh: fix arg vs. package parse with - or '' to disambiguate
04-05-11 package.sh: package verbose update lists closure for package setup
package.sh: add src/lib/libardir to nmake proto bootstrap
regress.sh: probe for rm -u vs. chmod -R u+rwx
@ -480,7 +480,7 @@ All recorded changes follow.
03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks
regress.sh: add COPY from to, like MOVE but comprison still done
regress.sh: add COPY from to, like MOVE but comparison still done
regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation
@ -579,7 +579,7 @@ All recorded changes follow.
make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check
02-10-24 WWW.mk: fix bug that required a :WWWBIN: assertion to post
02-10-23 mamake.c: fix unuinitialized time in make()
02-10-23 mamake.c: fix uninitialized time in make()
ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw
@ -661,7 +661,7 @@ All recorded changes follow.
package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include
iffe.sh,package.sh: remove vaibale from sccs,cvs ident strings -- duh
iffe.sh,package.sh: remove variable from sccs,cvs ident strings -- duh
02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results
@ -912,7 +912,7 @@ All recorded changes follow.
98-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe
Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first

View file

@ -20,17 +20,17 @@ ast-ksh :PACKAGE: ksh93 libast libcmd libcoshell libsum libdll
these symlinks
/bin/ksh.exe => ksh93.exe
/usr/share/man/man1/ksh93.1 => ksh.1
are created. This allows alternative ksh impelementations,
are created. This allows alternative ksh implementations,
e.g., /bin/pdksh.exe, to be selected by changing the ksh.exe
and ksh.1 symbolic links. In addition, ksh and ksh93 paths are
added to /etc/shells if not already present.
$()
Each builtin or special command accepts the --man and --html
options to list the man page on the standard error. The --???
options to show the man page on the standard error. The --???
option describes the self documenting options available to all
builtin and special commands.
$()
The stanadlone ksh is statically linked with the ast libcmd
The standlone ksh is statically linked with the ast libcmd
library which provides several builtin versions of /bin
commands. "builtin | grep /opt/ast/bin" lists the libcmd
builtins on the standard output. /opt/ast/bin/FOO accesses
@ -55,12 +55,12 @@ ast-ksh :PACKAGE: ksh93 libast libcmd libcoshell libsum libdll
variables to convert. PATH is handled by cygwin so it is not
converted by the ast library.
$()
The astksh cygwin source package provides a bootstrap build
The ast-ksh cygwin source package provides a bootstrap build
environment that is not suited for an edit/build/debug cycle.
If you want to explore and modify the source then you should
install the (non-cygwinized) ast-base package which includes
AT&T nmake. With ast-base you will also be able to regenerate
the astksh cygwin source and binary packages.
the ast-ksh cygwin source and binary packages.
$()
For more information on ksh and other AT&T ast tools see
http://www.research.att.com/sw/download/

View file

@ -423,7 +423,7 @@
03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks
regress.sh: add COPY from to, like MOVE but comprison still done
regress.sh: add COPY from to, like MOVE but comparison still done
regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation
@ -522,7 +522,7 @@
make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check
02-10-24 WWW.mk: fix bug that required a :WWWBIN: assertion to post
02-10-23 mamake.c: fix unuinitialized time in make()
02-10-23 mamake.c: fix uninitialized time in make()
ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw
@ -604,7 +604,7 @@
package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include
iffe.sh,package.sh: remove vaibale from sccs,cvs ident strings -- duh
iffe.sh,package.sh: remove variable from sccs,cvs ident strings -- duh
02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results
@ -855,7 +855,7 @@
98-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe
Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first

View file

@ -2157,8 +2157,8 @@ main(int argc, char** argv)
search(state.vars, "-strip-symbols", "1");
continue;
case '?':
error(ERROR_USAGE|4, "%s", opt_info.arg);
continue;
error(ERROR_usage(2), "%s", opt_info.arg);
UNREACHABLE();
case ':':
error(2, "%s", opt_info.arg);
continue;
@ -2166,7 +2166,10 @@ main(int argc, char** argv)
break;
}
if (error_info.errors)
error(ERROR_USAGE|4, "%s", optusage(NiL));
{
error(ERROR_usage(2), "%s", optusage(NiL));
UNREACHABLE();
}
argv += opt_info.index;
#else
while ((s = *++argv) && *s == '-')

View file

@ -4813,8 +4813,8 @@ char** argv;
sfprintf(sfstdout, "%s\n", id + 10);
return 0;
case '?':
error(ERROR_USAGE|4, "%s", opt_info.arg);
continue;
error(ERROR_usage(2), "%s", opt_info.arg);
UNREACHABLE();
case ':':
error(2, "%s", opt_info.arg);
continue;
@ -4822,7 +4822,10 @@ char** argv;
break;
}
if (error_info.errors)
error(ERROR_USAGE|4, "%s", optusage(NiL));
{
error(ERROR_usage(2), "%s", optusage(NiL));
UNREACHABLE();
}
argv += opt_info.index;
#else
while ((s = *++argv) && *s == '-' && *(s + 1))

View file

@ -238,8 +238,8 @@ main(int argc, char** argv)
sfprintf(sfstdout, "%s\n", id + 10);
return 0;
case '?':
error(ERROR_USAGE|4, "%s", opt_info.arg);
continue;
error(ERROR_usage(2), "%s", opt_info.arg);
UNREACHABLE();
case ':':
error(2, "%s", opt_info.arg);
continue;
@ -247,7 +247,10 @@ main(int argc, char** argv)
break;
}
if (error_info.errors)
error(ERROR_USAGE|4, "%s", optusage(NiL));
{
error(ERROR_usage(2), "%s", optusage(NiL));
UNREACHABLE();
}
argv += opt_info.index;
#else
while ((s = *++argv) && *s == '-' && *(s + 1))

View file

@ -125,9 +125,10 @@ static const char usage[] =
#define CMIN 1
#endif
static void outofmemory(void)
static noreturn void outofmemory(void)
{
error(ERROR_SYSTEM|ERROR_PANIC, "out of memory");
UNREACHABLE();
}
#if !_lib_openpty && !_lib__getpty && !defined(_pty_clone)
@ -221,7 +222,6 @@ static int
mkpty(int* master, int* minion)
{
struct termios tty;
struct termios tst;
struct termios* ttyp;
#ifdef TIOCGWINSZ
struct winsize win;
@ -316,6 +316,7 @@ mkpty(int* master, int* minion)
return -1;
#endif
#ifdef I_PUSH
struct termios tst;
if (tcgetattr(*minion, &tst) < 0 && (ioctl(*minion, I_PUSH, "ptem") < 0 || ioctl(*minion, I_PUSH, "ldterm") < 0))
{
close(*minion);
@ -1057,17 +1058,26 @@ b_pty(int argc, char** argv, Shbltin_t* context)
break;
case '?':
error(ERROR_usage(2), "%s", opt_info.arg);
break;
UNREACHABLE();
}
break;
}
argv += opt_info.index;
if (!argv[0])
{
error(ERROR_exit(1), "command must be specified");
UNREACHABLE();
}
if (mkpty(&master, &minion) < 0)
{
error(ERROR_system(1), "unable to create pty");
UNREACHABLE();
}
if (!(mp = sfnew(NiL, 0, SF_UNBOUND, master, SF_READ|SF_WRITE)))
{
error(ERROR_system(1), "cannot open master stream");
UNREACHABLE();
}
if (stty)
{
n = 2;
@ -1095,9 +1105,15 @@ b_pty(int argc, char** argv, Shbltin_t* context)
if (!log)
lp = 0;
else if (!(lp = sfopen(NiL, log, "w")))
{
error(ERROR_system(1), "%s: cannot write", log);
UNREACHABLE();
}
if (!(proc = runcmd(argv, minion, session)))
{
error(ERROR_system(1), "unable run %s", argv[0]);
UNREACHABLE();
}
close(minion);
if (messages)
{
@ -1109,7 +1125,10 @@ b_pty(int argc, char** argv, Shbltin_t* context)
else if ((fd = open(messages, O_CREAT|O_WRONLY, MODE_666)) >= 0)
drop = 0;
else
{
error(ERROR_system(1), "%s: cannot redirect messages", messages);
UNREACHABLE();
}
close(2);
dup(fd);
if (drop)
@ -1118,6 +1137,9 @@ b_pty(int argc, char** argv, Shbltin_t* context)
minion = (*fun)(mp, lp, delay, timeout);
master = procclose(proc);
if (lp && sfclose(lp))
{
error(ERROR_system(1), "%s: write error", log);
UNREACHABLE();
}
return minion ? minion : master;
}

View file

@ -128,8 +128,10 @@ omitted features that are completely upward compatible.
1. Functions, defined with name() with ksh-93 are compatible with
the POSIX standard, not with ksh-88. No local variables are
permitted, and there is no separate scope. Functions defined
with the function name syntax, maintain compatibility.
This also affects function traces.
with the function name syntax have local variables as in ksh-88,
but are statically scoped as in C so that a function does not
automatically have access to local variables of the caller.
This change also affects function traces.
2. ! is now a reserved word. As a result, any command by that
name will no longer work with ksh-93.

View file

@ -46,7 +46,7 @@ Directory layout:
Include directory:
1. argnod.h contains the type definitions for command
nodes, io nodes, argument nodes, and for positional
parameters.a It defines the prototypes for
parameters. It defines the prototypes for
all the positional parameters functions.
2. builtins.h contains prototypes for builtins as well
as symbolic constants that refer to the name-pairs

View file

@ -243,7 +243,7 @@
that caused a core dump has been fixed.
12-02-08 A bug in which .sh.fun disciplines could be cleared after a
function completes has been fixed.
12-02-08 A bug in job control in which the foregroup process group was not
12-02-08 A bug in job control in which the foreground process group was not
set correctly after restarting a stopped pipeline has been fixed.
12-02-07 A bug in which numbers with leading zeros could be treated as
octal constants outside of ((...)) has been fixed.
@ -297,7 +297,7 @@
quote argument in a form suitable for a field in a .csv format file.
11-12-02 +A -S option was added to read to be able to read .csv format files.
11-11-28 A bug in which redirection of standard error in a function called from
command substitution caused standard error to be lost has ben fixed.
command substitution caused standard error to be lost has been fixed.
11-11-21 [[ (-n foo) ]] no longer requires a space before (.
11-11-11 The readonly attribute for a variable now applies to compound
assignments to that variable.
@ -711,7 +711,7 @@
was invoked on a two dimensional array, i.e., arr[5][9].discipline.
10-07-19 Fixed a buffering problem which occurred when running a script with
ssh and the parent ssh process is killed.
10-07-14 Modified the parser to treat ((...)) inside [[...]] as ( (...) ) to
10-07-14 Modified the parser to treat ((...)) inside [[ ... ]] as ( (...) ) so
that it is a nested (...).
10-07-09 A bug in the handling of process substitution inside command
substitution as part of a pipeline has been fixed.
@ -1580,7 +1580,7 @@
name+=([sub]=value) could cause the array to become an associative
array has been fixed.
07-11-14 A bug in which typeset without arguments could coredump if a
variable is declared as in indexed array and has no elements has
variable is declared as an indexed array and has no elements has
been fixed.
07-11-14 A bug in which creating a local SECONDS variable with typeset in
a function could corrupt memory has been fixed.

View file

@ -57,10 +57,10 @@ static const char enum_type[] =
"field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]"
"[r?Enables readonly. Once enabled, the value cannot be changed or unset.]"
"[a?Indexed array. Each \aname\a will converted to an indexed "
"[a?Indexed array. Each \aname\a is converted to an indexed "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become index \b0\b.]"
"[A?Associative array. Each \aname\a will converted to an associative "
"[A?Associative array. Each \aname\a is converted to an associative "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become subscript \b0\b.]"
"[h]:[string?Used within a type definition to provide a help string "

View file

@ -224,6 +224,10 @@ int b_eval(int argc,char *argv[], Shbltin_t *context)
return(shp->exitval);
}
#if 0
/* for the dictionary generator */
int b_source(register int n,char *argv[],Shbltin_t *context){}
#endif
int b_dot_cmd(register int n,char *argv[],Shbltin_t *context)
{
register char *script;
@ -529,7 +533,7 @@ static void print_times(struct timeval utime, struct timeval stime)
sfprintf(sfstdout, "%dm%02d%c%03ds %dm%02d%c%03ds\n", ut_min, ut_sec, radix, ut_ms, st_min, st_sec, radix, st_ms);
}
#if _lib_getrusage
static void print_cpu_times()
static void print_cpu_times(void)
{
struct rusage usage;
/* Print the time (user & system) consumed by the shell. */
@ -540,7 +544,7 @@ static void print_cpu_times()
print_times(usage.ru_utime, usage.ru_stime);
}
#else /* _lib_getrusage */
static void print_cpu_times()
static void print_cpu_times(void)
{
struct timeval utime, stime;
double dtime;

View file

@ -183,6 +183,10 @@ int b_trap(int argc,char *argv[],Shbltin_t *context)
return(0);
}
#if 0
/* for the dictionary generator */
int b_stop(int argc,char *argv[],Shbltin_t *context){}
#endif
int b_kill(int argc,char *argv[],Shbltin_t *context)
{
register char *signame;

View file

@ -191,7 +191,13 @@ int b_alias(int argc,register char *argv[],Shbltin_t *context)
#if 0
/* for the dictionary generator */
int b_local(int argc,char *argv[],Shbltin_t *context){}
int b_autoload(int argc,register char *argv[],Shbltin_t *context){}
int b_compound(int argc,register char *argv[],Shbltin_t *context){}
int b_float(int argc,register char *argv[],Shbltin_t *context){}
int b_functions(int argc,register char *argv[],Shbltin_t *context){}
int b_integer(int argc,register char *argv[],Shbltin_t *context){}
int b_local(int argc,register char *argv[],Shbltin_t *context){}
int b_nameref(int argc,register char *argv[],Shbltin_t *context){}
#endif
int b_typeset(int argc,register char *argv[],Shbltin_t *context)
{

View file

@ -1844,7 +1844,7 @@ const char sh_opttypeset[] =
"value will be displayed as an unsigned integer.]"
"[x?Puts each \aname\a on the export list. See \bexport\b(1). \aname\a "
"cannot contain a \b.\b.]"
"[A?Associative array. Each \aname\a will converted to an associative "
"[A?Associative array. Each \aname\a is converted to an associative "
"array. If a variable already exists, the current value will "
"become index \b0\b.]"
"[C?Compound variable. Each \aname\a will be a compound variable. If "

View file

@ -1234,7 +1234,7 @@ static void xcommands(register Emacs_t *ep,int count)
show_info(ep,hbuf);
return;
}
# if !AST_ksh_release /* debugging, modify as required */
# if !_AST_ksh_release /* debugging, modify as required */
case cntl('D'): /* ^X^D show debugging info */
{
char debugbuf[MAXLINE];

View file

@ -501,7 +501,7 @@ int ed_viread(void *context, int fd, register char *shbuf, int nchar, int reedit
}
/*** Line terminated with escape, or escaped eol/eof, ***/
/* so set raw mode */
/*** so set raw mode ***/
if( tty_raw(ERRIO,0) < 0 )
{

View file

@ -88,7 +88,7 @@ struct Namarray
void *(*fun)(Namval_t*,const char*,int); /* associative arrays */
void *fixed; /* for fixed sized arrays */
Dt_t *table; /* for subscripts */
void *scope; /* non-zerp when scoped */
void *scope; /* non-zero when scoped */
};
/* The context pointer for declaration command */

View file

@ -113,7 +113,6 @@ typedef struct _shlex_
#define IORDWRSYM (SYMGT|'<')
#define IORDWRSYMT (SYMSEMI|'<')
#define IOCLOBSYM (SYMPIPE|'>')
#define PIPESYM2 (SYMPIPE|'&')
#define IPROCSYM (SYMLPAR|'<')
#define OPROCSYM (SYMLPAR|'>')
#define EOFSYM 04000 /* end-of-file */

View file

@ -221,7 +221,7 @@ name-value pair as a string. A \f5NULL\fP return value indicates
that the name-value pair is unset.
The \f5nv_getnum()\fP function returns the value of the given
name-value pair as a double precision number using the \f5Sfio\fP
library (See Sfio(3)) type \f5Sfdouble_t\fP.
library (see sfio(3)) type \f5Sfdouble_t\fP.
For name-value pairs without the \f5NV_INTEGER\fP attribute,
the string value is evaluated as an arithmetic expression to
arrive at a numerical value.
@ -541,7 +541,7 @@ and returned.
.IP
\f5NV_CLONE\fP:
If \fIfp\fP is non-\f5NULL\fP and it is on the stack,
it is replace by a copy created by \f5malloc\fP(3).
it is replaced by a copy created by \f5malloc\fP(3).
The \f5nofree\fP field is set to \f50\fP.
The new discipline is returned.
Otherwise, \f5NULL\fP is returned.

View file

@ -6145,7 +6145,7 @@ and IEEE POSIX 1003.2 standards.
(See
.IR pathconf (2)
and
.IR sysconf (2).)
.IR sysconf (3).)
The
.I pathname
argument is required for parameters whose value depends on
@ -7479,7 +7479,7 @@ or
\f3times\fP
Displays the accumulated user and system CPU times, one line with the times
used by the shell and another with those used by all of the shell's child
processes. No options are supporetd.
processes. No options are supported.
.TP
\(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
The
@ -8445,7 +8445,7 @@ except that the following are disallowed:
.RS
.PD 0
.PP
Unsetting the restricted option.
unsetting the restricted option,
.br
changing directory (see
.IR cd (1)),
@ -8470,9 +8470,9 @@ redirecting output
.BR >| ,
.BR <> ,
and
.BR >> ).
.BR >> ) ,
.br
adding or deleting built-in commands.
adding or deleting built-in commands,
.br
using
.B "command -p"
@ -8591,7 +8591,7 @@ lseek(2),
paste(1),
pathconf(2),
pipe(2),
sysconf(2),
sysconf(3),
umask(2),
ulimit(2),
wait(2),

View file

@ -768,7 +768,7 @@ struct argnod *sh_argprocsub(Shell_t *shp,struct argnod *argp)
sh_offstate(SH_INTERACTIVE);
sh_offstate(SH_MONITOR);
job.jobcontrol = 0;
/* do the process substitution */
/* run the process substitution */
shp->subshell = 0;
if(fd)
shp->inpipe = pv;

View file

@ -871,13 +871,8 @@ static struct index_array *array_grow(Namval_t *np, register struct index_array
}
}
else
if((ap->val[0].cp=np->nvalue.cp))
if((ap->val[0].cp=np->nvalue.cp) || (nv_isattr(np,NV_INTEGER) && !nv_isnull(np)))
i++;
else if(nv_isattr(np,NV_INTEGER) && !nv_isnull(np))
{
Sfdouble_t d= nv_getnum(np);
i++;
}
ap->header.nelem = i;
ap->header.hdr.disc = &array_disc;
nv_disc(np,(Namfun_t*)ap, NV_FIRST);
@ -1525,7 +1520,7 @@ char *nv_endsubscript(Namval_t *np, register char *cp, int mode)
{
Namarr_t *ap = nv_arrayptr(np);
/* Block an attempt to alter a readonly array via subscript assignment or by appending the array.
However need to allow instances of type variables. This exception is observed when np->nvflag
However instances of type variables must be allowed. This exception is observed when np->nvflag
has NV_BINARY and NV_LJUST set besides NV_RDONLY and NV_ARRAY. */
if(nv_isattr(np,NV_RDONLY) && nv_isattr(np,NV_ARRAY) && mode&NV_ASSIGN && np->nvflag&(NV_BINARY|NV_LJUST)^(NV_BINARY|NV_LJUST))
{

View file

@ -210,13 +210,6 @@ static char *env_init(Shell_t*);
static void env_import_attributes(Shell_t*,char*);
static Init_t *nv_init(Shell_t*);
static int shlvl;
#ifdef _WINIX
# define EXE "?(.exe)"
#else
# define EXE
#endif
static int rand_shift;
/*

View file

@ -2321,10 +2321,6 @@ struct argnod *sh_endword(Shell_t *shp,int mode)
break;
}
n = *sp;
#if SHOPT_DOS
if(!(inquote&1) && sh_lexstates[ST_NORM][n]==0)
break;
#endif /* SHOPT_DOS */
if(!(inquote&1) || (sh_lexstates[ST_QUOTE][n] && n!=RBRACE))
{
if(n=='\n')

View file

@ -734,9 +734,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
long mode, add=0;
int copy=0,isref,top=0,noscope=(flags&NV_NOSCOPE);
int nofree=0, level=0;
#if SHOPT_FIXEDARRAY
Namarr_t *ap;
#endif /* SHOPT_FIXEDARRAY */
if(root==shp->var_tree)
{
if(dtvnext(root))
@ -944,7 +942,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
{
if(flags&NV_ARRAY)
{
Namarr_t *ap = nv_arrayptr(np);
ap = nv_arrayptr(np);
nq = nv_opensub(np);
if((flags&NV_ASSIGN) && (!nq || nv_isnull(nq)))
ap->nelem++;
@ -1034,7 +1032,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
if(c=='[')
{
#if SHOPT_FIXEDARRAY
Namarr_t *ap = nv_arrayptr(np);
ap = nv_arrayptr(np);
#endif /* SHOPT_FIXEDARRAY */
n = mode|nv_isarray(np);
if(!mode && (flags&NV_ARRAY) && ((c=sp[1])=='*' || c=='@') && sp[2]==']')
@ -2604,36 +2602,6 @@ Namval_t *sh_scoped(Shell_t *shp, register Namval_t *np)
return(dtsearch(shp->var_tree,np));
}
/*
* return space separated list of names of variables in given tree
*/
static char *tableval(Dt_t *root)
{
static Sfio_t *out;
register Namval_t *np;
register int first=1;
register Dt_t *base = dtview(root,0);
if(out)
sfseek(out,(Sfoff_t)0,SEEK_SET);
else
out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
for(np=(Namval_t*)dtfirst(root);np;np=(Namval_t*)dtnext(root,np))
{
if(!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE))
{
if(!first)
sfputc(out,' ');
else
first = 0;
sfputr(out,np->nvname,-1);
}
}
sfputc(out,0);
if(base)
dtview(root,base);
return((char*)out->_data);
}
#if SHOPT_OPTIMIZE
struct optimize
{

View file

@ -41,12 +41,12 @@ static const char sh_opttype[] =
"field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]"
"[r?Enables readonly. Once enabled, the value cannot be changed or unset.]"
"[a]:?[type?Indexed array. Each \aname\a will converted to an indexed "
"[a]:?[type?Indexed array. Each \aname\a is converted to an indexed "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become index \b0\b. If \b[\b\atype\a\b]]\b is "
"specified, each subscript is interpreted as a value of enumeration "
"type \atype\a.]"
"[A?Associative array. Each \aname\a will converted to an associative "
"[A?Associative array. Each \aname\a is converted to an associative "
"array of type \b\f?\f\b. If a variable already exists, the current "
"value will become subscript \b0\b.]"
"[h]:[string?Used within a type definition to provide a help string "
@ -666,7 +666,6 @@ static int typeinfo(Opt_t* op, Sfio_t *out, const char *str, Optdisc_t *fp)
nq = nv_namptr(dp->nodes,i);
if(tp=nv_type(nq))
{
Namfun_t *pp = nv_hasdisc(nq,&type_disc);
sfprintf(out,"\t[+%s?%s.\n",nq->nvname,tp->nvname);
n = strlen(nq->nvname);
while((cp=nv_namptr(dp->nodes,i+1)->nvname) && memcmp(cp,nq->nvname,n)==0 && cp[n]=='.')

View file

@ -1261,7 +1261,7 @@ pid_t path_spawn(Shell_t *shp,const char *opath,register char **argv, char **env
/*
* File is executable but not machine code.
* Assume file is a Shell script and execute it.
* Assume file is a shell script and execute it.
*/
static noreturn void exscript(Shell_t *shp,register char *path,register char *argv[],char **envp)

View file

@ -87,7 +87,9 @@ static const char version[] = "\n@(#)$Id: suid_exec "SH_RELEASE" $\n";
static const char badopen[] = "cannot open";
static const char badexec[] = "cannot exec";
static const char devfd[] = "/dev/fd/10"; /* must match FDIN above */
#ifndef _lib_setreuid
static char tmpname[] = "/tmp/SUIDXXXXXX";
#endif
static char **arglist;
static char *shell;

View file

@ -158,8 +158,7 @@ static void get_cpu_times(Shell_t *shp, struct timeval *tv_usr, struct timeval *
#endif /* _lib_getrusage */
#ifdef timeofday
/* 'inline' is commented out because C89 doesn't have it */
static /*inline*/ double timeval_to_double(struct timeval tv)
static inline double timeval_to_double(struct timeval tv)
{
return (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
}

View file

@ -132,7 +132,7 @@ y=* z=[
s[$y]=1
s[$z]=2
if (( ${#s[@]} != 2 ))
then err_exit 'number of elements of is not 2'
then err_exit 'number of elements of s is not 2'
fi
(( s[$z] = s[$z] + ${s[$y]} ))
if [[ ${s[$z]} != 3 ]]

View file

@ -748,11 +748,11 @@ foo=BUG command eval ':'
# 'whence -f' should ignore functions
foo_bar() { true; }
actual="$(whence -f foo_bar)"
whence -f foo_bar >/dev/null && err_exit "'whence -f' doesn't ignore functions (got '$(printf %q "$actual")')"
whence -f foo_bar >/dev/null && err_exit "'whence -f' doesn't ignore functions (got $(printf %q "$actual"))"
# whence -vq/type -q must be tested as well
actual="$(type -f foo_bar 2>&1)"
type -f foo_bar >/dev/null 2>&1 && err_exit "'type -f' doesn't ignore functions (got '$(printf %q "$actual")')"
type -f foo_bar >/dev/null 2>&1 && err_exit "'type -f' doesn't ignore functions (got $(printf %q "$actual"))"
type -qf foo_bar && err_exit "'type -qf' doesn't ignore functions"
# Test the exit status of 'whence -q'
@ -1060,7 +1060,7 @@ exp=1
[[ $got == $exp ]] || err_exit "'kill %' has the wrong exit status (expected '$exp'; got '$got')"
# ======
# 'cd -' should recognize the value of an overriden $OLDPWD variable
# 'cd -' should recognize the value of an overridden $OLDPWD variable
# https://github.com/ksh93/ksh/pull/249
# https://github.com/att/ast/issues/8

View file

@ -1153,7 +1153,7 @@ func2
}
foo
EOF
} 2> /dev/null || err_exit 'problem with unset -f foo within function foo'
} 2> /dev/null || err_exit "problem with 'unset -f foo' within function foo"
val=$($SHELL 2> /dev/null <<- \EOF
.sh.fun.set() { set -x; }

View file

@ -776,7 +776,7 @@ got=$(umask 777; set +x; { cat <(echo ok); } 2>&1)
# ======
# https://github.com/att/ast/issues/1336
# Use the /proc psuedo filesystem on Linux as a convenient way to force a write I/O error.
# Use the /proc pseudo filesystem on Linux as a convenient way to force a write I/O error.
if [[ $(uname) == Linux ]]
then
actual=$($SHELL -c 'echo > /proc/self/uid_map; echo okay' 2>&1)

View file

@ -765,12 +765,14 @@ touch $'XXX\xc3\xa1' $'XXX\xc3\xab' &&
tst $LINENO <<"!"
L autocomplete should not fill partial multibyte characters
# https://github.com/ksh93/ksh/issues/223
d 15
p :test-1:
w : XX\t
r ^:test-1: : XXX\r\n$
!
# err_exit #
((SHOPT_VSH)) && tst $LINENO <<"!"
L Using b, B, w and W commands in vi mode
# https://github.com/att/ast/issues/1467

View file

@ -283,7 +283,7 @@
08-12-07 include/ast_std.h,misc/getenv.c: no _ast_getenv for uwin ast54 compatibility
08-12-07 tm/tmxfmt.c: add %[_][EO]K for [space pad] [full|long] iso
08-12-07 sfio/sfvscanf.c: fix ok[] short by one allocation
08-12-07 comp/setlocale.c: fix off by one composite initialition loop test
08-12-07 comp/setlocale.c: fix off by one composite initialization loop test
08-12-07 path/pathkey.c: fix off by one loop test
08-12-04 vmalloc/vmbest.c: catch sbrk() wraparound
08-12-04 comp/spawnveg.c: clean up attrs on failure too

View file

@ -42,6 +42,8 @@ typedef struct _direct_s
/* convert a pointer to an int */
#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
#ifdef F_DIOINFO
#if __STD_C
static ssize_t diordwr(Sfio_t* f, Void_t* buf, size_t n, Direct_t* di, int type)
#else
@ -59,7 +61,6 @@ int type;
done = 0; /* amount processed by direct IO */
rv = 0;
#ifdef F_DIOINFO
if((P2I(buf)%di->dio.d_mem) == 0 &&
(f->here%di->dio.d_miniosz) == 0 && n >= di->dio.d_miniosz )
{ /* direct IO ok, make sure we're in the right mode */
@ -92,7 +93,6 @@ int type;
di->cntl &= ~FDIRECT;
(void)fcntl(f->file, F_SETFL, di->cntl);
}
#endif /*F_DIOINFO*/
if((rw = n-done) > 0 &&
(rv = type == SF_READ ? read(f->file,buf,rw) : write(f->file,buf,rw)) > 0 )
@ -141,18 +141,18 @@ Sfdisc_t* disc;
if(type == SF_FINAL || type == SF_DPOP)
{
#ifdef F_DIOINFO
if(di->cntl&FDIRECT)
{ di->cntl &= ~FDIRECT;
(void)fcntl(f->file,F_SETFL,di->cntl);
}
#endif
free(disc);
}
return 0;
}
#endif /* F_DIOINFO */
#if __STD_C
int sfdcdio(Sfio_t* f, size_t bufsize)
#else

View file

@ -202,6 +202,14 @@ typedef struct
#define FMT_EXP_NOCR 0x100 /* skip \r */
#define FMT_EXP_NONL 0x200 /* skip \n */
/*
* Define inline as an empty macro if we are
* compiling with C89.
*/
#if __STDC_VERSION__ < 199901L
#define inline
#endif
/*
* multibyte macros
*/

View file

@ -226,7 +226,7 @@ outputs an
prompt specified by
.I "format, .\|.\|."
to the controlling terminal and reads a response from the controlling terminal.
Offirmative response returns
Affirmative response returns
.LR 0 ,
.L EOF
or quit response returns

View file

@ -2356,8 +2356,8 @@ symbol may be removed in a future release.
The printing and scanning functions were extended to handle multibyte characters
and to conform to the C99 standard.
.PP
The function \f5sfpoll()\fP was rehauled to make it useful
for writing servers that must commnunicate with multiple streams
The function \f5sfpoll()\fP was overhauled to make it useful
for writing servers that must communicate with multiple streams
without blocking.
.PP
The formatting pattern \f5%c\fP for \f5sf*printf\fP was extended

View file

@ -47,6 +47,12 @@
* not done for `csh script arg ...'
*/
#ifdef _WINIX
# define EXE "?(.exe)"
#else
# define EXE
#endif
char*
pathshell(void)
{
@ -59,13 +65,13 @@ pathshell(void)
static char* val;
if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))?(.exe)"))
if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))" EXE))
{
if (!(ru = getuid()) || !eaccess("/bin", W_OK))
{
if (stat(sh, &st))
goto defshell;
if (ru != st.st_uid && !strmatch(sh, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh?(.exe)"))
if (ru != st.st_uid && !strmatch(sh, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh" EXE))
goto defshell;
}
else

View file

@ -30,6 +30,9 @@
#include <ast.h>
#include <ctype.h>
#include <ls.h>
#ifdef __linux__
#include <sys/sysmacros.h>
#endif
char*
fmtdev(struct stat* st)

View file

@ -57,7 +57,7 @@ static const char usage[] =
"converted back to the native encoding. Multibyte characters in the "
"current locale are treated as printable characters.]"
"[A:show-all?Equivalent to \b-vET\b.]"
"[B:squeeze-blank?Multiple adjacent new-line characters are replace by one"
"[B:squeeze-blank?Multiple adjacent new-line characters are replaced by one"
" new-line.]"
"[D:dos-output?Output files are opened in \atext\amode which inserts carriage"
" returns in front of new-lines on some systems.]"

View file

@ -40,7 +40,7 @@
* ASSERT NOTE:
* Some sanity checking code is included using assert(). On my FreeBSD
* system, this additional code can be removed by compiling with NDEBUG
* defined. Check your own systems man page on assert() to see how to
* defined. Check your own system's man page on assert() to see how to
* compile WITHOUT the sanity checking code on your system.
*
* UNROLLED TRANSFORM LOOP NOTE: