summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshell/common/edit/emacs.c
diff options
context:
space:
mode:
authorApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
committerApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
commit7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch)
tree4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libshell/common/edit/emacs.c
parent6071ac1de68fed78e1e10052045bbb5f1732a263 (diff)
downloadillumos-joyent-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1 PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094 6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04 6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25 6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code 6599668 RFE: Move consumers of alias.sh over to ksh93 6595183 *ksh93* RFE: Update ksh93-integration demo code 6775901 *ksh93* no C message catalogs are generated for ksh93 6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values 6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop 6703761 *ksh93* crashes in script containing uncommon output redirections 6715496 *ksh93* SEGVs on array reinitialization 6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell 6672350 *ksh93* causes parent shell to die when child shell is suspended 6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris 6710205 *ksh93* problem with command substitution (within back quotes) containing \$' 6737600 *ksh93* exits debugger when user presses ctrl-c 6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument" 6754020 *ksh93* does weird '[' expansion 6753538 *ksh93* umask modification leaks out of a ksh93 subshell 6766246 *ksh93* bug in pattern matching 6763594 *ksh93* executes command after "command" builtin twice on failure 6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libshell/common/edit/emacs.c')
-rw-r--r--usr/src/lib/libshell/common/edit/emacs.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/usr/src/lib/libshell/common/edit/emacs.c b/usr/src/lib/libshell/common/edit/emacs.c
index 0882693cc9..02842994ab 100644
--- a/usr/src/lib/libshell/common/edit/emacs.c
+++ b/usr/src/lib/libshell/common/edit/emacs.c
@@ -1,10 +1,10 @@
/***********************************************************************
* *
* This software is part of the ast package *
-* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* Copyright (c) 1982-2008 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
-* by AT&T Knowledge Ventures *
+* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* http://www.opensource.org/licenses/cpl1.0.txt *
@@ -108,6 +108,7 @@ typedef struct _emacs_
char CntrlO;
char overflow; /* Screen overflow flag set */
char scvalid; /* Screen is up to date */
+ char lastdraw; /* last update type */
int offset; /* Screen offset */
enum
{
@@ -195,6 +196,7 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
}
Prompt = prompt;
ep->screen = Screen;
+ ep->lastdraw = FINAL;
if(tty_raw(ERRIO,0) < 0)
{
return(reedit?reedit:ed_read(context, fd,buff,scend,0));
@@ -206,7 +208,6 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
out = (genchar*)buff;
#if SHOPT_MULTIBYTE
out = (genchar*)roundof((char*)out-(char*)0,sizeof(genchar));
- ed_internal(buff,out);
#endif /* SHOPT_MULTIBYTE */
if(!kstack)
{
@@ -231,6 +232,12 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
i = sigsetjmp(env,0);
if (i !=0)
{
+ if(ep->ed->e_multiline)
+ {
+ cur = eol;
+ draw(ep,FINAL);
+ ed_flush(ep->ed);
+ }
tty_cooked(ERRIO);
if (i == UEOF)
{
@@ -588,8 +595,10 @@ update:
}
continue;
case cntl('L'):
- ed_crlf(ep->ed);
+ if(!ep->ed->e_nocrnl)
+ ed_crlf(ep->ed);
draw(ep,REFRESH);
+ ep->ed->e_nocrnl = 0;
continue;
case cntl('[') :
do_escape:
@@ -649,6 +658,8 @@ update:
location.hist_command = hline; /* save current position */
location.hist_line = hloff;
#endif
+ cur = 0;
+ draw(ep,UPDATE);
hist_copy((char*)out,MAXLINE, hline,hloff);
#if SHOPT_MULTIBYTE
ed_internal((char*)(out),out);
@@ -1000,6 +1011,26 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
switch(i=ed_getchar(ep->ed,1))
{
case 'A':
+ if(cur>0 && eol==cur && (cur<(SEARCHSIZE-2) || ep->prevdirection == -2))
+ {
+ if(ep->lastdraw==APPEND && ep->prevdirection != -2)
+ {
+ out[cur] = 0;
+ gencpy(&((genchar*)lstring)[1],out);
+#if SHOPT_MULTIBYTE
+ ed_external(&((genchar*)lstring)[1],lstring+1);
+#endif /* SHOPT_MULTIBYTE */
+ *lstring = '^';
+ ep->prevdirection = -2;
+ }
+ if(*lstring)
+ {
+ ed_ungetchar(ep->ed,'\r');
+ ed_ungetchar(ep->ed,cntl('R'));
+ return(-1);
+ }
+ }
+ *lstring = 0;
ed_ungetchar(ep->ed,cntl('P'));
return(-1);
case 'B':
@@ -1189,6 +1220,8 @@ static void search(Emacs_t* ep,genchar *out,int direction)
}
i = genlen(string);
+ if(ep->prevdirection == -2 && i!=2 || direction!=1)
+ ep->prevdirection = -1;
if (direction < 1)
{
ep->prevdirection = -ep->prevdirection;
@@ -1264,6 +1297,7 @@ static void draw(register Emacs_t *ep,Draw_t option)
sptr = drawbuff;
logcursor = sptr + cur;
longline = NORMAL;
+ ep->lastdraw = option;
if (option == FIRST || option == REFRESH)
{
@@ -1377,6 +1411,9 @@ static void draw(register Emacs_t *ep,Draw_t option)
}
#endif /* SHOPT_MULTIBYTE */
}
+ if(ep->ed->e_multiline && option == REFRESH && ep->ed->e_nocrnl==0)
+ ed_setcursor(ep->ed, ep->screen, ep->cursor-ep->screen, ep->ed->e_peol, -1);
+
/******************
@@ -1407,7 +1444,7 @@ static void draw(register Emacs_t *ep,Draw_t option)
i = (ncursor-nscreen) - ep->offset;
setcursor(ep,i,0);
if(option==FINAL && ep->ed->e_multiline)
- setcursor(ep,nscend-nscreen,0);
+ setcursor(ep,nscend+1-nscreen,0);
ep->scvalid = 1;
return;
}