diff --git a/bin/sh/Makefile b/bin/sh/Makefile index 38c372f..daac731 100644 --- a/bin/sh/Makefile +++ b/bin/sh/Makefile @@ -19,7 +19,7 @@ # utilities of the same name are handled with the associated manpage, # builtin.1 in share/man/man1/. -LIBADD= edit +LIBADD=edit CFLAGS+=-DSHELL -I. -I${.CURDIR} # for debug: @@ -30,7 +30,7 @@ .PATH: ${.CURDIR}/bltin \ ${.CURDIR:H}/kill \ ${.CURDIR:H}/test \ - ${SRCTOP}/usr.bin/printf + ${.CURDIR:H}/printf CLEANFILES+= mknodes mknodes.o \ mksyntax mksyntax.o diff --git a/bin/sh/Makefile.depend b/bin/sh/Makefile.depend index 2228483..c4b869e 100644 --- a/bin/sh/Makefile.depend +++ b/bin/sh/Makefile.depend @@ -2,16 +2,8 @@ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ lib/libedit \ - lib/ncurses/ncursesw \ - + lib/libc \ .include diff --git a/bin/sh/sh.1.gz b/bin/sh/sh.1.gz deleted file mode 100644 index b5b292c..0000000 --- a/bin/sh/sh.1.gz +++ /dev/null Binary files differ diff --git a/lib/csu/Makefile b/lib/csu/Makefile index 762732f..8c3a31f 100644 --- a/lib/csu/Makefile +++ b/lib/csu/Makefile @@ -1,36 +1,9 @@ -# $Id: Makefile 141 2016-01-17 02:05:18Z reddawg $ -# The System Makefile (C) 2002 The UbixOS Project +# $FreeBSD: releng/11.1/lib/csu/Makefile 283125 2015-05-19 21:00:53Z emaste $ -# Include Global 'Source' Options -include ../../Makefile.incl -include ../Makefile.incl +.if exists(${.CURDIR}/${MACHINE_ARCH}) +SUBDIR+= ${MACHINE_ARCH} +.else +SUBDIR+= ${MACHINE_CPUARCH} +.endif -CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -Wno-uninitialized -O2 -fno-strict-aliasing -pipe -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls #-DGCRT - -INCLUDES+= -I../libc_old/include - -#Objects -OBJS = crtn.o crti.o crt1.o crtbrand.o - -all: $(OBJS) - -# Compile the source files -.cc.o: - $(CXX) $(CFLAGS) -Wall -nostdlib -O $(INCLUDES) -c -o $@ $< - -.cc.s: - $(CXX) $(CFLAGS) -Wall -nostdlib -O $(INCLUDES) -S -o $@ $< - -.c.o: - $(CC) $(CFLAGS) -Wall -nostdlib -O $(INCLUDES) -c $< - -.c.s: - $(CC) $(CFLAGS) -Wall -nostdlib -O $(INCLUDES) -S -o $@ $< - -.S.o: - $(CC) $(CFLAGS) -Wall -nostdlib -c -o $@ $< - -# Clean up the junk -clean: - $(REMOVE) $(OBJS) - +.include diff --git a/lib/csu/crt1.c b/lib/csu/crt1.c deleted file mode 100644 index c412255..0000000 --- a/lib/csu/crt1.c +++ /dev/null @@ -1,120 +0,0 @@ -/* LINTLIBRARY */ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 lint -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif -#endif /* lint */ - -#include - -#include "libc_private.h" -#include "crtbrand.c" - -extern int _DYNAMIC; -#pragma weak _DYNAMIC - -typedef void (*fptr)(void); - -extern void _fini(void); -extern void _init(void); -extern int main(int, char **, char **); -extern void _start(unsigned int *, ...); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -char **environ; -const char *__progname = ""; - -static __inline fptr -get_rtld_cleanup(void) -{ - fptr retval; - -#ifdef __GNUC__ - __asm__("movl %%edx,%0" : "=rm"(retval)); -#else - retval = (fptr)0; /* XXXX Fix this for other compilers */ -#endif - return(retval); -} - -/* The entry function. */ -void -_start(unsigned int *ap, ...) -{ - fptr cleanup; - int argc; - char **argv; - char **env; - const char *s; - -#ifdef __GNUC__ - __asm__("and $0xfffffff0,%esp"); -#endif - cleanup = get_rtld_cleanup(); - //argv = ≈ - argc = *ap++;// *(long *)(void *)(argv - 1); - argv = (char **)ap; - env = argv + argc + 1; - environ = env; - - if (argc > 0 && argv[0] != NULL) { - __progname = argv[0]; - for (s = __progname; *s != '\0'; s++) - if (*s == '/') - __progname = s + 1; - } - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); - -#ifdef GCRT - atexit(_mcleanup); -#endif - atexit(_fini); -#ifdef GCRT - monstartup(&eprol, &etext); -#endif - _init(); - exit( main(argc, argv, env) ); -} - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif - -__asm__(".ident\t\"$FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.14 2005/05/19 07:36:07 dfr Exp $\""); diff --git a/lib/csu/crtbrand.c b/lib/csu/crtbrand.c deleted file mode 100644 index f17a450..0000000 --- a/lib/csu/crtbrand.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright 2000 David E. O'Brien, John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 - -#include - -#define ABI_VENDOR "UbixOS" -#define ABI_SECTION ".note.ABI-tag" -#define ABI_NOTETYPE 1 - -/* - * Special ".note" entry specifying the ABI version. See - * http://www.netbsd.org/Documentation/kernel/elf-notes.html - * for more information. - */ -static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof ABI_VENDOR]; - int32_t desc; -} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __unused = { - sizeof ABI_VENDOR, - sizeof(int32_t), - ABI_NOTETYPE, - ABI_VENDOR, - __UbixOS_version -}; diff --git a/lib/csu/crti.S b/lib/csu/crti.S deleted file mode 100644 index ff895cb..0000000 --- a/lib/csu/crti.S +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright 1996, 1997, 1998, 2000 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - - .section .init,"ax",@progbits - .align 4 - .globl _init - .type _init,@function -_init: - sub $12,%esp /* re-align stack pointer */ - - .section .fini,"ax",@progbits - .align 4 - .globl _fini - .type _fini,@function -_fini: - sub $12,%esp /* re-align stack pointer */ - - .section .rodata -.ascii "$FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.7 2005/05/19 07:31:06 dfr Exp $\0" diff --git a/lib/csu/crtn.S b/lib/csu/crtn.S deleted file mode 100644 index 8e820e3..0000000 --- a/lib/csu/crtn.S +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright 1996, 1997, 1998, 2000 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - - .section .init,"ax",@progbits - add $12,%esp - ret - - .section .fini,"ax",@progbits - add $12,%esp - ret - - .section .rodata -.ascii "$FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.6 2005/05/19 07:31:06 dfr Exp $\0" diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile index 2fb3355..228cc3d 100644 --- a/lib/libedit/Makefile +++ b/lib/libedit/Makefile @@ -1,41 +1,86 @@ -# $Id: Makefile 89 2016-01-12 00:20:40Z reddawg $ -# The System Makefile (C) 2002 The UbixOS Project +# $NetBSD: Makefile,v 1.56 2016/03/02 19:24:20 christos Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/4/93 +# $FreeBSD: releng/11.1/lib/libedit/Makefile 313981 2017-02-20 03:33:59Z pfg $ -# Include Global 'Source' Options -Makefile.incl -Makefile.incl +PACKAGE=clibs +LIB= edit +SHLIB_MAJOR= 7 +SHLIBDIR?= /lib -INCLUDES = -I. -I../../include +OSRCS= chared.c common.c el.c eln.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 -#Objects -OBJS = read.o el.o +LIBADD= ncursesw -#Sub Sections -SUBS = +MAN= editline.3 editrc.5 -#Output -OUTPUT = libedit.so +MLINKS= editline.3 el_deletestr.3 editline.3 el_end.3 editline.3 el_init.3 \ + editline.3 el_get.3 editline.3 el_getc.3 editline.3 el_gets.3 \ + editline.3 history.3 editline.3 history_end.3 \ + editline.3 history_init.3 editline.3 el_insertstr.3 \ + editline.3 el_line.3 editline.3 el_parse.3 editline.3 el_push.3 \ + editline.3 el_reset.3 editline.3 el_resize.3 editline.3 el_set.3 \ + editline.3 el_source.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 -lib.so: $(OBJS) - $(CC) -nostdlib -shared -Wl,-soname,libedit.so -o $(OUTPUT) $(OBJS) $(SUBS) +# For speed and debugging +#SRCS= ${OSRCS} +# For protection +SRCS= editline.c +SRCS+= tokenizer.c history.c readline.c +SRCS+= common.h emacs.h fcns.h help.h vi.h +CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h -# Compile the source files -.cc.o: - $(CXX) -Wall -nostdinc -O -I./include -c -o $@ $< - -.cc.s: - $(CXX) -Wall -nostdinc -O -I./include -S -o $@ $< - -.c.o: - $(CC) -Wall -nostdinc -O $(INCLUDES) -c $< +INCS= histedit.h -.c.s: - $(CC) -Wall -nostdinc -O -I./include -S -o $@ $< - -.S.o: - $(CC) -Wall -nostdinc -c -o $@ $< - -# Clean up the junk -clean: - $(REMOVE) $(OBJS) $(OUTPUT) - (cd test;make clean) +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 + +WARNS?= 1 + +SUBDIR= edit/readline + +AHDR= vi.h emacs.h common.h +ASRC= ${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c + +.for hdr in vi emacs common +${hdr}.h: ${hdr}.c makelist + sh ${.CURDIR}/makelist -h ${.CURDIR}/${hdr}.c > ${.TARGET} +.endfor + +fcns.h: ${AHDR} makelist + sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET} + +fcns.c: ${AHDR} fcns.h makelist + sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET} + +help.c: ${ASRC} makelist + sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET} + +help.h: ${ASRC} makelist + sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET} + +editline.c: ${OSRCS} + sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET} + +tokenizern.c: makelist Makefile + sh ${.CURDIR}/makelist -n tokenizer.c > ${.TARGET} + +historyn.c: makelist Makefile + sh ${.CURDIR}/makelist -n history.c > ${.TARGET} + +# minimal dependency to make "make depend" optional +editline.o editline.po editline.pico editline.ln: \ + common.h emacs.h fcns.c fcns.h help.c help.h vi.h + +tc1.o: ${.CURDIR}/TEST/tc1.c + +test: tc1.o libedit.a ${DPADD} ${LIBTERMCAP} + ${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} + +.include diff --git a/lib/libedit/chared.h b/lib/libedit/chared.h index c94e66d..92a101e 100644 --- a/lib/libedit/chared.h +++ b/lib/libedit/chared.h @@ -1,3 +1,5 @@ +/* $NetBSD: chared.h,v 1.27 2016/02/16 22:53:14 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)chared.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: chared.h,v 1.16 2005/08/08 14:05:37 christos Exp $ - * $FreeBSD: src/lib/libedit/chared.h,v 1.6.12.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/chared.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,11 +41,6 @@ #ifndef _h_el_chared #define _h_el_chared -#include -#include - -#include "histedit.h" - #define EL_MAXMACRO 10 /* @@ -63,25 +59,25 @@ typedef struct c_macro_t { int level; int offset; - char **macro; + Char **macro; } c_macro_t; /* * Undo information for vi - no undo in emacs (yet) */ typedef struct c_undo_t { - int len; /* length of saved line */ + ssize_t len; /* length of saved line */ int cursor; /* position of saved cursor */ - char *buf; /* full saved text */ + Char *buf; /* full saved text */ } c_undo_t; /* redo for vi */ typedef struct c_redo_t { - char *buf; /* redo insert key sequence */ - char *pos; - char *lim; + Char *buf; /* redo insert key sequence */ + Char *pos; + Char *lim; el_action_t cmd; /* command to redo */ - char ch; /* char that invoked it */ + Char ch; /* char that invoked it */ int count; int action; /* from cv_action() */ } c_redo_t; @@ -91,18 +87,21 @@ */ typedef struct c_vcmd_t { int action; - char *pos; + Char *pos; } c_vcmd_t; /* * Kill buffer for emacs */ typedef struct c_kill_t { - char *buf; - char *last; - char *mark; + Char *buf; + Char *last; + Char *mark; } c_kill_t; +typedef void (*el_zfunc_t)(EditLine *, void *); +typedef const char *(*el_afunc_t)(void *, const char *); + /* * Note that we use both data structures because the user can bind * commands from both editors! @@ -113,14 +112,16 @@ c_redo_t c_redo; c_vcmd_t c_vcmd; c_macro_t c_macro; + el_zfunc_t c_resizefun; + el_afunc_t c_aliasfun; + void * c_resizearg; + void * c_aliasarg; } el_chared_t; -#define STReof "^D\b\b" #define STRQQ "\"\"" #define isglob(a) (strchr("*[]?", (a)) != NULL) -#define isword(a) (isprint(a)) #define NOP 0x00 #define DELETE 0x01 @@ -134,34 +135,30 @@ #define MODE_REPLACE 1 #define MODE_REPLACE_1 2 -#include "common.h" -#include "vi.h" -#include "emacs.h" -#include "search.h" -#include "fcns.h" - -protected int cv__isword(int); -protected int cv__isWord(int); +protected int cv__isword(wint_t); +protected int cv__isWord(wint_t); protected void cv_delfini(EditLine *); -protected char *cv__endword(char *, char *, int, int (*)(int)); -protected int ce__isword(int); +protected Char *cv__endword(Char *, Char *, int, int (*)(wint_t)); +protected int ce__isword(wint_t); protected void cv_undo(EditLine *); -protected void cv_yank(EditLine *, const char *, int); -protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int)); -protected char *cv_prev_word(char *, char *, int, int (*)(int)); -protected char *c__next_word(char *, char *, int, int (*)(int)); -protected char *c__prev_word(char *, char *, int, int (*)(int)); +protected void cv_yank(EditLine *, const Char *, int); +protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(wint_t)); +protected Char *cv_prev_word(Char *, Char *, int, int (*)(wint_t)); +protected Char *c__next_word(Char *, Char *, int, int (*)(wint_t)); +protected Char *c__prev_word(Char *, Char *, int, int (*)(wint_t)); protected void c_insert(EditLine *, int); protected void c_delbefore(EditLine *, int); protected void c_delbefore1(EditLine *); protected void c_delafter(EditLine *, int); protected void c_delafter1(EditLine *); -protected int c_gets(EditLine *, char *, const char *); +protected int c_gets(EditLine *, Char *, const Char *); protected int c_hpos(EditLine *); protected int ch_init(EditLine *); protected void ch_reset(EditLine *, int); +protected int ch_resizefun(EditLine *, el_zfunc_t, void *); +protected int ch_aliasfun(EditLine *, el_afunc_t, void *); protected int ch_enlargebufs(EditLine *, size_t); protected void ch_end(EditLine *); diff --git a/lib/libedit/common.h b/lib/libedit/common.h deleted file mode 100644 index 35c61eb..0000000 --- a/lib/libedit/common.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Automatically generated file, do not edit */ -#ifndef _h_common_c -#define _h_common_c -protected el_action_t ed_end_of_file (EditLine *, int); -protected el_action_t ed_insert (EditLine *, int); -protected el_action_t ed_delete_prev_word (EditLine *, int); -protected el_action_t ed_delete_next_char (EditLine *, int); -protected el_action_t ed_kill_line (EditLine *, int); -protected el_action_t ed_move_to_end (EditLine *, int); -protected el_action_t ed_move_to_beg (EditLine *, int); -protected el_action_t ed_transpose_chars (EditLine *, int); -protected el_action_t ed_next_char (EditLine *, int); -protected el_action_t ed_prev_word (EditLine *, int); -protected el_action_t ed_prev_char (EditLine *, int); -protected el_action_t ed_quoted_insert (EditLine *, int); -protected el_action_t ed_digit (EditLine *, int); -protected el_action_t ed_argument_digit (EditLine *, int); -protected el_action_t ed_unassigned (EditLine *, int); -protected el_action_t ed_tty_sigint (EditLine *, int); -protected el_action_t ed_tty_dsusp (EditLine *, int); -protected el_action_t ed_tty_flush_output (EditLine *, int); -protected el_action_t ed_tty_sigquit (EditLine *, int); -protected el_action_t ed_tty_sigtstp (EditLine *, int); -protected el_action_t ed_tty_stop_output (EditLine *, int); -protected el_action_t ed_tty_start_output (EditLine *, int); -protected el_action_t ed_newline (EditLine *, int); -protected el_action_t ed_delete_prev_char (EditLine *, int); -protected el_action_t ed_clear_screen (EditLine *, int); -protected el_action_t ed_redisplay (EditLine *, int); -protected el_action_t ed_start_over (EditLine *, int); -protected el_action_t ed_sequence_lead_in (EditLine *, int); -protected el_action_t ed_prev_history (EditLine *, int); -protected el_action_t ed_next_history (EditLine *, int); -protected el_action_t ed_search_prev_history (EditLine *, int); -protected el_action_t ed_search_next_history (EditLine *, int); -protected el_action_t ed_prev_line (EditLine *, int); -protected el_action_t ed_next_line (EditLine *, int); -protected el_action_t ed_command (EditLine *, int); -#endif /* _h_common_c */ diff --git a/lib/libedit/el.c b/lib/libedit/el.c index dd0f7d7..4da0a2c 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -1,3 +1,5 @@ +/* $NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -28,29 +30,35 @@ * 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. - * - * $NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $ */ +#include "config.h" #if !defined(lint) && !defined(SCCSID) +#if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; +#else +__RCSID("$NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $"); +#endif #endif /* not lint && not SCCSID */ #include -__FBSDID("$FreeBSD: src/lib/libedit/el.c,v 1.11.14.1 2005/10/09 03:44:01 delphij Exp $"); +__FBSDID("$FreeBSD: releng/11.1/lib/libedit/el.c 313981 2017-02-20 03:33:59Z pfg $"); /* * el.c: EditLine interface functions */ -#include "sys.h" - #include #include -#include -#include +#include #include -#include "el.h" +#include +#include +#ifdef WIDECHAR +#include +#include +#endif -#define HAVE_ISSETUGID +#include "el.h" +#include "parse.h" /* el_init(): * Initialize editline and set default parameters. @@ -58,18 +66,31 @@ public EditLine * el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr) { + return el_init_fd(prog, fin, fout, ferr, fileno(fin), fileno(fout), + fileno(ferr)); +} - EditLine *el = (EditLine *) el_malloc(sizeof(EditLine)); +public EditLine * +el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr, + int fdin, int fdout, int fderr) +{ + EditLine *el = el_malloc(sizeof(*el)); if (el == NULL) - return (NULL); + return NULL; memset(el, 0, sizeof(EditLine)); - el->el_infd = fileno(fin); + el->el_infile = fin; el->el_outfile = fout; el->el_errfile = ferr; - if ((el->el_prog = el_strdup(prog)) == NULL) { + + el->el_infd = fdin; + el->el_outfd = fdout; + el->el_errfd = fderr; + + el->el_prog = Strdup(ct_decode_string(prog, &el->el_scratch)); + if (el->el_prog == NULL) { el_free(el); return NULL; } @@ -78,13 +99,17 @@ * Initialize all the modules. Order is important!!! */ el->el_flags = 0; + if (setlocale(LC_CTYPE, NULL) != NULL){ + if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) + el->el_flags |= CHARSET_IS_UTF8; + } - if (term_init(el) == -1) { + if (terminal_init(el) == -1) { el_free(el->el_prog); el_free(el); return NULL; } - (void) key_init(el); + (void) keymacro_init(el); (void) map_init(el); if (tty_init(el) == -1) el->el_flags |= NO_TTY; @@ -95,7 +120,7 @@ (void) sig_init(el); (void) read_init(el); - return (el); + return el; } @@ -111,18 +136,25 @@ el_reset(el); - term_end(el); - key_end(el); + terminal_end(el); + keymacro_end(el); map_end(el); - tty_end(el); + if (!(el->el_flags & NO_TTY)) + tty_end(el); ch_end(el); search_end(el); hist_end(el); prompt_end(el); sig_end(el); - el_free((ptr_t) el->el_prog); - el_free((ptr_t) el); + el_free(el->el_prog); +#ifdef WIDECHAR + el_free(el->el_scratch.cbuff); + el_free(el->el_scratch.wbuff); + el_free(el->el_lgcyconv.cbuff); + el_free(el->el_lgcyconv.wbuff); +#endif + el_free(el); } @@ -142,31 +174,57 @@ * set the editline parameters */ public int -el_set(EditLine *el, int op, ...) +FUN(el,set)(EditLine *el, int op, ...) { - vaList va; + va_list ap; int rv = 0; if (el == NULL) - return (-1); - vaStart(va, op); + return -1; + va_start(ap, op); switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_set(el, vaArg(va, el_pfunc_t), op); + case EL_RPROMPT: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + + rv = prompt_set(el, p, 0, op, 1); break; + } + + case EL_RESIZE: { + el_zfunc_t p = va_arg(ap, el_zfunc_t); + void *arg = va_arg(ap, void *); + rv = ch_resizefun(el, p, arg); + break; + } + + case EL_ALIAS_TEXT: { + el_afunc_t p = va_arg(ap, el_afunc_t); + void *arg = va_arg(ap, void *); + rv = ch_aliasfun(el, p, arg); + break; + } + + case EL_PROMPT_ESC: + case EL_RPROMPT_ESC: { + el_pfunc_t p = va_arg(ap, el_pfunc_t); + int c = va_arg(ap, int); + + rv = prompt_set(el, p, (Char)c, op, 1); + break; + } case EL_TERMINAL: - rv = term_set(el, vaArg(va, char *)); + rv = terminal_set(el, va_arg(ap, char *)); break; case EL_EDITOR: - rv = map_set_editor(el, vaArg(va, char *)); + rv = map_set_editor(el, va_arg(ap, Char *)); break; case EL_SIGNAL: - if (vaArg(va, int)) + if (va_arg(ap, int)) el->el_flags |= HANDLE_SIGNALS; else el->el_flags &= ~HANDLE_SIGNALS; @@ -178,36 +236,36 @@ case EL_ECHOTC: case EL_SETTY: { - const char *argv[20]; + const Char *argv[20]; int i; - for (i = 1; i < 20; i++) - if ((argv[i] = vaArg(va, char *)) == NULL) + for (i = 1; i < (int)__arraycount(argv); i++) + if ((argv[i] = va_arg(ap, Char *)) == NULL) break; switch (op) { case EL_BIND: - argv[0] = "bind"; + argv[0] = STR("bind"); rv = map_bind(el, i, argv); break; case EL_TELLTC: - argv[0] = "telltc"; - rv = term_telltc(el, i, argv); + argv[0] = STR("telltc"); + rv = terminal_telltc(el, i, argv); break; case EL_SETTC: - argv[0] = "settc"; - rv = term_settc(el, i, argv); + argv[0] = STR("settc"); + rv = terminal_settc(el, i, argv); break; case EL_ECHOTC: - argv[0] = "echotc"; - rv = term_echotc(el, i, argv); + argv[0] = STR("echotc"); + rv = terminal_echotc(el, i, argv); break; case EL_SETTY: - argv[0] = "setty"; + argv[0] = STR("setty"); rv = tty_stty(el, i, argv); break; @@ -221,9 +279,9 @@ case EL_ADDFN: { - char *name = vaArg(va, char *); - char *help = vaArg(va, char *); - el_func_t func = vaArg(va, el_func_t); + Char *name = va_arg(ap, Char *); + Char *help = va_arg(ap, Char *); + el_func_t func = va_arg(ap, el_func_t); rv = map_addfunc(el, name, help, func); break; @@ -231,15 +289,17 @@ case EL_HIST: { - hist_fun_t func = vaArg(va, hist_fun_t); - ptr_t ptr = vaArg(va, char *); + hist_fun_t func = va_arg(ap, hist_fun_t); + void *ptr = va_arg(ap, void *); rv = hist_set(el, func, ptr); + if (!(el->el_flags & CHARSET_IS_UTF8)) + el->el_flags &= ~NARROW_HISTORY; break; } case EL_EDITMODE: - if (vaArg(va, int)) + if (va_arg(ap, int)) el->el_flags &= ~EDIT_DISABLED; else el->el_flags |= EDIT_DISABLED; @@ -248,17 +308,17 @@ case EL_GETCFN: { - el_rfunc_t rc = vaArg(va, el_rfunc_t); + el_rfunc_t rc = va_arg(ap, el_rfunc_t); rv = el_read_setfn(el, rc); break; } case EL_CLIENTDATA: - el->el_data = vaArg(va, void *); + el->el_data = va_arg(ap, void *); break; case EL_UNBUFFERED: - rv = vaArg(va, int); + rv = va_arg(ap, int); if (rv && !(el->el_flags & UNBUFFERED)) { el->el_flags |= UNBUFFERED; read_prepare(el); @@ -270,7 +330,7 @@ break; case EL_PREP_TERM: - rv = vaArg(va, int); + rv = va_arg(ap, int); if (rv) (void) tty_rawmode(el); else @@ -278,13 +338,48 @@ rv = 0; break; + case EL_SETFP: + { + FILE *fp; + int what; + + what = va_arg(ap, int); + fp = va_arg(ap, FILE *); + + rv = 0; + switch (what) { + case 0: + el->el_infile = fp; + el->el_infd = fileno(fp); + break; + case 1: + el->el_outfile = fp; + el->el_outfd = fileno(fp); + break; + case 2: + el->el_errfile = fp; + el->el_errfd = fileno(fp); + break; + default: + rv = -1; + break; + } + break; + } + + case EL_REFRESH: + re_clear_display(el); + re_refresh(el); + terminal__flush(el); + break; + default: rv = -1; break; } - vaEnd(va); - return (rv); + va_end(ap); + return rv; } @@ -292,159 +387,123 @@ * retrieve the editline parameters */ public int -el_get(EditLine *el, int op, void *ret) +FUN(el,get)(EditLine *el, int op, ...) { + va_list ap; int rv; - if (el == NULL || ret == NULL) - return (-1); + if (el == NULL) + return -1; + + va_start(ap, op); + switch (op) { case EL_PROMPT: - case EL_RPROMPT: - rv = prompt_get(el, (el_pfunc_t *) ret, op); + case EL_RPROMPT: { + el_pfunc_t *p = va_arg(ap, el_pfunc_t *); + rv = prompt_get(el, p, 0, op); break; + } + case EL_PROMPT_ESC: + case EL_RPROMPT_ESC: { + el_pfunc_t *p = va_arg(ap, el_pfunc_t *); + Char *c = va_arg(ap, Char *); + + rv = prompt_get(el, p, c, op); + break; + } case EL_EDITOR: - rv = map_get_editor(el, (const char **)ret); + rv = map_get_editor(el, va_arg(ap, const Char **)); break; case EL_SIGNAL: - *((int *) ret) = (el->el_flags & HANDLE_SIGNALS); + *va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS); rv = 0; break; case EL_EDITMODE: - *((int *) ret) = (!(el->el_flags & EDIT_DISABLED)); + *va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED); rv = 0; break; case EL_TERMINAL: - term_get(el, (const char **)ret); + terminal_get(el, va_arg(ap, const char **)); rv = 0; break; -#if 0 /* XXX */ - case EL_BIND: - case EL_TELLTC: - case EL_SETTC: - case EL_ECHOTC: - case EL_SETTY: + case EL_GETTC: { - const char *argv[20]; + static char name[] = "gettc"; + char *argv[20]; int i; - for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++) - if ((argv[i] = vaArg(va, char *)) == NULL) + for (i = 1; i < (int)__arraycount(argv); i++) + if ((argv[i] = va_arg(ap, char *)) == NULL) break; - switch (op) { - case EL_BIND: - argv[0] = "bind"; - rv = map_bind(el, i, argv); - break; - - case EL_TELLTC: - argv[0] = "telltc"; - rv = term_telltc(el, i, argv); - break; - - case EL_SETTC: - argv[0] = "settc"; - rv = term_settc(el, i, argv); - break; - - case EL_ECHOTC: - argv[0] = "echotc"; - rv = term_echotc(el, i, argv); - break; - - case EL_SETTY: - argv[0] = "setty"; - rv = tty_stty(el, i, argv); - break; - - default: - rv = -1; - EL_ABORT((el->errfile, "Bad op %d\n", op)); - break; - } + argv[0] = name; + rv = terminal_gettc(el, i, argv); break; } - case EL_ADDFN: - { - char *name = vaArg(va, char *); - char *help = vaArg(va, char *); - el_func_t func = vaArg(va, el_func_t); - - rv = map_addfunc(el, name, help, func); - break; - } - - case EL_HIST: - { - hist_fun_t func = vaArg(va, hist_fun_t); - ptr_t ptr = vaArg(va, char *); - rv = hist_set(el, func, ptr); - } - break; -#endif /* XXX */ - case EL_GETCFN: - *((el_rfunc_t *)ret) = el_read_getfn(el); + *va_arg(ap, el_rfunc_t *) = el_read_getfn(el); rv = 0; break; case EL_CLIENTDATA: - *((void **)ret) = el->el_data; + *va_arg(ap, void **) = el->el_data; rv = 0; break; case EL_UNBUFFERED: - *((int *) ret) = (!(el->el_flags & UNBUFFERED)); + *va_arg(ap, int *) = (el->el_flags & UNBUFFERED) != 0; rv = 0; break; + case EL_GETFP: + { + int what; + FILE **fpp; + + what = va_arg(ap, int); + fpp = va_arg(ap, FILE **); + rv = 0; + switch (what) { + case 0: + *fpp = el->el_infile; + break; + case 1: + *fpp = el->el_outfile; + break; + case 2: + *fpp = el->el_errfile; + break; + default: + rv = -1; + break; + } + break; + } default: rv = -1; + break; } + va_end(ap); - return (rv); + return rv; } -/* el_data_get(): - * Set user private data. - */ -public void -el_data_set (el, data) - EditLine *el; - void *data; -{ - el->el_data = data; - - return; -} - -/* el_data_get(): - * Return user private data. - */ -public void * -el_data_get (el) - EditLine *el; -{ - if (el->el_data) - return (el->el_data); - return (NULL); -} /* el_line(): * Return editing info */ -public const LineInfo * -el_line(EditLine *el) +public const TYPE(LineInfo) * +FUN(el,line)(EditLine *el) { - return (const LineInfo *) (void *) &el->el_line; + return (const TYPE(LineInfo) *)(void *)&el->el_line; } @@ -456,22 +515,26 @@ { FILE *fp; size_t len; + ssize_t slen; char *ptr; + char *path = NULL; + const Char *dptr; + int error = 0; fp = NULL; if (fname == NULL) { #ifdef HAVE_ISSETUGID static const char elpath[] = "/.editrc"; - char path[MAXPATHLEN]; + size_t plen = sizeof(elpath); if (issetugid()) - return (-1); + return -1; if ((ptr = getenv("HOME")) == NULL) - return (-1); - if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path)) - return (-1); - if (strlcat(path, elpath, sizeof(path)) >= sizeof(path)) - return (-1); + 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; #else /* @@ -479,26 +542,40 @@ * to keep from inadvertently opening up the user to a security * hole. */ - return (-1); + return -1; #endif } if (fp == NULL) fp = fopen(fname, "r"); - if (fp == NULL) - return (-1); - - while ((ptr = fgetln(fp, &len)) != NULL) { - if (len > 0 && ptr[len - 1] == '\n') - --len; - ptr[len] = '\0'; - if (parse_line(el, ptr) == -1) { - (void) fclose(fp); - return (-1); - } + if (fp == NULL) { + el_free(path); + return -1; } + ptr = NULL; + len = 0; + while ((slen = getline(&ptr, &len, fp)) != -1) { + if (*ptr == '\n') + continue; /* Empty line. */ + if (slen > 0 && ptr[--slen] == '\n') + ptr[slen] = '\0'; + + dptr = ct_decode_string(ptr, &el->el_scratch); + if (!dptr) + continue; + /* loop until first non-space char or EOL */ + while (*dptr != '\0' && Isspace(*dptr)) + dptr++; + if (*dptr == '#') + continue; /* ignore, this is a comment line */ + if ((error = parse_line(el, dptr)) == -1) + break; + } + free(ptr); + + el_free(path); (void) fclose(fp); - return (0); + return error; } @@ -516,8 +593,8 @@ (void) sigprocmask(SIG_BLOCK, &nset, &oset); /* get the correct window size */ - if (term_get_size(el, &lins, &cols)) - term_change_size(el, lins, cols); + if (terminal_get_size(el, &lins, &cols)) + terminal_change_size(el, lins, cols); (void) sigprocmask(SIG_SETMASK, &oset, NULL); } @@ -530,7 +607,7 @@ el_beep(EditLine *el) { - term_beep(el); + terminal_beep(el); } @@ -539,24 +616,25 @@ */ protected int /*ARGSUSED*/ -el_editmode(EditLine *el, int argc, const char **argv) +el_editmode(EditLine *el, int argc, const Char **argv) { - const char *how; + const Char *how; if (argv == NULL || argc != 2 || argv[1] == NULL) - return (-1); + return -1; how = argv[1]; - if (strcmp(how, "on") == 0) { + if (Strcmp(how, STR("on")) == 0) { el->el_flags &= ~EDIT_DISABLED; tty_rawmode(el); - } else if (strcmp(how, "off") == 0) { + } else if (Strcmp(how, STR("off")) == 0) { tty_cookedmode(el); el->el_flags |= EDIT_DISABLED; } else { - (void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how); - return (-1); + (void) fprintf(el->el_errfile, "edit: Bad value `" FSTR "'.\n", + how); + return -1; } - return (0); + return 0; } diff --git a/lib/libedit/el.h b/lib/libedit/el.h index eee97df..619b0ce 100644 --- a/lib/libedit/el.h +++ b/lib/libedit/el.h @@ -1,3 +1,5 @@ +/* $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)el.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ - * $FreeBSD: src/lib/libedit/el.h,v 1.4.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/el.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -46,17 +47,17 @@ #define VIDEFAULT #define ANCHOR -#include -#include +#include "histedit.h" +#include "chartype.h" -#define EL_BUFSIZ 1024 /* Maximum line size */ +#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */ #define HANDLE_SIGNALS 0x01 #define NO_TTY 0x02 #define EDIT_DISABLED 0x04 #define UNBUFFERED 0x08 - -typedef int bool_t; /* True or not */ +#define CHARSET_IS_UTF8 0x10 +#define NARROW_HISTORY 0x40 typedef unsigned char el_action_t; /* Index to command array */ @@ -66,10 +67,10 @@ } coord_t; typedef struct el_line_t { - char *buffer; /* Input line */ - char *cursor; /* Cursor position */ - char *lastchar; /* Last character */ - const char *limit; /* Max position */ + Char *buffer; /* Input line */ + Char *cursor; /* Cursor position */ + Char *lastchar; /* Last character */ + const Char *limit; /* Max position */ } el_line_t; /* @@ -81,60 +82,66 @@ int argument; /* Numeric argument */ int metanext; /* Is the next char a meta char */ el_action_t lastcmd; /* Previous command */ - el_action_t thiscmd; /* this command */ - char thisch; /* char that generated it */ + el_action_t thiscmd; /* this command */ + Char thisch; /* char that generated it */ } el_state_t; /* * Until we come up with something better... */ -#define el_strdup(a) strdup(a) #define el_malloc(a) malloc(a) #define el_realloc(a,b) realloc(a, b) #define el_free(a) free(a) #include "tty.h" #include "prompt.h" -#include "key.h" -#include "term.h" +#include "keymacro.h" +#include "terminal.h" #include "refresh.h" #include "chared.h" -#include "common.h" #include "search.h" #include "hist.h" +#include "fcns.h" /* el_func_t is needed for map.h */ #include "map.h" -#include "parse.h" #include "sig.h" -#include "help.h" #include "read.h" struct editline { - char *el_prog; /* the program name */ + Char *el_prog; /* the program name */ + FILE *el_infile; /* Stdio stuff */ FILE *el_outfile; /* Stdio stuff */ FILE *el_errfile; /* Stdio stuff */ int el_infd; /* Input file descriptor */ + int el_outfd; /* Output file descriptor */ + int el_errfd; /* Error file descriptor */ int el_flags; /* Various flags. */ + int el_errno; /* Local copy of errno */ coord_t el_cursor; /* Cursor location */ - char **el_display; /* Real screen image = what is there */ - char **el_vdisplay; /* Virtual screen image = what we see */ + Char **el_display; /* Real screen image = what is there */ + Char **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 */ - el_term_t el_term; /* Terminal dependent stuff */ + el_terminal_t el_terminal; /* Terminal dependent stuff */ el_tty_t el_tty; /* Tty dependent stuff */ el_refresh_t el_refresh; /* Refresh stuff */ el_prompt_t el_prompt; /* Prompt stuff */ el_prompt_t el_rprompt; /* Prompt stuff */ el_chared_t el_chared; /* Characted editor stuff */ el_map_t el_map; /* Key mapping stuff */ - el_key_t el_key; /* Key binding stuff */ + el_keymacro_t el_keymacro; /* Key binding stuff */ el_history_t el_history; /* History stuff */ el_search_t el_search; /* Search stuff */ el_signal_t el_signal; /* Signal handling stuff */ el_read_t el_read; /* Character reading stuff */ +#ifdef WIDECHAR + ct_buffer_t el_scratch; /* Scratch conversion buffer */ + ct_buffer_t el_lgcyconv; /* Buffer for legacy wrappers */ + LineInfo el_lgcylinfo; /* Legacy LineInfo buffer */ +#endif }; -protected int el_editmode(EditLine *, int, const char **); +protected int el_editmode(EditLine *, int, const Char **); #ifdef DEBUG #define EL_ABORT(a) do { \ diff --git a/lib/libedit/emacs.h b/lib/libedit/emacs.h deleted file mode 100644 index 60a5e9e..0000000 --- a/lib/libedit/emacs.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Automatically generated file, do not edit */ -#ifndef _h_emacs_c -#define _h_emacs_c -protected el_action_t em_delete_or_list (EditLine *, int); -protected el_action_t em_delete_next_word (EditLine *, int); -protected el_action_t em_yank (EditLine *, int); -protected el_action_t em_kill_line (EditLine *, int); -protected el_action_t em_kill_region (EditLine *, int); -protected el_action_t em_copy_region (EditLine *, int); -protected el_action_t em_gosmacs_transpose (EditLine *, int); -protected el_action_t em_next_word (EditLine *, int); -protected el_action_t em_upper_case (EditLine *, int); -protected el_action_t em_capitol_case (EditLine *, int); -protected el_action_t em_lower_case (EditLine *, int); -protected el_action_t em_set_mark (EditLine *, int); -protected el_action_t em_exchange_mark (EditLine *, int); -protected el_action_t em_universal_argument (EditLine *, int); -protected el_action_t em_meta_next (EditLine *, int); -protected el_action_t em_toggle_overwrite (EditLine *, int); -protected el_action_t em_copy_prev_word (EditLine *, int); -protected el_action_t em_inc_search_next (EditLine *, int); -protected el_action_t em_inc_search_prev (EditLine *, int); -protected el_action_t em_delete_prev_char (EditLine *, int); -#endif /* _h_emacs_c */ diff --git a/lib/libedit/fcns.h b/lib/libedit/fcns.h deleted file mode 100644 index adf9c48..0000000 --- a/lib/libedit/fcns.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Automatically generated file, do not edit */ -#ifndef _h_fcns_c -#define _h_fcns_c -#define ED_ARGUMENT_DIGIT 0 -#define ED_CLEAR_SCREEN 1 -#define ED_COMMAND 2 -#define ED_DELETE_NEXT_CHAR 3 -#define ED_DELETE_PREV_CHAR 4 -#define ED_DELETE_PREV_WORD 5 -#define ED_DIGIT 6 -#define ED_END_OF_FILE 7 -#define ED_INSERT 8 -#define ED_KILL_LINE 9 -#define ED_MOVE_TO_BEG 10 -#define ED_MOVE_TO_END 11 -#define ED_NEWLINE 12 -#define ED_NEXT_CHAR 13 -#define ED_NEXT_HISTORY 14 -#define ED_NEXT_LINE 15 -#define ED_PREV_CHAR 16 -#define ED_PREV_HISTORY 17 -#define ED_PREV_LINE 18 -#define ED_PREV_WORD 19 -#define ED_QUOTED_INSERT 20 -#define ED_REDISPLAY 21 -#define ED_SEARCH_NEXT_HISTORY 22 -#define ED_SEARCH_PREV_HISTORY 23 -#define ED_SEQUENCE_LEAD_IN 24 -#define ED_START_OVER 25 -#define ED_TRANSPOSE_CHARS 26 -#define ED_TTY_DSUSP 27 -#define ED_TTY_FLUSH_OUTPUT 28 -#define ED_TTY_SIGINT 29 -#define ED_TTY_SIGQUIT 30 -#define ED_TTY_SIGTSTP 31 -#define ED_TTY_START_OUTPUT 32 -#define ED_TTY_STOP_OUTPUT 33 -#define ED_UNASSIGNED 34 -#define EM_CAPITOL_CASE 35 -#define EM_COPY_PREV_WORD 36 -#define EM_COPY_REGION 37 -#define EM_DELETE_NEXT_WORD 38 -#define EM_DELETE_OR_LIST 39 -#define EM_DELETE_PREV_CHAR 40 -#define EM_EXCHANGE_MARK 41 -#define EM_GOSMACS_TRANSPOSE 42 -#define EM_INC_SEARCH_NEXT 43 -#define EM_INC_SEARCH_PREV 44 -#define EM_KILL_LINE 45 -#define EM_KILL_REGION 46 -#define EM_LOWER_CASE 47 -#define EM_META_NEXT 48 -#define EM_NEXT_WORD 49 -#define EM_SET_MARK 50 -#define EM_TOGGLE_OVERWRITE 51 -#define EM_UNIVERSAL_ARGUMENT 52 -#define EM_UPPER_CASE 53 -#define EM_YANK 54 -#define VI_ADD 55 -#define VI_ADD_AT_EOL 56 -#define VI_ALIAS 57 -#define VI_CHANGE_CASE 58 -#define VI_CHANGE_META 59 -#define VI_CHANGE_TO_EOL 60 -#define VI_COMMAND_MODE 61 -#define VI_COMMENT_OUT 62 -#define VI_DELETE_META 63 -#define VI_DELETE_PREV_CHAR 64 -#define VI_END_BIG_WORD 65 -#define VI_END_WORD 66 -#define VI_HISTEDIT 67 -#define VI_HISTORY_WORD 68 -#define VI_INSERT 69 -#define VI_INSERT_AT_BOL 70 -#define VI_KILL_LINE_PREV 71 -#define VI_LIST_OR_EOF 72 -#define VI_MATCH 73 -#define VI_NEXT_BIG_WORD 74 -#define VI_NEXT_CHAR 75 -#define VI_NEXT_WORD 76 -#define VI_PASTE_NEXT 77 -#define VI_PASTE_PREV 78 -#define VI_PREV_BIG_WORD 79 -#define VI_PREV_CHAR 80 -#define VI_PREV_WORD 81 -#define VI_REDO 82 -#define VI_REPEAT_NEXT_CHAR 83 -#define VI_REPEAT_PREV_CHAR 84 -#define VI_REPEAT_SEARCH_NEXT 85 -#define VI_REPEAT_SEARCH_PREV 86 -#define VI_REPLACE_CHAR 87 -#define VI_REPLACE_MODE 88 -#define VI_SEARCH_NEXT 89 -#define VI_SEARCH_PREV 90 -#define VI_SUBSTITUTE_CHAR 91 -#define VI_SUBSTITUTE_LINE 92 -#define VI_TO_COLUMN 93 -#define VI_TO_HISTORY_LINE 94 -#define VI_TO_NEXT_CHAR 95 -#define VI_TO_PREV_CHAR 96 -#define VI_UNDO 97 -#define VI_UNDO_LINE 98 -#define VI_YANK 99 -#define VI_YANK_END 100 -#define VI_ZERO 101 -#define EL_NUM_FCNS 102 -typedef el_action_t (*el_func_t)(EditLine *, int); -protected const el_func_t* func__get(void); -#endif /* _h_fcns_c */ diff --git a/lib/libedit/help.h b/lib/libedit/help.h deleted file mode 100644 index a7e89a1..0000000 --- a/lib/libedit/help.h +++ /dev/null @@ -1,5 +0,0 @@ -/* Automatically generated file, do not edit */ -#ifndef _h_help_c -#define _h_help_c -protected const el_bindings_t *help__get(void); -#endif /* _h_help_c */ diff --git a/lib/libedit/hist.h b/lib/libedit/hist.h index 149e286..b8cb2df 100644 --- a/lib/libedit/hist.h +++ b/lib/libedit/hist.h @@ -1,3 +1,5 @@ +/* $NetBSD: hist.h,v 1.18 2016/02/17 19:47:49 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)hist.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp $ - * $FreeBSD: src/lib/libedit/hist.h,v 1.3.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/hist.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,23 +41,29 @@ #ifndef _h_el_hist #define _h_el_hist -#include "histedit.h" - -typedef int (*hist_fun_t)(ptr_t, HistEvent *, int, ...); +typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...); typedef struct el_history_t { - char *buf; /* The history buffer */ - size_t sz; /* Size of history buffer */ - char *last; /* The last character */ + Char *buf; /* The history buffer */ + size_t sz; /* Size of history buffer */ + Char *last; /* The last character */ int eventno; /* Event we are looking for */ - ptr_t ref; /* Argument for history fcns */ + void *ref; /* Argument for history fcns */ hist_fun_t fun; /* Event access */ - HistEvent ev; /* Event cookie */ + TYPE(HistEvent) ev; /* Event cookie */ } el_history_t; -#define HIST_FUN(el, fn, arg) \ +#define HIST_FUN_INTERNAL(el, fn, arg) \ ((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \ fn, arg)) == -1) ? NULL : (el)->el_history.ev.str) +#ifdef WIDECHAR +#define HIST_FUN(el, fn, arg) \ + (((el)->el_flags & NARROW_HISTORY) ? hist_convert(el, fn, arg) : \ + HIST_FUN_INTERNAL(el, fn, arg)) +#else +#define HIST_FUN(el, fn, arg) HIST_FUN_INTERNAL(el, fn, arg) +#endif + #define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL) #define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL) @@ -65,12 +72,16 @@ #define HIST_SET(el, num) HIST_FUN(el, H_SET, num) #define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname) #define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname) +#define HIST_SAVE_FP(el, fp) HIST_FUN(el, H_SAVE_FP fp) protected int hist_init(EditLine *); protected void hist_end(EditLine *); protected el_action_t hist_get(EditLine *); -protected int hist_set(EditLine *, hist_fun_t, ptr_t); -protected int hist_command(EditLine *, int, const char **); +protected int hist_set(EditLine *, hist_fun_t, void *); +protected int hist_command(EditLine *, int, const Char **); protected int hist_enlargebuf(EditLine *, size_t, size_t); +#ifdef WIDECHAR +protected wchar_t *hist_convert(EditLine *, int, void *); +#endif #endif /* _h_el_hist */ diff --git a/lib/libedit/key.h b/lib/libedit/key.h deleted file mode 100644 index 848553e..0000000 --- a/lib/libedit/key.h +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Christos Zoulas of Cornell University. - * - * 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. Neither the name of the University 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 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. - * - * @(#)key.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $ - * $FreeBSD: src/lib/libedit/key.h,v 1.3.14.1 2005/10/09 03:44:01 delphij Exp $ - */ - -/* - * el.key.h: Key macro header - */ -#ifndef _h_el_key -#define _h_el_key - -typedef union key_value_t { - el_action_t cmd; /* If it is a command the # */ - char *str; /* If it is a string... */ -} key_value_t; - -typedef struct key_node_t key_node_t; - -typedef struct el_key_t { - char *buf; /* Key print buffer */ - key_node_t *map; /* Key map */ - key_value_t val; /* Local conversion buffer */ -} el_key_t; - -#define XK_CMD 0 -#define XK_STR 1 -#define XK_NOD 2 -#define XK_EXE 3 - -#include - -#undef key_end -#undef key_clear -#undef key_print - -protected int key_init(EditLine *); -protected void key_end(EditLine *); -protected key_value_t *key_map_cmd(EditLine *, int); -protected key_value_t *key_map_str(EditLine *, char *); -protected void key_reset(EditLine *); -protected int key_get(EditLine *, char *, key_value_t *); -protected void key_add(EditLine *, const char *, key_value_t *, int); -protected void key_clear(EditLine *, el_action_t *, const char *); -protected int key_delete(EditLine *, const char *); -protected void key_print(EditLine *, const char *); -protected void key_kprint(EditLine *, const char *, key_value_t *, - int); -protected char *key__decode_str(const char *, char *, const char *); - -#endif /* _h_el_key */ diff --git a/lib/libedit/map.h b/lib/libedit/map.h index e271259..ef8a5f5 100644 --- a/lib/libedit/map.h +++ b/lib/libedit/map.h @@ -1,3 +1,5 @@ +/* $NetBSD: map.h,v 1.10 2014/07/06 18:15:34 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)map.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp $ - * $FreeBSD: src/lib/libedit/map.h,v 1.3.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/map.h 276881 2015-01-09 07:40:56Z bapt $ */ /* @@ -41,9 +42,9 @@ #define _h_el_map typedef struct el_bindings_t { /* for the "bind" shell command */ - const char *name; /* function name for bind command */ + const Char *name; /* function name for bind command */ int func; /* function numeric value */ - const char *description; /* description of function */ + const Char *description; /* description of function */ } el_bindings_t; @@ -57,19 +58,21 @@ int type; /* Emacs or vi */ el_bindings_t *help; /* The help for the editor functions */ el_func_t *func; /* List of available functions */ - int nfunc; /* The number of functions/help items */ + size_t nfunc; /* The number of functions/help items */ } el_map_t; #define MAP_EMACS 0 #define MAP_VI 1 -protected int map_bind(EditLine *, int, const char **); +#define N_KEYS 256 + +protected int map_bind(EditLine *, int, const Char **); protected int map_init(EditLine *); protected void map_end(EditLine *); protected void map_init_vi(EditLine *); protected void map_init_emacs(EditLine *); -protected int map_set_editor(EditLine *, char *); -protected int map_get_editor(EditLine *, const char **); -protected int map_addfunc(EditLine *, const char *, const char *, el_func_t); +protected int map_set_editor(EditLine *, Char *); +protected int map_get_editor(EditLine *, const Char **); +protected int map_addfunc(EditLine *, const Char *, const Char *, el_func_t); #endif /* _h_el_map */ diff --git a/lib/libedit/parse.h b/lib/libedit/parse.h index 0fdfd79..6013862 100644 --- a/lib/libedit/parse.h +++ b/lib/libedit/parse.h @@ -1,3 +1,5 @@ +/* $NetBSD: parse.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)parse.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp $ - * $FreeBSD: src/lib/libedit/parse.h,v 1.3.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/parse.h 276881 2015-01-09 07:40:56Z bapt $ */ /* @@ -40,9 +41,9 @@ #ifndef _h_el_parse #define _h_el_parse -protected int parse_line(EditLine *, const char *); -protected int parse__escape(const char **); -protected char *parse__string(char *, const char *); -protected int parse_cmd(EditLine *, const char *); +protected int parse_line(EditLine *, const Char *); +protected int parse__escape(const Char **); +protected Char *parse__string(Char *, const Char *); +protected int parse_cmd(EditLine *, const Char *); #endif /* _h_el_parse */ diff --git a/lib/libedit/prompt.h b/lib/libedit/prompt.h index 7d50318..95597ff 100644 --- a/lib/libedit/prompt.h +++ b/lib/libedit/prompt.h @@ -1,3 +1,5 @@ +/* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,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 $ - * $FreeBSD: src/lib/libedit/prompt.h,v 1.2.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/prompt.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,18 +41,18 @@ #ifndef _h_el_prompt #define _h_el_prompt -#include "histedit.h" - -typedef char * (*el_pfunc_t)(EditLine*); +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 */ + int p_wide; } el_prompt_t; protected void prompt_print(EditLine *, int); -protected int prompt_set(EditLine *, el_pfunc_t, int); -protected int prompt_get(EditLine *, el_pfunc_t *, int); +protected int prompt_set(EditLine *, el_pfunc_t, Char, int, int); +protected int prompt_get(EditLine *, el_pfunc_t *, Char *, int); protected int prompt_init(EditLine *); protected void prompt_end(EditLine *); diff --git a/lib/libedit/read.c b/lib/libedit/read.c index 6817b1b..d7ed83e 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,3 +1,5 @@ +/* $NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -28,33 +30,40 @@ * 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. - * - * $NetBSD: read.c,v 1.39 2005/08/02 12:11:14 christos Exp $ */ +#include "config.h" #if !defined(lint) && !defined(SCCSID) +#if 0 static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $"); +#endif #endif /* not lint && not SCCSID */ #include -__FBSDID("$FreeBSD: src/lib/libedit/read.c,v 1.11.14.1 2005/10/09 03:44:01 delphij Exp $"); +__FBSDID("$FreeBSD: releng/11.1/lib/libedit/read.c 313981 2017-02-20 03:33:59Z pfg $"); /* * read.c: Clean this junk up! This is horrible code. * Terminal read functions */ -#include "sys.h" +#include #include #include -#include +#include #include +#include +#include + #include "el.h" -#define OKCMD -1 +#define OKCMD -1 /* must be -1! */ private int read__fixio(int, int); private int read_preread(EditLine *); -private int read_char(EditLine *, char *); -private int read_getcmd(EditLine *, el_action_t *, char *); +private int read_char(EditLine *, wchar_t *); +private int read_getcmd(EditLine *, el_action_t *, Char *); +private void read_pop(c_macro_t *); /* read_init(): * Initialize the read stuff @@ -87,7 +96,7 @@ protected el_rfunc_t el_read_getfn(EditLine *el) { - return (el->el_read.read_char == read_char) ? + return el->el_read.read_char == read_char ? EL_BUILTIN_GETCFN : el->el_read.read_char; } @@ -120,7 +129,7 @@ */ /* ARGSUSED */ private int -read__fixio(int fd __unused, int e) +read__fixio(int fd __attribute__((__unused__)), int e) { switch (e) { @@ -129,7 +138,7 @@ #ifdef EWOULDBLOCK case EWOULDBLOCK: #ifndef TRY_AGAIN -#define TRY_AGAIN +#define TRY_AGAIN #endif #endif /* EWOULDBLOCK */ @@ -137,7 +146,7 @@ #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EAGAIN: #ifndef TRY_AGAIN -#define TRY_AGAIN +#define TRY_AGAIN #endif #endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */ #endif /* POSIX && EAGAIN */ @@ -146,10 +155,10 @@ #ifdef TRY_AGAIN #if defined(F_SETFL) && defined(O_NDELAY) if ((e = fcntl(fd, F_GETFL, 0)) == -1) - return (-1); + return -1; if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1) - return (-1); + return -1; else e = 1; #endif /* F_SETFL && O_NDELAY */ @@ -158,21 +167,21 @@ { int zero = 0; - if (ioctl(fd, FIONBIO, (ioctl_t) & zero) == -1) - return (-1); + if (ioctl(fd, FIONBIO, &zero) == -1) + return -1; else e = 1; } #endif /* FIONBIO */ #endif /* TRY_AGAIN */ - return (e ? 0 : -1); + return e ? 0 : -1; case EINTR: - return (0); + return 0; default: - return (-1); + return -1; } } @@ -186,10 +195,13 @@ int chrs = 0; if (el->el_tty.t_mode == ED_IO) - return (0); + return 0; +#ifndef WIDECHAR +/* FIONREAD attempts to buffer up multiple bytes, and to make that work + * properly with partial wide/UTF-8 characters would need some careful work. */ #ifdef FIONREAD - (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); + (void) ioctl(el->el_infd, FIONREAD, &chrs); if (chrs > 0) { char buf[EL_BUFSIZ]; @@ -201,8 +213,8 @@ } } #endif /* FIONREAD */ - - return (chrs > 0); +#endif + return chrs > 0; } @@ -210,36 +222,43 @@ * Push a macro */ public void -el_push(EditLine *el, char *str) +FUN(el,push)(EditLine *el, const Char *str) { c_macro_t *ma = &el->el_chared.c_macro; if (str != NULL && ma->level + 1 < EL_MAXMACRO) { ma->level++; - if ((ma->macro[ma->level] = el_strdup(str)) != NULL) + if ((ma->macro[ma->level] = Strdup(str)) != NULL) return; ma->level--; } - term_beep(el); - term__flush(); + terminal_beep(el); + terminal__flush(el); } /* read_getcmd(): - * Return next command from the input stream. + * Get next command from the input stream, return OKCMD on success. + * Character values > 255 are not looked up in the map, but inserted. */ private int -read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch) +read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) { + static const Char meta = (Char)0x80; el_action_t cmd; + wchar_t wc; int num; + el->el_errno = 0; do { - if ((num = el_getc(el, ch)) != 1) /* if EOF or error */ - return (num); + if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */ + el->el_errno = num == 0 ? 0 : errno; + return 0; /* not OKCMD */ + } + *ch = (Char)wc; #ifdef KANJI - if ((*ch & 0200)) { + if ((*ch & meta)) { el->el_state.metanext = 0; cmd = CcViMap[' ']; break; @@ -248,17 +267,22 @@ if (el->el_state.metanext) { el->el_state.metanext = 0; - *ch |= 0200; + *ch |= meta; } - cmd = el->el_map.current[(unsigned char) *ch]; +#ifdef WIDECHAR + if (*ch >= N_KEYS) + cmd = ED_INSERT; + else +#endif + cmd = el->el_map.current[(unsigned char) *ch]; if (cmd == ED_SEQUENCE_LEAD_IN) { - key_value_t val; - switch (key_get(el, ch, &val)) { + keymacro_value_t val; + switch (keymacro_get(el, ch, &val)) { case XK_CMD: cmd = val.cmd; break; case XK_STR: - el_push(el, val.str); + FUN(el,push)(el, val.str); break; #ifdef notyet case XK_EXE: @@ -275,77 +299,155 @@ el->el_map.current = el->el_map.key; } while (cmd == ED_SEQUENCE_LEAD_IN); *cmdnum = cmd; - return (OKCMD); + return OKCMD; } - /* read_char(): * Read a character from the tty. */ private int -read_char(EditLine *el, char *cp) +read_char(EditLine *el, wchar_t *cp) { - int num_read; + ssize_t num_read; int tried = 0; + char cbuf[MB_LEN_MAX]; + size_t cbp = 0; + int save_errno = errno; - while ((num_read = read(el->el_infd, cp, 1)) == -1) - if (!tried && read__fixio(el->el_infd, errno) == 0) - tried = 1; - else { - *cp = '\0'; - return (-1); + again: + el->el_signal->sig_no = 0; + while ((num_read = read(el->el_infd, cbuf + cbp, (size_t)1)) == -1) { + int e = errno; + switch (el->el_signal->sig_no) { + case SIGCONT: + FUN(el,set)(el, EL_REFRESH); + /*FALLTHROUGH*/ + case SIGWINCH: + sig_set(el); + goto again; + default: + break; } + if (!tried && read__fixio(el->el_infd, e) == 0) { + errno = save_errno; + tried = 1; + } else { + errno = e; + *cp = L'\0'; + return -1; + } + } - return (num_read); + /* Test for EOF */ + if (num_read == 0) { + *cp = L'\0'; + return 0; + } + + for (;;) { + + ++cbp; + switch (ct_mbrtowc(cp, cbuf, cbp)) { + case (size_t)-1: + if (cbp > 1) { + /* + * Invalid sequence, discard all bytes + * except the last one. + */ + cbuf[0] = cbuf[cbp - 1]; + cbp = 0; + break; + } else { + /* Invalid byte, discard it. */ + cbp = 0; + goto again; + } + case (size_t)-2: + /* + * We don't support other multibyte charsets. + * The second condition shouldn't happen + * and is here merely for additional safety. + */ + if ((el->el_flags & CHARSET_IS_UTF8) == 0 || + cbp >= MB_LEN_MAX) { + errno = EILSEQ; + *cp = L'\0'; + return -1; + } + /* Incomplete sequence, read another byte. */ + goto again; + default: + /* Valid character, process it. */ + return 1; + } + } } +/* read_pop(): + * Pop a macro from the stack + */ +private void +read_pop(c_macro_t *ma) +{ + int i; -/* el_getc(): - * Read a character + el_free(ma->macro[0]); + for (i = 0; i < ma->level; i++) + ma->macro[i] = ma->macro[i + 1]; + ma->level--; + ma->offset = 0; +} + +/* el_wgetc(): + * Read a wide character */ public int -el_getc(EditLine *el, char *cp) +el_wgetc(EditLine *el, wchar_t *cp) { int num_read; c_macro_t *ma = &el->el_chared.c_macro; - term__flush(); + terminal__flush(el); for (;;) { if (ma->level < 0) { if (!read_preread(el)) break; } + if (ma->level < 0) break; - if (ma->macro[ma->level][ma->offset] == '\0') { - el_free(ma->macro[ma->level--]); - ma->offset = 0; + if (ma->macro[0][ma->offset] == '\0') { + read_pop(ma); continue; } - *cp = ma->macro[ma->level][ma->offset++] & 0377; - if (ma->macro[ma->level][ma->offset] == '\0') { + + *cp = ma->macro[0][ma->offset++]; + + if (ma->macro[0][ma->offset] == '\0') { /* Needed for QuoteMode On */ - el_free(ma->macro[ma->level--]); - ma->offset = 0; + read_pop(ma); } - return (1); + + return 1; } #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Turning raw mode on\n"); #endif /* DEBUG_READ */ if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */ - return (0); + return 0; #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Reading a character\n"); #endif /* DEBUG_READ */ num_read = (*el->el_read.read_char)(el, cp); + if (num_read < 0) + el->el_errno = errno; #ifdef DEBUG_READ - (void) fprintf(el->el_errfile, "Got it %c\n", *cp); + (void) fprintf(el->el_errfile, "Got it %lc\n", *cp); #endif /* DEBUG_READ */ - return (num_read); + return num_read; } protected void @@ -366,7 +468,7 @@ re_refresh(el); /* print the prompt */ if (el->el_flags & UNBUFFERED) - term__flush(); + terminal__flush(el); } protected void @@ -378,27 +480,34 @@ sig_clr(el); } -public const char * -el_gets(EditLine *el, int *nread) +public const Char * +FUN(el,gets)(EditLine *el, int *nread) { int retval; el_action_t cmdnum = 0; int num; /* how many chars we have read at NL */ - char ch; + wchar_t wc; + Char ch, *cp; int crlf = 0; + int nrb; #ifdef FIONREAD c_macro_t *ma = &el->el_chared.c_macro; #endif /* FIONREAD */ + if (nread == NULL) + nread = &nrb; + *nread = 0; + if (el->el_flags & NO_TTY) { - char *cp = el->el_line.buffer; size_t idx; - while ((*el->el_read.read_char)(el, cp) == 1) { + cp = el->el_line.buffer; + while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { + *cp = (Char)wc; /* make sure there is space for next character */ if (cp + 1 >= el->el_line.limit) { - idx = (cp - el->el_line.buffer); - if (!ch_enlargebufs(el, 2)) + idx = (size_t)(cp - el->el_line.buffer); + if (!ch_enlargebufs(el, (size_t)2)) break; cp = &el->el_line.buffer[idx]; } @@ -408,12 +517,13 @@ if (cp[-1] == '\r' || cp[-1] == '\n') break; } + if (num == -1) { + if (errno == EINTR) + cp = el->el_line.buffer; + el->el_errno = errno; + } - el->el_line.cursor = el->el_line.lastchar = cp; - *cp = '\0'; - if (nread) - *nread = el->el_line.cursor - el->el_line.buffer; - return (el->el_line.buffer); + goto noedit; } @@ -421,12 +531,12 @@ if (el->el_tty.t_mode == EX_IO && ma->level < 0) { long chrs = 0; - (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); + (void) ioctl(el->el_infd, FIONREAD, &chrs); if (chrs == 0) { if (tty_rawmode(el) < 0) { - if (nread) - *nread = 0; - return (NULL); + errno = 0; + *nread = 0; + return NULL; } } } @@ -436,25 +546,24 @@ read_prepare(el); if (el->el_flags & EDIT_DISABLED) { - char *cp; size_t idx; + if ((el->el_flags & UNBUFFERED) == 0) cp = el->el_line.buffer; else cp = el->el_line.lastchar; - term__flush(); + terminal__flush(el); - while ((*el->el_read.read_char)(el, cp) == 1) { + while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { + *cp = (Char)wc; /* make sure there is space next character */ if (cp + 1 >= el->el_line.limit) { - idx = (cp - el->el_line.buffer); - if (!ch_enlargebufs(el, 2)) + idx = (size_t)(cp - el->el_line.buffer); + if (!ch_enlargebufs(el, (size_t)2)) break; cp = &el->el_line.buffer[idx]; } - if (*cp == 4) /* ought to be stty eof */ - break; cp++; crlf = cp[-1] == '\r' || cp[-1] == '\n'; if (el->el_flags & UNBUFFERED) @@ -463,11 +572,13 @@ break; } - el->el_line.cursor = el->el_line.lastchar = cp; - *cp = '\0'; - if (nread) - *nread = el->el_line.cursor - el->el_line.buffer; - return (el->el_line.buffer); + if (num == -1) { + if (errno == EINTR) + cp = el->el_line.buffer; + el->el_errno = errno; + } + + goto noedit; } for (num = OKCMD; num == OKCMD;) { /* while still editing this @@ -477,13 +588,20 @@ #endif /* DEBUG_EDIT */ /* if EOF or error */ if ((num = read_getcmd(el, &cmdnum, &ch)) != OKCMD) { + num = -1; #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Returning from el_gets %d\n", num); #endif /* DEBUG_READ */ break; } - if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */ + if (el->el_errno == EINTR) { + el->el_line.buffer[0] = '\0'; + el->el_line.lastchar = + el->el_line.cursor = el->el_line.buffer; + break; + } + if ((size_t)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */ #ifdef DEBUG_EDIT (void) fprintf(el->el_errfile, "ERROR: illegal command from key 0%o\r\n", ch); @@ -499,7 +617,7 @@ 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); @@ -513,7 +631,7 @@ el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) { if (cmdnum == VI_DELETE_PREV_CHAR && el->el_chared.c_redo.pos != el->el_chared.c_redo.buf - && isprint((unsigned char)el->el_chared.c_redo.pos[-1])) + && Isprint(el->el_chared.c_redo.pos[-1])) el->el_chared.c_redo.pos--; else *el->el_chared.c_redo.pos++ = ch; @@ -544,7 +662,7 @@ case CC_REFRESH_BEEP: re_refresh(el); - term_beep(el); + terminal_beep(el); break; case CC_NORM: /* normal char */ @@ -565,7 +683,7 @@ break; case CC_NEWLINE: /* normal end of line */ - num = el->el_line.lastchar - el->el_line.buffer; + num = (int)(el->el_line.lastchar - el->el_line.buffer); break; case CC_FATAL: /* fatal error, reset to known state */ @@ -576,7 +694,7 @@ /* put (real) cursor in a known place */ re_clear_display(el); /* reset the display stuff */ ch_reset(el, 1); /* reset the input pointers */ - re_refresh(el); /* print the prompt again */ + re_refresh(el); /* print the prompt again */ break; case CC_ERROR: @@ -585,8 +703,8 @@ (void) fprintf(el->el_errfile, "*** editor ERROR ***\r\n\n"); #endif /* DEBUG_READ */ - term_beep(el); - term__flush(); + terminal_beep(el); + terminal__flush(el); break; } el->el_state.argument = 1; @@ -596,15 +714,26 @@ break; } - term__flush(); /* flush any buffered output */ + terminal__flush(el); /* flush any buffered output */ /* make sure the tty is set up correctly */ if ((el->el_flags & UNBUFFERED) == 0) { read_finish(el); - if (nread) - *nread = num; + *nread = num != -1 ? num : 0; } else { - if (nread) - *nread = el->el_line.lastchar - el->el_line.buffer; + *nread = (int)(el->el_line.lastchar - el->el_line.buffer); } - return (num ? el->el_line.buffer : NULL); + goto done; +noedit: + el->el_line.cursor = el->el_line.lastchar = cp; + *cp = '\0'; + *nread = (int)(el->el_line.cursor - el->el_line.buffer); +done: + if (*nread == 0) { + if (num == -1) { + *nread = -1; + errno = el->el_errno; + } + return NULL; + } else + return el->el_line.buffer; } diff --git a/lib/libedit/read.h b/lib/libedit/read.h index 9bb5eac..d59a8a1 100644 --- a/lib/libedit/read.h +++ b/lib/libedit/read.h @@ -1,3 +1,5 @@ +/* $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $ */ + /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. @@ -13,13 +15,6 @@ * 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 @@ -33,8 +28,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.4 2004/02/27 14:52:18 christos Exp $ - * $FreeBSD: src/lib/libedit/read.h,v 1.1.2.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/read.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -43,12 +37,12 @@ #ifndef _h_el_read #define _h_el_read -typedef int (*el_rfunc_t)(EditLine *, char *); +typedef int (*el_rfunc_t)(EditLine *, wchar_t *); typedef struct el_read_t { el_rfunc_t read_char; /* Function to read a character */ } el_read_t; - + protected int read_init(EditLine *); protected void read_prepare(EditLine *); protected void read_finish(EditLine *); diff --git a/lib/libedit/refresh.h b/lib/libedit/refresh.h index 9496995..afc57ff 100644 --- a/lib/libedit/refresh.h +++ b/lib/libedit/refresh.h @@ -1,3 +1,5 @@ +/* $NetBSD: refresh.h,v 1.9 2016/02/16 15:53:48 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)refresh.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: refresh.h,v 1.5 2003/08/07 16:44:33 agc Exp $ - * $FreeBSD: src/lib/libedit/refresh.h,v 1.2.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/refresh.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,15 +41,13 @@ #ifndef _h_el_refresh #define _h_el_refresh -#include "histedit.h" - typedef struct { coord_t r_cursor; /* Refresh cursor position */ int r_oldcv; /* Vertical locations */ int r_newcv; } el_refresh_t; -protected void re_putc(EditLine *, int, int); +protected void re_putc(EditLine *, wint_t, int); protected void re_clear_lines(EditLine *); protected void re_clear_display(EditLine *); protected void re_refresh(EditLine *); diff --git a/lib/libedit/search.h b/lib/libedit/search.h index 2b63675..3940d03 100644 --- a/lib/libedit/search.h +++ b/lib/libedit/search.h @@ -1,3 +1,5 @@ +/* $NetBSD: search.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)search.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: search.h,v 1.8 2003/10/18 23:27:36 christos Exp $ - * $FreeBSD: src/lib/libedit/search.h,v 1.3.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/search.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,27 +41,25 @@ #ifndef _h_el_search #define _h_el_search -#include "histedit.h" - typedef struct el_search_t { - char *patbuf; /* The pattern buffer */ + Char *patbuf; /* The pattern buffer */ size_t patlen; /* Length of the pattern buffer */ int patdir; /* Direction of the last search */ int chadir; /* Character search direction */ - char chacha; /* Character we are looking for */ + Char chacha; /* Character we are looking for */ char chatflg; /* 0 if f, 1 if t */ } el_search_t; -protected int el_match(const char *, const char *); +protected int el_match(const Char *, const Char *); protected int search_init(EditLine *); protected void search_end(EditLine *); -protected int c_hmatch(EditLine *, const char *); +protected int c_hmatch(EditLine *, const Char *); protected void c_setpat(EditLine *); protected el_action_t ce_inc_search(EditLine *, int); protected el_action_t cv_search(EditLine *, int); protected el_action_t ce_search_line(EditLine *, int); -protected el_action_t cv_repeat_srch(EditLine *, int); -protected el_action_t cv_csearch(EditLine *, int, int, int, int); +protected el_action_t cv_repeat_srch(EditLine *, wint_t); +protected el_action_t cv_csearch(EditLine *, int, wint_t, int, int); #endif /* _h_el_search */ diff --git a/lib/libedit/sig.h b/lib/libedit/sig.h index 23cb9ab..cd80ad9 100644 --- a/lib/libedit/sig.h +++ b/lib/libedit/sig.h @@ -1,3 +1,5 @@ +/* $NetBSD: sig.h,v 1.10 2016/02/16 15:53:48 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)sig.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $ - * $FreeBSD: src/lib/libedit/sig.h,v 1.2.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/sig.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -42,8 +43,6 @@ #include -#include "histedit.h" - /* * Define here all the signals we are going to handle * The _DO macro is used to iterate in the source code @@ -51,15 +50,18 @@ #define ALLSIGS \ _DO(SIGINT) \ _DO(SIGTSTP) \ - _DO(SIGSTOP) \ _DO(SIGQUIT) \ _DO(SIGHUP) \ _DO(SIGTERM) \ _DO(SIGCONT) \ _DO(SIGWINCH) +#define ALLSIGSNO 7 -typedef void (*el_signalhandler_t)(int); -typedef el_signalhandler_t *el_signal_t; +typedef struct { + struct sigaction sig_action[ALLSIGSNO]; + sigset_t sig_set; + volatile sig_atomic_t sig_no; +} *el_signal_t; protected void sig_end(EditLine*); protected int sig_init(EditLine*); diff --git a/lib/libedit/sys.h b/lib/libedit/sys.h index 162efae..08ceeb8 100644 --- a/lib/libedit/sys.h +++ b/lib/libedit/sys.h @@ -1,3 +1,5 @@ +/* $NetBSD: sys.h,v 1.23 2016/02/17 19:47:49 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,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 $ - * $FreeBSD: src/lib/libedit/sys.h,v 1.4.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/sys.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,7 +41,23 @@ #ifndef _h_sys #define _h_sys +#ifdef HAVE_SYS_CDEFS_H #include +#endif + +#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(A) +#endif + +#ifndef __BEGIN_DECLS +# ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +# else +# define __BEGIN_DECLS +# define __END_DECLS +# endif +#endif #ifndef public # define public /* Externally visible functions/variables */ @@ -55,55 +72,58 @@ /* When we want to hide everything */ #endif -#ifndef _PTR_T -# define _PTR_T -typedef void *ptr_t; -#endif - -#ifndef _IOCTL_T -# define _IOCTL_T -typedef void *ioctl_t; +#ifndef __arraycount +# define __arraycount(a) (sizeof(a) / sizeof(*(a))) #endif #include +#ifndef HAVE_STRLCAT +#define strlcat libedit_strlcat +size_t strlcat(char *dst, const char *src, size_t size); +#endif + +#ifndef HAVE_STRLCPY +#define strlcpy libedit_strlcpy +size_t strlcpy(char *dst, const char *src, size_t size); +#endif + +#ifndef HAVE_GETLINE +#define getline libedit_getline +ssize_t getline(char **line, size_t *len, FILE *fp); +#endif + +#ifndef _DIAGASSERT +#define _DIAGASSERT(x) +#endif + +#ifndef __RCSID +#define __RCSID(x) +#endif + +#ifndef HAVE_U_INT32_T +typedef unsigned int u_int32_t; +#endif + +#ifndef HAVE_SIZE_MAX +#define SIZE_MAX ((size_t)-1) +#endif + #define REGEX /* Use POSIX.2 regular expression functions */ #undef REGEXP /* Use UNIX V8 regular expression functions */ -#ifdef notdef -# undef REGEX -# undef REGEXP -# include -# ifdef __GNUC__ -/* - * Broken hdrs. - */ -extern int tgetent(const char *bp, char *name); -extern int tgetflag(const char *id); -extern int tgetnum(const char *id); -extern char *tgetstr(const char *id, char **area); -extern char *tgoto(const char *cap, int col, int row); -extern int tputs(const char *str, int affcnt, int (*putc)(int)); -extern char *getenv(const char *); -extern int fprintf(FILE *, const char *, ...); -extern int sigsetmask(int); -extern int sigblock(int); -extern int fputc(int, FILE *); -extern int fgetc(FILE *); -extern int fflush(FILE *); -extern int tolower(int); -extern int toupper(int); -extern int errno, sys_nerr; -extern char *sys_errlist[]; -extern void perror(const char *); -# include -# define strerror(e) sys_errlist[e] -# endif -# ifdef SABER -extern ptr_t memcpy(ptr_t, const ptr_t, size_t); -extern ptr_t memset(ptr_t, int, size_t); -# endif -extern char *fgetline(FILE *, int *); +#ifndef WIDECHAR +#define setlocale(c, l) /*LINTED*/NULL +#define nl_langinfo(i) "" +#endif + +#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 #endif /* _h_sys */ diff --git a/lib/libedit/term.h b/lib/libedit/term.h deleted file mode 100644 index 6e0301d..0000000 --- a/lib/libedit/term.h +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Christos Zoulas of Cornell University. - * - * 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. Neither the name of the University 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 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. - * - * @(#)term.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: term.h,v 1.16 2005/03/15 00:10:40 christos Exp $ - * $FreeBSD: src/lib/libedit/term.h,v 1.5.14.1 2005/10/09 03:44:01 delphij Exp $ - */ - -/* - * el.term.h: Termcap header - */ -#ifndef _h_el_term -#define _h_el_term - -#include "histedit.h" - -typedef struct { /* Symbolic function key bindings */ - const char *name; /* name of the key */ - int key; /* Index in termcap table */ - key_value_t fun; /* Function bound to it */ - int type; /* Type of function */ -} fkey_t; - -typedef struct { - const char *t_name; /* the terminal name */ - coord_t t_size; /* # lines and cols */ - int t_flags; -#define TERM_CAN_INSERT 0x001 /* Has insert cap */ -#define TERM_CAN_DELETE 0x002 /* Has delete cap */ -#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ -#define TERM_CAN_TAB 0x008 /* Can use tabs */ -#define TERM_CAN_ME 0x010 /* Can turn all attrs. */ -#define TERM_CAN_UP 0x020 /* Can move up */ -#define TERM_HAS_META 0x040 /* Has a meta key */ -#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ -#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ - char *t_buf; /* Termcap buffer */ - int t_loc; /* location used */ - char **t_str; /* termcap strings */ - int *t_val; /* termcap values */ - char *t_cap; /* Termcap buffer */ - fkey_t *t_fkey; /* Array of keys */ -} el_term_t; - -/* - * fKey indexes - */ -#define A_K_DN 0 -#define A_K_UP 1 -#define A_K_LT 2 -#define A_K_RT 3 -#define A_K_HO 4 -#define A_K_EN 5 -#define A_K_NKEYS 6 - -protected void term_move_to_line(EditLine *, int); -protected void term_move_to_char(EditLine *, int); -protected void term_clear_EOL(EditLine *, int); -protected void term_overwrite(EditLine *, const char *, int); -protected void term_insertwrite(EditLine *, char *, int); -protected void term_deletechars(EditLine *, int); -protected void term_clear_screen(EditLine *); -protected void term_beep(EditLine *); -protected int term_change_size(EditLine *, int, int); -protected int term_get_size(EditLine *, int *, int *); -protected int term_init(EditLine *); -protected void term_bind_arrow(EditLine *); -protected void term_print_arrow(EditLine *, const char *); -protected int term_clear_arrow(EditLine *, const char *); -protected int term_set_arrow(EditLine *, const char *, key_value_t *, int); -protected void term_end(EditLine *); -protected void term_get(EditLine *, const char **); -protected int term_set(EditLine *, const char *); -protected int term_settc(EditLine *, int, const char **); -protected int term_telltc(EditLine *, int, const char **); -protected int term_echotc(EditLine *, int, const char **); -protected int term__putc(int); -protected void term__flush(void); - -/* - * Easy access macros - */ -#define EL_FLAGS (el)->el_term.t_flags - -#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) -#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) -#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL) -#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB) -#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME) -#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP) -#define EL_HAS_META (EL_FLAGS & TERM_HAS_META) -#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS) -#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS) - -#endif /* _h_el_term */ diff --git a/lib/libedit/tty.h b/lib/libedit/tty.h index 3a3a0b8..5432731 100644 --- a/lib/libedit/tty.h +++ b/lib/libedit/tty.h @@ -1,3 +1,5 @@ +/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,8 +32,7 @@ * SUCH DAMAGE. * * @(#)tty.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: tty.h,v 1.11 2005/06/01 11:37:52 lukem Exp $ - * $FreeBSD: src/lib/libedit/tty.h,v 1.4.14.1 2005/10/09 03:44:01 delphij Exp $ + * $FreeBSD: releng/11.1/lib/libedit/tty.h 313981 2017-02-20 03:33:59Z pfg $ */ /* @@ -40,7 +41,6 @@ #ifndef _h_el_tty #define _h_el_tty -#include "histedit.h" #include #include @@ -430,7 +430,7 @@ #define C_MIN 23 #define C_TIME 24 #define C_NCC 25 -#define C_SH(A) (1 << (A)) +#define C_SH(A) ((unsigned int)(1 << (A))) /* * Terminal dependend data structures @@ -441,6 +441,7 @@ #define QU_IO 2 /* used only for quoted chars */ #define NN_IO 3 /* The number of entries */ +/* Don't re-order */ #define MD_INP 0 #define MD_OUT 1 #define MD_CTL 2 @@ -458,7 +459,7 @@ protected int tty_init(EditLine *); protected void tty_end(EditLine *); -protected int tty_stty(EditLine *, int, const char **); +protected int tty_stty(EditLine *, int, const Char **); protected int tty_rawmode(EditLine *); protected int tty_cookedmode(EditLine *); protected int tty_quotemode(EditLine *); @@ -468,12 +469,13 @@ typedef struct { ttyperm_t t_t; ttychar_t t_c; - struct termios t_ex, t_ed, t_ts; + struct termios t_or, t_ex, t_ed, t_ts; int t_tabs; int t_eight; speed_t t_speed; - int t_mode; + unsigned char t_mode; unsigned char t_vdisable; + unsigned char t_initialized; } el_tty_t; diff --git a/lib/libedit/vi.h b/lib/libedit/vi.h deleted file mode 100644 index fec33b4..0000000 --- a/lib/libedit/vi.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Automatically generated file, do not edit */ -#ifndef _h_vi_c -#define _h_vi_c -protected el_action_t vi_paste_next (EditLine *, int); -protected el_action_t vi_paste_prev (EditLine *, int); -protected el_action_t vi_prev_big_word (EditLine *, int); -protected el_action_t vi_prev_word (EditLine *, int); -protected el_action_t vi_next_big_word (EditLine *, int); -protected el_action_t vi_next_word (EditLine *, int); -protected el_action_t vi_change_case (EditLine *, int); -protected el_action_t vi_change_meta (EditLine *, int); -protected el_action_t vi_insert_at_bol (EditLine *, int); -protected el_action_t vi_replace_char (EditLine *, int); -protected el_action_t vi_replace_mode (EditLine *, int); -protected el_action_t vi_substitute_char (EditLine *, int); -protected el_action_t vi_substitute_line (EditLine *, int); -protected el_action_t vi_change_to_eol (EditLine *, int); -protected el_action_t vi_insert (EditLine *, int); -protected el_action_t vi_add (EditLine *, int); -protected el_action_t vi_add_at_eol (EditLine *, int); -protected el_action_t vi_delete_meta (EditLine *, int); -protected el_action_t vi_end_big_word (EditLine *, int); -protected el_action_t vi_end_word (EditLine *, int); -protected el_action_t vi_undo (EditLine *, int); -protected el_action_t vi_command_mode (EditLine *, int); -protected el_action_t vi_zero (EditLine *, int); -protected el_action_t vi_delete_prev_char (EditLine *, int); -protected el_action_t vi_list_or_eof (EditLine *, int); -protected el_action_t vi_kill_line_prev (EditLine *, int); -protected el_action_t vi_search_prev (EditLine *, int); -protected el_action_t vi_search_next (EditLine *, int); -protected el_action_t vi_repeat_search_next (EditLine *, int); -protected el_action_t vi_repeat_search_prev (EditLine *, int); -protected el_action_t vi_next_char (EditLine *, int); -protected el_action_t vi_prev_char (EditLine *, int); -protected el_action_t vi_to_next_char (EditLine *, int); -protected el_action_t vi_to_prev_char (EditLine *, int); -protected el_action_t vi_repeat_next_char (EditLine *, int); -protected el_action_t vi_repeat_prev_char (EditLine *, int); -protected el_action_t vi_match (EditLine *, int); -protected el_action_t vi_undo_line (EditLine *, int); -protected el_action_t vi_to_column (EditLine *, int); -protected el_action_t vi_yank_end (EditLine *, int); -protected el_action_t vi_yank (EditLine *, int); -protected el_action_t vi_comment_out (EditLine *, int); -protected el_action_t vi_alias (EditLine *, int); -protected el_action_t vi_to_history_line (EditLine *, int); -protected el_action_t vi_histedit (EditLine *, int); -protected el_action_t vi_history_word (EditLine *, int); -protected el_action_t vi_redo (EditLine *, int); -#endif /* _h_vi_c */ diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk index a934225..183596e 100644 --- a/share/mk/local.dirdeps.mk +++ b/share/mk/local.dirdeps.mk @@ -22,7 +22,7 @@ #.info M_dep_qual_fixes=${M_dep_qual_fixes} # Cheat for including src.libnames.mk -____: +____: # Pull in _INTERNALLIBS .include @@ -109,7 +109,7 @@ _PROGS_SRCS+= ${SRCS${s}${_prog}} .endif .endfor # .for s in . _ -# Add in assumed source (bsd.prog.mk) +# Add in assumed source (ubix.prog.mk) .if !target(${_prog}) .if defined(PROG_CXX) _PROGS_SRCS+= ${_prog}.cc diff --git a/share/mk/local.init.mk b/share/mk/local.init.mk index ba7c731..52fafac 100644 --- a/share/mk/local.init.mk +++ b/share/mk/local.init.mk @@ -1,7 +1,7 @@ # $FreeBSD: releng/11.1/share/mk/local.init.mk 294349 2016-01-19 22:41:44Z bdrewery $ .if ${.MAKE.MODE:Mmeta*} != "" -.if !empty(SUBDIR) && !defined(LIB) && !defined(PROG) && ${.MAKE.MAKEFILES:M*bsd.prog.mk} == "" +.if !empty(SUBDIR) && !defined(LIB) && !defined(PROG) && ${.MAKE.MAKEFILES:M*ubix.prog.mk} == "" .if ${.MAKE.MODE:Mleaf*} != "" # we only want leaf dirs to build in meta mode... and we are not one .MAKE.MODE = normal diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk index 59b3cc8..cc1816f 100644 --- a/share/mk/local.sys.mk +++ b/share/mk/local.sys.mk @@ -50,9 +50,9 @@ # we can afford to use cookies to prevent some targets # re-running needlessly but only when using filemon. # Targets that should support the meta mode cookie handling should just be -# added to META_TARGETS. If bsd.sys.mk cannot be included then ${META_DEPS} +# added to META_TARGETS. If ubix.sys.mk cannot be included then ${META_DEPS} # should be added as a target dependency as well. Otherwise the target -# is added to in bsd.sys.mk since it comes last. +# is added to in ubix.sys.mk since it comes last. .if ${.MAKE.MODE:Mnofilemon} == "" # Prepend .OBJDIR if not already there. _META_COOKIE_COND= "${.TARGET:M${.OBJDIR}/*}" == "" diff --git a/share/mk/src.sys.mk b/share/mk/src.sys.mk index 15bcaaf..a3d4eba 100644 --- a/share/mk/src.sys.mk +++ b/share/mk/src.sys.mk @@ -13,7 +13,7 @@ !target(_srcconf_included_) # Validate that the user didn't try setting an env-only variable in -# their src.conf. This benefits from already including bsd.mkopt.mk. +# their src.conf. This benefits from already including ubix.mkopt.mk. .for var in ${__ENV_ONLY_OPTIONS} __presrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno:Dyes} .endfor @@ -34,6 +34,6 @@ .endif # SRCCONF .endif -# tempting, but bsd.compiler.mk causes problems this early -# probably need to remove dependence on bsd.own.mk +# tempting, but ubix.compiler.mk causes problems this early +# probably need to remove dependence on ubix.own.mk #.include "src.opts.mk" diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 27b0899..e5c4ff7 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -1,7 +1,7 @@ # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 # $FreeBSD: releng/11.1/share/mk/sys.mk 320297 2017-06-23 20:25:58Z bdrewery $ -unix ?= We run FreeBSD, not UNIX. +unix ?= We run UbixOS, not UNIX. .FreeBSD ?= true .if !defined(%POSIX)