cdesktopenv/src/lib/libast
Johnothan King bea4fd56e8 Fix 'read -a' failure to create array (re: d55e9686) (#516)
The commit that backported read -a did not add a case label for it
to read.c. This was under the assumption that AST optget(3) would
always convert -a to -A. However, that was only done for first use.

The cause is the short-form options caching mechanism in optget(3).
On the first run, the pre-caching result would be returned, but the
equivalent option (-a) would be cached as if it is its own option,
so on the second and subsequent runs, optget returned 'a' instead
of 'A'. This only happens if no long-form equivalent is present.

Reproducer:

  $ read -A foo <<< 'foo bar baz'
  $ unset foo
  $ read -a foo <<< 'foo bar baz'
  $ echo ${foo[0]}
  foo bar baz

Expected: foo

src/lib/libast/misc/optget.c,
src/lib/libast/misc/optlib.h:
- [by Martijn Dekker] Implement caching for short-option
  equivalents. If a short-form equivalent is found, instead of
  caching it as a separate option, cache the equivalent in a new
  equiv[] array. Check this when reading the cache and substitute
  the main option for the equivalent if one is cached.

src/lib/libcmd/cp.c:
- Fix cp -r/cp -R symlink handling. The -r and -R options sometimes
  ignored -P, -L and -H.
- The -r and -R options no longer follow symlinks by default.

src/cmd/ksh93/bltins/whence.c,
src/lib/libcmd/*.c:
- Remove case labels that are redundant now that the optget(3)
  caching bug is fixed.

src/cmd/ksh93/tests/libcmd.sh:
- Added. This is the new script for the /opt/ast/bin path-bound
  built-ins from libcmd. Other relevant tests are moved into here.

Co-authored-by: Martijn Dekker <martijn@inlv.org>
2022-08-20 17:11:52 +01:00
..
aso Update author attributions in all source files 2022-07-31 00:47:08 +02:00
cdt Update author attributions in all source files 2022-07-31 00:47:08 +02:00
comp Update author attributions in all source files 2022-07-31 00:47:08 +02:00
dir Update author attributions in all source files 2022-07-31 00:47:08 +02:00
disc Update author attributions in all source files 2022-07-31 00:47:08 +02:00
features Do not use noreturn in C99 mode on Solaris Sudio cc (re: c4f980eb) 2022-08-02 20:34:07 +02:00
hash Update author attributions in all source files 2022-07-31 00:47:08 +02:00
include Update author attributions in all source files 2022-07-31 00:47:08 +02:00
man Fix crashes on redefining/unsetting predefined alias (re: 7e7f1372) 2022-08-06 11:54:33 +01:00
misc Fix 'read -a' failure to create array (re: d55e9686) (#516) 2022-08-20 17:11:52 +01:00
path Update author attributions in all source files 2022-07-31 00:47:08 +02:00
port Update author attributions in all source files 2022-07-31 00:47:08 +02:00
preroot Update author attributions in all source files 2022-07-31 00:47:08 +02:00
regex Update author attributions in all source files 2022-07-31 00:47:08 +02:00
sfio Fix regression in handling of head builtin's -s flag (re: 4ca578bd) (#514) 2022-08-16 22:48:47 +01:00
std Update author attributions in all source files 2022-07-31 00:47:08 +02:00
stdio Update author attributions in all source files 2022-07-31 00:47:08 +02:00
string Update author attributions in all source files 2022-07-31 00:47:08 +02:00
tm Update author attributions in all source files 2022-07-31 00:47:08 +02:00
vec Update author attributions in all source files 2022-07-31 00:47:08 +02:00
vmalloc Fix build on macOS (re: 3389cab2) 2022-07-31 01:13:16 +02:00
Mamfile libast/Mamfile: no release version if git WD not clean 2022-07-30 01:29:41 +02:00
README Fix various typos, man page issues and improve the documentation (#415) 2022-01-07 16:17:55 +00:00
RELEASE Yet more accumulated tweaks and cleanups 2022-06-18 23:29:49 +01:00

README

The advanced software technology department has been collecting useful C
routines in a single library called libast.  libast is used by nmake, the
nmake cpp (which is mainly based on another library (libpp)), CIA
(C information abstractor from Robin Chen), and a collection of other
/bin and /usr/bin commands that benefit from concentrating functionality
in libast.

More detail is available in the man pages.  libast contains:

  (1)	routines to support a generic environment for
	a variety of UNIX operating system variants

  (2)	routines that update standard libc routines

  (3)	routines shared between several commands

If you already have nmake 2.0 or newer installed then use
`nmake install' from this directory, otherwise use
ship/shipin from the root of the distribution directory tree.

Some of the routines not found in section 3:

hash:			generic, scoped hash table support

	hashalloc	create a hash table or push new scope
	hashdump	debug dump of one or all hash tables
	hashfree	free a hashalloc()'d table
	hashlook	low level name lookup
	hashscan	entry generator for scoped table scan
	hashsize	explicitly change table size (usually automatic)
	hashwalk	apply function to each table entry
	memhash		return hash code for n-char chunk of memory
	strhash		return hash code for null-terminated string

include/ast:		libast support headers

	align.h		compile time type alignment support
	dirent.h	POSIX directory(3) interface definitions
	error.h		error() interface definitions
	ftw.h		ftwalk() interface definitions
	hash.h		hash*() interface definitions
	ls.h		strls() interface definitions
	re.h		re*() interface definitions
	tar.h		POSIX ustar format interface definitions
	tm.h		tm*() interface definitions

misc:

	cmdargs		apply a sequence of cmd line option parsers
	cmdopen		like popen() but stdin and stdout are specified
	cvtatoe		convert ASCII to EBCDIC
	cvtetoa		convert EBCDIC to ASCII
	error		output generic error and trace messages
	ftwalk		an ftw(3) that works -- used in new tw(1)
	getcwd		uses $PWD if ok, doesn't use /bin/pwd
	getshell	return full path of shell for cmdopen()
	ooptget		optget() for obsolete ar(1) and tar(1) options
	optget		YA getopt(3) but no argc or error message output
	pathaccess	find file with specific access on list of dirs
	pathcanon	canonicalize path name in place
	pathcmd		return full path name of executable using $PATH
	pathroot	determine `related root' directory for command
	perror		uses strerror()
	readargs	append each line of file to argv[0]

re:			egrep(1) and ed(1) style re's from V9
			(not the good awk(1) algorithm)

	recomp		compile re pattern
	reerror		report re*() errors
	reexec		match string using compiled re
	resub		ed(1) style substitute using last reexec()

string:

	chresc		return next char in string converting \ sequences
	ctoi		convert char constant string to int
	strcopy		like strcpy(3) but returns end of destination
	strdup		malloc(3) and strcpy(3) smashed together
	strerror	return error message string given errno
	stresc		convert \ sequences in string in place
	streval		evaluate C expression in string
	strls		ls -l format support
	strmatch	Korn shell file pattern match
	strmode		return ls -l style output given st.st_mode
	strsignal	return signal ID string given SIG* number
	strtape		convert generic tape unit to /dev/* file
	token		generate space separated tokens in string

tm:			time conversion support

	tmdate		convert date string to time_t
	tmform		format time_t to date string
	tmmake		return current time_t
	tmtime		convert struct tm to time_t