summaryrefslogtreecommitdiffstats
path: root/lib/libedit
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
committersjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
commitd7cd1d425cc1ea9451fa235e3af9b6625c3e0de2 (patch)
treeb04f4bd7cd887f50e7d98af35f46b9834ff86c80 /lib/libedit
parent3c8e37b1d04827f33c0c9a7594bd1b1ef7cdb3d3 (diff)
parent4fbde208c6460d576f64d6dc3cdc6cab085a4283 (diff)
downloadFreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.zip
FreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.tar.gz
Merge head from 7/28
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/Makefile10
-rw-r--r--lib/libedit/Makefile.depend2
-rw-r--r--lib/libedit/TEST/tc1.c (renamed from lib/libedit/TEST/test.c)10
-rw-r--r--lib/libedit/common.c7
-rw-r--r--lib/libedit/editline.33
-rw-r--r--lib/libedit/emacs.c13
-rw-r--r--lib/libedit/filecomplete.h2
-rw-r--r--lib/libedit/hist.h1
-rw-r--r--lib/libedit/histedit.h3
-rw-r--r--lib/libedit/history.c39
-rw-r--r--lib/libedit/prompt.c2
-rw-r--r--lib/libedit/prompt.h6
-rw-r--r--lib/libedit/read.h2
-rw-r--r--lib/libedit/sys.h11
-rw-r--r--lib/libedit/term.h2
-rw-r--r--lib/libedit/tty.c58
16 files changed, 119 insertions, 52 deletions
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index d8ae646..df86778 100644
--- a/lib/libedit/Makefile
+++ b/lib/libedit/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $
+# $NetBSD: Makefile,v 1.37 2009/01/18 12:17:49 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
@@ -10,8 +10,8 @@ OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
hist.c key.c map.c \
parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c
-DPADD= ${LIBNCURSES}
-LDADD= -lncurses
+DPADD= ${LIBNCURSESW}
+LDADD= -lncursesw
MAN= editline.3 editrc.5
@@ -70,9 +70,9 @@ editline.c: ${OSRCS}
editline.o editline.po editline.So editline.ln: \
common.h emacs.h fcns.c fcns.h help.c help.h vi.h
-test.o: ${.CURDIR}/TEST/test.c
+tc1.o: ${.CURDIR}/TEST/tc1.c
-test: test.o libedit.a ${DPADD} ${LIBTERMCAP}
+test: tc1.o libedit.a ${DPADD} ${LIBTERMCAP}
${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD}
.include <bsd.lib.mk>
diff --git a/lib/libedit/Makefile.depend b/lib/libedit/Makefile.depend
index 1d7ae94..918d492 100644
--- a/lib/libedit/Makefile.depend
+++ b/lib/libedit/Makefile.depend
@@ -3,6 +3,7 @@
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
+ bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
@@ -10,7 +11,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/ncurses/ncurses \
lib/ncurses/ncursesw \
usr.bin/xinstall.host \
diff --git a/lib/libedit/TEST/test.c b/lib/libedit/TEST/tc1.c
index facbdaa..a60aa75 100644
--- a/lib/libedit/TEST/test.c
+++ b/lib/libedit/TEST/tc1.c
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if !defined(lint) && !defined(SCCSID)
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint && not SCCSID */
-__RCSID("$NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $");
+__RCSID("$NetBSD: test.c,v 1.3 2009/07/17 12:25:52 christos Exp $");
__FBSDID("$FreeBSD$");
/*
@@ -68,7 +68,7 @@ static void sig(int);
static char *
prompt(EditLine *el)
{
- static char a[] = "Edit$ ";
+ static char a[] = "\1\e[7m\1Edit$\1\e[0m\1 ";
static char b[] = "Edit> ";
return (continuation ? b : a);
@@ -143,7 +143,7 @@ main(int argc, char *argv[])
el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */
el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */
- el_set(el, EL_PROMPT, prompt); /* Set the prompt function */
+ el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */
/* Tell editline to use this history interface */
el_set(el, EL_HIST, history, hist);
@@ -183,7 +183,7 @@ main(int argc, char *argv[])
#endif
if (gotsig) {
- (void) fprintf(stderr, "Got signal %d.\n", gotsig);
+ (void) fprintf(stderr, "Got signal %d.\n", (int)gotsig);
gotsig = 0;
el_reset(el);
}
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
} else if (el_parse(el, ac, av) == -1) {
switch (fork()) {
case 0:
- execvp(av[0], __DECONST(char *const *, av));
+ execvp(av[0], __DECONST(char **, av));
perror(av[0]);
_exit(1);
/*NOTREACHED*/
diff --git a/lib/libedit/common.c b/lib/libedit/common.c
index 0599554..64490c9 100644
--- a/lib/libedit/common.c
+++ b/lib/libedit/common.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $
+ * $NetBSD: common.c,v 1.23 2009/02/27 04:18:45 msaitoh Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -121,7 +121,7 @@ ed_delete_prev_word(EditLine *el, int c __unused)
*kp++ = *p;
el->el_chared.c_kill.last = kp;
- c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */
+ c_delbefore(el, (int)(el->el_line.cursor - cp));/* delete before dot */
el->el_line.cursor = cp;
if (el->el_line.cursor < el->el_line.buffer)
el->el_line.cursor = el->el_line.buffer; /* bounds check */
@@ -208,9 +208,6 @@ ed_move_to_end(EditLine *el, int c __unused)
el->el_line.cursor = el->el_line.lastchar;
if (el->el_map.type == MAP_VI) {
-#ifdef VI_MOVE
- el->el_line.cursor--;
-#endif
if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
diff --git a/lib/libedit/editline.3 b/lib/libedit/editline.3
index 33f7666..df7cd87 100644
--- a/lib/libedit/editline.3
+++ b/lib/libedit/editline.3
@@ -682,6 +682,9 @@ Load the history list stored in
.It Dv H_SAVE , Fa "const char *file"
Save the history list to
.Fa file .
+.It Dv H_SAVE_FP , Fa "FILE*"
+Save the history list to the opened
+.Fa FILE* .
.It Dv H_SETUNIQUE , Fa "int unique"
Set flag that adjacent identical event strings should not be entered
into the history.
diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c
index a285b1c..edcc84b 100644
--- a/lib/libedit/emacs.c
+++ b/lib/libedit/emacs.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $
+ * $NetBSD: emacs.c,v 1.22 2009/02/15 21:55:23 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -101,7 +101,7 @@ em_delete_next_word(EditLine *el, int c __unused)
*kp++ = *p;
el->el_chared.c_kill.last = kp;
- c_delafter(el, cp - el->el_line.cursor); /* delete after dot */
+ c_delafter(el, (int)(cp - el->el_line.cursor)); /* delete after dot */
if (el->el_line.cursor > el->el_line.lastchar)
el->el_line.cursor = el->el_line.lastchar;
/* bounds check */
@@ -131,7 +131,8 @@ em_yank(EditLine *el, int c __unused)
cp = el->el_line.cursor;
/* open the space, */
- c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
+ c_insert(el,
+ (int)(el->el_chared.c_kill.last - el->el_chared.c_kill.buf));
/* copy the chars */
for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
*cp++ = *kp;
@@ -185,14 +186,14 @@ em_kill_region(EditLine *el, int c __unused)
while (cp < el->el_chared.c_kill.mark)
*kp++ = *cp++; /* copy it */
el->el_chared.c_kill.last = kp;
- c_delafter(el, cp - el->el_line.cursor);
+ c_delafter(el, (int)(cp - el->el_line.cursor));
} else { /* mark is before cursor */
cp = el->el_chared.c_kill.mark;
kp = el->el_chared.c_kill.buf;
while (cp < el->el_line.cursor)
*kp++ = *cp++; /* copy it */
el->el_chared.c_kill.last = kp;
- c_delbefore(el, cp - el->el_chared.c_kill.mark);
+ c_delbefore(el, (int)(cp - el->el_chared.c_kill.mark));
el->el_line.cursor = el->el_chared.c_kill.mark;
}
return (CC_REFRESH);
@@ -446,7 +447,7 @@ em_copy_prev_word(EditLine *el, int c __unused)
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
el->el_state.argument, ce__isword);
- c_insert(el, oldc - cp);
+ c_insert(el, (int)(oldc - cp));
for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
*dp++ = *cp;
diff --git a/lib/libedit/filecomplete.h b/lib/libedit/filecomplete.h
index a3156e9..215cf7d 100644
--- a/lib/libedit/filecomplete.h
+++ b/lib/libedit/filecomplete.h
@@ -26,7 +26,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $NetBSD: filecomplete.h,v 1.9 2009/12/30 22:37:40 christos Exp $
+ * $NetBSD: filecomplete.h,v 1.8 2009/02/16 00:15:45 christos Exp $
* $FreeBSD$
*/
#ifndef _FILECOMPLETE_H_
diff --git a/lib/libedit/hist.h b/lib/libedit/hist.h
index 4f2824a..4ddedcc 100644
--- a/lib/libedit/hist.h
+++ b/lib/libedit/hist.h
@@ -65,6 +65,7 @@ typedef struct el_history_t {
#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)
#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
+#define HIST_SAVE_FP(el, fp) HIST_FUN(el, H_SAVE_FP fp)
protected int hist_init(EditLine *);
protected void hist_end(EditLine *);
diff --git a/lib/libedit/histedit.h b/lib/libedit/histedit.h
index 8a6caf9..7cc5246 100644
--- a/lib/libedit/histedit.h
+++ b/lib/libedit/histedit.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)histedit.h 8.2 (Berkeley) 1/3/94
- * $NetBSD: histedit.h,v 1.32 2007/06/10 20:20:28 christos Exp $
+ * $NetBSD: histedit.h,v 1.41 2009/09/07 21:24:33 christos Exp $
* $FreeBSD$
*/
@@ -208,6 +208,7 @@ int history(History *, HistEvent *, int, ...);
#define H_NEXT_EVDATA 23 /* , const int, histdata_t *); */
#define H_DELDATA 24 /* , int, histdata_t *);*/
#define H_REPLACE 25 /* , const char *, histdata_t); */
+#define H_SAVE_FP 26 /* , FILE*); */
/*
diff --git a/lib/libedit/history.c b/lib/libedit/history.c
index 8f30a05..cd86977 100644
--- a/lib/libedit/history.c
+++ b/lib/libedit/history.c
@@ -103,6 +103,7 @@ private int history_getunique(History *, HistEvent *);
private int history_set_fun(History *, History *);
private int history_load(History *, const char *);
private int history_save(History *, const char *);
+private int history_save_fp(History *, FILE*);
private int history_prev_event(History *, HistEvent *, int);
private int history_next_event(History *, HistEvent *, int);
private int history_next_string(History *, HistEvent *, const char *);
@@ -773,22 +774,16 @@ done:
return (i);
}
-
-/* history_save():
- * History save function
+/* history_save_fp():
+ * History save with open FILE*
*/
-private int
-history_save(History *h, const char *fname)
+private int history_save_fp(History *h, FILE* fp)
{
- FILE *fp;
HistEvent ev;
int i = -1, retval;
size_t len, max_size;
char *ptr;
- if ((fp = fopen(fname, "w")) == NULL)
- return (-1);
-
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
goto done;
if (fputs(hist_cookie, fp) == EOF)
@@ -816,6 +811,26 @@ history_save(History *h, const char *fname)
oomem:
h_free((ptr_t)ptr);
done:
+ return (i);
+
+}
+
+
+/* history_save():
+ * History save function
+ */
+private int
+history_save(History *h, const char *fname)
+{
+ FILE *fp;
+ int i;
+
+ if ((fp = fopen(fname, "w")) == NULL)
+ return (-1);
+
+ i = history_save_fp(h, fp);
+
+done:
(void) fclose(fp);
return (i);
}
@@ -1001,6 +1016,12 @@ history(History *h, HistEvent *ev, int fun, ...)
he_seterrev(ev, _HE_HIST_WRITE);
break;
+ case H_SAVE_FP:
+ retval = history_save_fp(h, va_arg(va, FILE*));
+ if (retval == -1)
+ he_seterrev(ev, _HE_HIST_WRITE);
+ break;
+
case H_PREV_EVENT:
retval = history_prev_event(h, ev, va_arg(va, int));
break;
diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c
index 76d2d64..2d37b67 100644
--- a/lib/libedit/prompt.c
+++ b/lib/libedit/prompt.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp $
+ * $NetBSD: prompt.c,v 1.14 2009/03/31 17:38:27 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
diff --git a/lib/libedit/prompt.h b/lib/libedit/prompt.h
index fe69ca4..c796d93 100644
--- a/lib/libedit/prompt.h
+++ b/lib/libedit/prompt.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)prompt.h 8.1 (Berkeley) 6/4/93
- * $NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp $
+ * $NetBSD: prompt.h,v 1.9 2009/03/31 17:38:27 christos Exp $
* $FreeBSD$
*/
@@ -45,8 +45,8 @@
typedef char * (*el_pfunc_t)(EditLine*);
typedef struct el_prompt_t {
- el_pfunc_t p_func; /* Function to return the prompt */
- coord_t p_pos; /* position in the line after prompt */
+ el_pfunc_t p_func; /* Function to return the prompt */
+ coord_t p_pos; /* position in the line after prompt */
char p_ignore; /* character to start/end literal
*/
} el_prompt_t;
diff --git a/lib/libedit/read.h b/lib/libedit/read.h
index 1dcf164..6018934 100644
--- a/lib/libedit/read.h
+++ b/lib/libedit/read.h
@@ -26,7 +26,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $NetBSD: read.h,v 1.5 2006/08/21 12:45:30 christos Exp $
+ * $NetBSD: read.h,v 1.6 2008/04/29 06:53:01 martin Exp $
* $FreeBSD$
*/
diff --git a/lib/libedit/sys.h b/lib/libedit/sys.h
index 9b1f040..5c017d3 100644
--- a/lib/libedit/sys.h
+++ b/lib/libedit/sys.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)sys.h 8.1 (Berkeley) 6/4/93
- * $NetBSD: sys.h,v 1.9 2004/01/17 17:57:40 christos Exp $
+ * $NetBSD: sys.h,v 1.12 2009/08/31 00:05:43 christos Exp $
* $FreeBSD$
*/
@@ -70,6 +70,15 @@ typedef void *ioctl_t;
#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */
+#if defined(__sun)
+extern int tgetent(char *, const char *);
+extern int tgetflag(char *);
+extern int tgetnum(char *);
+extern int tputs(const char *, int, int (*)(int));
+extern char* tgoto(const char*, int, int);
+extern char* tgetstr(char*, char**);
+#endif
+
#ifdef notdef
# undef REGEX
# undef REGEXP
diff --git a/lib/libedit/term.h b/lib/libedit/term.h
index 4bf4685..cf7a909 100644
--- a/lib/libedit/term.h
+++ b/lib/libedit/term.h
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)term.h 8.1 (Berkeley) 6/4/93
- * $NetBSD: term.h,v 1.18 2006/11/24 00:01:17 christos Exp $
+ * $NetBSD: term.h,v 1.20 2009/03/31 17:38:27 christos Exp $
* $FreeBSD$
*/
diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c
index c0b4638..f8bae94 100644
--- a/lib/libedit/tty.c
+++ b/lib/libedit/tty.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: tty.c,v 1.25 2006/03/18 09:09:41 christos Exp $
+ * $NetBSD: tty.c,v 1.31 2009/07/22 15:58:09 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -443,13 +443,12 @@ private const ttymodes_t ttymodes[] = {
-#define tty_getty(el, td) tcgetattr((el)->el_infd, (td))
-#define tty_setty(el, td) tcsetattr((el)->el_infd, TCSADRAIN, (td))
-
#define tty__gettabs(td) ((((td)->c_oflag & TAB3) == TAB3) ? 0 : 1)
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
+private int tty_getty(EditLine *, struct termios *);
+private int tty_setty(EditLine *, int, const struct termios *);
private int tty__getcharindex(int);
private void tty__getchar(struct termios *, unsigned char *);
private void tty__setchar(struct termios *, unsigned char *);
@@ -458,6 +457,29 @@ private int tty_setup(EditLine *);
#define t_qu t_ts
+/* tty_getty():
+ * Wrapper for tcgetattr to handle EINTR
+ */
+private int
+tty_getty(EditLine *el, struct termios *t)
+{
+ int rv;
+ while ((rv = tcgetattr(el->el_infd, t)) == -1 && errno == EINTR)
+ continue;
+ return rv;
+}
+
+/* tty_setty():
+ * Wrapper for tcsetattr to handle EINTR
+ */
+private int
+tty_setty(EditLine *el, int action, const struct termios *t)
+{
+ int rv;
+ while ((rv = tcsetattr(el->el_infd, action, t)) == -1 && errno == EINTR)
+ continue;
+ return rv;
+}
/* tty_setup():
* Get the tty parameters and initialize the editing state
@@ -996,7 +1018,7 @@ tty_rawmode(EditLine *el)
if (el->el_tty.t_mode == EX_IO)
el->el_tty.t_ex = el->el_tty.t_ts;
- if (tty_setty(el, &el->el_tty.t_ed) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n",
strerror(errno));
@@ -1021,7 +1043,7 @@ tty_cookedmode(EditLine *el)
if (el->el_flags & EDIT_DISABLED)
return (0);
- if (tty_setty(el, &el->el_tty.t_ex) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile,
"tty_cookedmode: tty_setty: %s\n",
@@ -1057,7 +1079,7 @@ tty_quotemode(EditLine *el)
el->el_tty.t_qu.c_lflag &= ~el->el_tty.t_t[QU_IO][MD_LIN].t_clrmask;
el->el_tty.t_qu.c_lflag |= el->el_tty.t_t[QU_IO][MD_LIN].t_setmask;
- if (tty_setty(el, &el->el_tty.t_qu) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_qu) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n",
strerror(errno));
@@ -1078,7 +1100,7 @@ tty_noquotemode(EditLine *el)
if (el->el_tty.t_mode != QU_IO)
return (0);
- if (tty_setty(el, &el->el_tty.t_ed) == -1) {
+ if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n",
strerror(errno));
@@ -1139,7 +1161,7 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
if (!argv || !*argv) {
int i = -1;
- int len = 0, st = 0, cu;
+ size_t len = 0, st = 0, cu;
for (m = ttymodes; m->m_name; m++) {
if (m->m_type != i) {
(void) fprintf(el->el_outfile, "%s%s",
@@ -1162,9 +1184,9 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
cu = strlen(m->m_name) + (x != '\0') + 1;
- if (len + cu >= el->el_term.t_size.h) {
+ if (len + cu >= (size_t)el->el_term.t_size.h) {
(void) fprintf(el->el_outfile, "\n%*s",
- st, "");
+ (int)st, "");
len = st + cu;
} else
len += cu;
@@ -1208,7 +1230,8 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
int c = ffs((int)m->m_value);
int v = *++p ? parse__escape((const char **) &p) :
el->el_tty.t_vdisable;
- assert(c-- != 0);
+ assert(c != 0);
+ c--;
c = tty__getcharindex(c);
assert(c != -1);
tios->c_cc[c] = v;
@@ -1229,6 +1252,17 @@ tty_stty(EditLine *el, int argc __unused, const char **argv)
break;
}
}
+
+ if (el->el_tty.t_mode == z) {
+ if (tty_setty(el, TCSADRAIN, tios) == -1) {
+#ifdef DEBUG_TTY
+ (void) fprintf(el->el_errfile,
+ "tty_stty: tty_setty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+ return (-1);
+ }
+ }
+
return (0);
}
OpenPOWER on IntegriCloud