Skip to content

Commit

Permalink
[v1.0] Fix SHOPT_EDPREDICT build (re: a45a0eb, 9ff7f3d, 5b0f235)
Browse files Browse the repository at this point in the history
The SHOPT_EDPREDICT compile-time option has been removed from the
dev branch (see #233) but kept on the 1.0 branch. Building with
this option enabled in SHOPT.sh was subsequently broken by the
three referenced commits as changes were cherry-picked from the dev
branch, which of course did not include the necessary code changes
to the SHOPT_EDPREDICT code. This commit backports those changes.

Thanks to @k2662 for the report.
Resolves: #786
  • Loading branch information
McDutchie committed Oct 27, 2024
1 parent 8d08f66 commit c55f94d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/README
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The options have the following defaults and meanings:
be displayed as a numbered list as you type. You can
scroll up and down this list or you can use <ESC>nTAB to
make this the current line (n defaults to 1 if omitted).
Experimental. Bugs: https://github.com/ksh93/ksh/issues/233
Deprecated. Bugs: https://github.com/ksh93/ksh/issues/233

ESH on Compile with emacs command line editing. The original
emacs line editor code was provided by Mike Veach at IH.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/SHOPT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SHOPT CRNL= # accept MS Windows newlines (<cr><nl>) for <nl>
SHOPT DEVFD= # use /dev/fd instead of FIFOs for process substitutions
SHOPT DYNAMIC=1 # dynamic loading for builtins
SHOPT ECHOPRINT= # make echo equivalent to print
SHOPT EDPREDICT=0 # History pattern search menu (type #<pattern>, then ESC <number> TAB). Experimental.
SHOPT EDPREDICT=0 # History pattern search menu (type #<pattern>, then ESC <number> TAB). Deprecated.
SHOPT ESH=1 # emacs/gmacs edit mode
SHOPT FILESCAN=1 # fast file scan: while <file; do [use $REPLY or positional parameters]; done
SHOPT FIXEDARRAY=1 # fixed dimension indexed array
Expand Down
14 changes: 7 additions & 7 deletions src/cmd/ksh93/edit/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ int ed_histgen(Edit_t *ep,const char *pattern)
hp = sh.hist_ptr;
if(*pattern=='#' && *++pattern=='#')
return(0);
cp = stakalloc(m=strlen(pattern)+6);
cp = stkalloc(sh.stk,m=strlen(pattern)+6);
sfsprintf(cp,m,"@(%s)*%c",pattern,0);
if(ep->hlist)
{
Expand All @@ -1444,7 +1444,7 @@ int ed_histgen(Edit_t *ep,const char *pattern)
maxmatch = ep->e_cur;
return(ep->hmax=av-argv);
}
stakset(ep->e_stkptr,ep->e_stkoff);
stkset(sh.stk,ep->e_stkptr,ep->e_stkoff);
}
if((m=strlen(cp)) >= sizeof(ep->hpat))
m = sizeof(ep->hpat)-1;
Expand All @@ -1463,7 +1463,7 @@ int ed_histgen(Edit_t *ep,const char *pattern)
if(strmatch(cp,pattern))
{
l = ed_histlencopy(cp,(char*)0);
mp = (Histmatch_t*)stakalloc(sizeof(Histmatch_t)+l);
mp = stkalloc(sh.stk,sizeof(Histmatch_t)+l);
mp->next = mplast;
mplast = mp;
mp->len = l;
Expand All @@ -1477,7 +1477,7 @@ int ed_histgen(Edit_t *ep,const char *pattern)
if(ac>0)
{
l = ac;
argv = av = (char**)stakalloc((ac+1)*sizeof(char*));
argv = av = stkalloc(sh.stk,(ac+1)*sizeof(char*));
for(; l>=0 && (*av= (char*)mp); mp=mp->next,av++)
l--;
*av = 0;
Expand Down Expand Up @@ -1530,11 +1530,11 @@ void ed_histlist(Edit_t *ep,int n)
}
else
{
stakset(ep->e_stkptr,ep->e_stkoff);
stkset(sh.stk,ep->e_stkptr,ep->e_stkoff);
ep->hlist = 0;
ep->nhlist = 0;
}
ed_putstring(ep,ERASE_EOS);
ed_putstring(ep,erase_eos);
if(n)
{
for(i=1; (mp= *mpp) && i <= 16 ; i++,mpp++)
Expand Down Expand Up @@ -1562,7 +1562,7 @@ void ed_histlist(Edit_t *ep,int n)
}
last = i-1;
while(i-->0)
ed_putstring(ep,CURSOR_UP);
ed_putstring(ep,cursor_up);
}
ed_flush(ep);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/edit/emacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ static void draw(Emacs_t *ep,Draw_t option)
if(ep->ed->hlist)
{
ed_histlist(ep->ed,n);
putstring(ep,Prompt);
ed_putstring(ep->ed,Prompt);
ed_setcursor(ep->ed,ep->screen,0,ep->cursor-ep->screen, 0);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/edit/vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ static void refresh(Vi_t* vp, int mode)
if(vp->ed->hlist)
{
ed_histlist(vp->ed,n);
pr_string(vp,Prompt);
ed_putstring(vp->ed,Prompt);
vp->ocur_virt = INVALID;
ed_setcursor(vp->ed,physical,0,cur_phys,0);
}
Expand Down

0 comments on commit c55f94d

Please sign in to comment.