ignore more dups
This commit is contained in:
parent
d44827dc5b
commit
13231b50eb
9
edit.c
9
edit.c
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.133 2008/09/30 17:49:24 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.134 2008/09/30 19:25:49 tg Exp $");
|
||||||
|
|
||||||
/* tty driver characters we are interested in */
|
/* tty driver characters we are interested in */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3154,8 +3154,7 @@ x_edit_line(int c __unused)
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
*xep = '\0';
|
*xep = '\0';
|
||||||
source->line++;
|
histsave(&source->line, xbuf, true, true);
|
||||||
histsave(source->line, xbuf, true);
|
|
||||||
x_arg = 0;
|
x_arg = 0;
|
||||||
} else
|
} else
|
||||||
x_arg = source->line - (histptr - x_histp);
|
x_arg = source->line - (histptr - x_histp);
|
||||||
|
@ -4365,8 +4364,8 @@ vi_cmd(int argcnt, const char *cmd)
|
||||||
if (!argcnt) {
|
if (!argcnt) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
es->cbuf[es->linelen] = '\0';
|
es->cbuf[es->linelen] = '\0';
|
||||||
source->line++;
|
histsave(&source->line, es->cbuf, true,
|
||||||
histsave(source->line, es->cbuf, true);
|
true);
|
||||||
} else
|
} else
|
||||||
argcnt = source->line + 1
|
argcnt = source->line + 1
|
||||||
- (hlast - hnum);
|
- (hlast - hnum);
|
||||||
|
|
8
funcs.c
8
funcs.c
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.88 2008/09/30 17:49:25 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.89 2008/09/30 19:25:50 tg Exp $");
|
||||||
|
|
||||||
/* A leading = means assignments before command are kept;
|
/* A leading = means assignments before command are kept;
|
||||||
* a leading * means a POSIX special builtin;
|
* a leading * means a POSIX special builtin;
|
||||||
|
@ -502,8 +502,7 @@ c_print(const char **wp)
|
||||||
|
|
||||||
if (flags & PO_HIST) {
|
if (flags & PO_HIST) {
|
||||||
Xput(xs, xp, '\0');
|
Xput(xs, xp, '\0');
|
||||||
source->line++;
|
histsave(&source->line, Xstring(xs, xp), true, false);
|
||||||
histsave(source->line, Xstring(xs, xp), true);
|
|
||||||
Xfree(xs, xp);
|
Xfree(xs, xp);
|
||||||
} else {
|
} else {
|
||||||
int n, len = Xlength(xs, xp);
|
int n, len = Xlength(xs, xp);
|
||||||
|
@ -1894,8 +1893,7 @@ c_read(const char **wp)
|
||||||
shf_flush(shf);
|
shf_flush(shf);
|
||||||
if (historyr) {
|
if (historyr) {
|
||||||
Xput(xs, xp, '\0');
|
Xput(xs, xp, '\0');
|
||||||
source->line++;
|
histsave(&source->line, Xstring(xs, xp), true, false);
|
||||||
histsave(source->line, Xstring(xs, xp), true);
|
|
||||||
Xfree(xs, xp);
|
Xfree(xs, xp);
|
||||||
}
|
}
|
||||||
/* if this is the co-process fd, close the file descriptor
|
/* if this is the co-process fd, close the file descriptor
|
||||||
|
|
23
histrap.c
23
histrap.c
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.68 2008/09/30 17:49:26 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.69 2008/09/30 19:25:51 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* MirOS: This is the default mapping type, and need not be specified.
|
* MirOS: This is the default mapping type, and need not be specified.
|
||||||
|
@ -280,7 +280,8 @@ hist_execute(char *cmd)
|
||||||
if (!*q) /* ignore trailing newline */
|
if (!*q) /* ignore trailing newline */
|
||||||
q = NULL;
|
q = NULL;
|
||||||
}
|
}
|
||||||
histsave(++(hist_source->line), p, true);
|
/* setting ignoredups to true breaks history-e-minus-5 */
|
||||||
|
histsave(&hist_source->line, p, true, false);
|
||||||
|
|
||||||
shellf("%s\n", p); /* POSIX doesn't say this is done... */
|
shellf("%s\n", p); /* POSIX doesn't say this is done... */
|
||||||
if ((p = q)) /* restore \n (trailing \n not restored) */
|
if ((p = q)) /* restore \n (trailing \n not restored) */
|
||||||
|
@ -574,7 +575,7 @@ init_histvec(void)
|
||||||
* save command in history
|
* save command in history
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
histsave(int lno __unused, const char *cmd, bool dowrite __unused)
|
histsave(int *lnp, const char *cmd, bool dowrite __unused, bool ignoredups)
|
||||||
{
|
{
|
||||||
char **hp;
|
char **hp;
|
||||||
char *c, *cp;
|
char *c, *cp;
|
||||||
|
@ -583,9 +584,15 @@ histsave(int lno __unused, const char *cmd, bool dowrite __unused)
|
||||||
if ((cp = strchr(c, '\n')) != NULL)
|
if ((cp = strchr(c, '\n')) != NULL)
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
|
if (ignoredups && !strcmp(c, *histptr)) {
|
||||||
|
afree(c, APERM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++*lnp;
|
||||||
|
|
||||||
#if HAVE_PERSISTENT_HISTORY
|
#if HAVE_PERSISTENT_HISTORY
|
||||||
if (histfd && dowrite)
|
if (histfd && dowrite)
|
||||||
writehistfile(lno, c);
|
writehistfile(*lnp, c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hp = histptr;
|
hp = histptr;
|
||||||
|
@ -824,8 +831,8 @@ static void
|
||||||
histload(Source *s, unsigned char *base, int bytes)
|
histload(Source *s, unsigned char *base, int bytes)
|
||||||
{
|
{
|
||||||
State state;
|
State state;
|
||||||
int lno = 0;
|
int lno = 0;
|
||||||
unsigned char *line = NULL;
|
unsigned char *line = NULL;
|
||||||
|
|
||||||
for (state = shdr; bytes-- > 0; base++) {
|
for (state = shdr; bytes-- > 0; base++) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -857,8 +864,8 @@ histload(Source *s, unsigned char *base, int bytes)
|
||||||
/* a replacement ? */
|
/* a replacement ? */
|
||||||
histinsert(s, lno, (char *)line);
|
histinsert(s, lno, (char *)line);
|
||||||
} else {
|
} else {
|
||||||
s->line = lno;
|
s->line = lno--;
|
||||||
histsave(lno, (char *)line, false);
|
histsave(&lno, line, false, false);
|
||||||
}
|
}
|
||||||
state = shdr;
|
state = shdr;
|
||||||
}
|
}
|
||||||
|
|
12
lex.c
12
lex.c
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.69 2008/09/30 17:58:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.70 2008/09/30 19:25:51 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
|
@ -1242,15 +1242,7 @@ getsc_line(Source *s)
|
||||||
} else if (interactive) {
|
} else if (interactive) {
|
||||||
char *p = Xstring(s->xs, xp);
|
char *p = Xstring(s->xs, xp);
|
||||||
if (*p && (cur_prompt != PS1 || !ctype(*p, C_IFS | C_IFSWS))) {
|
if (*p && (cur_prompt != PS1 || !ctype(*p, C_IFS | C_IFSWS))) {
|
||||||
if ((p = strchr(p, '\n')) != NULL)
|
histsave(&s->line, s->str, true, true);
|
||||||
*p = '\0';
|
|
||||||
/* ignore dups */
|
|
||||||
if (strcmp(s->str, *histptr)) {
|
|
||||||
s->line++;
|
|
||||||
histsave(s->line, s->str, true);
|
|
||||||
}
|
|
||||||
if (p != NULL)
|
|
||||||
*p = '\n';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (interactive)
|
if (interactive)
|
||||||
|
|
4
sh.h
4
sh.h
|
@ -100,7 +100,7 @@
|
||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.235 2008/09/30 18:43:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.236 2008/09/30 19:25:51 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R35 2008/09/30"
|
#define MKSH_VERSION "R35 2008/09/30"
|
||||||
|
|
||||||
|
@ -1306,7 +1306,7 @@ void hist_init(Source *);
|
||||||
#if HAVE_PERSISTENT_HISTORY
|
#if HAVE_PERSISTENT_HISTORY
|
||||||
void hist_finish(void);
|
void hist_finish(void);
|
||||||
#endif
|
#endif
|
||||||
void histsave(int, const char *, bool);
|
void histsave(int *, const char *, bool, bool);
|
||||||
int c_fc(const char **);
|
int c_fc(const char **);
|
||||||
void sethistsize(int);
|
void sethistsize(int);
|
||||||
#if HAVE_PERSISTENT_HISTORY
|
#if HAVE_PERSISTENT_HISTORY
|
||||||
|
|
Loading…
Reference in New Issue