1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +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 - 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 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, (globbing), as well as file name tab completion on interactive shells,
automatically become case-insensitive on file systems where the difference automatically become case-insensitive on file systems where the difference
between upper- and lowercase is ignored for file names. This is transparently 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. 7. Code style varies somewhat in this historic code base.
Your changes should match the style of the code surrounding it. Your changes should match the style of the code surrounding it.
Indent with tabs, assuming an 8-space tab width. 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. as their corresponding closing brace.
Comments always use `/*`...`*/`. Comments always use `/*`...`*/`.
8. Good judgment may override this policy. 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> <DT>How do I do global substitutions on the contents of shell variables?<DD>
Use // instead of / for global substitution, ${var//aa/bb} will 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> <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 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 04-06-11 package.sh: make sure $INSTALLROOT/bin is in front of $PATH
package.sh: skip nmake if older than 2000-10-31 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 04-05-11 package.sh: package verbose update lists closure for package setup
package.sh: add src/lib/libardir to nmake proto bootstrap package.sh: add src/lib/libardir to nmake proto bootstrap
regress.sh: probe for rm -u vs. chmod -R u+rwx 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 03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -* regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks 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 regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest 03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation 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 make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check 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-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 ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test 02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw 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 package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include 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* 02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b' iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results 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-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg 98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm 98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first 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 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 04-06-11 package.sh: make sure $INSTALLROOT/bin is in front of $PATH
package.sh: skip nmake if older than 2000-10-31 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 04-05-11 package.sh: package verbose update lists closure for package setup
package.sh: add src/lib/libardir to nmake proto bootstrap package.sh: add src/lib/libardir to nmake proto bootstrap
regress.sh: probe for rm -u vs. chmod -R u+rwx 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 03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -* regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks 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 regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest 03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation 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 make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check 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-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 ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test 02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw 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 package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include 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* 02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b' iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results 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-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg 98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm 98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first 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 these symlinks
/bin/ksh.exe => ksh93.exe /bin/ksh.exe => ksh93.exe
/usr/share/man/man1/ksh93.1 => ksh.1 /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 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 and ksh.1 symbolic links. In addition, ksh and ksh93 paths are
added to /etc/shells if not already present. added to /etc/shells if not already present.
$() $()
Each builtin or special command accepts the --man and --html 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 option describes the self documenting options available to all
builtin and special commands. 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 library which provides several builtin versions of /bin
commands. "builtin | grep /opt/ast/bin" lists the libcmd commands. "builtin | grep /opt/ast/bin" lists the libcmd
builtins on the standard output. /opt/ast/bin/FOO accesses 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 variables to convert. PATH is handled by cygwin so it is not
converted by the ast library. 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. environment that is not suited for an edit/build/debug cycle.
If you want to explore and modify the source then you should If you want to explore and modify the source then you should
install the (non-cygwinized) ast-base package which includes install the (non-cygwinized) ast-base package which includes
AT&T nmake. With ast-base you will also be able to regenerate 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 For more information on ksh and other AT&T ast tools see
http://www.research.att.com/sw/download/ 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 03-09-23 ratz.c: fix tar header number parse bug that skipped to next number
regress.sh: rm cleanup now handles files matching -* regress.sh: rm cleanup now handles files matching -*
03-09-11 iffe.sh: add unnamed { ... } blocks 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 regress.sh: rm -rfu to handle test dirs w/o u+rwx
03-08-14 Makefile: add hello.c to the manifest 03-08-14 Makefile: add hello.c to the manifest
03-08-11 package.sh: fix `html binary' generation 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 make.probe: add CC.LD.STRIP for link time a.out strip
package.sh: fix package_use vs. PACKAGE_USE check 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-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 ratz.c: fix meter buffer overflow
02-10-20 package.sh: fix lib/probe/C/make/probe update test 02-10-20 package.sh: fix lib/probe/C/make/probe update test
02-10-18 probe.win32: update for mingw 02-10-18 probe.win32: update for mingw
@ -604,7 +604,7 @@
package.sh: add check for { cc ar nm yacc/bison } before make package.sh: add check for { cc ar nm yacc/bison } before make
ratz.c: fix "rb" vs. "r" macro tests ratz.c: fix "rb" vs. "r" macro tests
iffe.sh: add nxt, similar to lcl but defines _nxt_foo for #include 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* 02-01-24 C+probe: check CC.DYNAMIC to handle cc that accept but ignore -B*
iffe.sh: handle 'mem struct.a.b' iffe.sh: handle 'mem struct.a.b'
02-01-22 iffe.sh: cache (internal) `foo vs. struct foo' test results 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-05-01 regress: fix bug sometimes didn't list last test
98-04-01 hostinfo: add cc path arg 98-04-01 hostinfo: add cc path arg
hostinfo: now works with /bin/sh hostinfo: now works with /bin/sh
Makefile: strengthed -lm probe Makefile: strengthen -lm probe
98-01-23 Makefile: check for -ldl -lm 98-01-23 Makefile: check for -ldl -lm
C.probe: handle gcc -v -E phony include dirs C.probe: handle gcc -v -E phony include dirs
iffe: fix lcl by dropping sort -u -- we need the real first 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"); search(state.vars, "-strip-symbols", "1");
continue; continue;
case '?': case '?':
error(ERROR_USAGE|4, "%s", opt_info.arg); error(ERROR_usage(2), "%s", opt_info.arg);
continue; UNREACHABLE();
case ':': case ':':
error(2, "%s", opt_info.arg); error(2, "%s", opt_info.arg);
continue; continue;
@ -2166,7 +2166,10 @@ main(int argc, char** argv)
break; break;
} }
if (error_info.errors) if (error_info.errors)
error(ERROR_USAGE|4, "%s", optusage(NiL)); {
error(ERROR_usage(2), "%s", optusage(NiL));
UNREACHABLE();
}
argv += opt_info.index; argv += opt_info.index;
#else #else
while ((s = *++argv) && *s == '-') while ((s = *++argv) && *s == '-')

View file

@ -1391,7 +1391,7 @@ typedef struct internal_state {
*/ */
int level; /* compression level (1..9) */ int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/ int strategy; /* favor or force Huffman coding */
uInt good_match; uInt good_match;
/* Use a faster search when the previous match is longer than this */ /* Use a faster search when the previous match is longer than this */
@ -4813,8 +4813,8 @@ char** argv;
sfprintf(sfstdout, "%s\n", id + 10); sfprintf(sfstdout, "%s\n", id + 10);
return 0; return 0;
case '?': case '?':
error(ERROR_USAGE|4, "%s", opt_info.arg); error(ERROR_usage(2), "%s", opt_info.arg);
continue; UNREACHABLE();
case ':': case ':':
error(2, "%s", opt_info.arg); error(2, "%s", opt_info.arg);
continue; continue;
@ -4822,7 +4822,10 @@ char** argv;
break; break;
} }
if (error_info.errors) if (error_info.errors)
error(ERROR_USAGE|4, "%s", optusage(NiL)); {
error(ERROR_usage(2), "%s", optusage(NiL));
UNREACHABLE();
}
argv += opt_info.index; argv += opt_info.index;
#else #else
while ((s = *++argv) && *s == '-' && *(s + 1)) while ((s = *++argv) && *s == '-' && *(s + 1))

View file

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

View file

@ -125,9 +125,10 @@ static const char usage[] =
#define CMIN 1 #define CMIN 1
#endif #endif
static void outofmemory(void) static noreturn void outofmemory(void)
{ {
error(ERROR_SYSTEM|ERROR_PANIC, "out of memory"); error(ERROR_SYSTEM|ERROR_PANIC, "out of memory");
UNREACHABLE();
} }
#if !_lib_openpty && !_lib__getpty && !defined(_pty_clone) #if !_lib_openpty && !_lib__getpty && !defined(_pty_clone)
@ -221,7 +222,6 @@ static int
mkpty(int* master, int* minion) mkpty(int* master, int* minion)
{ {
struct termios tty; struct termios tty;
struct termios tst;
struct termios* ttyp; struct termios* ttyp;
#ifdef TIOCGWINSZ #ifdef TIOCGWINSZ
struct winsize win; struct winsize win;
@ -316,6 +316,7 @@ mkpty(int* master, int* minion)
return -1; return -1;
#endif #endif
#ifdef I_PUSH #ifdef I_PUSH
struct termios tst;
if (tcgetattr(*minion, &tst) < 0 && (ioctl(*minion, I_PUSH, "ptem") < 0 || ioctl(*minion, I_PUSH, "ldterm") < 0)) if (tcgetattr(*minion, &tst) < 0 && (ioctl(*minion, I_PUSH, "ptem") < 0 || ioctl(*minion, I_PUSH, "ldterm") < 0))
{ {
close(*minion); close(*minion);
@ -1057,17 +1058,26 @@ b_pty(int argc, char** argv, Shbltin_t* context)
break; break;
case '?': case '?':
error(ERROR_usage(2), "%s", opt_info.arg); error(ERROR_usage(2), "%s", opt_info.arg);
break; UNREACHABLE();
} }
break; break;
} }
argv += opt_info.index; argv += opt_info.index;
if (!argv[0]) if (!argv[0])
{
error(ERROR_exit(1), "command must be specified"); error(ERROR_exit(1), "command must be specified");
UNREACHABLE();
}
if (mkpty(&master, &minion) < 0) if (mkpty(&master, &minion) < 0)
{
error(ERROR_system(1), "unable to create pty"); error(ERROR_system(1), "unable to create pty");
UNREACHABLE();
}
if (!(mp = sfnew(NiL, 0, SF_UNBOUND, master, SF_READ|SF_WRITE))) if (!(mp = sfnew(NiL, 0, SF_UNBOUND, master, SF_READ|SF_WRITE)))
{
error(ERROR_system(1), "cannot open master stream"); error(ERROR_system(1), "cannot open master stream");
UNREACHABLE();
}
if (stty) if (stty)
{ {
n = 2; n = 2;
@ -1095,9 +1105,15 @@ b_pty(int argc, char** argv, Shbltin_t* context)
if (!log) if (!log)
lp = 0; lp = 0;
else if (!(lp = sfopen(NiL, log, "w"))) else if (!(lp = sfopen(NiL, log, "w")))
{
error(ERROR_system(1), "%s: cannot write", log); error(ERROR_system(1), "%s: cannot write", log);
UNREACHABLE();
}
if (!(proc = runcmd(argv, minion, session))) if (!(proc = runcmd(argv, minion, session)))
{
error(ERROR_system(1), "unable run %s", argv[0]); error(ERROR_system(1), "unable run %s", argv[0]);
UNREACHABLE();
}
close(minion); close(minion);
if (messages) 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) else if ((fd = open(messages, O_CREAT|O_WRONLY, MODE_666)) >= 0)
drop = 0; drop = 0;
else else
{
error(ERROR_system(1), "%s: cannot redirect messages", messages); error(ERROR_system(1), "%s: cannot redirect messages", messages);
UNREACHABLE();
}
close(2); close(2);
dup(fd); dup(fd);
if (drop) if (drop)
@ -1118,6 +1137,9 @@ b_pty(int argc, char** argv, Shbltin_t* context)
minion = (*fun)(mp, lp, delay, timeout); minion = (*fun)(mp, lp, delay, timeout);
master = procclose(proc); master = procclose(proc);
if (lp && sfclose(lp)) if (lp && sfclose(lp))
{
error(ERROR_system(1), "%s: write error", log); error(ERROR_system(1), "%s: write error", log);
UNREACHABLE();
}
return minion ? minion : master; 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 1. Functions, defined with name() with ksh-93 are compatible with
the POSIX standard, not with ksh-88. No local variables are the POSIX standard, not with ksh-88. No local variables are
permitted, and there is no separate scope. Functions defined permitted, and there is no separate scope. Functions defined
with the function name syntax, maintain compatibility. with the function name syntax have local variables as in ksh-88,
This also affects function traces. 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 2. ! is now a reserved word. As a result, any command by that
name will no longer work with ksh-93. name will no longer work with ksh-93.

View file

@ -46,7 +46,7 @@ Directory layout:
Include directory: Include directory:
1. argnod.h contains the type definitions for command 1. argnod.h contains the type definitions for command
nodes, io nodes, argument nodes, and for positional 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. all the positional parameters functions.
2. builtins.h contains prototypes for builtins as well 2. builtins.h contains prototypes for builtins as well
as symbolic constants that refer to the name-pairs as symbolic constants that refer to the name-pairs
@ -89,7 +89,7 @@ Include directory:
functions. functions.
19. terminal.h is a header file that includes the appropriate 19. terminal.h is a header file that includes the appropriate
terminal include. terminal include.
20. test.h contains the definitions for the test and [[...]] 20. test.h contains the definitions for the test and [[ ... ]]
commands. commands.
21. timeout.h contains the define constant for the maximum 21. timeout.h contains the define constant for the maximum
shell timeout. shell timeout.

View file

@ -243,7 +243,7 @@
that caused a core dump has been fixed. that caused a core dump has been fixed.
12-02-08 A bug in which .sh.fun disciplines could be cleared after a 12-02-08 A bug in which .sh.fun disciplines could be cleared after a
function completes has been fixed. 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. 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 12-02-07 A bug in which numbers with leading zeros could be treated as
octal constants outside of ((...)) has been fixed. 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. 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-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 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-21 [[ (-n foo) ]] no longer requires a space before (.
11-11-11 The readonly attribute for a variable now applies to compound 11-11-11 The readonly attribute for a variable now applies to compound
assignments to that variable. assignments to that variable.
@ -711,7 +711,7 @@
was invoked on a two dimensional array, i.e., arr[5][9].discipline. 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 10-07-19 Fixed a buffering problem which occurred when running a script with
ssh and the parent ssh process is killed. 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 (...). that it is a nested (...).
10-07-09 A bug in the handling of process substitution inside command 10-07-09 A bug in the handling of process substitution inside command
substitution as part of a pipeline has been fixed. substitution as part of a pipeline has been fixed.
@ -1142,9 +1142,9 @@
has been fixed. has been fixed.
09-01-19 A bug in which sending SIGWINCH to a process that reads from a pipe 09-01-19 A bug in which sending SIGWINCH to a process that reads from a pipe
could cause a memory fault has been fixed. could cause a memory fault has been fixed.
09-01-16 +The -R unary operator was added to [[...]] and test to check whether 09-01-16 +The -R unary operator was added to [[ ... ]] and test to check whether
a variable is a name reference. a variable is a name reference.
09-01-16 +The -v unary operator was added to [[...]] and test to check whether 09-01-16 +The -v unary operator was added to [[ ... ]] and test to check whether
a variable is set. a variable is set.
09-01-14 The unset built-in was modified to return 0 exit status when 09-01-14 The unset built-in was modified to return 0 exit status when
unsetting a variable that was unset to conform with the POSIX unsetting a variable that was unset to conform with the POSIX
@ -1261,7 +1261,7 @@
cases where the command caused the shell to fork has been fixed. cases where the command caused the shell to fork has been fixed.
08-09-19 type, whence -v, and command -v were fixed to comply with POSIX 08-09-19 type, whence -v, and command -v were fixed to comply with POSIX
by writing 'not found' diagnostics to the standard error. by writing 'not found' diagnostics to the standard error.
08-09-18 test and [...] were fixed to comply with POSIX in the case 08-09-18 test and [ ... ] were fixed to comply with POSIX in the case
of test '(' binop ')' where binop is a valid binary test operator. of test '(' binop ')' where binop is a valid binary test operator.
08-09-16 +If a method discipline named create is specified when defining a 08-09-16 +If a method discipline named create is specified when defining a
type, this function will be called when an instance is created. type, this function will be called when an instance is created.
@ -1468,7 +1468,7 @@
08-03-04 A bug in multiline mode in emacs and vi mode which could cause the 08-03-04 A bug in multiline mode in emacs and vi mode which could cause the
cursor to be on the wrong line when interrupt was hit has been fixed. cursor to be on the wrong line when interrupt was hit has been fixed.
08-03-03 The change made in ksh93s+ on 07-06-18 in which braces became 08-03-03 The change made in ksh93s+ on 07-06-18 in which braces became
optional for ${a[i]} inside [[...]] was restored in the case optional for ${a[i]} inside [[ ... ]] was restored in the case
where the argument can be a pattern. where the argument can be a pattern.
08-03-03 A bug in which creating a name reference to an associative array 08-03-03 A bug in which creating a name reference to an associative array
instance would fail when the subscript contained characters [ or instance would fail when the subscript contained characters [ or
@ -1580,7 +1580,7 @@
name+=([sub]=value) could cause the array to become an associative name+=([sub]=value) could cause the array to become an associative
array has been fixed. array has been fixed.
07-11-14 A bug in which typeset without arguments could coredump if a 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. been fixed.
07-11-14 A bug in which creating a local SECONDS variable with typeset in 07-11-14 A bug in which creating a local SECONDS variable with typeset in
a function could corrupt memory has been fixed. a function could corrupt memory has been fixed.
@ -1636,7 +1636,7 @@
07-06-25 A bug in the expansion of ${var/pattern/rep} when pattern or rep 07-06-25 A bug in the expansion of ${var/pattern/rep} when pattern or rep
contained a left parenthesis in single quotes has been fixed. contained a left parenthesis in single quotes has been fixed.
07-06-18 The braces for a subscripted variable with ${var[sub]} are now 07-06-18 The braces for a subscripted variable with ${var[sub]} are now
optional when inside [[...]], ((...)) or as a subscript. optional when inside [[ ... ]], ((...)) or as a subscript.
07-05-28 A bug in brace expansion in which single and double quotes did 07-05-28 A bug in brace expansion in which single and double quotes did
not treat the comma as a literal character has been fixed. not treat the comma as a literal character has been fixed.
07-05-24 The -p option of whence now disables -v. 07-05-24 The -p option of whence now disables -v.
@ -1788,7 +1788,7 @@
06-05-19 +Modified arithmetic so that conversions to strings default to 06-05-19 +Modified arithmetic so that conversions to strings default to
the maximum number of precision digits. the maximum number of precision digits.
06-05-16 Bug fixes for multibyte locales. 06-05-16 Bug fixes for multibyte locales.
06-05-10 The =~ operator was added to [[...]] and [[ string ~= ERE ]] 06-05-10 The =~ operator was added to [[ ... ]] and [[ string ~= ERE ]]
is equivalent to [[ string == ~(E)ERE ]]. is equivalent to [[ string == ~(E)ERE ]].
06-04-25 A bug in the vi edit mode which could cause the shell to core dump 06-04-25 A bug in the vi edit mode which could cause the shell to core dump
when switching from emacs mode. when switching from emacs mode.
@ -1880,7 +1880,7 @@
05-05-18 A bug in which the line number for errors was not correct for 05-05-18 A bug in which the line number for errors was not correct for
functions loaded from FPATH has been fixed. functions loaded from FPATH has been fixed.
05-04-18 A bug in which the exit status $? is not set when a trap triggered 05-04-18 A bug in which the exit status $? is not set when a trap triggered
by the [[...]] command is executed has been fixed. by the [[ ... ]] command is executed has been fixed.
05-04-08 +Redirection operators can be directly preceded with {varname} 05-04-08 +Redirection operators can be directly preceded with {varname}
with no intervening space, where varname is a variable name which with no intervening space, where varname is a variable name which
allows the shell to select a file descriptor > 10 and store it allows the shell to select a file descriptor > 10 and store it
@ -2144,7 +2144,7 @@
did not follow x has been fixed. did not follow x has been fixed.
03-03-18 --- Release ksh93o --- 03-03-18 --- Release ksh93o ---
03-03-18 +A -N unary operator was added to test and [[...]] which returns 03-03-18 +A -N unary operator was added to test and [[ ... ]] which returns
true if the file exists and the file has been modified since it true if the file exists and the file has been modified since it
was last read. was last read.
03-03-18 +The TIMEFORMAT variable was added to control the format for 03-03-18 +The TIMEFORMAT variable was added to control the format for
@ -2703,7 +2703,7 @@
99-03-31 +The TAB key can be used for completion in emacs and viraw mode. 99-03-31 +The TAB key can be used for completion in emacs and viraw mode.
99-03-31 A bug in setting .sh.editchar during the KEYBD trap 99-03-31 A bug in setting .sh.editchar during the KEYBD trap
for the MULTIBYTE option was fixed in release ksh93h. for the MULTIBYTE option was fixed in release ksh93h.
99-03-31 A bug in shcomp for compilation of unary operators with [[...]] 99-03-31 A bug in shcomp for compilation of unary operators with [[ ... ]]
has been fixed. has been fixed.
99-03-31 A bug in which the value of $? was changed when executing 99-03-31 A bug in which the value of $? was changed when executing
a keyboard trap has been fixed. a keyboard trap has been fixed.

View file

@ -258,7 +258,7 @@ of ksh.
2. The -C option is equivalent to -o noclobber. Files are 2. The -C option is equivalent to -o noclobber. Files are
created with O_EXCL when -C is on. created with O_EXCL when -C is on.
h. The following changes have been made to [[...]]: h. The following changes have been made to [[ ... ]]:
1. A string by itself is equivalent to -n string. 1. A string by itself is equivalent to -n string.
2. -e has been added as equivalent to -a. 2. -e has been added as equivalent to -a.
3. == has been added as equivalent =. 3. == has been added as equivalent =.

View file

@ -359,7 +359,7 @@ of ksh.
were split across buffer boundaries has been fixed. were split across buffer boundaries has been fixed.
14. Bugs fixed in 12/28/93h for default OPTIONS 14. Bugs fixed in 12/28/93h for default OPTIONS
a. I bug in shcomp for compilation of unary operators with [[...]] a. I bug in shcomp for compilation of unary operators with [[ ... ]]
has been fixed. has been fixed.
b. A bug in which the value of $? was changed when executing b. A bug in which the value of $? was changed when executing
a keyboard trap has been fixed. a keyboard trap has been fixed.

View file

@ -57,10 +57,10 @@ static const char enum_type[] =
"field splitting and pathname expansion are not performed on " "field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]" "the arguments. Tilde expansion occurs on \avalue\a.]"
"[r?Enables readonly. Once enabled, the value cannot be changed or unset.]" "[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 " "array of type \b\f?\f\b. If a variable already exists, the current "
"value will become index \b0\b.]" "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 " "array of type \b\f?\f\b. If a variable already exists, the current "
"value will become subscript \b0\b.]" "value will become subscript \b0\b.]"
"[h]:[string?Used within a type definition to provide a help string " "[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); 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) int b_dot_cmd(register int n,char *argv[],Shbltin_t *context)
{ {
register char *script; 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); 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 #if _lib_getrusage
static void print_cpu_times() static void print_cpu_times(void)
{ {
struct rusage usage; struct rusage usage;
/* Print the time (user & system) consumed by the shell. */ /* 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); print_times(usage.ru_utime, usage.ru_stime);
} }
#else /* _lib_getrusage */ #else /* _lib_getrusage */
static void print_cpu_times() static void print_cpu_times(void)
{ {
struct timeval utime, stime; struct timeval utime, stime;
double dtime; double dtime;

View file

@ -183,6 +183,10 @@ int b_trap(int argc,char *argv[],Shbltin_t *context)
return(0); 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) int b_kill(int argc,char *argv[],Shbltin_t *context)
{ {
register char *signame; register char *signame;

View file

@ -191,7 +191,13 @@ int b_alias(int argc,register char *argv[],Shbltin_t *context)
#if 0 #if 0
/* for the dictionary generator */ /* 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 #endif
int b_typeset(int argc,register char *argv[],Shbltin_t *context) 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.]" "value will be displayed as an unsigned integer.]"
"[x?Puts each \aname\a on the export list. See \bexport\b(1). \aname\a " "[x?Puts each \aname\a on the export list. See \bexport\b(1). \aname\a "
"cannot contain a \b.\b.]" "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 " "array. If a variable already exists, the current value will "
"become index \b0\b.]" "become index \b0\b.]"
"[C?Compound variable. Each \aname\a will be a compound variable. If " "[C?Compound variable. Each \aname\a will be a compound variable. If "

View file

@ -411,7 +411,7 @@ const char e_lexlabunknown[] = "line %d: %s unknown label";
const char e_lexobsolete1[] = "line %d: `...` obsolete, use $(...)"; const char e_lexobsolete1[] = "line %d: `...` obsolete, use $(...)";
const char e_lexobsolete2[] = "line %d: -a obsolete, use -e"; const char e_lexobsolete2[] = "line %d: -a obsolete, use -e";
const char e_lexobsolete3[] = "line %d: '=' obsolete, use '=='"; const char e_lexobsolete3[] = "line %d: '=' obsolete, use '=='";
const char e_lexobsolete4[] = "line %d: %s within [[...]] obsolete, use ((...))"; const char e_lexobsolete4[] = "line %d: %s within [[ ... ]] obsolete, use ((...))";
const char e_lexobsolete5[] = "line %d: set %s obsolete"; const char e_lexobsolete5[] = "line %d: set %s obsolete";
const char e_lexobsolete6[] = "line %d: `{' instead of `in' is obsolete"; const char e_lexobsolete6[] = "line %d: `{' instead of `in' is obsolete";
const char e_lexusebrace[] = "line %d: use braces to avoid ambiguities with $id[...]"; const char e_lexusebrace[] = "line %d: use braces to avoid ambiguities with $id[...]";

View file

@ -1234,7 +1234,7 @@ static void xcommands(register Emacs_t *ep,int count)
show_info(ep,hbuf); show_info(ep,hbuf);
return; 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 */ case cntl('D'): /* ^X^D show debugging info */
{ {
char debugbuf[MAXLINE]; 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, ***/ /*** Line terminated with escape, or escaped eol/eof, ***/
/* so set raw mode */ /*** so set raw mode ***/
if( tty_raw(ERRIO,0) < 0 ) if( tty_raw(ERRIO,0) < 0 )
{ {

View file

@ -150,6 +150,6 @@ cat{
# endif /* FD_SET */ # endif /* FD_SET */
# ifndef _typ_fd_set # ifndef _typ_fd_set
typedef long fd_set; typedef long fd_set;
# endif /*_typ_fd_set */ # endif /* _typ_fd_set */
#endif /* _lib_select */ #endif /* _lib_select */
}end }end

View file

@ -81,7 +81,7 @@ struct sh_scoped
char *funname; char *funname;
int lineno; int lineno;
Dt_t *save_tree; /* var_tree for calling function */ Dt_t *save_tree; /* var_tree for calling function */
struct sh_scoped *self; /* pointer to copy of this scope*/ struct sh_scoped *self; /* pointer to copy of this scope */
Dt_t *var_local; /* local level variables for name() */ Dt_t *var_local; /* local level variables for name() */
struct slnod *staklist; /* link list of function stacks */ struct slnod *staklist; /* link list of function stacks */
int states; /* shell state bits used by sh_isstate(), etc. */ int states; /* shell state bits used by sh_isstate(), etc. */
@ -163,10 +163,10 @@ struct shared
char *lastarg; \ char *lastarg; \
char *lastpath; /* last absolute path found */ \ char *lastpath; /* last absolute path found */ \
int path_err; /* last error on path search */ \ int path_err; /* last error on path search */ \
Dt_t *track_tree; /* for tracked aliases*/ \ Dt_t *track_tree; /* for tracked aliases */ \
Dt_t *var_base; /* global level variables */ \ Dt_t *var_base; /* global level variables */ \
Dt_t *openmatch; \ Dt_t *openmatch; \
Namval_t *namespace; /* current active namespace*/ \ Namval_t *namespace; /* current active namespace */ \
Namval_t *last_table; /* last table used in last nv_open */ \ Namval_t *last_table; /* last table used in last nv_open */ \
Namval_t *prev_table; /* previous table used in nv_open */ \ Namval_t *prev_table; /* previous table used in nv_open */ \
Sfio_t *outpool; /* output stream pool */ \ Sfio_t *outpool; /* output stream pool */ \

View file

@ -88,7 +88,7 @@ struct Namarray
void *(*fun)(Namval_t*,const char*,int); /* associative arrays */ void *(*fun)(Namval_t*,const char*,int); /* associative arrays */
void *fixed; /* for fixed sized arrays */ void *fixed; /* for fixed sized arrays */
Dt_t *table; /* for subscripts */ Dt_t *table; /* for subscripts */
void *scope; /* non-zerp when scoped */ void *scope; /* non-zero when scoped */
}; };
/* The context pointer for declaration command */ /* The context pointer for declaration command */
@ -242,7 +242,7 @@ struct Namval
# define extern __IMPORT__ # define extern __IMPORT__
# endif /* _BLD_shell */ # endif /* _BLD_shell */
#endif /* _DLL */ #endif /* _DLL */
/* prototype for array interface*/ /* prototype for array interface */
extern Namarr_t *nv_arrayptr(Namval_t*); extern Namarr_t *nv_arrayptr(Namval_t*);
extern Namarr_t *nv_setarray(Namval_t*,void*(*)(Namval_t*,const char*,int)); extern Namarr_t *nv_setarray(Namval_t*,void*(*)(Namval_t*,const char*,int));
extern int nv_arraynsub(Namarr_t*); extern int nv_arraynsub(Namarr_t*);
@ -285,7 +285,7 @@ extern void nv_setvec(Namval_t*,int,int,char*[]);
extern void nv_setvtree(Namval_t*); extern void nv_setvtree(Namval_t*);
extern int nv_setsize(Namval_t*,int); extern int nv_setsize(Namval_t*,int);
extern Namfun_t *nv_disc(Namval_t*,Namfun_t*,int); extern Namfun_t *nv_disc(Namval_t*,Namfun_t*,int);
extern void nv_unset(Namval_t*); /*obsolete */ extern void nv_unset(Namval_t*); /* obsolete */
extern void _nv_unset(Namval_t*,int); extern void _nv_unset(Namval_t*,int);
extern Namval_t *nv_search(const char *, Dt_t*, int); extern Namval_t *nv_search(const char *, Dt_t*, int);
extern char *nv_name(Namval_t*); extern char *nv_name(Namval_t*);

View file

@ -45,7 +45,7 @@
#define PATH_STD_DIR 0100 /* directory is on $(getconf PATH) */ #define PATH_STD_DIR 0100 /* directory is on $(getconf PATH) */
#define PATH_OFFSET 2 /* path offset for path_join */ #define PATH_OFFSET 2 /* path offset for path_join */
#define MAXDEPTH (sizeof(char*)==2?64:1024) /* maximum recursion depth*/ #define MAXDEPTH (sizeof(char*)==2?64:1024) /* maximum recursion depth */
/* /*
* path component structure for path searching * path component structure for path searching

View file

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

View file

@ -43,9 +43,9 @@
#define FLINENO (04<<COMBITS) /* for/case has line number */ #define FLINENO (04<<COMBITS) /* for/case has line number */
#define FOPTGET (0200<<COMBITS) /* function calls getopts */ #define FOPTGET (0200<<COMBITS) /* function calls getopts */
#define TNEGATE (01<<COMBITS) /* ! inside [[...]] */ #define TNEGATE (01<<COMBITS) /* ! inside [[ ... ]] */
#define TBINARY (02<<COMBITS) /* binary operator in [[...]] */ #define TBINARY (02<<COMBITS) /* binary operator in [[ ... ]] */
#define TUNARY (04<<COMBITS) /* unary operator in [[...]] */ #define TUNARY (04<<COMBITS) /* unary operator in [[ ... ]] */
#define TTEST (010<<COMBITS) #define TTEST (010<<COMBITS)
#define TPAREN (TBINARY|TUNARY) #define TPAREN (TBINARY|TUNARY)
#define TSHIFT (COMBITS+4) #define TSHIFT (COMBITS+4)

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. that the name-value pair is unset.
The \f5nv_getnum()\fP function returns the value of the given The \f5nv_getnum()\fP function returns the value of the given
name-value pair as a double precision number using the \f5Sfio\fP 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, For name-value pairs without the \f5NV_INTEGER\fP attribute,
the string value is evaluated as an arithmetic expression to the string value is evaluated as an arithmetic expression to
arrive at a numerical value. arrive at a numerical value.
@ -541,7 +541,7 @@ and returned.
.IP .IP
\f5NV_CLONE\fP: \f5NV_CLONE\fP:
If \fIfp\fP is non-\f5NULL\fP and it is on the stack, 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 \f5nofree\fP field is set to \f50\fP.
The new discipline is returned. The new discipline is returned.
Otherwise, \f5NULL\fP is returned. Otherwise, \f5NULL\fP is returned.

View file

@ -6145,7 +6145,7 @@ and IEEE POSIX 1003.2 standards.
(See (See
.IR pathconf (2) .IR pathconf (2)
and and
.IR sysconf (2).) .IR sysconf (3).)
The The
.I pathname .I pathname
argument is required for parameters whose value depends on argument is required for parameters whose value depends on
@ -7479,7 +7479,7 @@ or
\f3times\fP \f3times\fP
Displays the accumulated user and system CPU times, one line with the times 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 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 .TP
\(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|. \(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
The The
@ -8445,7 +8445,7 @@ except that the following are disallowed:
.RS .RS
.PD 0 .PD 0
.PP .PP
Unsetting the restricted option. unsetting the restricted option,
.br .br
changing directory (see changing directory (see
.IR cd (1)), .IR cd (1)),
@ -8470,9 +8470,9 @@ redirecting output
.BR >| , .BR >| ,
.BR <> , .BR <> ,
and and
.BR >> ). .BR >> ) ,
.br .br
adding or deleting built-in commands. adding or deleting built-in commands,
.br .br
using using
.B "command -p" .B "command -p"
@ -8591,7 +8591,7 @@ lseek(2),
paste(1), paste(1),
pathconf(2), pathconf(2),
pipe(2), pipe(2),
sysconf(2), sysconf(3),
umask(2), umask(2),
ulimit(2), ulimit(2),
wait(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_INTERACTIVE);
sh_offstate(SH_MONITOR); sh_offstate(SH_MONITOR);
job.jobcontrol = 0; job.jobcontrol = 0;
/* do the process substitution */ /* run the process substitution */
shp->subshell = 0; shp->subshell = 0;
if(fd) if(fd)
shp->inpipe = pv; shp->inpipe = pv;

View file

@ -871,13 +871,8 @@ static struct index_array *array_grow(Namval_t *np, register struct index_array
} }
} }
else 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++; i++;
else if(nv_isattr(np,NV_INTEGER) && !nv_isnull(np))
{
Sfdouble_t d= nv_getnum(np);
i++;
}
ap->header.nelem = i; ap->header.nelem = i;
ap->header.hdr.disc = &array_disc; ap->header.hdr.disc = &array_disc;
nv_disc(np,(Namfun_t*)ap, NV_FIRST); 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); Namarr_t *ap = nv_arrayptr(np);
/* Block an attempt to alter a readonly array via subscript assignment or by appending the array. /* 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. */ 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)) 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

@ -578,7 +578,7 @@ void sh_exit(register int xno)
shp->prefix = 0; shp->prefix = 0;
#if SHOPT_TYPEDEF #if SHOPT_TYPEDEF
shp->mktype = 0; shp->mktype = 0;
#endif /* SHOPT_TYPEDEF*/ #endif /* SHOPT_TYPEDEF */
if(job.in_critical) if(job.in_critical)
job_unlock(); job_unlock();
if(pp->mode == SH_JMPSCRIPT && !pp->prev) if(pp->mode == SH_JMPSCRIPT && !pp->prev)

View file

@ -210,13 +210,6 @@ static char *env_init(Shell_t*);
static void env_import_attributes(Shell_t*,char*); static void env_import_attributes(Shell_t*,char*);
static Init_t *nv_init(Shell_t*); static Init_t *nv_init(Shell_t*);
static int shlvl; static int shlvl;
#ifdef _WINIX
# define EXE "?(.exe)"
#else
# define EXE
#endif
static int rand_shift; static int rand_shift;
/* /*
@ -284,7 +277,7 @@ static void put_ed(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
goto done; goto done;
if(!(cp=val) && (*name=='E' || !(cp=nv_getval(sh_scoped(shp,EDITNOD))))) if(!(cp=val) && (*name=='E' || !(cp=nv_getval(sh_scoped(shp,EDITNOD)))))
goto done; goto done;
/* turn on vi or emacs option if editor name is either*/ /* turn on vi or emacs option if editor name is either */
cp = path_basename(cp); cp = path_basename(cp);
#if SHOPT_VSH #if SHOPT_VSH
if(strmatch(cp,"*[Vv][Ii]*")) if(strmatch(cp,"*[Vv][Ii]*"))
@ -1970,7 +1963,7 @@ static void env_import_attributes(Shell_t *shp, char *next)
int size = *(unsigned char*)(cp+1)-' '; int size = *(unsigned char*)(cp+1)-' ';
if((flag&NV_INTEGER) && size==0) if((flag&NV_INTEGER) && size==0)
{ {
/* check for floating*/ /* check for floating */
char *dp, *val = nv_getval(np); char *dp, *val = nv_getval(np);
strtol(val,&dp,10); strtol(val,&dp,10);
if(*dp=='.' || *dp=='e' || *dp=='E') if(*dp=='.' || *dp=='e' || *dp=='E')

View file

@ -436,7 +436,7 @@ int job_reap(register int sig)
#ifdef DEBUG #ifdef DEBUG
sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d job %d with pid %d flags=%o complete with status=%x exit=%d\n",__LINE__,shgd->current_pid,job.in_critical,pw->p_job,pid,pw->p_flag,wstat,pw->p_exit); sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d job %d with pid %d flags=%o complete with status=%x exit=%d\n",__LINE__,shgd->current_pid,job.in_critical,pw->p_job,pid,pw->p_flag,wstat,pw->p_exit);
sfsync(sfstderr); sfsync(sfstderr);
#endif /* DEBUG*/ #endif /* DEBUG */
/* only top-level process in job should have notify set */ /* only top-level process in job should have notify set */
if(px && pw != px) if(px && pw != px)
pw->p_flag &= ~P_NOTIFY; pw->p_flag &= ~P_NOTIFY;
@ -1461,7 +1461,7 @@ int job_wait(register pid_t pid)
sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d job=%d pid=%d\n",__LINE__,shgd->current_pid,job.in_critical,jobid,pid); sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d job=%d pid=%d\n",__LINE__,shgd->current_pid,job.in_critical,jobid,pid);
if(pw) if(pw)
sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d flags=%o\n",__LINE__,shgd->current_pid,job.in_critical,pw->p_flag); sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d flags=%o\n",__LINE__,shgd->current_pid,job.in_critical,pw->p_flag);
#endif /* DEBUG*/ #endif /* DEBUG */
errno = 0; errno = 0;
if(shp->coutpipe>=0 && lastpid && shp->cpid==lastpid) if(shp->coutpipe>=0 && lastpid && shp->cpid==lastpid)
{ {

View file

@ -73,7 +73,7 @@ local_iswblank(wchar_t wc)
struct lexstate struct lexstate
{ {
char incase; /* 1 for case pattern, 2 after case */ char incase; /* 1 for case pattern, 2 after case */
char intest; /* 1 inside [[...]] */ char intest; /* 1 inside [[ ... ]] */
char testop1; /* 1 when unary test op legal */ char testop1; /* 1 when unary test op legal */
char testop2; /* 1 when binary test op legal */ char testop2; /* 1 when binary test op legal */
char reservok; /* >0 for reserved word legal */ char reservok; /* >0 for reserved word legal */
@ -2321,10 +2321,6 @@ struct argnod *sh_endword(Shell_t *shp,int mode)
break; break;
} }
n = *sp; 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(!(inquote&1) || (sh_lexstates[ST_QUOTE][n] && n!=RBRACE))
{ {
if(n=='\n') if(n=='\n')

View file

@ -53,7 +53,7 @@
#if _WINIX #if _WINIX
static int Skip; static int Skip;
#endif /*_WINIX */ #endif /* _WINIX */
static int _c_; static int _c_;
typedef struct _mac_ typedef struct _mac_
@ -823,7 +823,7 @@ static void copyto(register Mac_t *mp,int endch, int newquote)
first = cp = fcseek(Skip); first = cp = fcseek(Skip);
Skip = 0; Skip = 0;
} }
#endif /*_WINIX */ #endif /* _WINIX */
tilde = -1; tilde = -1;
c=0; c=0;
} }

View file

@ -280,7 +280,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
shtp.rp = 0; shtp.rp = 0;
shtp.nodes = (Namval_t**)sh_malloc(shtp.maxnodes*sizeof(Namval_t*)); shtp.nodes = (Namval_t**)sh_malloc(shtp.maxnodes*sizeof(Namval_t*));
} }
#endif /* SHOPT_TYPEDEF*/ #endif /* SHOPT_TYPEDEF */
#if SHOPT_NAMESPACE #if SHOPT_NAMESPACE
if(shp->namespace && nv_dict(shp->namespace)==shp->var_tree) if(shp->namespace && nv_dict(shp->namespace)==shp->var_tree)
flags |= NV_NOSCOPE; flags |= NV_NOSCOPE;
@ -734,9 +734,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
long mode, add=0; long mode, add=0;
int copy=0,isref,top=0,noscope=(flags&NV_NOSCOPE); int copy=0,isref,top=0,noscope=(flags&NV_NOSCOPE);
int nofree=0, level=0; int nofree=0, level=0;
#if SHOPT_FIXEDARRAY
Namarr_t *ap; Namarr_t *ap;
#endif /* SHOPT_FIXEDARRAY */
if(root==shp->var_tree) if(root==shp->var_tree)
{ {
if(dtvnext(root)) 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) if(flags&NV_ARRAY)
{ {
Namarr_t *ap = nv_arrayptr(np); ap = nv_arrayptr(np);
nq = nv_opensub(np); nq = nv_opensub(np);
if((flags&NV_ASSIGN) && (!nq || nv_isnull(nq))) if((flags&NV_ASSIGN) && (!nq || nv_isnull(nq)))
ap->nelem++; ap->nelem++;
@ -1034,7 +1032,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
if(c=='[') if(c=='[')
{ {
#if SHOPT_FIXEDARRAY #if SHOPT_FIXEDARRAY
Namarr_t *ap = nv_arrayptr(np); ap = nv_arrayptr(np);
#endif /* SHOPT_FIXEDARRAY */ #endif /* SHOPT_FIXEDARRAY */
n = mode|nv_isarray(np); n = mode|nv_isarray(np);
if(!mode && (flags&NV_ARRAY) && ((c=sp[1])=='*' || c=='@') && sp[2]==']') 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(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 #if SHOPT_OPTIMIZE
struct optimize struct optimize
{ {

View file

@ -41,12 +41,12 @@ static const char sh_opttype[] =
"field splitting and pathname expansion are not performed on " "field splitting and pathname expansion are not performed on "
"the arguments. Tilde expansion occurs on \avalue\a.]" "the arguments. Tilde expansion occurs on \avalue\a.]"
"[r?Enables readonly. Once enabled, the value cannot be changed or unset.]" "[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 " "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 " "value will become index \b0\b. If \b[\b\atype\a\b]]\b is "
"specified, each subscript is interpreted as a value of enumeration " "specified, each subscript is interpreted as a value of enumeration "
"type \atype\a.]" "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 " "array of type \b\f?\f\b. If a variable already exists, the current "
"value will become subscript \b0\b.]" "value will become subscript \b0\b.]"
"[h]:[string?Used within a type definition to provide a help string " "[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); nq = nv_namptr(dp->nodes,i);
if(tp=nv_type(nq)) if(tp=nv_type(nq))
{ {
Namfun_t *pp = nv_hasdisc(nq,&type_disc);
sfprintf(out,"\t[+%s?%s.\n",nq->nvname,tp->nvname); sfprintf(out,"\t[+%s?%s.\n",nq->nvname,tp->nvname);
n = strlen(nq->nvname); n = strlen(nq->nvname);
while((cp=nv_namptr(dp->nodes,i+1)->nvname) && memcmp(cp,nq->nvname,n)==0 && cp[n]=='.') 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. * 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) 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 badopen[] = "cannot open";
static const char badexec[] = "cannot exec"; static const char badexec[] = "cannot exec";
static const char devfd[] = "/dev/fd/10"; /* must match FDIN above */ static const char devfd[] = "/dev/fd/10"; /* must match FDIN above */
#ifndef _lib_setreuid
static char tmpname[] = "/tmp/SUIDXXXXXX"; static char tmpname[] = "/tmp/SUIDXXXXXX";
#endif
static char **arglist; static char **arglist;
static char *shell; static char *shell;

View file

@ -79,7 +79,7 @@ struct funenv
Namval_t **nref; Namval_t **nref;
}; };
/* ======== command execution ========*/ /* ======== command execution ======== */
#if !SHOPT_DEVFD #if !SHOPT_DEVFD
static pid_t fifo_save_ppid; static pid_t fifo_save_ppid;
@ -158,8 +158,7 @@ static void get_cpu_times(Shell_t *shp, struct timeval *tv_usr, struct timeval *
#endif /* _lib_getrusage */ #endif /* _lib_getrusage */
#ifdef timeofday #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); return (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
} }

View file

@ -145,9 +145,9 @@ The \f5Shell_t\fP structure contains the following fields:
Dt_t *\fIalias_tree\fP; \fR/* shell alias dictionary */\fP Dt_t *\fIalias_tree\fP; \fR/* shell alias dictionary */\fP
Dt_t *\fIbltin_tree\fP; \fR/* shell built-in dictionary */\fP Dt_t *\fIbltin_tree\fP; \fR/* shell built-in dictionary */\fP
Shscope_t *\fItopscope\fP; \fR/* pointer to top-level scope */\fP Shscope_t *\fItopscope\fP; \fR/* pointer to top-level scope */\fP
char *\fIinfile_name\fP; \fR/* path name of current input file*/\fP char *\fIinfile_name\fP; \fR/* path name of current input file */\fP
int \fIinlineno\fP; \fR/* line number of current input file*/\fP int \fIinlineno\fP; \fR/* line number of current input file */\fP
int \fIexitval\fP; \fR/* most recent exit value*/\fP int \fIexitval\fP; \fR/* most recent exit value */\fP
.ft R .ft R
.fi .fi
This structure is returned by \f5sh_init()\fP but can also be retrieved This structure is returned by \f5sh_init()\fP but can also be retrieved

View file

@ -132,7 +132,7 @@ y=* z=[
s[$y]=1 s[$y]=1
s[$z]=2 s[$z]=2
if (( ${#s[@]} != 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 fi
(( s[$z] = s[$z] + ${s[$y]} )) (( s[$z] = s[$z] + ${s[$y]} ))
if [[ ${s[$z]} != 3 ]] if [[ ${s[$z]} != 3 ]]

View file

@ -132,26 +132,26 @@ fi
[[ -z '' && -z '' && -z '' ]] || err_exit "three ors not working" [[ -z '' && -z '' && -z '' ]] || err_exit "three ors not working"
(exit 8) (exit 8)
if [[ $? -ne 8 || $? -ne 8 ]] if [[ $? -ne 8 || $? -ne 8 ]]
then err_exit 'value $? within [[...]]' then err_exit 'value $? within [[ ... ]]'
fi fi
x='(x' x='(x'
if [[ '(x' != '('* ]] if [[ '(x' != '('* ]]
then err_exit " '(x' does not match '('* within [[...]]" then err_exit " '(x' does not match '('* within [[ ... ]]"
fi fi
if [[ '(x' != "("* ]] if [[ '(x' != "("* ]]
then err_exit ' "(x" does not match "("* within [[...]]' then err_exit ' "(x" does not match "("* within [[ ... ]]'
fi fi
if [[ '(x' != \(* ]] if [[ '(x' != \(* ]]
then err_exit ' "(x" does not match \(* within [[...]]' then err_exit ' "(x" does not match \(* within [[ ... ]]'
fi fi
if [[ 'x(' != *'(' ]] if [[ 'x(' != *'(' ]]
then err_exit " 'x(' does not match '('* within [[...]]" then err_exit " 'x(' does not match '('* within [[ ... ]]"
fi fi
if [[ 'x&' != *'&' ]] if [[ 'x&' != *'&' ]]
then err_exit " 'x&' does not match '&'* within [[...]]" then err_exit " 'x&' does not match '&'* within [[ ... ]]"
fi fi
if [[ 'xy' == *'*' ]] if [[ 'xy' == *'*' ]]
then err_exit " 'xy' matches *'*' within [[...]]" then err_exit " 'xy' matches *'*' within [[ ... ]]"
fi fi
if [[ 3 > 4 ]] if [[ 3 > 4 ]]
then err_exit '3 < 4' then err_exit '3 < 4'
@ -330,7 +330,7 @@ unset x
unset x y z foo bar unset x y z foo bar
{ x=$($SHELL -c '[[ (( $# -eq 0 )) ]] && print ok') 2> /dev/null;} { x=$($SHELL -c '[[ (( $# -eq 0 )) ]] && print ok') 2> /dev/null;}
[[ $x == ok ]] || err_exit '((...)) inside [[...]] not treated as nested ()' [[ $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 exits'
[[ -e /dev/tcp/ ]] || err_exit '/dev/tcp/ does not exist' [[ -e /dev/tcp/ ]] || err_exit '/dev/tcp/ does not exist'
@ -400,11 +400,11 @@ done
# ====== # ======
# Tests from ksh93v- for the -eq operator # Tests from ksh93v- for the -eq operator
[[ 010 -eq 10 ]] || err_exit '010 is not 10 in [[...]]' [[ 010 -eq 10 ]] || err_exit '010 is not 10 in [[ ... ]]'
unset foo unset foo
foo=10 foo=10
([[ foo -eq 10 ]]) || err_exit 'foo -eq 10 fails in [[...]] with foo=10' ([[ foo -eq 10 ]]) || err_exit 'foo -eq 10 fails in [[ ... ]] with foo=10'
# ====== # ======
exit $((Errors<125?Errors:125)) exit $((Errors<125?Errors:125))

View file

@ -748,11 +748,11 @@ foo=BUG command eval ':'
# 'whence -f' should ignore functions # 'whence -f' should ignore functions
foo_bar() { true; } foo_bar() { true; }
actual="$(whence -f foo_bar)" 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 # whence -vq/type -q must be tested as well
actual="$(type -f foo_bar 2>&1)" 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" type -qf foo_bar && err_exit "'type -qf' doesn't ignore functions"
# Test the exit status of 'whence -q' # 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')" [[ $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/ksh93/ksh/pull/249
# https://github.com/att/ast/issues/8 # https://github.com/att/ast/issues/8

View file

@ -1153,7 +1153,7 @@ func2
} }
foo foo
EOF 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 val=$($SHELL 2> /dev/null <<- \EOF
.sh.fun.set() { set -x; } .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 # 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 ]] if [[ $(uname) == Linux ]]
then then
actual=$($SHELL -c 'echo > /proc/self/uid_map; echo okay' 2>&1) 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 <<"!" tst $LINENO <<"!"
L autocomplete should not fill partial multibyte characters L autocomplete should not fill partial multibyte characters
# https://github.com/ksh93/ksh/issues/223 # https://github.com/ksh93/ksh/issues/223
d 15 d 15
p :test-1: p :test-1:
w : XX\t w : XX\t
r ^:test-1: : XXX\r\n$ r ^:test-1: : XXX\r\n$
! !
# err_exit #
((SHOPT_VSH)) && tst $LINENO <<"!" ((SHOPT_VSH)) && tst $LINENO <<"!"
L Using b, B, w and W commands in vi mode L Using b, B, w and W commands in vi mode
# https://github.com/att/ast/issues/1467 # 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 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 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 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-07 path/pathkey.c: fix off by one loop test
08-12-04 vmalloc/vmbest.c: catch sbrk() wraparound 08-12-04 vmalloc/vmbest.c: catch sbrk() wraparound
08-12-04 comp/spawnveg.c: clean up attrs on failure too 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 */ /* convert a pointer to an int */
#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0) #define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
#ifdef F_DIOINFO
#if __STD_C #if __STD_C
static ssize_t diordwr(Sfio_t* f, Void_t* buf, size_t n, Direct_t* di, int type) static ssize_t diordwr(Sfio_t* f, Void_t* buf, size_t n, Direct_t* di, int type)
#else #else
@ -59,7 +61,6 @@ int type;
done = 0; /* amount processed by direct IO */ done = 0; /* amount processed by direct IO */
rv = 0; rv = 0;
#ifdef F_DIOINFO
if((P2I(buf)%di->dio.d_mem) == 0 && if((P2I(buf)%di->dio.d_mem) == 0 &&
(f->here%di->dio.d_miniosz) == 0 && n >= di->dio.d_miniosz ) (f->here%di->dio.d_miniosz) == 0 && n >= di->dio.d_miniosz )
{ /* direct IO ok, make sure we're in the right mode */ { /* direct IO ok, make sure we're in the right mode */
@ -92,7 +93,6 @@ int type;
di->cntl &= ~FDIRECT; di->cntl &= ~FDIRECT;
(void)fcntl(f->file, F_SETFL, di->cntl); (void)fcntl(f->file, F_SETFL, di->cntl);
} }
#endif /*F_DIOINFO*/
if((rw = n-done) > 0 && if((rw = n-done) > 0 &&
(rv = type == SF_READ ? read(f->file,buf,rw) : write(f->file,buf,rw)) > 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) if(type == SF_FINAL || type == SF_DPOP)
{ {
#ifdef F_DIOINFO
if(di->cntl&FDIRECT) if(di->cntl&FDIRECT)
{ di->cntl &= ~FDIRECT; { di->cntl &= ~FDIRECT;
(void)fcntl(f->file,F_SETFL,di->cntl); (void)fcntl(f->file,F_SETFL,di->cntl);
} }
#endif
free(disc); free(disc);
} }
return 0; return 0;
} }
#endif /* F_DIOINFO */
#if __STD_C #if __STD_C
int sfdcdio(Sfio_t* f, size_t bufsize) int sfdcdio(Sfio_t* f, size_t bufsize)
#else #else

View file

@ -202,6 +202,14 @@ typedef struct
#define FMT_EXP_NOCR 0x100 /* skip \r */ #define FMT_EXP_NOCR 0x100 /* skip \r */
#define FMT_EXP_NONL 0x200 /* skip \n */ #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 * multibyte macros
*/ */

View file

@ -226,7 +226,7 @@ outputs an
prompt specified by prompt specified by
.I "format, .\|.\|." .I "format, .\|.\|."
to the controlling terminal and reads a response from the controlling terminal. to the controlling terminal and reads a response from the controlling terminal.
Offirmative response returns Affirmative response returns
.LR 0 , .LR 0 ,
.L EOF .L EOF
or quit response returns 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 The printing and scanning functions were extended to handle multibyte characters
and to conform to the C99 standard. and to conform to the C99 standard.
.PP .PP
The function \f5sfpoll()\fP was rehauled to make it useful The function \f5sfpoll()\fP was overhauled to make it useful
for writing servers that must commnunicate with multiple streams for writing servers that must communicate with multiple streams
without blocking. without blocking.
.PP .PP
The formatting pattern \f5%c\fP for \f5sf*printf\fP was extended The formatting pattern \f5%c\fP for \f5sf*printf\fP was extended

View file

@ -47,6 +47,12 @@
* not done for `csh script arg ...' * not done for `csh script arg ...'
*/ */
#ifdef _WINIX
# define EXE "?(.exe)"
#else
# define EXE
#endif
char* char*
pathshell(void) pathshell(void)
{ {
@ -59,13 +65,13 @@ pathshell(void)
static char* val; 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 (!(ru = getuid()) || !eaccess("/bin", W_OK))
{ {
if (stat(sh, &st)) if (stat(sh, &st))
goto defshell; 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; goto defshell;
} }
else else

View file

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

View file

@ -280,7 +280,7 @@ extern double erf(x)
if (ax < .84375) { if (ax < .84375) {
if (ax < 3.7e-09) { if (ax < 3.7e-09) {
if (ax < 1.0e-308) if (ax < 1.0e-308)
return 0.125*(8.0*x+p0t8*x); /*avoid underflow */ return 0.125*(8.0*x+p0t8*x); /* avoid underflow */
return x + p0*x; return x + p0*x;
} }
y = x*x; y = x*x;

View file

@ -57,7 +57,7 @@ static const char usage[] =
"converted back to the native encoding. Multibyte characters in the " "converted back to the native encoding. Multibyte characters in the "
"current locale are treated as printable characters.]" "current locale are treated as printable characters.]"
"[A:show-all?Equivalent to \b-vET\b.]" "[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.]" " new-line.]"
"[D:dos-output?Output files are opened in \atext\amode which inserts carriage" "[D:dos-output?Output files are opened in \atext\amode which inserts carriage"
" returns in front of new-lines on some systems.]" " returns in front of new-lines on some systems.]"

View file

@ -478,7 +478,7 @@ outfield(Join_t* jp, int index, register int n, int last)
{ {
register unsigned char* sp = jp->state; register unsigned char* sp = jp->state;
/*eliminate leading spaces */ /* eliminate leading spaces */
if (jp->mb) if (jp->mb)
for (;;) for (;;)
{ {

View file

@ -201,9 +201,9 @@ static const char id[] = "\n@(#)$Id: dll library (AT&T Research) 2010-10-20 $\0\
* its virtual origin and where it was * its virtual origin and where it was
* actually placed * actually placed
*/ */
/*N.B. o_sndata etc. are one based */ /* N.B. o_sndata etc. are one based */
datareloc = (ulong)data - hdr->s[hdr->a.o_sndata-1].s_vaddr; datareloc = (ulong)data - hdr->s[hdr->a.o_sndata-1].s_vaddr;
/*hdr is address of header, not text, so add text s_scnptr */ /* hdr is address of header, not text, so add text s_scnptr */
textreloc = (ulong)hdr + hdr->s[hdr->a.o_sntext-1].s_scnptr textreloc = (ulong)hdr + hdr->s[hdr->a.o_sntext-1].s_scnptr
- hdr->s[hdr->a.o_sntext-1].s_vaddr; - hdr->s[hdr->a.o_sntext-1].s_vaddr;
ldhdr = (void*)((char*)hdr+ hdr->s[hdr->a.o_snloader-1].s_scnptr); ldhdr = (void*)((char*)hdr+ hdr->s[hdr->a.o_snloader-1].s_scnptr);

View file

@ -40,7 +40,7 @@
* ASSERT NOTE: * ASSERT NOTE:
* Some sanity checking code is included using assert(). On my FreeBSD * Some sanity checking code is included using assert(). On my FreeBSD
* system, this additional code can be removed by compiling with NDEBUG * 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. * compile WITHOUT the sanity checking code on your system.
* *
* UNROLLED TRANSFORM LOOP NOTE: * UNROLLED TRANSFORM LOOP NOTE: