diff options
Diffstat (limited to 'usr/src/lib/libshell/common/edit')
-rw-r--r-- | usr/src/lib/libshell/common/edit/completion.c | 40 | ||||
-rw-r--r-- | usr/src/lib/libshell/common/edit/edit.c | 11 | ||||
-rw-r--r-- | usr/src/lib/libshell/common/edit/emacs.c | 12 | ||||
-rw-r--r-- | usr/src/lib/libshell/common/edit/hexpand.c | 4 | ||||
-rw-r--r-- | usr/src/lib/libshell/common/edit/history.c | 12 | ||||
-rw-r--r-- | usr/src/lib/libshell/common/edit/vi.c | 15 |
6 files changed, 59 insertions, 35 deletions
diff --git a/usr/src/lib/libshell/common/edit/completion.c b/usr/src/lib/libshell/common/edit/completion.c index 54b4212470..f90f7af9c6 100644 --- a/usr/src/lib/libshell/common/edit/completion.c +++ b/usr/src/lib/libshell/common/edit/completion.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -24,7 +24,6 @@ */ #include "defs.h" -#include <ctype.h> #include <ast_wchar.h> #include "lexstates.h" #include "path.h" @@ -32,6 +31,31 @@ #include "edit.h" #include "history.h" +#if !SHOPT_MULTIBYTE +#define mbchar(p) (*(unsigned char*)p++) +#endif + +static char *fmtx(const char *string) +{ + register const char *cp = string; + register int n,c; + unsigned char *state = (unsigned char*)sh_lexstates[2]; + int offset; + while((c=mbchar(cp)),(c>UCHAR_MAX)||(n=state[c])==0); + if(n==S_EOF) + return((char*)string); + offset = staktell(); + stakwrite(string,--cp-string); + while(c=mbchar(cp)) + { + if(state[c]) + stakputc('\\'); + stakputc(c); + } + stakputc(0); + return(stakptr(offset)); +} + static int charcmp(int a, int b, int nocase) { if(nocase) @@ -337,7 +361,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) { char **savcom = com; while (*com) - size += strlen(cp=sh_fmtq(*com++)); + size += strlen(cp=fmtx(*com++)); com = savcom; } } @@ -364,7 +388,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) var = 0; } else - out = strcopy(begin,sh_fmtq(*com)); + out = strcopy(begin,fmtx(*com)); com++; } else @@ -394,7 +418,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) out = strcopy(begin,cp); } /* add quotes if necessary */ - if((cp=sh_fmtq(begin))!=begin) + if((cp=fmtx(begin))!=begin) out = strcopy(begin,cp); if(var=='$' && begin[-1]=='{') *out = '}'; @@ -402,11 +426,11 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) *out = ' '; *++out = 0; } - else if(out[-1]=='/' && (cp=sh_fmtq(begin))!=begin) + else if((cp=fmtx(begin))!=begin) { out = strcopy(begin,cp); if(out[-1] =='"' || out[-1]=='\'') - *--out = 0;; + *--out = 0; } if(*begin==0) ed_ringbell(); @@ -416,7 +440,7 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) while (*com) { *out++ = ' '; - out = strcopy(out,sh_fmtq(*com++)); + out = strcopy(out,fmtx(*com++)); } } if(ep->e_nlist) diff --git a/usr/src/lib/libshell/common/edit/edit.c b/usr/src/lib/libshell/common/edit/edit.c index fbee33ca57..7fe6a99c47 100644 --- a/usr/src/lib/libshell/common/edit/edit.c +++ b/usr/src/lib/libshell/common/edit/edit.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -30,7 +30,6 @@ #include <ast.h> #include <errno.h> #include <ccode.h> -#include <ctype.h> #include "FEATURE/options" #include "FEATURE/time" #include "FEATURE/cmds" @@ -43,6 +42,7 @@ # include "defs.h" # include "variables.h" #else +# include <ctype.h> extern char ed_errbuf[]; char e_version[] = "\n@(#)$Id: Editlib version 1993-12-28 r $\0\n"; #endif /* KSHELL */ @@ -818,7 +818,7 @@ int ed_read(void *context, int fd, char *buff, int size, int reedit) { if(shp->trapnote&(SH_SIGSET|SH_SIGTRAP)) goto done; - if(ep->sh->winch) + if(ep->sh->winch && sh_isstate(SH_INTERACTIVE) && (sh_isoption(SH_VI) || sh_isoption(SH_EMACS))) { Edpos_t lastpos; int n, rows, newsize; @@ -857,9 +857,12 @@ int ed_read(void *context, int fd, char *buff, int size, int reedit) buff[2] = 'a'; return(3); } - buff[0] = cntl('L'); + if(sh_isoption(SH_EMACS) || sh_isoption(SH_VI)) + buff[0] = cntl('L'); return(1); } + else + ep->sh->winch = 0; /* an interrupt that should be ignored */ errno = 0; if(!waitevent || (rv=(*waitevent)(fd,-1L,0))>=0) diff --git a/usr/src/lib/libshell/common/edit/emacs.c b/usr/src/lib/libshell/common/edit/emacs.c index 02842994ab..8faf4c7856 100644 --- a/usr/src/lib/libshell/common/edit/emacs.c +++ b/usr/src/lib/libshell/common/edit/emacs.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -62,10 +62,11 @@ One line screen editor for any program */ #include <ast.h> -#include <ctype.h> #include "FEATURE/cmds" #if KSHELL # include "defs.h" +#else +# include <ctype.h> #endif /* KSHELL */ #include "io.h" @@ -207,7 +208,9 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) ed_setup(ep->ed,fd,reedit); out = (genchar*)buff; #if SHOPT_MULTIBYTE - out = (genchar*)roundof((char*)out-(char*)0,sizeof(genchar)); + out = (genchar*)roundof(buff-(char*)0,sizeof(genchar)); + if(reedit) + ed_internal(buff,out); #endif /* SHOPT_MULTIBYTE */ if(!kstack) { @@ -907,13 +910,11 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) char buf[MAXLINE]; char *ptr; ptr = hist_word(buf,MAXLINE,(count?count:-1)); -#if !KSHELL if(ptr==0) { beep(); break; } -#endif /* KSHELL */ if ((eol - cur) >= sizeof(name)) { beep(); @@ -1072,6 +1073,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) beep(); return(-1); } + return(-1); } diff --git a/usr/src/lib/libshell/common/edit/hexpand.c b/usr/src/lib/libshell/common/edit/hexpand.c index 49444ca464..497f8170d5 100644 --- a/usr/src/lib/libshell/common/edit/hexpand.c +++ b/usr/src/lib/libshell/common/edit/hexpand.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -41,8 +41,6 @@ NoN(hexpand) #else -#include <ctype.h> - static char *modifiers = "htrepqxs&"; static int mod_flags[] = { 0, 0, 0, 0, HIST_PRINT, HIST_QUOTE, HIST_QUOTE|HIST_QUOTE_BR, 0, 0 }; diff --git a/usr/src/lib/libshell/common/edit/history.c b/usr/src/lib/libshell/common/edit/history.c index da875d70c4..b0a3c8db27 100644 --- a/usr/src/lib/libshell/common/edit/history.c +++ b/usr/src/lib/libshell/common/edit/history.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -74,7 +74,6 @@ #include <sfio.h> #include "FEATURE/time" #include <error.h> -#include <ctype.h> #include <ls.h> #if KSHELL # include "defs.h" @@ -82,6 +81,8 @@ # include "path.h" # include "builtins.h" # include "io.h" +#else +# include <ctype.h> #endif /* KSHELL */ #include "history.h" @@ -1071,14 +1072,7 @@ char *hist_word(char *string,int size,int word) register int flag = 0; History_t *hp = hist_ptr; if(!hp) -#if KSHELL - { - strncpy(string,((Shell_t*)hp->histshell)->lastarg,size); - return(string); - } -#else return(NIL(char*)); -#endif /* KSHELL */ hist_copy(string,size,(int)hp->histind-1,-1); for(;c = *cp;cp++) { diff --git a/usr/src/lib/libshell/common/edit/vi.c b/usr/src/lib/libshell/common/edit/vi.c index 391999b5e9..b374aa4b0d 100644 --- a/usr/src/lib/libshell/common/edit/vi.c +++ b/usr/src/lib/libshell/common/edit/vi.c @@ -1,7 +1,7 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1982-2008 AT&T Intellectual Property * +* Copyright (c) 1982-2009 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -34,8 +34,8 @@ #else # include <ast.h> # include "FEATURE/options" +# include <ctype.h> #endif /* KSHELL */ -#include <ctype.h> #include "io.h" #include "history.h" @@ -581,7 +581,11 @@ int ed_viread(void *context, int fd, register char *shbuf, int nchar, int reedit vp->U_saved = 0; if(reedit) + { + cur_phys = vp->first_wind; + vp->ofirst_wind = INVALID; refresh(vp,INPUT); + } if(viraw) getline(vp,APPEND); else if(last_virt>=0 && virtual[last_virt]==term_char) @@ -1566,9 +1570,10 @@ static int mvcursor(register Vi_t* vp,register int motion) if(cur_virt>=0 && cur_virt<(SEARCHSIZE-2) && cur_virt == last_virt) { virtual[last_virt + 1] = '\0'; - gencpy(&((genchar*)lsearch)[1], virtual); #if SHOPT_MULTIBYTE - ed_external(&((genchar*)lsearch)[1],lsearch+1); + ed_external(virtual,lsearch+1); +#else + strcpy(lsearch+1,virtual); #endif /* SHOPT_MULTIBYTE */ *lsearch = '^'; vp->direction = -2; @@ -2381,13 +2386,11 @@ addin: if(vp->repeat_set==0) vp->repeat = -1; p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat); -#if !KSHELL if(p==0) { ed_ringbell(); break; } -#endif /* KSHELL */ #if SHOPT_MULTIBYTE ed_internal((char*)p,tmpbuf); p = tmpbuf; |