Skip to content

Commit

Permalink
Smattering of minor fixes (#713)
Browse files Browse the repository at this point in the history
Notable changes:

src/lib/libast/features/lib:
- Add missing strlcat and strlcpy lib tests. Their absence caused
  ksh to needlessly override the native implementations of strlcpy
  and strlcat (see string/strlc*.c).

src/cmd/ksh93/data/builtins.c: sh_optksh[]:
- Add documentation for exit status 128 to 'ksh --man' output.
  (These are the ERROR_PANIC errors.)

src/cmd/ksh93/sh/parse.c:
- Mark b_dummy() with the noreturn attribute (re: a19e1e9).

src/cmd/ksh93/sh/path.c: path_spawn():
- Fix uninitialized variable if _lib_readlink is not present.

src/cmd/ksh93/tests/signal.sh:
- Disabled the failing SIGBUS test on ASan because the design
  of the test isn't compatible with ASan's signal handling.

Co-authored-by: Martijn Dekker <[email protected]>
  • Loading branch information
JohnoKing and McDutchie committed Jan 31, 2024
1 parent 6497470 commit e47d3f7
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ FEATURE/
/src/lib/libdll/dlldefs.h

# Miscellaneous artefacts
*.stackdump
*.dSYM/
*.bak
*.sav
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@ Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library.
specifies and as all other POSIX shells do. To redirect standard output
for reading and writing, you now need '1<>'.
Ref.: https://github.com/att/ast/issues/75
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_07
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_07

2020-05-12:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ in performance. In addition, "sh" scripts can be run on KSH-93 without
modification.

The code should conform to the
[IEEE POSIX 1003.1 standard](http://www.opengroup.org/austin/papers/posix_faq.html)
[IEEE POSIX 1003.1 standard](https://www.opengroup.org/austin/papers/posix_faq.html)
and to the proposed ANSI C standard so that it should be portable to all
such systems. Like the previous version, KSH-88, it is designed to accept
eight bit character sets transparently, thereby making it internationally
Expand Down
2 changes: 1 addition & 1 deletion bin/shtests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wrapper script to run the ksh93 regression tests directly.
# By Martijn Dekker <[email protected]> 2020-05-14, 2023-03-17
# Public domain. http://creativecommons.org/publicdomain/zero/1.0/
# Public domain. https://creativecommons.org/publicdomain/zero/1.0/
#
# The manual: bin/shtests --man
# Brief help: bin/shtests --help
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/INIT/README-mamake.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ to be built using only a standard C compiler and utilities installation
without any other dependencies or complications.

MAM was designed by Glenn Fowler at AT&T.
The [original documentation](http://web.archive.org/web/20041227143022/http://www2.research.att.com/~gsf/mam/mam.html)
The [original documentation](https://web.archive.org/web/20041227143022/http://www2.research.att.com/~gsf/mam/mam.html)
for MAM specified a more extensive language than was actually implemented in `mamake.c`,
while the `ignore` attribute is not documented there.
This file documents the MAM implementation that we are actually using.
Expand Down Expand Up @@ -174,7 +174,7 @@ The `exec` command assigns the `generated` attribute to the current rule, even i

`bind` `-l`*libraryname* [ `dontcare` ]

These commands are scanned for while sorting leaf directories for recurive
These commands are scanned for while sorting leaf directories for recursive
building, and executed as normal commands while building the current directory.

#### …while scanning and sorting leaf directories ####
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/ksh93/data/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* Copyright (c) 2020-2023 Contributors to ksh 93u+m *
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 2.0 *
* *
Expand Down Expand Up @@ -1685,6 +1685,7 @@ const char sh_optksh[] =
"was found on \bPATH\b but was not executable.]"
"[+127?\b-c\b and \b-s\b were not specified and the command script "
"corresponding to \aarg\a could not be found.]"
"[+128?An unrecoverable system or internal error occurred.]"
"}"

"[+SEE ALSO?\bset\b(1), \bbuiltin\b(1)]"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static void typeset_order(const char *str,int line)
}
}

static int b_dummy(int argc, char *argv[], Shbltin_t *context)
static noreturn int b_dummy(int argc, char *argv[], Shbltin_t *context)
{
NOT_USED(argc);
NOT_USED(argv[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ pid_t path_spawn(const char *opath,char **argv, char **envp, Pathcomp_t *libpath
char **xp=0, *xval, *libenv = (libpath?libpath->lib:0);
Namval_t* np;
char *s, *v;
int r, n, pidsize;
int r, n, pidsize=0;
pid_t pid= -1;
if(nv_search(opath,sh.bltin_tree,0))
{
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/builtins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ exp='ok1ok2ok3ok4ok5ok6ok7ok8ok9ok10ok11ok12end'
got=$( readonly v=foo
exec 2>/dev/null
# All the "special builtins" below should fail, and not exit, so 'print end' is reached.
# Ref.: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
# Ref.: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
# Left out are 'command exec /dev/null/nonexistent', where no shell follows the standard,
# as well as 'command exit' and 'command return', because, well, obviously.
command : </dev/null/no || print -n ok1
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/tests/comvar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# #
# This software is part of the ast package #
# Copyright (c) 1982-2012 AT&T Intellectual Property #
# Copyright (c) 2020-2023 Contributors to ksh 93u+m #
# Copyright (c) 2020-2024 Contributors to ksh 93u+m #
# and is licensed under the #
# Eclipse Public License, Version 2.0 #
# #
Expand Down Expand Up @@ -574,7 +574,7 @@ got=$(typeset -p x)
x=(typeset -C -a y;float z=2)
got=$(print -C x)
expected='(typeset -C -a y;typeset -l -E z=2)'
[[ $expected == "$got" ]] || err_exit "print -C x exects '$expected' got '$got'"
[[ $expected == "$got" ]] || err_exit "print -C x expects '$expected' got '$got'"

unset vx vy
compound vx=(
Expand Down
5 changes: 3 additions & 2 deletions src/cmd/ksh93/tests/glob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# #
# This software is part of the ast package #
# Copyright (c) 1982-2012 AT&T Intellectual Property #
# Copyright (c) 2020-2023 Contributors to ksh 93u+m #
# Copyright (c) 2020-2024 Contributors to ksh 93u+m #
# and is licensed under the #
# Eclipse Public License, Version 2.0 #
# #
Expand All @@ -12,6 +12,7 @@
# #
# David Korn <[email protected]> #
# Martijn Dekker <[email protected]> #
# Johnothan King <[email protected]> #
# #
########################################################################

Expand Down Expand Up @@ -533,7 +534,7 @@ test_glob '<a\\b.txt>' a\\\\b.*
test_glob '<a\\b.txt>' $unquoted_patvar

# ======
# 93u+m/1.0.5 regression - glob expansion with brace expansion and parameter exapansion
# 93u+m/1.0.5 regression - glob expansion with brace expansion and parameter expansion
v='./'
mkdir -p bin/BAD sbin/WRONG
((SHOPT_BRACEPAT)) && test_glob '<./bin/*> <./sbin/*>' "./"{bin,sbin}"/*"
Expand Down
7 changes: 5 additions & 2 deletions src/cmd/ksh93/tests/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ exp=$PWD/rm
command -p mkdir bin
print 'print ok' > bin/tst
command -p chmod +x bin/tst
if [[ $(PATH=$PWD/bin tst 2>/dev/null) != ok ]]
then err_exit '(PATH=$PWD/bin foo) does not find $PWD/bin/foo'
exp=ok
got=$(PATH=$PWD/bin tst 2>&1)
if [[ $exp != "$got" ]]
then err_exit '"PATH=$PWD/bin tst" does not run $PWD/bin/tst' \
"(expected $exp, got $(printf %q "$got"))"
fi
cd /
if whence ls > /dev/null
Expand Down
12 changes: 9 additions & 3 deletions src/cmd/ksh93/tests/signal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,15 @@ e=$?
[[ $x == done ]] || err_exit "output failed -- expected 'done', got '$x'"
(( SECONDS > .35 )) && err_exit "took $SECONDS seconds, expected around .2"
trap '' SIGBUS
[[ $($SHELL -c 'trap date SIGBUS; trap -p SIGBUS') ]] && err_exit 'SIGBUS should not have a trap'
trap -- - SIGBUS
# The test for SIGBUS trap handling below is incompatible with ASan because ASan
# implements its own SIGBUS handler independently of ksh.
if ! [[ -v ASAN_OPTIONS || -v TSAN_OPTIONS || -v MSAN_OPTIONS || -v LSAN_OPTIONS ]]; then
trap '' SIGBUS
got=$("$SHELL" -c 'trap date SIGBUS; trap -p SIGBUS')
[[ "$got" ]] && err_exit 'SIGBUS should not have a trap' \
"(got $(printf %q "$got"))"
trap -- - SIGBUS
fi
{
x=$(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ ____
vmalloc/vmbest.c: set /dev/zero mmap fd FD_CLOEXEC
features/mmap: fix ancient read() vs. mmap() time arithmetic typo
vmalloc/malloc.c: _AST_std_malloc==1 to force standard malloc
03-06-09 comp/omitted.c: add _imp__FUNCTION sybols for __CYGWIN__ static link
03-06-09 comp/omitted.c: add _imp__FUNCTION symbols for __CYGWIN__ static link
vmalloc/vmbest.c: handle systems with sbrk() but no brk()
03-06-04 port/astconf.c: drop non-standard diagnostics
03-06-03 comp/conf.sh: rework symbol collision logic
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/features/lib
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lib readlink,remove,rename,rewinddir,rmdir,setlocale
lib setpgid,setpgrp,setpgrp2,setreuid,setsid,setuid,sigaction
lib sigprocmask,sigsetmask,sigunblock,sigvec,socketpair
lib spawn,spawnve
lib strcoll,strdup,strerror,strcasecmp,strncasecmp
lib strcoll,strdup,strerror,strcasecmp,strncasecmp,strlcat,strlcpy
lib strmode,strxfrm,strftime,swab,symlink,sysconf,sysinfo
lib telldir,tmpnam,tzset,universe,unlink,utime,wctype
lib ftruncate,truncate
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/man/sfio.3
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ Otherwise, \f3top\fP is pushed on top of the stack identified by \f3base\fP
and \f3sfstack()\fP returns the \f3base\fP stream.
.Ss " char* sfstruse(Sfio_t* f)"
Makes the string in a Sfio string buffer ready for use
and makes the buffer ready for re-use. This is done by
and makes the buffer ready for reuse. This is done by
writing a terminating 0 byte to the given
.B SF_STRING
buffer, setting the I/O position to the start of the buffer
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/sfio/sfsetbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
f->blksz = (size_t)st.st_blksize;
#endif
bufsize = 64 * 1024;
#ifdef MAP_TUPE
#ifdef MAP_TYPE
if(S_ISDIR(st.st_mode) || (Sfoff_t)st.st_size < (Sfoff_t)SF_GRAIN)
okmmap = 0;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libsum/sum-sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ typedef uint64_t sha2_word64; /* Exactly 8 bytes */
*
* NOTE: The naming of R and S appears backwards here (R is a SHIFT and
* S is a ROTATION) because the SHA-256/384/512 description document
* (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this
* same "backwards" definition.
* uses this same "backwards" definition:
* https://web.archive.org/web/20050907174740/http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
*/

/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */
Expand Down

0 comments on commit e47d3f7

Please sign in to comment.