Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/lib/libedit Pull up following revision(s) (requested by k...



details:   https://anonhg.NetBSD.org/src/rev/0752c19c44c5
branches:  netbsd-8
changeset: 850845:0752c19c44c5
user:      snj <snj%NetBSD.org@localhost>
date:      Sun Jul 23 14:41:26 2017 +0000

description:
Pull up following revision(s) (requested by kre in ticket #102):
        lib/libedit/Makefile: 1.64-1.65
        lib/libedit/editline.3: 1.94-1.96
        lib/libedit/editrc.5: 1.33
        lib/libedit/el.c: 1.93-1.94
        lib/libedit/el.h: 1.42
        lib/libedit/literal.c: 1.1-1.3
        lib/libedit/literal.h: 1.1-1.2
        lib/libedit/prompt.c: 1.27
        lib/libedit/read.c: 1.103
        lib/libedit/refresh.c: 1.52-1.54
        lib/libedit/refresh.h: 1.11
        lib/libedit/terminal.c: 1.33
Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise.    Better support for this in sh coming.
--
Include EDITRC in doc.
--
mention the limitation of the literal sequence delimiter.
--
- handle literal escape sequence printing.
- factor out common code in allocation and freeing of the display.
--
- add literal sequence handling.
--
remove unused variable
--
add literal escape sequence support, patterned after the tcsh ones.
--
fix comment
--
Fix an obvious, but almost invisible typo (avoid some core dumps).
--
Allow wide characters (properly encoded as byte strings according to LC_CTYPE)
to be (perhaps part of) the "invisible" characters in a prompt, or the
required prompt character which follows the literal sequence (this character
must be one with a printing column width >= 1).  The literal indicator
character (which is just a marker, and not printed anywhere) (the PSlit
parameter in sh(1)) can also be a wide char (passed to libedit as a wchar_t,
encoded as that by sh(1) or other applications that support this.)
Note: this has currently only been tested with everything ascii (C locale).
--
Remove workaround for ancient HTML generation code.

diffstat:

 lib/libedit/Makefile   |    5 +-
 lib/libedit/editline.3 |   10 ++-
 lib/libedit/editrc.5   |   12 +++-
 lib/libedit/el.c       |   33 +++++++----
 lib/libedit/el.h       |    8 +-
 lib/libedit/literal.c  |  136 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libedit/literal.h  |   53 +++++++++++++++++++
 lib/libedit/prompt.c   |   19 +++--
 lib/libedit/read.c     |    7 +-
 lib/libedit/refresh.c  |   54 +++++++++++++++---
 lib/libedit/refresh.h  |    4 +-
 lib/libedit/terminal.c |   99 +++++++++++++++++------------------
 12 files changed, 344 insertions(+), 96 deletions(-)

diffs (truncated from 758 to 300 lines):

diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/Makefile
--- a/lib/libedit/Makefile      Thu Jul 20 01:24:13 2017 +0000
+++ b/lib/libedit/Makefile      Sun Jul 23 14:41:26 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.63 2016/05/24 17:42:54 christos Exp $
+#      $NetBSD: Makefile,v 1.63.8.1 2017/07/23 14:41:26 snj Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
@@ -15,7 +15,7 @@
 CWARNFLAGS.clang+=     -Wno-cast-qual
 
 SRCS = chared.c chartype.c common.c el.c eln.c emacs.c filecomplete.c \
-       hist.c history.c historyn.c keymacro.c map.c \
+       hist.c history.c historyn.c keymacro.c literal.c map.c \
        parse.c prompt.c read.c readline.c refresh.c search.c sig.c \
        terminal.c tokenizer.c tokenizern.c tty.c vi.c
 
@@ -133,6 +133,7 @@
 # XXX
 .if defined(HAVE_GCC)
 COPTS.editline.c+=     -Wno-cast-qual
+COPTS.literal.c+=      -Wno-sign-conversion
 COPTS.tokenizer.c+=    -Wno-cast-qual
 COPTS.tokenizern.c+=   -Wno-cast-qual
 .endif
diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/editline.3
--- a/lib/libedit/editline.3    Thu Jul 20 01:24:13 2017 +0000
+++ b/lib/libedit/editline.3    Sun Jul 23 14:41:26 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: editline.3,v 1.93 2017/04/10 15:02:40 abhinav Exp $
+.\"    $NetBSD: editline.3,v 1.93.4.1 2017/07/23 14:41:26 snj Exp $
 .\"
 .\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 22, 2016
+.Dd June 27, 2017
 .Dt EDITLINE 3
 .Os
 .Sh NAME
@@ -358,6 +358,8 @@
 A subsequent second start/stop literal character ends this behavior.
 This is typically used to embed literal escape sequences that change the
 color/style of the terminal in the prompt.
+Note that the literal escape character cannot be the last character in the
+prompt, as the escape sequence is attached to the next character in the prompt.
 .Dv 0
 unsets it.
 .It Dv EL_REFRESH
@@ -667,6 +669,8 @@
 is
 .Dv NULL ,
 try
+.Pa $EDITRC
+and if that is not set
 .Pa $HOME/.editrc .
 Refer to
 .Xr editrc 5
@@ -856,7 +860,7 @@
 .El
 .Pp
 .Fn history
-returns \*[Gt]= 0 if the operation
+returns >= 0 if the operation
 .Fa op
 succeeds.
 Otherwise, \-1 is returned and
diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/editrc.5
--- a/lib/libedit/editrc.5      Thu Jul 20 01:24:13 2017 +0000
+++ b/lib/libedit/editrc.5      Sun Jul 23 14:41:26 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: editrc.5,v 1.32 2016/05/22 23:54:20 christos Exp $
+.\"    $NetBSD: editrc.5,v 1.32.8.1 2017/07/23 14:41:26 snj Exp $
 .\"
 .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -293,10 +293,18 @@
 List the values of all the terminal capabilities (see
 .Xr termcap 5 ) .
 .El
+.Sh ENVIRONMENT
+.Bl -tag -width "~/.editrcXXX"
+.It Ev EDITRC
+Names the default configuration file for the
+.Xr editline 3
+library.
+.El
 .Sh FILES
 .Bl -tag -width "~/.editrcXXX"
 .It Pa ~/.editrc
-User configuration file for the
+Last resort, if no other file is specified,
+user configuration file for the
 .Xr editline 3
 library.
 .El
diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/el.c
--- a/lib/libedit/el.c  Thu Jul 20 01:24:13 2017 +0000
+++ b/lib/libedit/el.c  Sun Jul 23 14:41:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.92 2016/05/22 19:44:26 christos Exp $ */
+/*     $NetBSD: el.c,v 1.92.8.1 2017/07/23 14:41:26 snj Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.92 2016/05/22 19:44:26 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.92.8.1 2017/07/23 14:41:26 snj Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -115,6 +115,7 @@
        (void) hist_init(el);
        (void) prompt_init(el);
        (void) sig_init(el);
+       (void) literal_init(el);
        if (read_init(el) == -1) {
                el_end(el);
                return NULL;
@@ -146,6 +147,7 @@
        hist_end(el);
        prompt_end(el);
        sig_end(el);
+       literal_end(el);
 
        el_free(el->el_prog);
        el_free(el->el_visual.cbuff);
@@ -524,18 +526,22 @@
        fp = NULL;
        if (fname == NULL) {
 #ifdef HAVE_ISSETUGID
-               static const char elpath[] = "/.editrc";
-               size_t plen = sizeof(elpath);
-
                if (issetugid())
                        return -1;
-               if ((ptr = getenv("HOME")) == NULL)
-                       return -1;
-               plen += strlen(ptr);
-               if ((path = el_malloc(plen * sizeof(*path))) == NULL)
-                       return -1;
-               (void)snprintf(path, plen, "%s%s", ptr, elpath);
-               fname = path;
+
+               if ((fname = getenv("EDITRC")) == NULL) {
+                       static const char elpath[] = "/.editrc";
+                       size_t plen = sizeof(elpath);
+
+                       if ((ptr = getenv("HOME")) == NULL)
+                               return -1;
+                       plen += strlen(ptr);
+                       if ((path = el_malloc(plen * sizeof(*path))) == NULL)
+                               return -1;
+                       (void)snprintf(path, plen, "%s%s", ptr,
+                               elpath + (*ptr == '\0'));
+                       fname = path;
+               }
 #else
                /*
                 * If issetugid() is missing, always return an error, in order
@@ -545,6 +551,9 @@
                return -1;
 #endif
        }
+       if (fname[0] == '\0')
+               return -1;
+
        if (fp == NULL)
                fp = fopen(fname, "r");
        if (fp == NULL) {
diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/el.h
--- a/lib/libedit/el.h  Thu Jul 20 01:24:13 2017 +0000
+++ b/lib/libedit/el.h  Sun Jul 23 14:41:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.h,v 1.41 2016/05/24 15:00:45 christos Exp $ */
+/*     $NetBSD: el.h,v 1.41.8.1 2017/07/23 14:41:26 snj Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -94,6 +94,7 @@
 
 #include "tty.h"
 #include "prompt.h"
+#include "literal.h"
 #include "keymacro.h"
 #include "terminal.h"
 #include "refresh.h"
@@ -115,8 +116,8 @@
        int               el_errfd;     /* Error file descriptor        */
        int               el_flags;     /* Various flags.               */
        coord_t           el_cursor;    /* Cursor location              */
-       wchar_t         **el_display;   /* Real screen image = what is there */
-       wchar_t         **el_vdisplay;  /* Virtual screen image = what we see */
+       wint_t          **el_display;   /* Real screen image = what is there */
+       wint_t          **el_vdisplay;  /* Virtual screen image = what we see */
        void             *el_data;      /* Client data                  */
        el_line_t         el_line;      /* The current line information */
        el_state_t        el_state;     /* Current editor state         */
@@ -125,6 +126,7 @@
        el_refresh_t      el_refresh;   /* Refresh stuff                */
        el_prompt_t       el_prompt;    /* Prompt stuff                 */
        el_prompt_t       el_rprompt;   /* Prompt stuff                 */
+       el_literal_t      el_literal;   /* prompt literal bits          */
        el_chared_t       el_chared;    /* Characted editor stuff       */
        el_map_t          el_map;       /* Key mapping stuff            */
        el_keymacro_t     el_keymacro;  /* Key binding stuff            */
diff -r 011c9e8cec4b -r 0752c19c44c5 lib/libedit/literal.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libedit/literal.c     Sun Jul 23 14:41:26 2017 +0000
@@ -0,0 +1,136 @@
+/*     $NetBSD: literal.c,v 1.3.4.2 2017/07/23 14:41:26 snj Exp $      */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+__RCSID("$NetBSD: literal.c,v 1.3.4.2 2017/07/23 14:41:26 snj Exp $");
+#endif /* not lint && not SCCSID */
+
+/*
+ * literal.c: Literal sequences handling.
+ */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "el.h"
+
+libedit_private void
+literal_init(EditLine *el)
+{
+       el_literal_t *l = &el->el_literal;
+
+       memset(l, 0, sizeof(*l));
+}
+
+libedit_private void
+literal_end(EditLine *el)
+{
+       literal_clear(el);
+}
+
+libedit_private void
+literal_clear(EditLine *el)
+{
+       el_literal_t *l = &el->el_literal;
+       size_t i;
+
+       if (l->l_len == 0)
+               return;
+
+       for (i = 0; i < l->l_idx; i++)
+               el_free(l->l_buf[i]);
+       el_free(l->l_buf);
+       l->l_buf = NULL;
+       l->l_len = 0;
+       l->l_idx = 0;
+}
+
+libedit_private wint_t
+literal_add(EditLine *el, const wchar_t *buf, const wchar_t *end, int *wp)
+{
+       el_literal_t *l = &el->el_literal;
+       size_t i, len;
+       ssize_t w, n;
+       char *b;



Home | Main Index | Thread Index | Old Index