1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Another round of accumulated tweaks and cleanups

Notable changes:

src/cmd/ksh93/*.c:
- Get rid of all the dtuserdata(FOO,&sh,1) calls backported in
  cc492752. These set pointers to sh in Cdt objects. As of
  b590a9f1, the code does not use any pointers to sh, so these are
  superfluous.

src/cmd/ksh93/data/builtins.c,
src/cmd/ksh93/sh.1:
- As of ksh 93l 2001-06-01, the -h/trackall option has no effect at
  all, so trim its documentation.

src/lib/libast/man/stk.3,
src/lib/libast/man/stak.3:
- Correct the documentation on what the ST(A)K_SMALL option bit
  actually does based on a reading of the code.
- Document the STK_NULL option bit.

README.md,
src/cmd/ksh93/README:
- Add a note that -fdiagnostics-color=always will break the build.
  Ref.: https://github.com/ksh93/ksh/issues/379

src/lib/libast/Mamfile:
- Remove a 'rm -f astmath' command -- a file that is never created.
  But on Cygwin this removes astmath.exe, which *is* used. As a
  result, executing it failed on Cygwin, so the system incorrectly
  detected that Cygwin needs -lm for math functions.
This commit is contained in:
Martijn Dekker 2022-01-28 20:30:52 +00:00
parent bd9faa81bf
commit 304648d0c5
19 changed files with 27 additions and 64 deletions

View file

@ -3,7 +3,7 @@ ksh 93u+m general copyright notice
######################################################################## ########################################################################
# # # #
# The KornShell 93u+m distribution # # The KornShell 93u+m distribution #
# Copyright (c) 2021 Contributors to ksh 93u+m # # Copyright (c) 2020-2022 Contributors to ksh 93u+m #
# <https://github.com/ksh93/ksh> # # <https://github.com/ksh93/ksh> #
# Derived from AT&T's ast package (see below) # # Derived from AT&T's ast package (see below) #
# Licensed under the Eclipse Public License, Version 1.0 # # Licensed under the Eclipse Public License, Version 1.0 #
@ -50,6 +50,8 @@ ast package general copyright notice
# Glenn Fowler <gsf@research.att.com> # # Glenn Fowler <gsf@research.att.com> #
# David Korn <dgk@research.att.com> # # David Korn <dgk@research.att.com> #
# Phong Vo <kpv@research.att.com> # # Phong Vo <kpv@research.att.com> #
# Roland Mainz <roland.mainz@nrubsig.org> #
# Karsten Fleischer <K.Fleischer@omnium.de> #
# Adam Edgar <aedgar@research.att.com> # # Adam Edgar <aedgar@research.att.com> #
# Adam Buchsbaum <alb@adambuchsbaum.com> # # Adam Buchsbaum <alb@adambuchsbaum.com> #
# Aman Shaikh <ashaikh@research.att.com> # # Aman Shaikh <ashaikh@research.att.com> #

View file

@ -42,7 +42,7 @@ Between 2017 and 2020 there was an ultimately unsuccessful
[attempt](https://github.com/att/ast/tree/2020.0.1) [attempt](https://github.com/att/ast/tree/2020.0.1)
to breathe new life into the KornShell by extensively refactoring the last to breathe new life into the KornShell by extensively refactoring the last
unstable AST beta version (93v-). unstable AST beta version (93v-).
While that ksh2020 branch is now abandoned and still has many critical bugs, While that ksh2020 effort is now abandoned and still has many critical bugs,
it also had a lot of bugs fixed. More importantly, the AST issue tracker it also had a lot of bugs fixed. More importantly, the AST issue tracker
now contains a lot of documentation on how to fix those bugs, which made now contains a lot of documentation on how to fix those bugs, which made
it possible to backport many of them to the last stable release instead. it possible to backport many of them to the last stable release instead.
@ -57,8 +57,10 @@ as well as many new fixes from the community
[2](https://github.com/ksh93/ksh/issues?q=is%3Aissue+is%3Aclosed+label%3Abug)). [2](https://github.com/ksh93/ksh/issues?q=is%3Aissue+is%3Aclosed+label%3Abug)).
Though there are many Though there are many
[bugs left to fix](https://github.com/ksh93/ksh/issues), [bugs left to fix](https://github.com/ksh93/ksh/issues),
we are confident at this point that 93u+m is already the least buggy branch we are confident at this point that 93u+m is already the least buggy version
of ksh93 ever released. of ksh93 ever released.
As of late 2021, distributions such as Debian and Slackware have begun
to package it as their default version of ksh93.
## Build ## Build
@ -92,6 +94,10 @@ to run the build scripts this way. For example:
bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" LDFLAGS="-L/opt/local/lib" bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" LDFLAGS="-L/opt/local/lib"
``` ```
**Note:** Do not add compiler flags that cause the compiler to emit terminal
escape codes, such as `-fdiagnostics-color=always`; this will cause the
build to fail as the probing code greps compiler diagnostics.
For more information run For more information run
```sh ```sh
bin/package help bin/package help

View file

@ -192,6 +192,10 @@ run the build scripts this way. For example:
bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" \ bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" \
LDFLAGS="-L/opt/local/lib" LDFLAGS="-L/opt/local/lib"
Note: Do not add compiler flags that cause the compiler to emit terminal
escape codes, such as -fdiagnostics-color=always; this will cause the build
to fail as the probing code greps compiler diagnostics.
For more information, run: For more information, run:
bin/package help bin/package help

View file

@ -180,9 +180,8 @@ const char sh_set[] =
"[++?contained in the pipeline following \b!\b.]" "[++?contained in the pipeline following \b!\b.]"
"}" "}"
"[f?Pathname expansion is disabled.]" "[f?Pathname expansion is disabled.]"
"[h?Obsolete. Causes each command whose name has the syntax of an " "[h?Obsolete; no effect.]"
"alias to become a tracked alias when it is first encountered.]" "[k?All arguments of the form \aname\a\b=\b\avalue\a "
"[k?This is obsolete. All arguments of the form \aname\a\b=\b\avalue\a "
"are removed and placed in the variable assignment list for " "are removed and placed in the variable assignment list for "
"the command. Ordinarily, variable assignments must precede " "the command. Ordinarily, variable assignments must precede "
"command arguments.]" "command arguments.]"

View file

@ -7296,11 +7296,9 @@ This mode is disabled while reading profiles.
Disables pathname expansion. Disables pathname expansion.
.TP 8 .TP 8
.B \-h .B \-h
Each command Obsolete; no effect.
becomes a tracked alias when first encountered.
.TP 8 .TP 8
.B \-k .B \-k
(Obsolete).
All variable assignment arguments are placed in the environment for a command, All variable assignment arguments are placed in the environment for a command,
not just those that precede the command name. not just those that precede the command name.
.TP 8 .TP 8

View file

@ -180,10 +180,7 @@ static Namval_t *scope(register Namval_t *np,register struct lval *lvalue,int as
{ {
ap = nv_arrayptr(np); ap = nv_arrayptr(np);
if(ap && !ap->table) if(ap && !ap->table)
{
ap->table = dtopen(&_Nvdisc,Dtoset); ap->table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->table,&sh,1);
}
if(ap && ap->table && (nq=nv_search(nv_getsub(np),ap->table,NV_ADD))) if(ap && ap->table && (nq=nv_search(nv_getsub(np),ap->table,NV_ADD)))
nq->nvenv = (char*)np; nq->nvenv = (char*)np;
if(nq && nv_isnull(nq)) if(nq && nv_isnull(nq))

View file

@ -94,7 +94,6 @@ static Namarr_t *array_scope(Namval_t *np, Namarr_t *ap, int flags)
if(is_associative(aq)) if(is_associative(aq))
{ {
aq->scope = (void*)dtopen(&_Nvdisc,Dtoset); aq->scope = (void*)dtopen(&_Nvdisc,Dtoset);
dtuserdata(aq->scope,&sh,1);
dtview((Dt_t*)aq->scope,aq->table); dtview((Dt_t*)aq->scope,aq->table);
aq->table = (Dt_t*)aq->scope; aq->table = (Dt_t*)aq->scope;
return(aq); return(aq);
@ -379,10 +378,7 @@ static Namval_t *array_find(Namval_t *np,Namarr_t *arp, int flag)
{ {
char *cp; char *cp;
if(!ap->header.table) if(!ap->header.table)
{
ap->header.table = dtopen(&_Nvdisc,Dtoset); ap->header.table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->header.table,&sh,1);
}
sfprintf(sh.strbuf,"%d",ap->cur); sfprintf(sh.strbuf,"%d",ap->cur);
cp = sfstruse(sh.strbuf); cp = sfstruse(sh.strbuf);
mp = nv_search(cp, ap->header.table, NV_ADD); mp = nv_search(cp, ap->header.table, NV_ADD);
@ -415,10 +411,7 @@ int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags)
Namarr_t *ap = nv_arrayptr(np); Namarr_t *ap = nv_arrayptr(np);
sh.last_table = 0; sh.last_table = 0;
if(!ap->table) if(!ap->table)
{
ap->table = dtopen(&_Nvdisc,Dtoset); ap->table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->table,&sh,1);
}
if(nq = nv_search(sub, ap->table, NV_ADD)) if(nq = nv_search(sub, ap->table, NV_ADD))
{ {
char *saved_value = NIL(char*); char *saved_value = NIL(char*);
@ -481,7 +474,6 @@ static Namfun_t *array_clone(Namval_t *np, Namval_t *mp, int flags, Namfun_t *fp
if(ap->table) if(ap->table)
{ {
ap->table = dtopen(&_Nvdisc,Dtoset); ap->table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->table,&sh,1);
if(ap->scope && !(flags&NV_COMVAR)) if(ap->scope && !(flags&NV_COMVAR))
{ {
ap->scope = ap->table; ap->scope = ap->table;
@ -863,7 +855,6 @@ static struct index_array *array_grow(Namval_t *np, register struct index_array
if(nv_hasdisc(np,&array_disc) || (nv_type(np) && nv_isvtree(np))) if(nv_hasdisc(np,&array_disc) || (nv_type(np) && nv_isvtree(np)))
{ {
ap->header.table = dtopen(&_Nvdisc,Dtoset); ap->header.table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->header.table,&sh,1);
mp = nv_search("0", ap->header.table,NV_ADD); mp = nv_search("0", ap->header.table,NV_ADD);
if(mp && nv_isnull(mp)) if(mp && nv_isnull(mp))
{ {
@ -1248,10 +1239,7 @@ Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
char *cp; char *cp;
Namval_t *mp; Namval_t *mp;
if(!ap->header.table) if(!ap->header.table)
{
ap->header.table = dtopen(&_Nvdisc,Dtoset); ap->header.table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->header.table,&sh,1);
}
sfprintf(sh.strbuf,"%d",ap->cur); sfprintf(sh.strbuf,"%d",ap->cur);
cp = sfstruse(sh.strbuf); cp = sfstruse(sh.strbuf);
mp = nv_search(cp, ap->header.table, NV_ADD); mp = nv_search(cp, ap->header.table, NV_ADD);
@ -1676,7 +1664,6 @@ void *nv_associative(register Namval_t *np,const char *sp,int mode)
case NV_AINIT: case NV_AINIT:
ap = (struct assoc_array*)sh_calloc(1,sizeof(struct assoc_array)); ap = (struct assoc_array*)sh_calloc(1,sizeof(struct assoc_array));
ap->header.table = dtopen(&_Nvdisc,Dtoset); ap->header.table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->header.table,&sh,1);
ap->cur = 0; ap->cur = 0;
ap->pos = 0; ap->pos = 0;
ap->header.hdr.disc = &array_disc; ap->header.hdr.disc = &array_disc;

View file

@ -1805,13 +1805,9 @@ static Init_t *nv_init(void)
(OPTINDNOD)->nvalue.lp = (&sh.st.optindex); (OPTINDNOD)->nvalue.lp = (&sh.st.optindex);
/* set up the seconds clock */ /* set up the seconds clock */
sh.alias_tree = dtopen(&_Nvdisc,Dtoset); sh.alias_tree = dtopen(&_Nvdisc,Dtoset);
dtuserdata(sh.alias_tree,&sh,1);
sh.track_tree = dtopen(&_Nvdisc,Dtset); sh.track_tree = dtopen(&_Nvdisc,Dtset);
dtuserdata(sh.track_tree,&sh,1);
sh.bltin_tree = sh_inittree((const struct shtable2*)shtab_builtins); sh.bltin_tree = sh_inittree((const struct shtable2*)shtab_builtins);
dtuserdata(sh.bltin_tree,&sh,1);
sh.fun_base = sh.fun_tree = dtopen(&_Nvdisc,Dtoset); sh.fun_base = sh.fun_tree = dtopen(&_Nvdisc,Dtoset);
dtuserdata(sh.fun_tree,&sh,1);
dtview(sh.fun_tree,sh.bltin_tree); dtview(sh.fun_tree,sh.bltin_tree);
nv_mount(DOTSHNOD, "type", sh.typedict=dtopen(&_Nvdisc,Dtoset)); nv_mount(DOTSHNOD, "type", sh.typedict=dtopen(&_Nvdisc,Dtoset));
nv_adddisc(DOTSHNOD, shdiscnames, (Namval_t**)0); nv_adddisc(DOTSHNOD, shdiscnames, (Namval_t**)0);
@ -1853,7 +1849,6 @@ Dt_t *sh_inittree(const struct shtable2 *name_vals)
nbltins = n; nbltins = n;
} }
base_treep = treep = dtopen(&_Nvdisc,Dtoset); base_treep = treep = dtopen(&_Nvdisc,Dtoset);
dtuserdata(treep,&sh,1);
treep->user = (void*)&sh; treep->user = (void*)&sh;
for(tp=name_vals;*tp->sh_name;tp++,np++) for(tp=name_vals;*tp->sh_name;tp++,np++)
{ {

View file

@ -2730,10 +2730,7 @@ static char *sh_tilde(register const char *string)
skip: skip:
#endif /* _WINIX */ #endif /* _WINIX */
if(!logins_tree) if(!logins_tree)
{
logins_tree = dtopen(&_Nvdisc,Dtbag); logins_tree = dtopen(&_Nvdisc,Dtbag);
dtuserdata(logins_tree,&sh,1);
}
if(np=nv_search(string,logins_tree,NV_ADD)) if(np=nv_search(string,logins_tree,NV_ADD))
{ {
save = sh.subshell; save = sh.subshell;

View file

@ -174,7 +174,6 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
/* preset aliases for interactive non-POSIX ksh */ /* preset aliases for interactive non-POSIX ksh */
dtclose(sh.alias_tree); dtclose(sh.alias_tree);
sh.alias_tree = sh_inittree(shtab_aliases); sh.alias_tree = sh_inittree(shtab_aliases);
dtuserdata(sh.alias_tree,&sh,1);
} }
} }
#if SHOPT_REMOTE #if SHOPT_REMOTE

View file

@ -811,7 +811,6 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
{ {
Dt_t *dp = dtview(sh.var_tree,(Dt_t*)0); Dt_t *dp = dtview(sh.var_tree,(Dt_t*)0);
rp->sdict = dtopen(&_Nvdisc,Dtoset); rp->sdict = dtopen(&_Nvdisc,Dtoset);
dtuserdata(rp->sdict,&sh,1);
dtview(rp->sdict,dp); dtview(rp->sdict,dp);
dtview(sh.var_tree,rp->sdict); dtview(sh.var_tree,rp->sdict);
} }
@ -1164,10 +1163,7 @@ Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
ap = nv_arrayptr(np); ap = nv_arrayptr(np);
} }
if(n && ap && !ap->table) if(n && ap && !ap->table)
{
ap->table = dtopen(&_Nvdisc,Dtoset); ap->table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->table,&sh,1);
}
if(ap && ap->table && (nq=nv_search(sub,ap->table,n))) if(ap && ap->table && (nq=nv_search(sub,ap->table,n)))
nq->nvenv = (char*)np; nq->nvenv = (char*)np;
if(nq && nv_isnull(nq)) if(nq && nv_isnull(nq))
@ -2344,7 +2340,6 @@ void sh_scope(struct argnod *envlist, int fun)
newroot = nv_dict(sh.namespace); newroot = nv_dict(sh.namespace);
#endif /* SHOPT_NAMESPACE */ #endif /* SHOPT_NAMESPACE */
newscope = dtopen(&_Nvdisc,Dtoset); newscope = dtopen(&_Nvdisc,Dtoset);
dtuserdata(newscope,&sh,1);
if(envlist) if(envlist)
{ {
dtview(newscope,(Dt_t*)sh.var_tree); dtview(newscope,(Dt_t*)sh.var_tree);
@ -3334,10 +3329,7 @@ int nv_rename(register Namval_t *np, int flags)
if(ap=nv_arrayptr(np)) if(ap=nv_arrayptr(np))
{ {
if(!ap->table) if(!ap->table)
{
ap->table = dtopen(&_Nvdisc,Dtoset); ap->table = dtopen(&_Nvdisc,Dtoset);
dtuserdata(ap->table,&sh,1);
}
if(ap->table) if(ap->table)
mp = nv_search(nv_getsub(np),ap->table,NV_ADD); mp = nv_search(nv_getsub(np),ap->table,NV_ADD);
nv_arraychild(np,mp,0); nv_arraychild(np,mp,0);

View file

@ -1326,7 +1326,6 @@ static Namfun_t *clone_table(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp
Dt_t *oroot=tp->dict,*nroot=dtopen(&_Nvdisc,Dtoset); Dt_t *oroot=tp->dict,*nroot=dtopen(&_Nvdisc,Dtoset);
if(!nroot) if(!nroot)
return(0); return(0);
dtuserdata(nroot,dtuserdata(oroot,0,0),1);
memcpy((void*)ntp,(void*)fp,sizeof(struct table)); memcpy((void*)ntp,(void*)fp,sizeof(struct table));
ntp->dict = nroot; ntp->dict = nroot;
ntp->parent = nv_lastdict(); ntp->parent = nv_lastdict();

View file

@ -1216,7 +1216,7 @@ pid_t path_spawn(const char *opath,register char **argv, char **envp, Pathcomp_t
#endif /* SHELLMAGIC */ #endif /* SHELLMAGIC */
#if __CYGWIN__ #if __CYGWIN__
/* /*
* On Cygwin, execve(2) happily executes shell scripts without a #! path with /bin/sh (which is bash --posix). * On Cygwin, execve(2) happily executes shell scripts without a #! path with bash (which violates POSIX).
* However, ksh relies on execve(2) executing binaries or #! only, as it uses an ENOEXEC failure to decide * However, ksh relies on execve(2) executing binaries or #! only, as it uses an ENOEXEC failure to decide
* whether to fork and execute a #!-less shell script with a reinitialized copy of itself via exscript() below. * whether to fork and execute a #!-less shell script with a reinitialized copy of itself via exscript() below.
* So, simulate that failure if the file is not a Windows executable or a script with a #! path. * So, simulate that failure if the file is not a Windows executable or a script with a #! path.

View file

@ -412,7 +412,6 @@ Dt_t *sh_subtracktree(int create)
if(sp && !sp->strack) if(sp && !sp->strack)
{ {
sp->strack = dtopen(&_Nvdisc,Dtset); sp->strack = dtopen(&_Nvdisc,Dtset);
dtuserdata(sp->strack,&sh,1);
dtview(sp->strack,sh.track_tree); dtview(sp->strack,sh.track_tree);
sh.track_tree = sp->strack; sh.track_tree = sp->strack;
} }
@ -432,7 +431,6 @@ Dt_t *sh_subfuntree(int create)
if(sp && !sp->sfun) if(sp && !sp->sfun)
{ {
sp->sfun = dtopen(&_Nvdisc,Dtoset); sp->sfun = dtopen(&_Nvdisc,Dtoset);
dtuserdata(sp->sfun,&sh,1);
dtview(sp->sfun,sh.fun_tree); dtview(sp->sfun,sh.fun_tree);
sh.fun_tree = sp->sfun; sh.fun_tree = sp->sfun;
} }

View file

@ -2501,7 +2501,6 @@ int sh_exec(register const Shnode_t *t, int flags)
else else
{ {
root = dtopen(&_Nvdisc,Dtoset); root = dtopen(&_Nvdisc,Dtoset);
dtuserdata(root,&sh,1);
nv_mount(np, (char*)0, root); nv_mount(np, (char*)0, root);
np->nvalue.cp = Empty; np->nvalue.cp = Empty;
dtview(root,sh.var_base); dtview(root,sh.var_base);
@ -2620,10 +2619,7 @@ int sh_exec(register const Shnode_t *t, int flags)
if(!sh.fpathdict) if(!sh.fpathdict)
sh.fpathdict = dtopen(&_Rpdisc,Dtobag); sh.fpathdict = dtopen(&_Rpdisc,Dtobag);
if(sh.fpathdict) if(sh.fpathdict)
{
dtuserdata(sh.fpathdict,&sh,1);
dtinsert(sh.fpathdict,rp); dtinsert(sh.fpathdict,rp);
}
} }
} }
else else

View file

@ -359,7 +359,6 @@ make install
exec - 0) rm -f astmath.exe ;; exec - 0) rm -f astmath.exe ;;
exec - *) touch astmath.exe ;; exec - *) touch astmath.exe ;;
exec - esac exec - esac
exec - rm -f astmath
done astmath.exe dontcare generated done astmath.exe dontcare generated
prev FEATURE/aso prev FEATURE/aso
exec - sed -e '/^#define _REQ_/!d' -e 's/#define _REQ_\([a-z0-9_]*\).*/ -l\1/' FEATURE/aso >> ast.req exec - sed -e '/^#define _REQ_/!d' -e 's/#define _REQ_\([a-z0-9_]*\).*/ -l\1/' FEATURE/aso >> ast.req

View file

@ -54,9 +54,9 @@ There is a preset initial active stack.
To use an additional stack, it is necessary to create it and to To use an additional stack, it is necessary to create it and to
install it as the active stack. install it as the active stack.
A stack is created with the \f3stakcreate\fP() function. A stack is created with the \f3stakcreate\fP() function.
A \fIflags\fP argument of \f3STAK_SMALL\fP indicates that unused The \fIflags\fP argument is an options bitmask.
space on the stack should be freed whenever this stack ceases If the \f3STAK_SMALL\fP bit is set, the stack allocates memory in
to be the active stack. small blocks, optimizing for memory usage at the expense of performance.
If successful, If successful,
\f3stakcreate\fP() returns a pointer to a stack whose reference \f3stakcreate\fP() returns a pointer to a stack whose reference
count is 1. count is 1.

View file

@ -55,9 +55,11 @@ There is a preset initial active stack.
To use an additional stack, it is necessary to create it and to To use an additional stack, it is necessary to create it and to
install it as the active stack. install it as the active stack.
A stack is created with the \f3stkopen\fP() function. A stack is created with the \f3stkopen\fP() function.
A \fIflags\fP argument of \f3STK_SMALL\fP indicates that unused The \fIflags\fP argument is an options bitmask.
space on the stack should be freed whenever this stack ceases If the \f3STK_SMALL\fP bit is set, the stack allocates memory in
to be the active stack. small blocks, optimizing for memory usage at the expense of performance.
If the \f3STK_NULL\fP bit is set, a stack overflow will cause stack
operations to return a null pointer instead of throwing an error.
If successful, If successful,
\f3stkopen\fP() returns a pointer to a stack whose reference \f3stkopen\fP() returns a pointer to a stack whose reference
count is 1. count is 1.

View file

@ -229,11 +229,9 @@ Sfio_t *stkopen(int flags)
if(flags&STK_NULL) sp->stkoverflow = 0; if(flags&STK_NULL) sp->stkoverflow = 0;
else sp->stkoverflow = stkcur?stkcur->stkoverflow:overflow; else sp->stkoverflow = stkcur?stkcur->stkoverflow:overflow;
bsize = init+sizeof(struct frame); bsize = init+sizeof(struct frame);
#ifndef USE_REALLOC
if(flags&STK_SMALL) if(flags&STK_SMALL)
bsize = roundof(bsize,STK_FSIZE/16); bsize = roundof(bsize,STK_FSIZE/16);
else else
#endif /* USE_REALLOC */
bsize = roundof(bsize,STK_FSIZE); bsize = roundof(bsize,STK_FSIZE);
bsize -= sizeof(struct frame); bsize -= sizeof(struct frame);
if(!(fp=newof((char*)0,struct frame, 1,bsize))) if(!(fp=newof((char*)0,struct frame, 1,bsize)))
@ -279,9 +277,6 @@ Sfio_t *stkinstall(Sfio_t *stream, _stk_overflow_ oflow)
if(stream!=stkstd) if(stream!=stkstd)
sfstack(stkstd,stream); sfstack(stkstd,stream);
stkcur = sp; stkcur = sp;
#ifdef USE_REALLOC
/*** someday ***/
#endif /* USE_REALLOC */
} }
else else
sp = stkcur; sp = stkcur;
@ -509,10 +504,8 @@ static char *stkgrow(register Sfio_t *stream, size_t size)
int nn=0,add=1; int nn=0,add=1;
n += (m + sizeof(struct frame)+1); n += (m + sizeof(struct frame)+1);
if(sp->stkflags&STK_SMALL) if(sp->stkflags&STK_SMALL)
#ifndef USE_REALLOC
n = roundof(n,STK_FSIZE/16); n = roundof(n,STK_FSIZE/16);
else else
#endif /* !USE_REALLOC */
n = roundof(n,STK_FSIZE); n = roundof(n,STK_FSIZE);
/* see whether current frame can be extended */ /* see whether current frame can be extended */
if(stkptr(stream,0)==sp->stkbase+sizeof(struct frame)) if(stkptr(stream,0)==sp->stkbase+sizeof(struct frame))