From owner-svn-src-all@FreeBSD.ORG Thu Jul 10 17:52:20 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 95EBB239; Thu, 10 Jul 2014 17:52:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80BE5235D; Thu, 10 Jul 2014 17:52:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6AHqKUX022523; Thu, 10 Jul 2014 17:52:20 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6AHqIRA022508; Thu, 10 Jul 2014 17:52:18 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201407101752.s6AHqIRA022508@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 10 Jul 2014 17:52:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268502 - in head/lib/libedit: . TEST X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2014 17:52:20 -0000 Author: pfg Date: Thu Jul 10 17:52:17 2014 New Revision: 268502 URL: http://svnweb.freebsd.org/changeset/base/268502 Log: Sync some (mostly cosmetical) changes from NetBSD Makefile,v 1.37 tc1.c v 1.3 Rename TEST/test.c tc1.c common.c,v 1.23 pass lint on _LP64. emacs.c,v 1.22 pass lint on _LP64. filecomplete.h,v 1.8 mv NetBSD ID back from 1.9 as we don't have the widecharacter support. prompt.c,v 1.14 prompt.h,v 1.9 term.h,v 1.20 read.h,v 1.6 Update NetBSD version strings sys.h,v 1.12 Misc sun stuff. tty.c 1.31 handle EINTR in the termios operations Allow a single process to control multiple ttys (for pthreads using _REENTRANT) using multiple EditLine objects. pass lint on _LP64. Don't depend on side effects inside an assert MFC after: 1 week Obtained from: NetBSD Added: head/lib/libedit/TEST/tc1.c - copied, changed from r268462, head/lib/libedit/TEST/test.c Deleted: head/lib/libedit/TEST/test.c Modified: head/lib/libedit/Makefile head/lib/libedit/common.c head/lib/libedit/emacs.c head/lib/libedit/filecomplete.h head/lib/libedit/histedit.h head/lib/libedit/prompt.c head/lib/libedit/prompt.h head/lib/libedit/read.h head/lib/libedit/sys.h head/lib/libedit/term.h head/lib/libedit/tty.c Modified: head/lib/libedit/Makefile ============================================================================== --- head/lib/libedit/Makefile Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/Makefile Thu Jul 10 17:52:17 2014 (r268502) @@ -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 Copied and modified: head/lib/libedit/TEST/tc1.c (from r268462, head/lib/libedit/TEST/test.c) ============================================================================== --- head/lib/libedit/TEST/test.c Wed Jul 9 16:07:36 2014 (r268462, copy source) +++ head/lib/libedit/TEST/tc1.c Thu Jul 10 17:52:17 2014 (r268502) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #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); } Modified: head/lib/libedit/common.c ============================================================================== --- head/lib/libedit/common.c Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/common.c Thu Jul 10 17:52:17 2014 (r268502) @@ -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 *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 __unu 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); Modified: head/lib/libedit/emacs.c ============================================================================== --- head/lib/libedit/emacs.c Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/emacs.c Thu Jul 10 17:52:17 2014 (r268502) @@ -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 *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 __unu 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 __ 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; Modified: head/lib/libedit/filecomplete.h ============================================================================== --- head/lib/libedit/filecomplete.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/filecomplete.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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_ Modified: head/lib/libedit/histedit.h ============================================================================== --- head/lib/libedit/histedit.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/histedit.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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$ */ Modified: head/lib/libedit/prompt.c ============================================================================== --- head/lib/libedit/prompt.c Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/prompt.c Thu Jul 10 17:52:17 2014 (r268502) @@ -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) Modified: head/lib/libedit/prompt.h ============================================================================== --- head/lib/libedit/prompt.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/prompt.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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; Modified: head/lib/libedit/read.h ============================================================================== --- head/lib/libedit/read.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/read.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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$ */ Modified: head/lib/libedit/sys.h ============================================================================== --- head/lib/libedit/sys.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/sys.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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 Modified: head/lib/libedit/term.h ============================================================================== --- head/lib/libedit/term.h Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/term.h Thu Jul 10 17:52:17 2014 (r268502) @@ -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$ */ Modified: head/lib/libedit/tty.c ============================================================================== --- head/lib/libedit/tty.c Thu Jul 10 16:46:46 2014 (r268501) +++ head/lib/libedit/tty.c Thu Jul 10 17:52:17 2014 (r268502) @@ -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 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 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 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 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); }