Skip to content

Commit

Permalink
Another round of accumulated tweaks and cleanups
Browse files Browse the repository at this point in the history
Notable changes:

src/cmd/INIT/mkdeps.sh:
- Single source of truth: use $prefix variable while processing
  dependencies of dependencies.

src/lib/libast/Mamfile:
- Avoid regenerating header dependencies whenever the git commit
  or working directory status changes.

src/cmd/ksh93/sh/init.c:
- Remove redundant NULL check when initialising stats.
  • Loading branch information
McDutchie committed Jul 22, 2024
1 parent 2c069af commit 9926e2b
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library.

2024-07-21:

- Fixed a long-stnading parsing bug: a '((' that was unmatched by
- Fixed a long-standing parsing bug: a '((' that was unmatched by
corresponding closing parentheses and enclosed within a compound command
failed to throw a syntax error and could cause the shell to crash.

Expand Down
1 change: 0 additions & 1 deletion bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -2633,7 +2633,6 @@ do_install() # dir [ command ... ]
if test -d "dyn/lib"
then trace mkdir -p "$libdir" "$man3dir" "$includedir"
# install libraries
# note: to copy symlinks with BSD cp, we need to specify -R as well as -P, contra POSIX
set +o noglob
for f in dyn/lib/*
do set -o noglob
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/INIT/mkdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ do case $opt in
done
shift $((OPTIND - 1))

# Process library header dependencies.
for f in $libdeps
do test -f "$INSTALLROOT/lib/mam/$f" || error_out "$f: header dependencies not found"
# assign state_NAME=made for each dependency header, so only prev commands are generated
f=$(sed -n 's|.*make \${INCLUDE_AST}/\([A-Za-z0-9_]*\)\.h.*|state_\1=made|p' "$INSTALLROOT/lib/mam/$f") || exit
eval "$f"
done

# Init state.
ast=include/ast
root=${INSTALLROOT?AST environment not initialised}/$ast
Expand All @@ -131,6 +123,14 @@ prefix="\${$prevar}/"
cd "$root" || error_out "cd '$root' failed"
indent=1

# Process library header dependencies.
for f in $libdeps
do test -f "$INSTALLROOT/lib/mam/$f" || error_out "$f: header dependencies not found"
# assign state_NAME=made for each dependency header, so only prev commands are generated
f=$(sed -n "s|.*make \\$prefix\([A-Za-z0-9_]*\)\.h.*|state_\1=made|p" "$INSTALLROOT/lib/mam/$f") || exit
eval "$f"
done

# Validate for 'eval' safety: header file names minus $root and .h must be valid variable name components.
for f
do test -f "$f" || error_out "$f: not found"
Expand Down
14 changes: 7 additions & 7 deletions src/cmd/ksh93/data/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,10 @@ const char sh_opttypeset[] =
"[+NAME?typeset - declare or display variables with attributes]"
"[+DESCRIPTION?Without the \b-f\b option, \btypeset\b sets, unsets, "
"or displays attributes of variables as specified with the "
"options. If the first option is specified with a \b-\b "
"options. If the first option is specified with a \b-\b, "
"then the attributes are set for each of the given \aname\as. "
"If the first option is specified with a \b+\b, then the specified "
"attributes are unset. If \b=\b\avalue\a is specified value is "
"attributes are unset. If \b=\b\avalue\a is specified, \avalue\a is "
"assigned before the attributes are set.]"
"[+?When \btypeset\b is called inside a function defined with the "
"\bfunction\b reserved word, and \aname\a does not contain a "
Expand All @@ -1867,9 +1867,9 @@ const char sh_opttypeset[] =
"[+integer?\btypeset -li\b]"
"[+nameref?\btypeset -n\b]"
"}"
"[+?If no \aname\as are specified then variables that have the specified "
"[+?If no \aname\as are specified, then variables that have the specified "
"options are displayed. If the first option is specified with "
"a leading \b-\b then the name and value of each variable is "
"a leading \b-\b, then the name and value of each variable is "
"written to standard output. Otherwise, only the names are "
"written. If no options are specified or just \b-p\b is "
"specified, then the names and attributes of all variables that have "
Expand Down Expand Up @@ -1939,14 +1939,14 @@ const char sh_opttypeset[] =
"UNIX format pathname will cause it to be converted to a pathname "
"suitable for the current host. This has no effect when the "
"native system is UNIX.]"
"[L]#?[n?Left justify. If \an\a is given it represents the field width. If "
"[L]#?[n?Left justify. If \an\a is given, it represents the field width. If "
"the \b-Z\b attribute is also specified, then leading zeros are "
"stripped.]"
"[M]:?[mapping?\amapping\a is the name of a character mapping known by "
"\bwctrans\b(3) such as \btolower\b or \btoupper\b. When the option "
"value \bmapping\b is omitted and there are no operands, all mapped "
"variables are displayed.]"
"[R]#?[n?Right justify. If \an\a is given it represents the field width. If "
"[R]#?[n?Right justify. If \an\a is given, it represents the field width. If "
"the \b-Z\b attribute is also specified, then zeros will "
"be used as the fill character. Otherwise, spaces are used.]"
"[X]#?[n:=2*sizeof(long long)?Floating point number represented in hexadecimal "
Expand All @@ -1960,7 +1960,7 @@ const char sh_opttypeset[] =
"will have function static scope. Otherwise, the variable is "
"unset prior to processing the assignment list.]"
"[T]:?[tname?\atname\a is the name of a type name given to each \aname\a.]"
"[Z]#?[n?Zero fill. If \an\a is given it represents the field width.]"
"[Z]#?[n?Zero fill. If \an\a is given, it represents the field width.]"
"\n"
"\n[name[=value]...]\n"
" -f [-tu] [name...]\n"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/edit/hexpand.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-2011 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
7 changes: 4 additions & 3 deletions src/cmd/ksh93/sh.1
Original file line number Diff line number Diff line change
Expand Up @@ -4362,9 +4362,7 @@ like:
indicating that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process ID was 1234.
.PP
This paragraph and the next require features that are
not in all versions of UNIX and may not apply.
If you are running a job and wish to do something else you may hit the key
If you are running a job and wish to do something else, you may hit the key
\fB^Z\fR (control-Z) which sends a STOP signal to the current job.
The shell will then normally indicate that the job has been `Stopped',
and print another prompt.
Expand Down Expand Up @@ -4429,6 +4427,9 @@ option of the
command causes
the shell to print these job change messages
as soon as they occur.
If this happens while you are typing a command with one of the
built-in line editors active, the job change message appears
above your input without disturbing your command entry.
.PP
When the
.B monitor
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/ksh93/sh/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,6 @@ void sh_reinit(void)
freeup_tree(sh.var_tree);
#if SHOPT_STATS
free(sh.stats);
sh.stats = NULL;
#endif
/* Re-init variables, functions and built-ins */
free(sh.bltin_cmds);
Expand Down Expand Up @@ -1938,8 +1937,7 @@ static Init_t *nv_init(void)
nv_onattr(VERSIONNOD,NV_REF);
math_init();
#if SHOPT_STATS
if(!sh.stats)
stat_init();
stat_init();
#endif
return ip;
}
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/ksh93/tests/arith.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1099,23 +1099,23 @@ got=$(let '016#F' 2>&1)
exp=": \`(' unmatched"
got=$( ( ulimit -c 0; set +x; eval '{ (( $(( 1 )); }' ) 2>&1 )
[[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 1" \
"(expected status 1 and match of *'$exp'," \
"(expected status 1 and match of *$(printf %q "$exp")," \
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))"
got=$( ( ulimit -c 0; set +x; eval 'x=$(( }; echo end' ) 2>&1 )
[[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 2" \
"(expected status 1 and match of *'$exp'," \
"(expected status 1 and match of *$(printf %q "$exp")," \
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))"
got=$( ( ulimit -c 0; set +x; eval '{ x=$(( }; echo end; }' ) 2>&1 )
[[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 3" \
"(expected status 1 and match of *'$exp'," \
"(expected status 1 and match of *$(printf %q "$exp")," \
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))"
got=$( ( ulimit -c 0; set +x; eval '(( }; echo end' ) 2>&1 )
[[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 4" \
"(expected status 1 and match of *'$exp'," \
"(expected status 1 and match of *$(printf %q "$exp")," \
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))"
got=$( ( ulimit -c 0; set +x; eval '{ (( }; echo end; }' ) 2>&1 )
[[ e=$? -eq 3 && $got == *"$exp" ]] || err_exit "unmatched '((', test 5" \
"(expected status 1 and match of *'$exp'," \
"(expected status 1 and match of *$(printf %q "$exp")," \
"got status $e$( ((e>128)) && print -n /SIG && kill -l "$e") and $(printf %q "$got"))"

got=$( ( ulimit -c 0; set +x; eval '{ (( $(( 1 )) )); }' ) 2>&1 )
Expand Down
11 changes: 9 additions & 2 deletions src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -4830,6 +4830,13 @@ make install virtual
done
done

note * install releaseflags.h outside the lib/ast/mam block below, so the mkdeps action is not triggered when
note * releaseflags.h changes every time that the git commit changes (it doesn't contain #includes anyway)
make ${INCLUDE_AST}/releaseflags.h
prev releaseflags.h
exec - cp -f ${<} ${@}
done

note * #include headers
make ${INSTALLROOT}/lib/mam/ast
note * ...main AST headers
Expand All @@ -4854,14 +4861,14 @@ make install virtual
done
done
note * ...generated headers
loop HDR releaseflags ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mmap ast_mode ast_ndbm ast_param ast_random ast_time ast_tty ast_wait ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype
loop HDR ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mmap ast_mode ast_ndbm ast_param ast_random ast_time ast_tty ast_wait ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype
make ${INCLUDE_AST}/${HDR}.h
prev ${HDR}.h
exec - cp -f ${<} ${@}
done
done
note * generate header dependency rules
exec - mkdeps -last ${^} > ${@}
exec - mkdeps -last ${INCLUDE_AST}/releaseflags.h ${^} > ${@}
prev ${INSTALLROOT}/bin/mkdeps
done ${INSTALLROOT}/lib/mam/ast

Expand Down
5 changes: 1 addition & 4 deletions src/lib/libast/features/fcntl.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) 1985-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 @@ -308,8 +308,5 @@ main(void)
printf("extern int open(const char*, int, ...);\n");
#endif
#endif
printf("\n");
printf("#include <ast_fs.h>\n");

return 0;
}
2 changes: 1 addition & 1 deletion src/lib/libast/man/path.3
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Path buffers are assumed to be of size
always defines
.LR PATH_MAX ,
even if it's indeterminate on the local system.
Yes, this was probably a bad choice, but it was made about 10 years ago.
Yes, this was probably a bad choice, but it was made in the 1980s.
We will probably move to a <stk.h> based implementation.
.PP
.L pathaccess
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/man/sig.3
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sig \- signal interface routines
.SH DESCRIPTION
.B sigunblock
is called to
unblocks the signal
unblock the signal
.B sig
from within a handler currently servicing
.BR sig .
Expand Down

0 comments on commit 9926e2b

Please sign in to comment.