summaryrefslogtreecommitdiffstats
path: root/lib/libedit
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/Makefile6
-rw-r--r--lib/libedit/TEST/tc1.c (renamed from lib/libedit/TEST/test.c)8
-rw-r--r--lib/libedit/common.c7
-rw-r--r--lib/libedit/emacs.c13
-rw-r--r--lib/libedit/filecomplete.h2
-rw-r--r--lib/libedit/histedit.h2
-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
12 files changed, 80 insertions, 39 deletions
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index d8ae646..c8de253 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$
@@ -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/TEST/test.c b/lib/libedit/TEST/tc1.c
index facbdaa..e2e9ce1 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);
}
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/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/histedit.h b/lib/libedit/histedit.h
index 8a6caf9..55f1277 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$
*/
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