Author: pfg Date: Mon Jan 30 23:00:51 2017 New Revision: 313002 URL: https://svnweb.freebsd.org/changeset/base/313002
Log: MFV 312999: Update libedit 2016-03-21 Minor cleanups plus some license syncing. Obtained from: NetBSD X-MFC with: r312997 Modified: head/lib/libedit/Makefile head/lib/libedit/TEST/rl1.c head/lib/libedit/chartype.h head/lib/libedit/common.c head/lib/libedit/read.c head/lib/libedit/refresh.c head/lib/libedit/terminal.c head/lib/libedit/tty.c head/lib/libedit/vi.c Directory Properties: head/lib/libedit/ (props changed) Modified: head/lib/libedit/Makefile ============================================================================== --- head/lib/libedit/Makefile Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/Makefile Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $ +# $NetBSD: Makefile,v 1.56 2016/03/02 19:24:20 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 # $FreeBSD$ @@ -38,8 +38,8 @@ INCS= histedit.h SRCS+= tokenizern.c historyn.c CLEANFILES+= tokenizern.c historyn.c CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR -CFLAGS+= #-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH -CFLAGS+= #-DDEBUG_PASTE -DDEBUG_EDIT +#CFLAGS+= -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +#CFLAGS+= -DDEBUG_PASTE -DDEBUG_EDIT WARNS?= 1 Modified: head/lib/libedit/TEST/rl1.c ============================================================================== --- head/lib/libedit/TEST/rl1.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/TEST/rl1.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $ */ +/* $NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if !defined(lint) -__RCSID("$NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $"); +__RCSID("$NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $"); #endif /* not lint */ __FBSDID("$FreeBSD$"); Modified: head/lib/libedit/chartype.h ============================================================================== --- head/lib/libedit/chartype.h Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/chartype.h Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.h,v 1.23 2016/02/24 17:20:01 christos Exp $ */ +/* $NetBSD: chartype.h,v 1.25 2016/03/07 00:05:20 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -65,6 +65,7 @@ #define FUNW(type) type ## _w #define TYPE(type) type ## W #define FSTR "%ls" +#define FSTARSTR "%.*ls" #define STR(x) L ## x #define UC(c) c #define Isalpha(x) iswalpha(x) @@ -117,6 +118,7 @@ Width(wchar_t c) #define FUNW(type) type #define TYPE(type) type #define FSTR "%s" +#define FSTARSTR "%.*s" #define STR(x) x #define UC(c) (unsigned char)(c) Modified: head/lib/libedit/common.c ============================================================================== --- head/lib/libedit/common.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/common.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */ +/* $NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $"); +__RCSID("$NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -149,8 +149,9 @@ ed_delete_next_char(EditLine *el, wint_t { #ifdef DEBUG_EDIT #define EL el->el_line - (void) fprintf(el->el_errlfile, - "\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n", + (void) fprintf(el->el_errfile, + "\nD(b: %p(" FSTR ") c: %p(" FSTR ") last: %p(" FSTR + ") limit: %p(" FSTR ")\n", EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar, EL.lastchar, EL.limit, EL.limit); #endif Modified: head/lib/libedit/read.c ============================================================================== --- head/lib/libedit/read.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/read.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $ */ +/* $NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $"); +__RCSID("$NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -617,7 +617,7 @@ FUN(el,gets)(EditLine *el, int *nread) break; if (b->name) (void) fprintf(el->el_errfile, - "Executing %s\n", b->name); + "Executing " FSTR "\n", b->name); else (void) fprintf(el->el_errfile, "Error command = %d\n", cmdnum); Modified: head/lib/libedit/refresh.c ============================================================================== --- head/lib/libedit/refresh.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/refresh.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -63,7 +63,7 @@ private void re__strncopy(Char *, Char * private void re__copy_and_pad(Char *, const Char *, size_t); #ifdef DEBUG_REFRESH -private void re_printstr(EditLine *, const char *, char *, char *); +private void re_printstr(EditLine *, const char *, Char *, Char *); #define __F el->el_errfile #define ELRE_ASSERT(a, b, c) do \ if (/*CONSTCOND*/ a) { \ @@ -77,7 +77,7 @@ private void re_printstr(EditLine *, con * Print a string on the debugging pty */ private void -re_printstr(EditLine *el, const char *str, char *f, char *t) +re_printstr(EditLine *el, const char *str, Char *f, Char *t) { ELRE_DEBUG(1, (__F, "%s:\"", str)); @@ -207,7 +207,7 @@ re_refresh(EditLine *el) size_t termsz; #endif - ELRE_DEBUG(1, (__F, "el->el_line.buffer = :%s:\r\n", + ELRE_DEBUG(1, (__F, "el->el_line.buffer = :" FSTR ":\r\n", el->el_line.buffer)); /* reset the Drawing cursor */ @@ -295,7 +295,8 @@ re_refresh(EditLine *el) ELRE_DEBUG(1, (__F, "term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n", el->el_terminal.t_size.h, el->el_refresh.r_cursor.h, - el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0]))); + el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0], + &el->el_scratch))); ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv)); for (i = 0; i <= el->el_refresh.r_newcv; i++) { @@ -323,7 +324,7 @@ re_refresh(EditLine *el) /* This Strlen should be safe even with MB_FILL_CHARs */ terminal_clear_EOL(el, (int) Strlen(el->el_display[i])); #ifdef DEBUG_REFRESH - terminal_overwrite(el, "C\b", (size_t)2); + terminal_overwrite(el, STR("C\b"), 2); #endif /* DEBUG_REFRESH */ el->el_display[i][0] = '\0'; } @@ -370,8 +371,9 @@ re_insert(EditLine *el __attribute__((__ ELRE_DEBUG(1, (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); - ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s, + &el->el_scratch))); /* open up the space for num chars */ if (num > 0) { @@ -384,8 +386,9 @@ re_insert(EditLine *el __attribute__((__ ELRE_DEBUG(1, (__F, "re_insert() after insert: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); - ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s, + &el->el_scratch))); /* copy the characters */ for (a = d + dat; (a < d + dlen) && (num > 0); num--) @@ -420,7 +423,7 @@ re_delete(EditLine *el __attribute__((__ } ELRE_DEBUG(1, (__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); /* open up the space for num chars */ if (num > 0) { @@ -432,7 +435,7 @@ re_delete(EditLine *el __attribute__((__ } ELRE_DEBUG(1, (__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); } @@ -690,9 +693,9 @@ re_update_line(EditLine *el, Char *old, sx = (int)((nls - nse) - (ols - ose)); ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx)); - ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n", + ELRE_DEBUG(1, (__F, "ofd %td, osb %td, ose %td, ols %td, oe %td\n", ofd - old, osb - old, ose - old, ols - old, oe - old)); - ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n", + ELRE_DEBUG(1, (__F, "nfd %td, nsb %td, nse %td, nls %td, ne %td\n", nfd - new, nsb - new, nse - new, nls - new, ne - new)); ELRE_DEBUG(1, (__F, "xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n")); @@ -766,7 +769,7 @@ re_update_line(EditLine *el, Char *old, if ((nsb != nfd) && fx > 0 && ((p - old) + fx <= el->el_terminal.t_size.h)) { ELRE_DEBUG(1, - (__F, "first diff insert at %d...\r\n", nfd - new)); + (__F, "first diff insert at %td...\r\n", nfd - new)); /* * Move to the first char to insert, where the first diff is. */ @@ -805,7 +808,7 @@ re_update_line(EditLine *el, Char *old, } } else if (fx < 0) { ELRE_DEBUG(1, - (__F, "first diff delete at %d...\r\n", ofd - old)); + (__F, "first diff delete at %td...\r\n", ofd - old)); /* * move to the first char to delete where the first diff is */ @@ -852,7 +855,7 @@ re_update_line(EditLine *el, Char *old, if (sx < 0 && (ose - old) + fx < el->el_terminal.t_size.h) { ELRE_DEBUG(1, (__F, - "second diff delete at %d...\r\n", (ose - old) + fx)); + "second diff delete at %td...\r\n", (ose - old) + fx)); /* * Check if we have stuff to delete */ @@ -890,7 +893,7 @@ re_update_line(EditLine *el, Char *old, * if we have a first insert AND WE HAVEN'T ALREADY DONE IT... */ if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) { - ELRE_DEBUG(1, (__F, "late first diff insert at %d...\r\n", + ELRE_DEBUG(1, (__F, "late first diff insert at %td...\r\n", nfd - new)); terminal_move_to_char(el, (int)(nfd - new)); Modified: head/lib/libedit/terminal.c ============================================================================== --- head/lib/libedit/terminal.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/terminal.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: terminal.c,v 1.24 2016/03/22 01:38:17 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: terminal.c,v 1.24 2016/03/22 01:38:17 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -380,7 +380,7 @@ terminal_alloc(EditLine *el, const struc */ tlen = 0; for (tmp = tlist; tmp < &tlist[T_str]; tmp++) - if (*tmp != NULL && *tmp != '\0' && *tmp != *str) { + if (*tmp != NULL && **tmp != '\0' && *tmp != *str) { char *ptr; for (ptr = *tmp; *ptr != '\0'; termbuf[tlen++] = *ptr++) @@ -668,7 +668,7 @@ terminal_overwrite(EditLine *el, const C if (n > (size_t)el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "%s: n is ridiculous: %d\r\n", __func__, n); + "%s: n is ridiculous: %zu\r\n", __func__, n); #endif /* DEBUG_SCREEN */ return; } Modified: head/lib/libedit/tty.c ============================================================================== --- head/lib/libedit/tty.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/tty.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $ */ +/* $NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $"); +__RCSID("$NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -500,10 +500,12 @@ tty_setup(EditLine *el) { int rst = 1; - el->el_tty.t_initialized = 0; if (el->el_flags & EDIT_DISABLED) return 0; + if (el->el_tty.t_initialized) + return -1; + if (!isatty(el->el_outfd)) { #ifdef DEBUG_TTY (void) fprintf(el->el_errfile, "%s: isatty: %s\n", __func__, @@ -573,6 +575,7 @@ tty_init(EditLine *el) el->el_tty.t_mode = EX_IO; el->el_tty.t_vdisable = _POSIX_VDISABLE; + el->el_tty.t_initialized = 0; (void) memcpy(el->el_tty.t_t, ttyperm, sizeof(ttyperm_t)); (void) memcpy(el->el_tty.t_c, ttychar, sizeof(ttychar_t)); return tty_setup(el); @@ -589,7 +592,7 @@ tty_end(EditLine *el) if (el->el_flags & EDIT_DISABLED) return; - if (el->el_tty.t_initialized) + if (!el->el_tty.t_initialized) return; if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) { Modified: head/lib/libedit/vi.c ============================================================================== --- head/lib/libedit/vi.c Mon Jan 30 22:47:48 2017 (r313001) +++ head/lib/libedit/vi.c Mon Jan 30 23:00:51 2017 (r313002) @@ -1,4 +1,4 @@ -/* $NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: vi.c,v 1.55 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: vi.c,v 1.55 2016/03/02 19:24:20 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -105,7 +105,8 @@ cv_paste(EditLine *el, wint_t c) if (k->buf == NULL || len == 0) return CC_ERROR; #ifdef DEBUG_PASTE - (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf); + (void) fprintf(el->el_errfile, "Paste: \"" FSTARSTR "\"\n", (int)len, + k->buf); #endif cv_undo(el); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"