Hi,
I don't know how did you modified it, but we use slightly different patch now,
because M-_ was caused some garbage has been printed, when history file was
empty.
Michal Hlavinka
On Tuesday 07 April 2009 19:48:01 you wrote:
> cc: [email protected]
> Subject: hist_word() coredump
> --------
>
> Thanks, I modified you change by causing the shell to beep if you try
> using the M-_ or M-. when there is no history file.
>
> David Korn
> [email protected]
diff -up ksh-20080202/src/cmd/ksh93/edit/emacs.c.histword ksh-20080202/src/cmd/ksh93/edit/emacs.c
--- ksh-20080202/src/cmd/ksh93/edit/emacs.c.histword 2007-12-06 16:01:06.000000000 +0100
+++ ksh-20080202/src/cmd/ksh93/edit/emacs.c 2009-04-09 10:33:12.000000000 +0200
@@ -895,14 +895,11 @@ static int escape(register Emacs_t* ep,r
genchar name[MAXLINE];
char buf[MAXLINE];
char *ptr;
- ptr = hist_word(buf,MAXLINE,(count?count:-1));
-#if !KSHELL
- if(ptr==0)
+ if(!(ptr = hist_word(buf,MAXLINE,(count?count:-1))))
{
beep();
- break;
+ return -1;
}
-#endif /* KSHELL */
if ((eol - cur) >= sizeof(name))
{
beep();
diff -up ksh-20080202/src/cmd/ksh93/edit/history.c.histword ksh-20080202/src/cmd/ksh93/edit/history.c
--- ksh-20080202/src/cmd/ksh93/edit/history.c.histword 2007-07-09 22:22:57.000000000 +0200
+++ ksh-20080202/src/cmd/ksh93/edit/history.c 2009-04-09 13:57:49.000000000 +0200
@@ -1032,6 +1032,13 @@ int hist_copy(char *s1,int size,int comm
hist_seek(hp,command);
while ((c = sfgetc(hp->histfp)) && c!=EOF)
{
+ if ((command == 0) && (c == (int)HIST_UNDO))
+ {
+ /* start of the history file, let's skip the two byte magic */
+ if (!(c = sfgetc(hp->histfp)) || c == EOF)
+ break;
+ continue;
+ }
if(c=='\n')
{
if(count++ ==line)
@@ -1070,12 +1077,11 @@ char *hist_word(char *string,int size,in
register unsigned char *cp = (unsigned char*)s1;
register int flag = 0;
History_t *hp = hist_ptr;
+
+ *string = '\0';
if(!hp)
#if KSHELL
- {
- strncpy(string,((Shell_t*)hp->histshell)->lastarg,size);
- return(string);
- }
+ return NULL;
#else
return(NIL(char*));
#endif /* KSHELL */
diff -up ksh-20080202/src/cmd/ksh93/edit/vi.c.histword ksh-20080202/src/cmd/ksh93/edit/vi.c
--- ksh-20080202/src/cmd/ksh93/edit/vi.c.histword 2007-06-26 04:52:48.000000000 +0200
+++ ksh-20080202/src/cmd/ksh93/edit/vi.c 2009-04-09 10:33:27.000000000 +0200
@@ -2356,14 +2356,11 @@ addin:
genchar tmpbuf[MAXLINE];
if(vp->repeat_set==0)
vp->repeat = -1;
- p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat);
-#if !KSHELL
- if(p==0)
+ if (!(p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat)))
{
ed_ringbell();
- break;
+ return(BAD);
}
-#endif /* KSHELL */
#if SHOPT_MULTIBYTE
ed_internal((char*)p,tmpbuf);
p = tmpbuf;
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers