Author: pfg
Date: Sun Feb  7 01:45:24 2016
New Revision: 295361
URL: https://svnweb.freebsd.org/changeset/base/295361

Log:
  Tag import of libedit 2016-01-16.

Added:
  vendor/NetBSD/libedit/2016-01-16/
     - copied from r295359, vendor/NetBSD/libedit/dist/
Replaced:
  vendor/NetBSD/libedit/2016-01-16/Makefile
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/2016-01-16/chartype.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/chartype.c
  vendor/NetBSD/libedit/2016-01-16/chartype.h
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/chartype.h
  vendor/NetBSD/libedit/2016-01-16/editline.3
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/2016-01-16/el.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/2016-01-16/eln.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/eln.c
  vendor/NetBSD/libedit/2016-01-16/hist.h
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/2016-01-16/keymacro.h
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/keymacro.h
  vendor/NetBSD/libedit/2016-01-16/map.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/2016-01-16/readline.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/2016-01-16/readline/readline.h
     - copied unchanged from r295360, 
vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/2016-01-16/search.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/2016-01-16/tokenizer.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/2016-01-16/tty.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/2016-01-16/vi.c
     - copied unchanged from r295360, vendor/NetBSD/libedit/dist/vi.c

Copied: vendor/NetBSD/libedit/2016-01-16/Makefile (from r295360, 
vendor/NetBSD/libedit/dist/Makefile)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/libedit/2016-01-16/Makefile   Sun Feb  7 01:45:24 2016        
(r295361, copy of r295360, vendor/NetBSD/libedit/dist/Makefile)
@@ -0,0 +1,135 @@
+#      $NetBSD: Makefile,v 1.53 2015/01/29 20:30:02 joerg Exp $
+#      @(#)Makefile    8.1 (Berkeley) 6/4/93
+
+USE_SHLIBDIR=  yes
+
+WIDECHAR ?= yes
+WARNS?=        5
+LIB=   edit
+
+LIBDPLIBS+=     terminfo ${.CURDIR}/../libterminfo
+
+.include "bsd.own.mk"
+
+COPTS+=        -Wunused-parameter
+CWARNFLAGS.gcc+=       -Wconversion
+CWARNFLAGS.clang+=     -Wno-cast-qual
+
+OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
+       hist.c keymacro.c map.c chartype.c \
+       parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
+
+MAN=   editline.3 editrc.5
+
+MLINKS=        editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \
+       editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \
+       editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \
+       editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \
+       editline.3 el_insertstr.3 editline.3 el_deletestr.3 \
+       editline.3 history_init.3 editline.3 history_end.3 \
+       editline.3 history.3 \
+       editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \
+       editline.3 tok_line.3 editline.3 tok_str.3
+
+# For speed and debugging
+#SRCS=   ${OSRCS} readline.c tokenizer.c history.c
+# For protection
+SRCS=  editline.c readline.c tokenizer.c history.c
+
+.if ${WIDECHAR} == "yes"
+OSRCS += eln.c
+SRCS += tokenizern.c historyn.c
+CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
+CPPFLAGS+=-DWIDECHAR
+.endif
+
+LIBEDITDIR?=${.CURDIR}
+
+INCS= histedit.h
+INCSDIR=/usr/include
+
+CLEANFILES+=editline.c
+CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp
+CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1
+CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
+CPPFLAGS+=-I. -I${LIBEDITDIR} 
+CPPFLAGS+=-I. -I${.CURDIR}
+CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
+CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT
+
+AHDR=vi.h emacs.h common.h 
+ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
+
+DPSRCS+=       ${AHDR} fcns.h help.h fcns.c help.c
+CLEANFILES+=   ${AHDR} fcns.h help.h fcns.c help.c
+
+SUBDIR=        readline
+
+vi.h: vi.c makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \
+           > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+emacs.h: emacs.c makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \
+           > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+common.h: common.c makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \
+           > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+fcns.h: ${AHDR} makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+fcns.c: ${AHDR} fcns.h help.h makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+help.c: ${ASRC} makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+help.h: ${ASRC} makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+editline.c: ${OSRCS} makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+tokenizern.c: makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+historyn.c: makelist Makefile
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \
+           mv ${.TARGET}.tmp ${.TARGET}
+
+tc1.o: ${LIBEDITDIR}/TEST/tc1.c
+
+tc1:   libedit.a tc1.o 
+       ${_MKTARGET_LINK}
+       ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib
+
+.include <bsd.lib.mk>
+.include <bsd.subdir.mk>
+
+# XXX
+.if defined(HAVE_GCC)
+COPTS.editline.c+=     -Wno-cast-qual
+COPTS.tokenizer.c+=    -Wno-cast-qual
+COPTS.tokenizern.c+=   -Wno-cast-qual
+.endif

Copied: vendor/NetBSD/libedit/2016-01-16/chartype.c (from r295360, 
vendor/NetBSD/libedit/dist/chartype.c)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/libedit/2016-01-16/chartype.c Sun Feb  7 01:45:24 2016        
(r295361, copy of r295360, vendor/NetBSD/libedit/dist/chartype.c)
@@ -0,0 +1,364 @@
+/*     $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $   */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * chartype.c: character classification and meta information
+ */
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+__RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
+#endif /* not lint && not SCCSID */
+#include "el.h"
+#include <stdlib.h>
+
+#define CT_BUFSIZ ((size_t)1024)
+
+#ifdef WIDECHAR
+protected int
+ct_conv_cbuff_resize(ct_buffer_t *conv, size_t csize)
+{
+       void *p;
+
+       if (csize <= conv->csize)
+               return 0;
+
+       conv->csize = csize;
+
+       p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
+       if (p == NULL) {
+               conv->csize = 0;
+               el_free(conv->cbuff);
+               conv->cbuff = NULL;
+               return -1;
+       }
+       conv->cbuff = p;
+       return 0;
+}
+
+protected int
+ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
+{
+       void *p;
+
+       if (wsize <= conv->wsize) 
+               return 0;
+
+       conv->wsize = wsize;
+
+       p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
+       if (p == NULL) {
+               conv->wsize = 0;
+               el_free(conv->wbuff);
+               conv->wbuff = NULL;
+               return -1;
+       }
+       conv->wbuff = p;
+       return 0;
+}
+
+
+public char *
+ct_encode_string(const Char *s, ct_buffer_t *conv)
+{
+       char *dst;
+       ssize_t used;
+
+       if (!s)
+               return NULL;
+
+       dst = conv->cbuff;
+       for (;;) {
+               used = (ssize_t)(dst - conv->cbuff);
+               if ((conv->csize - (size_t)used) < 5) {
+                       if (ct_conv_cbuff_resize(conv,
+                           conv->csize + CT_BUFSIZ) == -1)
+                               return NULL;
+                       dst = conv->cbuff + used;
+               }
+               if (!*s)
+                       break;
+               used = ct_encode_char(dst, (size_t)5, *s);
+               if (used == -1) /* failed to encode, need more buffer space */
+                       abort();
+               ++s;
+               dst += used;
+       }
+       *dst = '\0';
+       return conv->cbuff;
+}
+
+public Char *
+ct_decode_string(const char *s, ct_buffer_t *conv)
+{
+       size_t len;
+
+       if (!s)
+               return NULL;
+
+       len = ct_mbstowcs(NULL, s, (size_t)0);
+       if (len == (size_t)-1)
+               return NULL;
+
+       if (conv->wsize < ++len)
+               if (ct_conv_wbuff_resize(conv, len + CT_BUFSIZ) == -1)
+                       return NULL;
+
+       ct_mbstowcs(conv->wbuff, s, conv->wsize);
+       return conv->wbuff;
+}
+
+
+protected Char **
+ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
+{
+       size_t bufspace;
+       int i;
+       Char *p;
+       Char **wargv;
+       ssize_t bytes;
+
+       /* Make sure we have enough space in the conversion buffer to store all
+        * the argv strings. */
+       for (i = 0, bufspace = 0; i < argc; ++i)
+               bufspace += argv[i] ? strlen(argv[i]) + 1 : 0;
+       if (conv->wsize < ++bufspace)
+               if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
+                       return NULL;
+
+       wargv = el_malloc((size_t)argc * sizeof(*wargv));
+
+       for (i = 0, p = conv->wbuff; i < argc; ++i) {
+               if (!argv[i]) {   /* don't pass null pointers to mbstowcs */
+                       wargv[i] = NULL;
+                       continue;
+               } else {
+                       wargv[i] = p;
+                       bytes = (ssize_t)mbstowcs(p, argv[i], bufspace);
+               }
+               if (bytes == -1) {
+                       el_free(wargv);
+                       return NULL;
+               } else
+                       bytes++;  /* include '\0' in the count */
+               bufspace -= (size_t)bytes;
+               p += bytes;
+       }
+
+       return wargv;
+}
+
+
+protected size_t
+ct_enc_width(Char c)
+{
+       /* UTF-8 encoding specific values */
+       if (c < 0x80)
+               return 1;
+       else if (c < 0x0800)
+               return 2;
+       else if (c < 0x10000)
+               return 3;
+       else if (c < 0x110000)
+               return 4;
+       else
+               return 0; /* not a valid codepoint */
+}
+
+protected ssize_t
+ct_encode_char(char *dst, size_t len, Char c)
+{
+       ssize_t l = 0;
+       if (len < ct_enc_width(c))
+               return -1;
+       l = ct_wctomb(dst, c);
+
+       if (l < 0) {
+               ct_wctomb_reset;
+               l = 0;
+       }
+       return l;
+}
+#endif
+
+protected const Char *
+ct_visual_string(const Char *s)
+{
+       static Char *buff = NULL;
+       static size_t buffsize = 0;
+       void *p;
+       Char *dst;
+       ssize_t used = 0;
+
+       if (!s)
+               return NULL;
+       if (!buff) {
+           buffsize = CT_BUFSIZ;
+           buff = el_malloc(buffsize * sizeof(*buff));
+       }
+       dst = buff;
+       while (*s) {
+               used = ct_visual_char(dst, buffsize - (size_t)(dst - buff), *s);
+               if (used == -1) { /* failed to encode, need more buffer space */
+                       used = dst - buff;
+                       buffsize += CT_BUFSIZ;
+                       p = el_realloc(buff, buffsize * sizeof(*buff));
+                       if (p == NULL)
+                               goto out;
+                       buff = p;
+                       dst = buff + used;
+                       /* don't increment s here - we want to retry it! */
+               }
+               else
+                   ++s;
+               dst += used;
+       }
+       if (dst >= (buff + buffsize)) { /* sigh */
+               buffsize += 1;
+               p = el_realloc(buff, buffsize * sizeof(*buff));
+               if (p == NULL)
+                       goto out;
+               buff = p;
+               dst = buff + buffsize - 1;
+       }
+       *dst = 0;
+       return buff;
+out:
+       el_free(buff);
+       buffsize = 0;
+       return NULL;
+}
+
+
+
+protected int
+ct_visual_width(Char c)
+{
+       int t = ct_chr_class(c);
+       switch (t) {
+       case CHTYPE_ASCIICTL:
+               return 2; /* ^@ ^? etc. */
+       case CHTYPE_TAB:
+               return 1; /* Hmm, this really need to be handled outside! */
+       case CHTYPE_NL:
+               return 0; /* Should this be 1 instead? */
+#ifdef WIDECHAR
+       case CHTYPE_PRINT:
+               return wcwidth(c);
+       case CHTYPE_NONPRINT:
+               if (c > 0xffff) /* prefer standard 4-byte display over 5-byte */
+                       return 8; /* \U+12345 */
+               else
+                       return 7; /* \U+1234 */
+#else
+       case CHTYPE_PRINT:
+               return 1;
+       case CHTYPE_NONPRINT:
+               return 4; /* \123 */
+#endif
+       default:
+               return 0; /* should not happen */
+       }
+}
+
+
+protected ssize_t
+ct_visual_char(Char *dst, size_t len, Char c)
+{
+       int t = ct_chr_class(c);
+       switch (t) {
+       case CHTYPE_TAB:
+       case CHTYPE_NL:
+       case CHTYPE_ASCIICTL:
+               if (len < 2)
+                       return -1;   /* insufficient space */
+               *dst++ = '^';
+               if (c == '\177')
+                       *dst = '?'; /* DEL -> ^? */
+               else
+                       *dst = c | 0100;    /* uncontrolify it */
+               return 2;
+       case CHTYPE_PRINT:
+               if (len < 1)
+                       return -1;  /* insufficient space */
+               *dst = c;
+               return 1;
+       case CHTYPE_NONPRINT:
+               /* we only use single-width glyphs for display,
+                * so this is right */
+               if ((ssize_t)len < ct_visual_width(c))
+                       return -1;   /* insufficient space */
+#ifdef WIDECHAR
+               *dst++ = '\\';
+               *dst++ = 'U';
+               *dst++ = '+';
+#define tohexdigit(v) "0123456789ABCDEF"[v]
+               if (c > 0xffff) /* prefer standard 4-byte display over 5-byte */
+                       *dst++ = tohexdigit(((unsigned int) c >> 16) & 0xf);
+               *dst++ = tohexdigit(((unsigned int) c >> 12) & 0xf);
+               *dst++ = tohexdigit(((unsigned int) c >>  8) & 0xf);
+               *dst++ = tohexdigit(((unsigned int) c >>  4) & 0xf);
+               *dst   = tohexdigit(((unsigned int) c      ) & 0xf);
+               return c > 0xffff ? 8 : 7;
+#else
+               *dst++ = '\\';
+#define tooctaldigit(v) ((v) + '0')
+               *dst++ = tooctaldigit(((unsigned int) c >> 6) & 0x7);
+               *dst++ = tooctaldigit(((unsigned int) c >> 3) & 0x7);
+               *dst++ = tooctaldigit(((unsigned int) c     ) & 0x7);
+#endif
+               /*FALLTHROUGH*/
+       /* these two should be handled outside this function */
+       default:            /* we should never hit the default */
+               return 0;
+       }
+}
+
+
+
+
+protected int
+ct_chr_class(Char c)
+{
+       if (c == '\t')
+               return CHTYPE_TAB;
+       else if (c == '\n')
+               return CHTYPE_NL;
+       else if (IsASCII(c) && Iscntrl(c))
+               return CHTYPE_ASCIICTL;
+       else if (Isprint(c))
+               return CHTYPE_PRINT;
+       else
+               return CHTYPE_NONPRINT;
+}

Copied: vendor/NetBSD/libedit/2016-01-16/chartype.h (from r295360, 
vendor/NetBSD/libedit/dist/chartype.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/libedit/2016-01-16/chartype.h Sun Feb  7 01:45:24 2016        
(r295361, copy of r295360, vendor/NetBSD/libedit/dist/chartype.h)
@@ -0,0 +1,254 @@
+/*     $NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $   */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _h_chartype_f
+#define _h_chartype_f
+
+
+
+#ifdef WIDECHAR
+
+/* Ideally we should also test the value of the define to see if it
+ * supports non-BMP code points without requiring UTF-16, but nothing
+ * seems to actually advertise this properly, despite Unicode 3.1 having
+ * been around since 2001... */
+#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && 
defined(__MACH__)) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#ifndef __STDC_ISO_10646__
+/* In many places it is assumed that the first 127 code points are ASCII
+ * compatible, so ensure wchar_t indeed does ISO 10646 and not some other
+ * funky encoding that could break us in weird and wonderful ways. */
+       #error wchar_t must store ISO 10646 characters
+#endif
+#endif
+
+/* Oh for a <uchar.h> with char32_t and __STDC_UTF_32__ in it...
+ * ref: ISO/IEC DTR 19769
+ */
+#if WCHAR_MAX < INT32_MAX
+#warning Build environment does not support non-BMP characters
+#endif
+
+#define ct_mbtowc            mbtowc
+#define ct_mbtowc_reset      mbtowc(0,0,(size_t)0)
+#define ct_wctomb            wctomb
+#define ct_wctomb_reset      wctomb(0,0)
+#define ct_wcstombs          wcstombs
+#define ct_mbstowcs          mbstowcs
+
+#define Char                   wchar_t
+#define Int                    wint_t
+#define FUN(prefix,rest)       prefix ## _w ## rest
+#define FUNW(type)             type ## _w
+#define TYPE(type)             type ## W
+#define FCHAR                  "%lc"
+#define FSTR                   "%ls"
+#define STR(x)                         L ## x
+#define UC(c)                  c
+#define Isalpha(x)  iswalpha(x)
+#define Isalnum(x)  iswalnum(x)
+#define Isgraph(x)  iswgraph(x)
+#define Isspace(x)  iswspace(x)
+#define Isdigit(x)  iswdigit(x)
+#define Iscntrl(x)  iswcntrl(x)
+#define Isprint(x)  iswprint(x)
+
+#define Isupper(x)  iswupper(x)
+#define Islower(x)  iswlower(x)
+#define Toupper(x)  towupper(x)
+#define Tolower(x)  towlower(x)
+
+#define IsASCII(x)  (x < 0x100)
+
+#define Strlen(x)       wcslen(x)
+#define Strchr(s,c)     wcschr(s,c)
+#define Strrchr(s,c)    wcsrchr(s,c)
+#define Strstr(s,v)     wcsstr(s,v)
+#define Strdup(x)       wcsdup(x)
+#define Strcpy(d,s)     wcscpy(d,s)
+#define Strncpy(d,s,n)  wcsncpy(d,s,n)
+#define Strncat(d,s,n)  wcsncat(d,s,n)
+
+#define Strcmp(s,v)     wcscmp(s,v)
+#define Strncmp(s,v,n)  wcsncmp(s,v,n)
+#define Strcspn(s,r)    wcscspn(s,r)
+
+#define Strtol(p,e,b)   wcstol(p,e,b)
+
+static inline int
+Width(wchar_t c)
+{
+       int w = wcwidth(c);
+       return w < 0 ? 0 : w;
+}
+
+#else /* NARROW */
+
+#define ct_mbtowc            error
+#define ct_mbtowc_reset      
+#define ct_wctomb            error
+#define ct_wctomb_reset      
+#define ct_wcstombs(a, b, c)    (strncpy(a, b, c), strlen(a))
+#define ct_mbstowcs(a, b, c)    (strncpy(a, b, c), strlen(a))
+
+#define Char                   char
+#define Int                    int
+#define FUN(prefix,rest)       prefix ## _ ## rest
+#define FUNW(type)             type
+#define TYPE(type)             type
+#define FCHAR                  "%c"
+#define FSTR                   "%s"
+#define STR(x)                         x
+#define UC(c)                  (unsigned char)(c)
+
+#define Isalpha(x)  isalpha((unsigned char)x)
+#define Isalnum(x)  isalnum((unsigned char)x)
+#define Isgraph(x)  isgraph((unsigned char)x)
+#define Isspace(x)  isspace((unsigned char)x)
+#define Isdigit(x)  isdigit((unsigned char)x)
+#define Iscntrl(x)  iscntrl((unsigned char)x)
+#define Isprint(x)  isprint((unsigned char)x)
+
+#define Isupper(x)  isupper((unsigned char)x)
+#define Islower(x)  islower((unsigned char)x)
+#define Toupper(x)  toupper((unsigned char)x)
+#define Tolower(x)  tolower((unsigned char)x)
+
+#define IsASCII(x)  isascii((unsigned char)x)
+
+#define Strlen(x)       strlen(x)
+#define Strchr(s,c)     strchr(s,c)
+#define Strrchr(s,c)    strrchr(s,c)
+#define Strstr(s,v)     strstr(s,v)
+#define Strdup(x)       strdup(x)
+#define Strcpy(d,s)     strcpy(d,s)
+#define Strncpy(d,s,n)  strncpy(d,s,n)
+#define Strncat(d,s,n)  strncat(d,s,n)
+
+#define Strcmp(s,v)     strcmp(s,v)
+#define Strncmp(s,v,n)  strncmp(s,v,n)
+#define Strcspn(s,r)    strcspn(s,r)
+
+#define Strtol(p,e,b)   strtol(p,e,b)
+
+#define Width(c)       1
+
+#endif
+
+
+#ifdef WIDECHAR
+/*
+ * Conversion buffer
+ */
+typedef struct ct_buffer_t {
+        char    *cbuff;
+        size_t  csize;
+        Char *wbuff;
+        size_t  wsize;
+} ct_buffer_t;
+
+#define ct_encode_string __ct_encode_string
+/* Encode a wide-character string and return the UTF-8 encoded result. */
+public char *ct_encode_string(const Char *, ct_buffer_t *);
+
+#define ct_decode_string __ct_decode_string
+/* Decode a (multi)?byte string and return the wide-character string result. */
+public Char *ct_decode_string(const char *, ct_buffer_t *);
+
+/* Decode a (multi)?byte argv string array.
+ * The pointer returned must be free()d when done. */
+protected Char **ct_decode_argv(int, const char *[],  ct_buffer_t *);
+
+/* Resizes the conversion buffer(s) if needed. */
+protected int ct_conv_cbuff_resize(ct_buffer_t *, size_t);
+protected int ct_conv_wbuff_resize(ct_buffer_t *, size_t);
+protected ssize_t ct_encode_char(char *, size_t, Char);
+protected size_t ct_enc_width(Char);
+
+#define ct_free_argv(s)        el_free(s)
+
+#else
+#define        ct_encode_string(s, b)  (s)
+#define ct_decode_string(s, b) (s)
+#define ct_decode_argv(l, s, b)        (s)
+#define ct_conv_cbuff_resize(b, s) ((s) == (0))
+#define ct_conv_wbuff_resize(b, s) ((s) == (0))
+#define ct_encode_char(d, l, s)        (*d = s, 1)
+#define ct_free_argv(s)
+#endif
+
+#ifndef NARROWCHAR
+/* Encode a characted into the destination buffer, provided there is sufficent
+ * buffer space available. Returns the number of bytes used up (zero if the
+ * character cannot be encoded, -1 if there was not enough space available). */
+
+/* The maximum buffer size to hold the most unwieldly visual representation,
+ * in this case \U+nnnnn. */
+#define VISUAL_WIDTH_MAX ((size_t)8)
+
+/* The terminal is thought of in terms of X columns by Y lines. In the cases
+ * where a wide character takes up more than one column, the adjacent 
+ * occupied column entries will contain this faux character. */
+#define MB_FILL_CHAR ((Char)-1)
+
+/* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn
+ * style visual expansions. */
+protected int ct_visual_width(Char);
+
+/* Turn the given character into the appropriate visual format, matching
+ * the width given by ct_visual_width(). Returns the number of characters used
+ * up, or -1 if insufficient space. Buffer length is in count of Char's. */
+protected ssize_t ct_visual_char(Char *, size_t, Char);
+
+/* Convert the given string into visual format, using the ct_visual_char()
+ * function. Uses a static buffer, so not threadsafe. */
+protected const Char *ct_visual_string(const Char *);
+
+
+/* printable character, use ct_visual_width() to find out display width */
+#define CHTYPE_PRINT        ( 0)
+/* control character found inside the ASCII portion of the charset */
+#define CHTYPE_ASCIICTL     (-1)
+/* a \t */
+#define CHTYPE_TAB          (-2)
+/* a \n */
+#define CHTYPE_NL           (-3)
+/* non-printable character */
+#define CHTYPE_NONPRINT     (-4)
+/* classification of character c, as one of the above defines */
+protected int ct_chr_class(Char c);
+#endif
+
+
+#endif /* _chartype_f */

Copied: vendor/NetBSD/libedit/2016-01-16/editline.3 (from r295360, 
vendor/NetBSD/libedit/dist/editline.3)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor/NetBSD/libedit/2016-01-16/editline.3 Sun Feb  7 01:45:24 2016        
(r295361, copy of r295360, vendor/NetBSD/libedit/dist/editline.3)
@@ -0,0 +1,937 @@
+.\"    $NetBSD: editline.3,v 1.85 2015/11/03 21:36:59 christos Exp $
+.\"
+.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
+.\"
+.\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+.\"
+.Dd November 3, 2015
+.Dt EDITLINE 3
+.Os
+.Sh NAME
+.Nm editline ,
+.Nm el_init ,
+.Nm el_init_fd ,
+.Nm el_end ,
+.Nm el_reset ,
+.Nm el_gets ,
+.Nm el_wgets ,
+.Nm el_getc ,
+.Nm el_wgetc ,
+.Nm el_push ,
+.Nm el_wpush ,
+.Nm el_parse ,
+.Nm el_wparse ,
+.Nm el_set ,
+.Nm el_wset ,
+.Nm el_get ,
+.Nm el_wget ,
+.Nm el_source ,
+.Nm el_resize ,
+.Nm el_cursor ,
+.Nm el_line ,
+.Nm el_wline ,
+.Nm el_insertstr ,
+.Nm el_winsertstr ,
+.Nm el_deletestr ,
+.Nm el_wdeletestr ,
+.Nm history_init ,
+.Nm history_winit ,
+.Nm history_end ,
+.Nm history_wend ,
+.Nm history ,
+.Nm history_w ,
+.Nm tok_init ,
+.Nm tok_winit ,
+.Nm tok_end ,
+.Nm tok_wend ,
+.Nm tok_reset ,
+.Nm tok_wreset ,
+.Nm tok_line ,
+.Nm tok_wline ,
+.Nm tok_str
+.Nm tok_wstr
+.Nd line editor, history and tokenization functions
+.Sh LIBRARY
+.Lb libedit
+.Sh SYNOPSIS
+.In histedit.h
+.Ft EditLine *
+.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
+.Ft EditLine *
+.Fn el_init_fd "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr" "int 
fdin" "int fdout" "int fderr"
+.Ft void
+.Fn el_end "EditLine *e"
+.Ft void
+.Fn el_reset "EditLine *e"
+.Ft const char *
+.Fn el_gets "EditLine *e" "int *count"
+.Ft const wchar_t *
+.Fn el_wgets "EditLine *e" "int *count"
+.Ft int
+.Fn el_getc "EditLine *e" "char *ch"
+.Ft int
+.Fn el_wgetc "EditLine *e" "wchar_t *ch"
+.Ft void
+.Fn el_push "EditLine *e" "const char *str"
+.Ft void
+.Fn el_wpush "EditLine *e" "const wchar_t *str"
+.Ft int
+.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
+.Ft int
+.Fn el_wparse "EditLine *e" "int argc" "const wchar_t *argv[]"
+.Ft int
+.Fn el_set "EditLine *e" "int op" "..."
+.Ft int
+.Fn el_wset "EditLine *e" "int op" "..."
+.Ft int
+.Fn el_get "EditLine *e" "int op" "..."
+.Ft int
+.Fn el_wget "EditLine *e" "int op" "..."
+.Ft int
+.Fn el_source "EditLine *e" "const char *file"
+.Ft void
+.Fn el_resize "EditLine *e"
+.Fn int
+.Fn el_cursor "EditLine *e" "int count"
+.Ft const LineInfo *
+.Fn el_line "EditLine *e"
+.Ft const LineInfoW *
+.Fn el_wline "EditLine *e"
+.Ft int
+.Fn el_insertstr "EditLine *e" "const char *str"
+.Ft int
+.Fn el_winsertstr "EditLine *e" "const wchar_t *str"
+.Ft void
+.Fn el_deletestr "EditLine *e" "int count"
+.Ft void
+.Fn el_wdeletestr "EditLine *e" "int count"
+.Ft History *
+.Fn history_init
+.Ft HistoryW *
+.Fn history_winit
+.Ft void
+.Fn history_end "History *h"
+.Ft void
+.Fn history_wend "HistoryW *h"
+.Ft int
+.Fn history "History *h" "HistEvent *ev" "int op" "..."
+.Ft int
+.Fn history_w "HistoryW *h" "HistEventW *ev" "int op" "..."
+.Ft Tokenizer *
+.Fn tok_init "const char *IFS"
+.Ft TokenizerW *
+.Fn tok_winit "const wchar_t *IFS"
+.Ft void
+.Fn tok_end "Tokenizer *t"
+.Ft void
+.Fn tok_wend "TokenizerW *t"
+.Ft void
+.Fn tok_reset "Tokenizer *t"
+.Ft void
+.Fn tok_wreset "TokenizerW *t"
+.Ft int
+.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char 
**argv[]" "int *cursorc" "int *cursoro"
+.Ft int
+.Fn tok_wline "TokenizerW *t" "const LineInfoW *li" "int *argc" "const wchar_t 
**argv[]" "int *cursorc" "int *cursoro"
+.Ft int
+.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
+.Ft int
+.Fn tok_wstr "TokenizerW *t" "const wchar_t *str" "int *argc" "const wchar_t 
**argv[]"
+.Sh DESCRIPTION
+The
+.Nm
+library provides generic line editing, history and tokenization functions,
+similar to those found in
+.Xr sh 1 .
+.Pp
+These functions are available in the
+.Nm libedit
+library (which needs the
+.Nm libtermcap
+library).
+Programs should be linked with
+.Fl ledit ltermcap .
+.Sh LINE EDITING FUNCTIONS
+The line editing functions use a common data structure,
+.Fa EditLine ,
+which is created by
+.Fn el_init
+or
+.Fn el_init_fd
+and freed by
+.Fn el_end .
+.Pp
+The wide-character functions behave the same way as their narrow
+counterparts.
+.Pp
+The following functions are available:
+.Bl -tag -width 4n
+.It Fn el_init
+Initialize the line editor, and return a data structure
+to be used by all other line editing functions, or
+.Dv NULL
+on failure.
+.Fa prog
+is the name of the invoking program, used when reading the
+.Xr editrc 5
+file to determine which settings to use.
+.Fa fin ,
+.Fa fout
+and
+.Fa ferr
+are the input, output, and error streams (respectively) to use.
+In this documentation, references to
+.Dq the tty
+are actually to this input/output stream combination.
+.It Fn el_init_fd
+Like
+.Fn el_init
+but allows specifying file descriptors for the
+.Xr stdio 3
+corresponding streams, in case those were created with
+.Xr funopen 3 .
+.It Fn el_end
+Clean up and finish with
+.Fa e ,
+assumed to have been created with
+.Fn el_init
+or
+.Fn el_init_fd .
+.It Fn el_reset
+Reset the tty and the parser.
+This should be called after an error which may have upset the tty's
+state.
+.It Fn el_gets
+Read a line from the tty.
+.Fa count
+is modified to contain the number of characters read.
+Returns the line read if successful, or
+.Dv NULL
+if no characters were read or if an error occurred.
+If an error occurred,
+.Fa count
+is set to \-1 and

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to