Skip to content

Commit

Permalink
22d3150: move remaining parts to st_restore
Browse files Browse the repository at this point in the history
  • Loading branch information
Krush206 committed Jun 6, 2024
1 parent d0167d4 commit 911ed6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,11 @@ st_restore(void *xst)

xclose(SHIN);

if (insource == 2) {
xclose(fpipe);
fpipe = st->fpipe;
fdecl = st->fdecl;
}
insource = st->insource;
SHIN = st->SHIN;
if (st->OLDSTD != -1)
Expand Down
13 changes: 4 additions & 9 deletions sh.func.c
Original file line number Diff line number Diff line change
Expand Up @@ -2732,7 +2732,7 @@ getYN(const char *prompt)
return doit;
}

int fpipe;
int fpipe = -1;
Char *fdecl;

void
Expand All @@ -2758,8 +2758,6 @@ dofunction(Char **v, struct command *c)
stderror(ERR_NAME | ERR_FUNCALNUM);
if ((varp = adrof1(Sgoal, &functions))) {
static int l;
int pvsav;
Char *fsav;

if (l == 100) {
l = 0;
Expand All @@ -2768,16 +2766,13 @@ dofunction(Char **v, struct command *c)
mypipe(pv);
cleanup_push(&st, st_restore);
st_save(&st, pv[0], 0, &fdecl, v);
pvsav = fpipe;
st.fpipe = fpipe;
fpipe = pv[1];
fsav = fdecl;
st.fdecl = fdecl;
fdecl = *varp->vec;
l++;
process(0);
cleanup_until(&st);
xclose(pv[1]);
fpipe = pvsav;
fdecl = fsav;
l--;

return;
Expand Down Expand Up @@ -2851,7 +2846,7 @@ dofunction(Char **v, struct command *c)
cleanup_until(&aword);
if (!func.len)
return;
func.s[--func.len] = 0;
Strbuf_terminate(&func);
**(varvec = xcalloc(1, sizeof *varvec -
(sizeof **varvec * 2))) =
func.s;
Expand Down
2 changes: 2 additions & 0 deletions sh.h
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@ struct saved_state {
int cantell;
struct Bin B;
int justpr;
int fpipe;
Char *fdecl;
};

#include "sh.decls.h"
Expand Down
2 changes: 1 addition & 1 deletion sh.lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ bgetc(void)
buf = (int) feobp / BUFSIZE;
balloc(buf);
roomleft = BUFSIZE - off;
if (fpipe) {
if (insource == 2) {
if (!*fdecl)
return CHAR_ERR;
(void) xwrite(fpipe, fdecl++, (size_t) 1);
Expand Down

0 comments on commit 911ed6e

Please sign in to comment.