diff options
author | 2017-07-24 22:28:09 +0000 | |
---|---|---|
committer | 2017-07-24 22:28:09 +0000 | |
commit | e475da58b5001752f56c05d56e3db1f3224943a4 (patch) | |
tree | 261d19fa79670a25725f9f438ec2d7a489373a75 | |
parent | Use memmove instead of a hand-rolled loop (diff) | |
download | wireguard-openbsd-e475da58b5001752f56c05d56e3db1f3224943a4.tar.xz wireguard-openbsd-e475da58b5001752f56c05d56e3db1f3224943a4.zip |
Prettify, simplify
Input & ok tb@
-rw-r--r-- | bin/ksh/history.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bin/ksh/history.c b/bin/ksh/history.c index c2abb0f924a..3eff7ee75ad 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.60 2017/07/24 22:26:12 jca Exp $ */ +/* $OpenBSD: history.c,v 1.61 2017/07/24 22:28:09 jca Exp $ */ /* * command history @@ -594,7 +594,7 @@ void histsave(int lno, const char *cmd, int dowrite) { struct stat sb; - char **hp, *c, *cp, *encoded; + char *c, *cp, *encoded; if (dowrite && histfh) { history_lock(LOCK_EX); @@ -614,15 +614,14 @@ histsave(int lno, const char *cmd, int dowrite) if ((cp = strrchr(c, '\n')) != NULL) *cp = '\0'; - hp = histptr; - if (++hp >= history + histsize) { /* remove oldest command */ + if (histptr < history + histsize) + histptr++; + else { /* remove oldest command */ afree(*history, APERM); memmove(history, history + 1, (histsize - 1) * sizeof(*history)); - hp = histptr; } - *hp = c; - histptr = hp; + *histptr = c; if (dowrite && histfh) { /* append to file */ |