From d98addf085611cbaa50db36d783b8e5842e32165 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sun, 5 Jan 2025 15:47:18 +0000 Subject: [PATCH] more miscellaneous maintenance src/lib/libast/misc/stk.c, src/lib/libast/include/stk.h, src/lib/libast/man/stk.3: - Remove unused stkon function. (It was never used in the history of open-ast-archive either. I can't really imagine a use case.) src/lib/libast/features/tv: - Test for stat.st_mtimespec.tv_nsec first, as this is the variant that ended up standardised in POSIX-1.2017 and should now be preferred over the others. src/lib/libast/man/tv.3: - Update tv_sec type to time_t. (re: 0a2302e2) - Tweak formatting. src/cmd/ksh93/tests/arrays.sh: - Add a regression test based on this discussion (re: 5c02cd49): https://github.com/ksh93/ksh/discussions/815 --- src/cmd/INIT/include/link_ar.mam | 2 +- src/cmd/ksh93/tests/arrays.sh | 5 +++++ src/lib/libast/features/tv | 13 +++++++------ src/lib/libast/include/stk.h | 1 - src/lib/libast/man/stk.3 | 5 ----- src/lib/libast/man/tv.3 | 10 +++------- src/lib/libast/misc/stk.c | 12 ------------ 7 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/cmd/INIT/include/link_ar.mam b/src/cmd/INIT/include/link_ar.mam index c92155d23e59..1cfc634eb00d 100644 --- a/src/cmd/INIT/include/link_ar.mam +++ b/src/cmd/INIT/include/link_ar.mam @@ -39,7 +39,7 @@ exec - y) %{AR} -d %{@} $to_delete exec - ;; exec - esac -note * Some old systems do not automatically update the symbol table upon ad +note * Some old systems do not automatically update the symbol table upon note * adding or deleting object files (contra POSIX), so update it manually exec - %{AR} -s %{@} 2>/dev/null || ranlib %{@} 2>/dev/null || true diff --git a/src/cmd/ksh93/tests/arrays.sh b/src/cmd/ksh93/tests/arrays.sh index d75522c00c9d..8a06914c62a1 100755 --- a/src/cmd/ksh93/tests/arrays.sh +++ b/src/cmd/ksh93/tests/arrays.sh @@ -945,6 +945,11 @@ got=$(typeset -A yarr; typeset -i yarr[lorem=ipsum]=456 yarr[foo=bar]=123 2>&1; exp='typeset -A -i yarr=([foo=bar]=123 [lorem=ipsum]=456)' [[ $got == "$exp" ]] || err_exit "associative array index containing '=' misparsed in declaration command" \ "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +unset SUCCESS +got=$(typeset toto[${SUCCESS:=0}]="SUCCESS" 2>&1; typeset -p toto) +exp='typeset -a toto=(SUCCESS)' +[[ $got == "$exp" ]] || err_exit "array index containing expansion containing '=' misparsed in declaration command" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" # ====== exit $((Errors<125?Errors:125)) diff --git a/src/lib/libast/features/tv b/src/lib/libast/features/tv index e41de21520c2..b63ade820339 100644 --- a/src/lib/libast/features/tv +++ b/src/lib/libast/features/tv @@ -20,7 +20,13 @@ cat{ } Tv_t; }end -if mem stat.st_mtimespec.tv_nsec sys/stat.h { +if mem stat.st_mtim.tv_nsec sys/stat.h { + /* POSIX-1.2017 */ + #define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec) + #define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec) + #define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec) +} +elif mem stat.st_mtimespec.tv_nsec sys/stat.h { #define ST_ATIME_NSEC_GET(st) ((st)->st_atimespec.tv_nsec) #define ST_CTIME_NSEC_GET(st) ((st)->st_ctimespec.tv_nsec) #define ST_MTIME_NSEC_GET(st) ((st)->st_mtimespec.tv_nsec) @@ -30,11 +36,6 @@ elif mem stat.st_mtim.st__tim.tv_nsec sys/stat.h { #define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.st__tim.tv_nsec) #define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.st__tim.tv_nsec) } -elif mem stat.st_mtim.tv_nsec sys/stat.h { - #define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec) - #define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec) - #define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec) -} elif mem stat.st_mtimensec sys/stat.h { #define ST_ATIME_NSEC_GET(st) ((st)->st_atimensec) #define ST_CTIME_NSEC_GET(st) ((st)->st_ctimensec) diff --git a/src/lib/libast/include/stk.h b/src/lib/libast/include/stk.h index 1f4c81287098..1139b543c7ed 100644 --- a/src/lib/libast/include/stk.h +++ b/src/lib/libast/include/stk.h @@ -56,6 +56,5 @@ extern char* stkcopy(Stk_t*, const char*); extern void* stkset(Stk_t*, void*, size_t); extern void* _stkseek(Stk_t*, ssize_t); extern void* stkfreeze(Stk_t*, size_t); -extern int stkon(Stk_t*, char*); #endif diff --git a/src/lib/libast/man/stk.3 b/src/lib/libast/man/stk.3 index 9c9e21abd3ce..739a0dce783d 100644 --- a/src/lib/libast/man/stk.3 +++ b/src/lib/libast/man/stk.3 @@ -28,7 +28,6 @@ void *stkseek(Stk_t *\fIstack\fP, unsigned \fIoffset\fP); int stktell(Stk_t *\fIstack\fP); char *stkptr(Stk_t *\fIstack\fP, unsigned \fIoffset\fP); void *stkfreeze(Stk_t *\fIstack\fP, unsigned \fIextra\fP); -int stkon(Stk *\fIstack\fP, char* \fIaddr\fP) \fR .fi .SH DESCRIPTION @@ -175,10 +174,6 @@ stack and returns a pointer to the beginning of this object. If \fIextra\fP is non-zero, \fIextra\fP bytes are added to the stack before the current object is terminated. The first added byte will contain zero and the contents of the remaining bytes are undefined. -.PP -The \f3stkon\fP() -function returns non-zero if the address given by \fIaddr\fP is -on the stack \fIstack\fP and \f30\fP otherwise. .SH HISTORY The \f3stk\fP diff --git a/src/lib/libast/man/tv.3 b/src/lib/libast/man/tv.3 index fb2a83dc5ea7..55df4a04086b 100644 --- a/src/lib/libast/man/tv.3 +++ b/src/lib/libast/man/tv.3 @@ -47,17 +47,13 @@ The library supports high resolution .B Tv_t time specifications. -.SS Tv_t +.B Tv_t contains these elements: .TP -.L unsigned -.L _ast_int4_t -.L tv_sec +.L "time_t tv_sec" Seconds since the epoch. .TP -.L unsigned -.L _ast_int4_t -.L tv_nsec +.L "uint32_t tv_nsec" Nanosecond resolution. .PP In practice resolution is much coarser than 1 nanosecond. diff --git a/src/lib/libast/misc/stk.c b/src/lib/libast/misc/stk.c index f6c8cd329134..471a1d563add 100644 --- a/src/lib/libast/misc/stk.c +++ b/src/lib/libast/misc/stk.c @@ -290,18 +290,6 @@ int stkclose(Sfio_t* stream) return sfclose(stream); } -/* - * returns 1 if is on this stack - */ -int stkon(Sfio_t * stream, char* loc) -{ - struct stk *sp = stream2stk(stream); - struct frame *fp; - for(fp=(struct frame*)sp->stkbase; fp; fp=(struct frame*)fp->prev) - if(loc>=((char*)(fp+1)) && loc< fp->end) - return 1; - return 0; -} /* * reset the bottom of the current stack back to
* if
is null, then the stack is reset to the beginning