Skip to content

Commit

Permalink
more miscellaneous maintenance
Browse files Browse the repository at this point in the history
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: 0a2302e)
- Tweak formatting.

src/cmd/ksh93/tests/arrays.sh:
- Add a regression test based on this discussion (re: 5c02cd4):
  #815
  • Loading branch information
McDutchie committed Jan 5, 2025
1 parent da4c5bc commit d98addf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/cmd/INIT/include/link_ar.mam
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/cmd/ksh93/tests/arrays.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
13 changes: 7 additions & 6 deletions src/lib/libast/features/tv
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/lib/libast/include/stk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions src/lib/libast/man/stk.3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/lib/libast/man/tv.3
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions src/lib/libast/misc/stk.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,6 @@ int stkclose(Sfio_t* stream)
return sfclose(stream);
}

/*
* returns 1 if <loc> 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 <address>
* if <address> is null, then the stack is reset to the beginning
Expand Down

0 comments on commit d98addf

Please sign in to comment.