(partial) sync with openbsd (and fix after them),

gives us a better wrapping prompt and a manpage wording cleanup
This commit is contained in:
tg 2006-08-01 14:09:20 +00:00
parent 5e619e1ef3
commit c504a42ac1
5 changed files with 36 additions and 16 deletions

27
edit.c
View File

@ -1,11 +1,11 @@
/* $OpenBSD: edit.c,v 1.31 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: edit.h,v 1.8 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: emacs.c,v 1.39 2005/09/26 19:25:22 otto Exp $ */
/* $OpenBSD: emacs.c,v 1.40 2006/07/10 17:12:41 beck Exp $ */
/* $OpenBSD: vi.c,v 1.23 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.24 2006/08/01 12:44:16 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.25 2006/08/01 14:09:18 tg Exp $");
/* tty driver characters we are interested in */
typedef struct {
@ -956,6 +956,7 @@ static int cur_col; /* current column on line */
static int pwidth; /* width of prompt */
static int prompt_trunc; /* how much of prompt to truncate */
static int prompt_skip; /* how much of prompt to skip */
static int prompt_redraw; /* do we need to redraw the prompt? */
static int winwidth; /* width of window */
static char *wbuf[2]; /* window buffers */
static int wbuf_len; /* length of window buffers (x_cols-3)*/
@ -1278,10 +1279,19 @@ x_emacs(char *buf, size_t len)
x_col = promptlen(prompt, &p);
prompt_skip = p - prompt;
x_adj_ok = 1;
prompt_redraw = 1;
if (x_col > xx_cols)
x_col = x_col - (x_col / xx_cols) * xx_cols;
x_displen = xx_cols - 2 - x_col;
x_adj_done = 0;
pprompt(prompt, 0);
if (x_displen < 1) {
x_col = 0;
x_displen = xx_cols - 2;
x_e_putc('\n');
prompt_redraw = 0;
}
if (x_nextcmd >= 0) {
int off = source->line - x_nextcmd;
@ -1954,7 +1964,7 @@ x_draw_line(int c __attribute__((unused)))
static void
x_redraw(int limit)
{
int i, j;
int i, j, x_trunc = 0;
u_char *cp;
x_adj_ok = 0;
@ -1964,10 +1974,19 @@ x_redraw(int limit)
x_e_putc('\r');
x_flush();
if (xbp == xbuf) {
pprompt(prompt + prompt_skip, 0);
x_col = promptlen(prompt, NULL);
if (x_col > xx_cols)
x_trunc = (x_col / xx_cols) * xx_cols;
if (prompt_redraw)
pprompt(prompt + prompt_skip, x_trunc);
}
if (x_col > xx_cols)
x_col = x_col - (x_col / xx_cols) * xx_cols;
x_displen = xx_cols - 2 - x_col;
if (x_displen < 1) {
x_col = 0;
x_displen = xx_cols - 2;
}
xlp_valid = false;
cp = (u_char *)x_lastcp();
x_zots((u_char *)xbp);

View File

@ -1,9 +1,9 @@
/* $OpenBSD: history.c,v 1.34 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: history.c,v 1.35 2006/05/29 18:22:24 otto Exp $ */
/* $OpenBSD: trap.c,v 1.22 2005/03/30 17:16:37 deraadt Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.18 2006/08/01 13:43:27 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.19 2006/08/01 14:09:19 tg Exp $");
static int histfd;
static int hsize;
@ -857,8 +857,7 @@ histload(Source *s, unsigned char *base, int bytes)
if (histptr >= history && lno-1 != s->line) {
/* a replacement ? */
histinsert(s, lno, line);
}
else {
} else {
s->line = lno;
histsave(lno, (char *)line, 0);
}

4
lex.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: lex.c,v 1.39 2006/04/10 14:38:59 jaredy Exp $ */
/* $OpenBSD: lex.c,v 1.42 2006/07/10 17:12:41 beck Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.14 2006/08/01 13:43:27 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.15 2006/08/01 14:09:19 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */

10
mksh.1
View File

@ -1,5 +1,5 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.42 2006/08/01 12:44:17 tg Exp $
.\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.43 2006/08/01 14:09:19 tg Exp $
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
.Dd August 1, 2006
@ -1430,7 +1430,7 @@ When using
.Ic getopts ,
it contains the argument for a parsed option, if it requires one.
.It Ev OPTIND
The index of the last argument processed when using
The index of the next argument to be processed when using
.Ic getopts .
Assigning 1 to this parameter causes
.Ic getopts
@ -2796,7 +2796,9 @@ Each time
.Ic getopts
is invoked, it places the next option in the shell parameter
.Ar name
and the index of the next argument to be processed in the shell parameter
and the index of the argument to be processed by the next call to
.Ic getopts
in the shell parameter
.Ev OPTIND .
If the option was introduced with a
.Ql + ,

4
sh.h
View File

@ -3,12 +3,12 @@
/* $OpenBSD: table.h,v 1.7 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: lex.h,v 1.10 2005/09/11 18:02:27 otto Exp $ */
/* $OpenBSD: lex.h,v 1.11 2006/05/29 18:22:24 otto Exp $ */
/* $OpenBSD: proto.h,v 1.30 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.28 2006/08/01 12:22:26 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.29 2006/08/01 14:09:20 tg Exp $"
#include <sys/param.h>