CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri May 17 02:59:09 UTC 2024 Modified Files: src/lib/libedit: el.h eln.c Log Message: When calling el_line make sure that we call the resizing function callback because el_line updates the legacy LineInfo structure and we need to notify that the cached copy of the the buffer has changed. Of course the resizing function can call el_line itself to update the buffer, so prevent recursion. Bug found by Peter Rufer at Arista. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/lib/libedit/el.h cvs rdiff -u -r1.37 -r1.38 src/lib/libedit/eln.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/el.h diff -u src/lib/libedit/el.h:1.46 src/lib/libedit/el.h:1.47 --- src/lib/libedit/el.h:1.46 Sun Aug 15 06:08:41 2021 +++ src/lib/libedit/el.h Thu May 16 22:59:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: el.h,v 1.46 2021/08/15 10:08:41 christos Exp $ */ +/* $NetBSD: el.h,v 1.47 2024/05/17 02:59:08 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -58,6 +58,7 @@ #define NARROW_HISTORY 0x040 #define NO_RESET 0x080 #define FIXIO 0x100 +#define FROM_ELLINE 0x200 typedef unsigned char el_action_t; /* Index to command array */ Index: src/lib/libedit/eln.c diff -u src/lib/libedit/eln.c:1.37 src/lib/libedit/eln.c:1.38 --- src/lib/libedit/eln.c:1.37 Tue Jan 11 13:30:15 2022 +++ src/lib/libedit/eln.c Thu May 16 22:59:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $ */ +/* $NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $"); +__RCSID("$NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -365,6 +365,10 @@ el_line(EditLine *el) size_t offset; const wchar_t *p; + if (el->el_flags & FROM_ELLINE) + return info; + + el->el_flags |= FROM_ELLINE; info->buffer = ct_encode_string(winfo->buffer, >el_lgcyconv); offset = 0; @@ -377,6 +381,10 @@ el_line(EditLine *el) offset += ct_enc_width(*p); info->lastchar = info->buffer + offset; + if (el->el_chared.c_resizefun) + (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg); + el->el_flags &= ~FROM_ELLINE; + return info; }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri May 17 02:59:09 UTC 2024 Modified Files: src/lib/libedit: el.h eln.c Log Message: When calling el_line make sure that we call the resizing function callback because el_line updates the legacy LineInfo structure and we need to notify that the cached copy of the the buffer has changed. Of course the resizing function can call el_line itself to update the buffer, so prevent recursion. Bug found by Peter Rufer at Arista. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/lib/libedit/el.h cvs rdiff -u -r1.37 -r1.38 src/lib/libedit/eln.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Apr 6 13:36:11 UTC 2024 Modified Files: src/lib/libedit: editline.7 Log Message: update em-toggle-overwrite binding (Xose Vazquez Perez) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libedit/editline.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/editline.7 diff -u src/lib/libedit/editline.7:1.5 src/lib/libedit/editline.7:1.6 --- src/lib/libedit/editline.7:1.5 Mon May 9 17:27:55 2016 +++ src/lib/libedit/editline.7 Sat Apr 6 09:36:11 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: editline.7,v 1.5 2016/05/09 21:27:55 christos Exp $ +.\" $NetBSD: editline.7,v 1.6 2024/04/06 13:36:11 christos Exp $ .\" $OpenBSD: editline.7,v 1.1 2016/04/20 01:11:45 schwarze Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd May 7, 2016 +.Dd April 6, 2024 .Dt EDITLINE 7 .Os .Sh NAME @@ -546,7 +546,7 @@ It is an error if the cursor is already buffer. .It Ic em-set-mark Pq emacs: Ctrl-Q, NUL Set the mark at the current cursor position. -.It Ic em-toggle-overwrite Pq not bound by default +.It Ic em-toggle-overwrite Pq insert Switch from insert to overwrite mode or vice versa. .It Ic em-universal-argument Pq not bound by default If in argument input mode, multiply the argument by 4.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Apr 6 13:36:11 UTC 2024 Modified Files: src/lib/libedit: editline.7 Log Message: update em-toggle-overwrite binding (Xose Vazquez Perez) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libedit/editline.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Mar 26 18:02:04 UTC 2024 Modified Files: src/lib/libedit: readline.c Log Message: fix insert key (Xose Vazquez Perez) To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.181 src/lib/libedit/readline.c:1.182 --- src/lib/libedit/readline.c:1.181 Tue Apr 25 13:51:32 2023 +++ src/lib/libedit/readline.c Tue Mar 26 14:02:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.181 2023/04/25 17:51:32 christos Exp $ */ +/* $NetBSD: readline.c,v 1.182 2024/03/26 18:02:04 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.181 2023/04/25 17:51:32 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.182 2024/03/26 18:02:04 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -402,7 +402,7 @@ rl_initialize(void) * Allow the use of the Delete/Insert keys. */ el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL); - el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL); + el_set(e, EL_BIND, "\\e[2~", "em-toggle-overwrite", NULL); /* * Ctrl-left-arrow and Ctrl-right-arrow for word moving.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Mar 26 18:02:04 UTC 2024 Modified Files: src/lib/libedit: readline.c Log Message: fix insert key (Xose Vazquez Perez) To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: wiz Date: Wed Jun 21 21:44:31 UTC 2023 Modified Files: src/lib/libedit: libedit.pc Log Message: libedit: fix pkg-config to really provide readline directory as intended To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libedit/libedit.pc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/libedit.pc diff -u src/lib/libedit/libedit.pc:1.1 src/lib/libedit/libedit.pc:1.2 --- src/lib/libedit/libedit.pc:1.1 Tue Jun 20 23:09:14 2023 +++ src/lib/libedit/libedit.pc Wed Jun 21 21:44:31 2023 @@ -9,4 +9,4 @@ Version: 3.1 Requires: Libs: -Wl,-R${libdir} -L${libdir} -ledit Libs.private: -ltermcap -Cflags: -I${includedir} -I${includedir}/editline +Cflags: -I${includedir} -I${includedir}/readline
CVS commit: src/lib/libedit
Module Name:src Committed By: wiz Date: Wed Jun 21 21:44:31 UTC 2023 Modified Files: src/lib/libedit: libedit.pc Log Message: libedit: fix pkg-config to really provide readline directory as intended To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libedit/libedit.pc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue May 30 11:53:40 UTC 2023 Modified Files: src/lib/libedit: tokenizer.c Log Message: Fix some const qual (Piotr Pawel Stefaniak) To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libedit/tokenizer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/tokenizer.c diff -u src/lib/libedit/tokenizer.c:1.28 src/lib/libedit/tokenizer.c:1.29 --- src/lib/libedit/tokenizer.c:1.28 Mon Apr 11 14:56:31 2016 +++ src/lib/libedit/tokenizer.c Tue May 30 07:53:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tokenizer.c,v 1.28 2016/04/11 18:56:31 christos Exp $ */ +/* $NetBSD: tokenizer.c,v 1.29 2023/05/30 11:53:40 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: tokenizer.c,v 1.28 2016/04/11 18:56:31 christos Exp $"); +__RCSID("$NetBSD: tokenizer.c,v 1.29 2023/05/30 11:53:40 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -85,7 +85,7 @@ typedef enum { struct TYPE(tokenizer) { Char *ifs; /* In field separator */ size_t argc, amax; /* Current and maximum number of args */ - Char **argv; /* Argument list */ + const Char **argv; /* Argument list */ Char *wptr, *wmax; /* Space and limit on the word buffer */ Char *wstart; /* Beginning of next word */ Char *wspace; /* Space of word buffer */ @@ -424,7 +424,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, cons tok->wmax = s + size; } if (tok->argc >= tok->amax - 4) { - Char **p; + const Char **p; tok->amax += AINCR; p = tok_realloc(tok->argv, tok->amax * sizeof(*p)); if (p == NULL) { @@ -444,7 +444,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, cons if (cursoro != NULL) *cursoro = co; FUN(tok,finish)(tok); - *argv = (const Char **)tok->argv; + *argv = tok->argv; *argc = (int)tok->argc; return 0; }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue May 30 11:53:40 UTC 2023 Modified Files: src/lib/libedit: tokenizer.c Log Message: Fix some const qual (Piotr Pawel Stefaniak) To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libedit/tokenizer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Apr 25 17:51:32 UTC 2023 Modified Files: src/lib/libedit: filecomplete.c filecomplete.h readline.c sys.h src/lib/libedit/readline: readline.h Log Message: pass lint. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.14 -r1.15 src/lib/libedit/filecomplete.h cvs rdiff -u -r1.180 -r1.181 src/lib/libedit/readline.c cvs rdiff -u -r1.28 -r1.29 src/lib/libedit/sys.h cvs rdiff -u -r1.54 -r1.55 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Apr 25 17:51:32 UTC 2023 Modified Files: src/lib/libedit: filecomplete.c filecomplete.h readline.c sys.h src/lib/libedit/readline: readline.h Log Message: pass lint. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.14 -r1.15 src/lib/libedit/filecomplete.h cvs rdiff -u -r1.180 -r1.181 src/lib/libedit/readline.c cvs rdiff -u -r1.28 -r1.29 src/lib/libedit/sys.h cvs rdiff -u -r1.54 -r1.55 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.72 src/lib/libedit/filecomplete.c:1.73 --- src/lib/libedit/filecomplete.c:1.72 Fri Feb 3 17:01:42 2023 +++ src/lib/libedit/filecomplete.c Tue Apr 25 13:51:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.73 2023/04/25 17:51:32 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.73 2023/04/25 17:51:32 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -459,11 +459,11 @@ out: el_free(expname); return rs; } + /* * returns list of completions for text given * non-static for readline. */ -char ** completion_matches(const char *, char *(*)(const char *, int)); char ** completion_matches(const char *text, char *(*genfunc)(const char *, int)) { Index: src/lib/libedit/filecomplete.h diff -u src/lib/libedit/filecomplete.h:1.14 src/lib/libedit/filecomplete.h:1.15 --- src/lib/libedit/filecomplete.h:1.14 Sun Sep 26 09:45:54 2021 +++ src/lib/libedit/filecomplete.h Tue Apr 25 13:51:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.h,v 1.14 2021/09/26 13:45:54 christos Exp $ */ +/* $NetBSD: filecomplete.h,v 1.15 2023/04/25 17:51:32 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -48,4 +48,7 @@ void fn_display_match_list(EditLine *, c char *fn_tilde_expand(const char *); char *fn_filename_completion_function(const char *, int); +/* XXX: readline */ +char **completion_matches(const char *, char *(*)(const char *, int)); + #endif Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.180 src/lib/libedit/readline.c:1.181 --- src/lib/libedit/readline.c:1.180 Mon Apr 24 16:02:53 2023 +++ src/lib/libedit/readline.c Tue Apr 25 13:51:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.180 2023/04/24 20:02:53 christos Exp $ */ +/* $NetBSD: readline.c,v 1.181 2023/04/25 17:51:32 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.180 2023/04/24 20:02:53 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.181 2023/04/25 17:51:32 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -51,7 +51,9 @@ __RCSID("$NetBSD: readline.c,v 1.180 202 #include #include +#define completion_matches xxx_completion_matches #include "readline/readline.h" +#undef completion_matches #include "el.h" #include "fcns.h" #include "filecomplete.h" @@ -101,7 +103,7 @@ int max_input_history = 0; char history_expansion_char = '!'; char history_subst_char = '^'; char *history_no_expand_chars = expand_chars; -Function *history_inhibit_expansion_function = NULL; +rl_linebuf_func_t *history_inhibit_expansion_function = NULL; char *history_arg_extract(int start, int end, const char *str); int rl_inhibit_completion = 0; Index: src/lib/libedit/sys.h diff -u src/lib/libedit/sys.h:1.28 src/lib/libedit/sys.h:1.29 --- src/lib/libedit/sys.h:1.28 Sat Feb 4 09:34:28 2023 +++ src/lib/libedit/sys.h Tue Apr 25 13:51:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sys.h,v 1.28 2023/02/04 14:34:28 christos Exp $ */ +/* $NetBSD: sys.h,v 1.29 2023/04/25 17:51:32 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -44,7 +44,7 @@ #include #endif -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +#if !defined(__attribute__) && !defined(__lint__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) # define __attribute__(A) #endif Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.54 src/lib/libedit/readline/readline.h:1.55 --- src/lib/libedit/readline/readline.h:1.54 Fri Apr 21 10:56:13 2023 +++ src/lib/libedit/readline/readline.h Tue Apr 25 13:51:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.54 2023/04/21 14:56:13 christos Exp $ */ +/* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */ /*- *
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Apr 24 20:02:53 UTC 2023 Modified Files: src/lib/libedit: readline.c Log Message: PR/57376: Jorge Giner: readline file completion does not quote; do the same. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.179 src/lib/libedit/readline.c:1.180 --- src/lib/libedit/readline.c:1.179 Fri Apr 21 10:56:13 2023 +++ src/lib/libedit/readline.c Mon Apr 24 16:02:53 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.179 2023/04/21 14:56:13 christos Exp $ */ +/* $NetBSD: readline.c,v 1.180 2023/04/24 20:02:53 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.179 2023/04/21 14:56:13 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.180 2023/04/24 20:02:53 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -1978,7 +1978,7 @@ rl_complete(int ignore __attribute__((__ _rl_update_pos(); /* Just look at how many global variables modify this operation! */ - return fn_complete(e, + return fn_complete2(e, (rl_compentry_func_t *)rl_completion_entry_function, rl_attempted_completion_function, ct_decode_string(rl_basic_word_break_characters, _conv), @@ -1986,7 +1986,7 @@ rl_complete(int ignore __attribute__((__ _rl_completion_append_character_function, (size_t)rl_completion_query_items, _completion_type, _attempted_completion_over, - _point, _end); + _point, _end, 0); }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Apr 24 20:02:53 UTC 2023 Modified Files: src/lib/libedit: readline.c Log Message: PR/57376: Jorge Giner: readline file completion does not quote; do the same. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Apr 21 14:56:13 UTC 2023 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: Align types with readline-8.2 (wiz@) To generate a diff of this commit: cvs rdiff -u -r1.178 -r1.179 src/lib/libedit/readline.c cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.178 src/lib/libedit/readline.c:1.179 --- src/lib/libedit/readline.c:1.178 Fri Dec 2 14:23:15 2022 +++ src/lib/libedit/readline.c Fri Apr 21 10:56:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $ */ +/* $NetBSD: readline.c,v 1.179 2023/04/21 14:56:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.179 2023/04/21 14:56:13 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -122,11 +122,11 @@ int rl_filename_completion_desired = 0; int rl_ignore_completion_duplicates = 0; int readline_echoing_p = 1; int _rl_print_completions_horizontally = 0; -VFunction *rl_redisplay_function = NULL; +rl_voidfunc_t *rl_redisplay_function = NULL; rl_hook_func_t *rl_startup_hook = NULL; -VFunction *rl_completion_display_matches_hook = NULL; -VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; -VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; +rl_compdisp_func_t *rl_completion_display_matches_hook = NULL; +rl_vintfunc_t *rl_prep_term_function = (rl_vintfunc_t *)rl_prep_terminal; +rl_voidfunc_t *rl_deprep_term_function = (rl_voidfunc_t *)rl_deprep_terminal; KEYMAP_ENTRY_ARRAY emacs_meta_keymap; unsigned long rl_readline_state = RL_STATE_NONE; int _rl_complete_mark_directories; @@ -2573,7 +2573,7 @@ void rl_reset_after_signal(void) { if (rl_prep_term_function) - (*rl_prep_term_function)(); + (*rl_prep_term_function)(1); } void Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.53 src/lib/libedit/readline/readline.h:1.54 --- src/lib/libedit/readline/readline.h:1.53 Sat Feb 19 12:45:02 2022 +++ src/lib/libedit/readline/readline.h Fri Apr 21 10:56:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.53 2022/02/19 17:45:02 christos Exp $ */ +/* $NetBSD: readline.h,v 1.54 2023/04/21 14:56:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,11 +38,12 @@ /* typedefs */ typedef int Function(const char *, int); -typedef char *CPFunction(const char *, int); -typedef void VFunction(void); +typedef void rl_voidfunc_t(void); +typedef void rl_vintfunc_t(int); typedef void rl_vcpfunc_t(char *); typedef char **rl_completion_func_t(const char *, int, int); typedef char *rl_compentry_func_t(const char *, int); +typedef void rl_compdisp_func_t(char **, int, int); typedef int rl_command_func_t(int, int); typedef int rl_hook_func_t(void); typedef int rl_icppfunc_t(char **); @@ -145,10 +146,10 @@ extern KEYMAP_ENTRY_ARRAY emacs_standard extern int rl_filename_completion_desired; extern int rl_ignore_completion_duplicates; extern int (*rl_getc_function)(FILE *); -extern VFunction *rl_redisplay_function; -extern VFunction *rl_completion_display_matches_hook; -extern VFunction *rl_prep_term_function; -extern VFunction *rl_deprep_term_function; +extern rl_voidfunc_t *rl_redisplay_function; +extern rl_compdisp_func_t *rl_completion_display_matches_hook; +extern rl_vintfunc_t *rl_prep_term_function; +extern rl_voidfunc_t *rl_deprep_term_function; extern rl_hook_func_t *rl_event_hook; extern int readline_echoing_p; extern int _rl_print_completions_horizontally;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Apr 21 14:56:13 UTC 2023 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: Align types with readline-8.2 (wiz@) To generate a diff of this commit: cvs rdiff -u -r1.178 -r1.179 src/lib/libedit/readline.c cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Feb 4 14:34:28 UTC 2023 Modified Files: src/lib/libedit: config.h sys.h terminal.c Log Message: Remove unused stuff, and limit the scope of some of the used ones. (from des@freebsd) To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libedit/config.h cvs rdiff -u -r1.27 -r1.28 src/lib/libedit/sys.h cvs rdiff -u -r1.45 -r1.46 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/config.h diff -u src/lib/libedit/config.h:1.9 src/lib/libedit/config.h:1.10 --- src/lib/libedit/config.h:1.9 Wed Mar 23 18:27:48 2016 +++ src/lib/libedit/config.h Sat Feb 4 09:34:28 2023 @@ -1,31 +1,6 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if the `closedir' function returns void instead of `int'. */ -/* #undef CLOSEDIR_VOID */ - /* Define to 1 if you have the header file. */ #define HAVE_CURSES_H 1 -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `endpwent' function. */ -#define HAVE_ENDPWENT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `getline' function. */ -#define HAVE_GETLINE 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - /* Define to 1 if you have getpwnam_r and getpwuid_r that are draft POSIX.1 versions. */ /* #undef HAVE_GETPW_R_DRAFT */ @@ -34,253 +9,23 @@ compatible. */ #define HAVE_GETPW_R_POSIX 1 -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `isascii' function. */ -#define HAVE_ISASCII 1 - /* Define to 1 if you have the `issetugid' function. */ #define HAVE_ISSETUGID 1 -/* Define to 1 if you have the `curses' library (-lcurses). */ -/* #undef HAVE_LIBCURSES */ - -/* Define to 1 if you have the `ncurses' library (-lncurses). */ -/* #undef HAVE_LIBNCURSES */ - -/* Define to 1 if you have the `termcap' library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define to 1 if you have the `terminfo' library (-lterminfo). */ -#define HAVE_LIBTERMINFO 1 - -/* Define to 1 if you have the `termlib' library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the `memchr' function. */ -#define HAVE_MEMCHR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - /* Define to 1 if you have the header file. */ /* #undef HAVE_NCURSES_H */ -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the `regcomp' function. */ -#define HAVE_REGCOMP 1 - -/* Define to 1 if you have the `re_comp' function. */ -/* #undef HAVE_RE_COMP */ - -/* Define to 1 if `stat' has the bug that it succeeds when given the - zero-length file name argument. */ -/* #undef HAVE_STAT_EMPTY_STRING_BUG */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strcspn' function. */ -#define HAVE_STRCSPN 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strlcat' function. */ -#define HAVE_STRLCAT 1 - -/* Define to 1 if you have the `strlcpy' function. */ -#define HAVE_STRLCPY 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - /* Define to 1 if struct dirent has member d_namlen */ #define HAVE_STRUCT_DIRENT_D_NAMLEN 1 -/* Define to 1 if you have the `strunvis' function. */ -#define HAVE_STRUNVIS 1 - -/* Define to 1 if you have the `strvis' function. */ -#define HAVE_STRVIS 1 - /* Define to 1 if you have the header file. */ #define HAVE_SYS_CDEFS_H 1 -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Feb 4 14:34:28 UTC 2023 Modified Files: src/lib/libedit: config.h sys.h terminal.c Log Message: Remove unused stuff, and limit the scope of some of the used ones. (from des@freebsd) To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libedit/config.h cvs rdiff -u -r1.27 -r1.28 src/lib/libedit/sys.h cvs rdiff -u -r1.45 -r1.46 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Feb 3 22:01:43 UTC 2023 Modified Files: src/lib/libedit: filecomplete.c histedit.h Log Message: Add a entry point for the complete function for FreeBSD compatibility with sh. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.61 -r1.62 src/lib/libedit/histedit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Feb 3 22:01:43 UTC 2023 Modified Files: src/lib/libedit: filecomplete.c histedit.h Log Message: Add a entry point for the complete function for FreeBSD compatibility with sh. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.61 -r1.62 src/lib/libedit/histedit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.71 src/lib/libedit/filecomplete.c:1.72 --- src/lib/libedit/filecomplete.c:1.71 Sun Oct 30 15:11:31 2022 +++ src/lib/libedit/filecomplete.c Fri Feb 3 17:01:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.71 2022/10/30 19:11:31 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.71 2022/10/30 19:11:31 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -851,3 +851,13 @@ _el_fn_complete(EditLine *el, int ch __a break_chars, NULL, NULL, (size_t)100, NULL, NULL, NULL, NULL); } + +/* + * el-compatible wrapper around rl_complete; needed for key binding + */ +/* ARGSUSED */ +unsigned char +_el_fn_sh_complete(EditLine *el, int ch) +{ + return _el_fn_complete(el, ch); +} Index: src/lib/libedit/histedit.h diff -u src/lib/libedit/histedit.h:1.61 src/lib/libedit/histedit.h:1.62 --- src/lib/libedit/histedit.h:1.61 Tue Feb 8 16:13:22 2022 +++ src/lib/libedit/histedit.h Fri Feb 3 17:01:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.h,v 1.61 2022/02/08 21:13:22 rillig Exp $ */ +/* $NetBSD: histedit.h,v 1.62 2023/02/03 22:01:42 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -113,6 +113,7 @@ int el_parse(EditLine *, int, const ch int el_set(EditLine *, int, ...); int el_get(EditLine *, int, ...); unsigned char _el_fn_complete(EditLine *, int); +unsigned char _el_fn_sh_complete(EditLine *, int); /* * el_set/el_get parameters
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Feb 3 19:47:39 UTC 2023 Modified Files: src/lib/libedit: sig.c Log Message: Don't clear the handle to el "sel" and set it earlier to prevent handling a signal before the handle is set. (From: des at FreeBSD) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libedit/sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/sig.c diff -u src/lib/libedit/sig.c:1.26 src/lib/libedit/sig.c:1.27 --- src/lib/libedit/sig.c:1.26 Mon May 9 17:46:56 2016 +++ src/lib/libedit/sig.c Fri Feb 3 14:47:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sig.c,v 1.26 2016/05/09 21:46:56 christos Exp $ */ +/* $NetBSD: sig.c,v 1.27 2023/02/03 19:47:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: sig.c,v 1.26 2016/05/09 21:46:56 christos Exp $"); +__RCSID("$NetBSD: sig.c,v 1.27 2023/02/03 19:47:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -170,6 +170,7 @@ sig_set(EditLine *el) nsa.sa_flags = 0; sigemptyset(_mask); + sel = el; (void) sigprocmask(SIG_BLOCK, >el_signal->sig_set, ); for (i = 0; sighdl[i] != -1; i++) { @@ -178,7 +179,6 @@ sig_set(EditLine *el) osa.sa_handler != sig_handler) el->el_signal->sig_action[i] = osa; } - sel = el; (void) sigprocmask(SIG_SETMASK, , NULL); } @@ -199,7 +199,5 @@ sig_clr(EditLine *el) (void)sigaction(sighdl[i], >el_signal->sig_action[i], NULL); - sel = NULL; /* we are going to die if the handler is - * called */ (void)sigprocmask(SIG_SETMASK, , NULL); }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Feb 3 19:47:39 UTC 2023 Modified Files: src/lib/libedit: sig.c Log Message: Don't clear the handle to el "sel" and set it earlier to prevent handling a signal before the handle is set. (From: des at FreeBSD) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libedit/sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: uwe Date: Tue Dec 6 00:59:20 UTC 2022 Modified Files: src/lib/libedit: editrc.5 Log Message: editrc(5): Markup fixes To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/editrc.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/editrc.5 diff -u src/lib/libedit/editrc.5:1.33 src/lib/libedit/editrc.5:1.34 --- src/lib/libedit/editrc.5:1.33 Tue Jun 27 01:22:58 2017 +++ src/lib/libedit/editrc.5 Tue Dec 6 00:59:20 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: editrc.5,v 1.33 2017/06/27 01:22:58 kre Exp $ +.\" $NetBSD: editrc.5,v 1.34 2022/12/06 00:59:20 uwe Exp $ .\" .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -43,7 +43,7 @@ library. .Pp The format of each line is: .Pp -.Dl [prog:]command [arg ...] +.D1 Oo Ar prog Ns Ic \&: Oc Ns Ar command Oo Ar arg ... Oc .Pp .Ar command is one of the @@ -59,7 +59,7 @@ is the program name string that a progra to set up .Xr editline 3 , which is usually -.Va argv[0] . +.Va argv Ns Li [0] . .Ar command will be executed for any program which matches .Ar prog . @@ -107,15 +107,17 @@ List or change key bindings in the .Xr vi 1 mode alternate (command mode) key map. .It Fl e -Bind all keys to the standard GNU Emacs-like bindings. +Bind all keys to the standard +.Tn GNU +Emacs-like bindings. .It Fl k .Ar key is interpreted as a symbolic arrow key name, which may be one of -.Sq up , -.Sq down , -.Sq left +.Ic up , +.Ic down , +.Ic left or -.Sq right . +.Ic right . .It Fl l List all editor commands and a short description of each. .It Fl r @@ -146,16 +148,14 @@ about macros and the input queue. and .Ar command can contain control characters of the form -.Sm off -.Sq No ^ Ar character -.Sm on +.Sq Ic ^ Ns Ar character .Po e.g.\& -.Sq ^A +.Ql ^A .Pc , and the following backslashed escape sequences: .Pp -.Bl -tag -compact -offset indent -width 4n +.Bl -tag -compact -offset indent -width Ic .It Ic \ea Bell .It Ic \eb @@ -173,31 +173,33 @@ Horizontal tab .It Ic \ev Vertical tab .Sm off -.It Sy \e Ar nnn +.It Ic \e Ar nnn .Sm on -The ASCII character corresponding to the octal number +The +.Tn ASCII +character corresponding to the octal number .Ar nnn . .El .Pp -.Sq \e +.Ql \e nullifies the special meaning of the following character, if it has any, notably -.Sq \e +.Ql \e and -.Sq ^ . +.Ql ^ . .It Ic echotc Oo Fl sv Oc Ar arg Ar ... Exercise terminal capabilities given in -.Ar arg ... . +.Ar arg . If .Ar arg is -.Sq baud , -.Sq cols , -.Sq lines , -.Sq rows , -.Sq meta , +.Ql baud , +.Ql cols , +.Ql lines , +.Ql rows , +.Ql meta , or -.Sq tabs , +.Ql tabs , the value of that capability is printed, with .Dq yes or @@ -209,27 +211,27 @@ returns an empty string for non-existent causing an error. .Fl v causes messages to be verbose. -.It Ic edit Op Li on | Li off +.It Ic edit Op Li on No | Li off Enable or disable the .Nm editline functionality in a program. -.It Ic history Ar list | Ar size Dv n | Ar unique Dv n +.It Ic history Li list No | Li size Ar n No | Li unique Ar n The -.Ar list +.Ql list command lists all entries in the history. The -.Ar size +.Ql size command sets the history size to -.Dv n +.Ar n entries. The -.Ar unique +.Ql unique command controls if history should keep duplicate entries. If -.Dv n +.Ar n is non zero, only keep unique history entries. If -.Dv n +.Ar n is zero, then keep all entries (the default). .It Ic settc Ar cap Ar val Set the terminal capability @@ -239,8 +241,8 @@ to as defined in .Xr termcap 5 . No sanity checking is done. -.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ar +mode Oc \ -Oo Ar -mode Oc Oo Ar mode Oc Oo Ar char=c Oc +.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ic \&+ Ns Ar mode Oc \ +Oo Fl Ar mode Oc Oo Ar mode Oc Oo Ar char\| Ns Ic = Ns Ar c Oc Control which tty modes that .Nm won't allow the user to change. @@ -262,17 +264,17 @@ Without other arguments, .Ic setty lists the modes in the chosen set which are fixed on .Po -.Sq +mode +.Ic + Ns Ar mode .Pc or off .Po -.Sq -mode +.Fl Ns Ar mode .Pc . .Fl a lists all tty modes in the chosen set regardless of the setting. With -.Ar +mode , -.Ar -mode +.Ic + Ns Ar mode , +.Fl Ns Ar mode or .Ar mode , fixes @@ -283,7 +285,7 @@ in the chosen set. .Pp .Ic Setty can also be used to set tty characters to particular values using -.Ar char=value . +.Ar char\| Ns Ic = Ns Ar value . If .Ar value is empty @@ -294,19 +296,18 @@ List the values of all the terminal capa .Xr termcap 5 ) . .El .Sh ENVIRONMENT -.Bl -tag -width "~/.editrcXXX" +.Bl -tag -width Ev .It Ev EDITRC Names the default configuration file for the .Xr editline 3 library. .El .Sh FILES -.Bl -tag -width "~/.editrcXXX" +.Bl -tag -width Pa .It Pa ~/.editrc -Last resort, if no other file is specified,
CVS commit: src/lib/libedit
Module Name:src Committed By: uwe Date: Tue Dec 6 00:59:20 UTC 2022 Modified Files: src/lib/libedit: editrc.5 Log Message: editrc(5): Markup fixes To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/editrc.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Dec 2 19:23:16 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57095: Yilei Yang: Change readline's replace_history_entry to not make a copy of the string to replace since H_REPLACE already makes a copy (fixes memory leak) To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.177 src/lib/libedit/readline.c:1.178 --- src/lib/libedit/readline.c:1.177 Sun Oct 30 15:11:31 2022 +++ src/lib/libedit/readline.c Fri Dec 2 14:23:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.177 2022/10/30 19:11:31 christos Exp $ */ +/* $NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.177 2022/10/30 19:11:31 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -1606,7 +1606,7 @@ replace_history_entry(int num, const cha if (history(h, , H_NEXT_EVDATA, num, >data)) goto out; - he->line = strdup(ev.str); + he->line = ev.str; if (he->line == NULL) goto out;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Dec 2 19:23:16 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57095: Yilei Yang: Change readline's replace_history_entry to not make a copy of the string to replace since H_REPLACE already makes a copy (fixes memory leak) To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Oct 30 19:11:31 UTC 2022 Modified Files: src/lib/libedit: chared.c chartype.c el.c filecomplete.c map.c read.c read.h readline.c terminal.c Log Message: improvements in malloc/free handling. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/lib/libedit/chared.c cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/chartype.c cvs rdiff -u -r1.100 -r1.101 src/lib/libedit/el.c cvs rdiff -u -r1.70 -r1.71 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.54 -r1.55 src/lib/libedit/map.c cvs rdiff -u -r1.107 -r1.108 src/lib/libedit/read.c cvs rdiff -u -r1.12 -r1.13 src/lib/libedit/read.h cvs rdiff -u -r1.176 -r1.177 src/lib/libedit/readline.c cvs rdiff -u -r1.44 -r1.45 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Oct 30 19:11:31 UTC 2022 Modified Files: src/lib/libedit: chared.c chartype.c el.c filecomplete.c map.c read.c read.h readline.c terminal.c Log Message: improvements in malloc/free handling. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/lib/libedit/chared.c cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/chartype.c cvs rdiff -u -r1.100 -r1.101 src/lib/libedit/el.c cvs rdiff -u -r1.70 -r1.71 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.54 -r1.55 src/lib/libedit/map.c cvs rdiff -u -r1.107 -r1.108 src/lib/libedit/read.c cvs rdiff -u -r1.12 -r1.13 src/lib/libedit/read.h cvs rdiff -u -r1.176 -r1.177 src/lib/libedit/readline.c cvs rdiff -u -r1.44 -r1.45 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chared.c diff -u src/lib/libedit/chared.c:1.62 src/lib/libedit/chared.c:1.63 --- src/lib/libedit/chared.c:1.62 Tue Feb 8 16:13:22 2022 +++ src/lib/libedit/chared.c Sun Oct 30 15:11:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.62 2022/02/08 21:13:22 rillig Exp $ */ +/* $NetBSD: chared.c,v 1.63 2022/10/30 19:11:31 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.62 2022/02/08 21:13:22 rillig Exp $"); +__RCSID("$NetBSD: chared.c,v 1.63 2022/10/30 19:11:31 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -414,7 +414,7 @@ ch_init(EditLine *el) el->el_chared.c_redo.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_chared.c_redo.buf)); if (el->el_chared.c_redo.buf == NULL) - return -1; + goto out; el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; el->el_chared.c_redo.cmd = ED_UNASSIGNED; @@ -425,7 +425,7 @@ ch_init(EditLine *el) el->el_chared.c_kill.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_chared.c_kill.buf)); if (el->el_chared.c_kill.buf == NULL) - return -1; + goto out; el->el_chared.c_kill.mark = el->el_line.buffer; el->el_chared.c_kill.last = el->el_chared.c_kill.buf; el->el_chared.c_resizefun = NULL; @@ -442,6 +442,9 @@ ch_init(EditLine *el) el->el_state.lastcmd = ED_UNASSIGNED; return 0; +out: + ch_end(el); + return -1; } /* ch_reset(): Index: src/lib/libedit/chartype.c diff -u src/lib/libedit/chartype.c:1.35 src/lib/libedit/chartype.c:1.36 --- src/lib/libedit/chartype.c:1.35 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/chartype.c Sun Oct 30 15:11:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: chartype.c,v 1.36 2022/10/30 19:11:31 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: chartype.c,v 1.36 2022/10/30 19:11:31 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -158,6 +158,8 @@ ct_decode_argv(int argc, const char *arg return NULL; wargv = el_calloc((size_t)(argc + 1), sizeof(*wargv)); + if (wargv == NULL) + return NULL; for (i = 0, p = conv->wbuff; i < argc; ++i) { if (!argv[i]) { /* don't pass null pointers to mbstowcs */ Index: src/lib/libedit/el.c diff -u src/lib/libedit/el.c:1.100 src/lib/libedit/el.c:1.101 --- src/lib/libedit/el.c:1.100 Sun Aug 15 06:08:41 2021 +++ src/lib/libedit/el.c Sun Oct 30 15:11:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: el.c,v 1.100 2021/08/15 10:08:41 christos Exp $ */ +/* $NetBSD: el.c,v 1.101 2022/10/30 19:11:31 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; #else -__RCSID("$NetBSD: el.c,v 1.100 2021/08/15 10:08:41 christos Exp $"); +__RCSID("$NetBSD: el.c,v 1.101 2022/10/30 19:11:31 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -142,7 +142,7 @@ el_end(EditLine *el) if (!(el->el_flags & NO_TTY)) tty_end(el, TCSAFLUSH); ch_end(el); - read_end(el->el_read); + read_end(el); search_end(el); hist_end(el); prompt_end(el); Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.70 src/lib/libedit/filecomplete.c:1.71 --- src/lib/libedit/filecomplete.c:1.70 Sat Mar 12 10:29:17 2022 +++ src/lib/libedit/filecomplete.c Sun Oct 30 15:11:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.71 2022/10/30 19:11:31 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.71
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Sep 21 01:33:53 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57016: Ricky Zhou: declare lastidx To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.175 src/lib/libedit/readline.c:1.176 --- src/lib/libedit/readline.c:1.175 Tue Sep 20 19:41:14 2022 +++ src/lib/libedit/readline.c Tue Sep 20 21:33:53 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos Exp $ */ +/* $NetBSD: readline.c,v 1.176 2022/09/21 01:33:53 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.176 2022/09/21 01:33:53 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -478,6 +478,8 @@ readline(const char *p) ret = el_gets(e, ); if (ret && count > 0) { + int lastidx; + buf = strdup(ret); if (buf == NULL) goto out;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Sep 21 01:33:53 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57016: Ricky Zhou: declare lastidx To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Sep 20 23:41:14 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57016: Ricky Zhou: Revert to trimming the last newline instead of the first one so that multi-line commands work again. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.174 src/lib/libedit/readline.c:1.175 --- src/lib/libedit/readline.c:1.174 Fri Apr 8 16:11:31 2022 +++ src/lib/libedit/readline.c Tue Sep 20 19:41:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos Exp $ */ +/* $NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -481,7 +481,9 @@ readline(const char *p) buf = strdup(ret); if (buf == NULL) goto out; - buf[strcspn(buf, "\n")] = '\0'; + lastidx = count - 1; + if (buf[lastidx] == '\n') + buf[lastidx] = '\0'; } else buf = NULL;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Sep 20 23:41:14 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/57016: Ricky Zhou: Revert to trimming the last newline instead of the first one so that multi-line commands work again. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: tnn Date: Mon Apr 11 19:37:20 UTC 2022 Modified Files: src/lib/libedit: chartype.h Log Message: libedit/chartype.h: portability fix for OSF/1 To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/chartype.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chartype.h diff -u src/lib/libedit/chartype.h:1.36 src/lib/libedit/chartype.h:1.37 --- src/lib/libedit/chartype.h:1.36 Sun Sep 15 21:09:11 2019 +++ src/lib/libedit/chartype.h Mon Apr 11 19:37:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.h,v 1.36 2019/09/15 21:09:11 christos Exp $ */ +/* $NetBSD: chartype.h,v 1.37 2022/04/11 19:37:20 tnn Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -35,6 +35,7 @@ * been around since 2001... */ #if !defined(__NetBSD__) && \ !defined(__sun) && \ + !defined(__osf__) && \ !(defined(__APPLE__) && defined(__MACH__)) && \ !defined(__OpenBSD__) && \ !defined(__FreeBSD__) && \
CVS commit: src/lib/libedit
Module Name:src Committed By: tnn Date: Mon Apr 11 19:37:20 UTC 2022 Modified Files: src/lib/libedit: chartype.h Log Message: libedit/chartype.h: portability fix for OSF/1 To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/chartype.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Apr 8 20:11:31 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/56778: Detlev Casanova: Missing rl_initialize call in rl_copy_text To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Apr 8 20:11:31 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: PR/56778: Detlev Casanova: Missing rl_initialize call in rl_copy_text To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.173 src/lib/libedit/readline.c:1.174 --- src/lib/libedit/readline.c:1.173 Sat Feb 19 12:45:02 2022 +++ src/lib/libedit/readline.c Fri Apr 8 16:11:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $ */ +/* $NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -2307,10 +2307,15 @@ _rl_update_pos(void) char * rl_copy_text(int from, int to) { - const LineInfo *li = el_line(e); + const LineInfo *li; size_t len; char * out; + if (h == NULL || e == NULL) + rl_initialize(); + + li = el_line(e); + if (from > to) return NULL;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Mar 12 15:29:18 UTC 2022 Modified Files: src/lib/libedit: filecomplete.c Log Message: Fix filename autocompletion for strings like a\)b An escaped character should unconditionally be skipped together with the character that does the escaping. For example, in "a\)b" only the ")b" part was skipped but then the loop stopped at the "\" since it's one of the characters listed in word_break. (Piotr P. Stefaniak) To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.69 src/lib/libedit/filecomplete.c:1.70 --- src/lib/libedit/filecomplete.c:1.69 Sun Sep 26 09:45:37 2021 +++ src/lib/libedit/filecomplete.c Sat Mar 12 10:29:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.69 2021/09/26 13:45:37 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.69 2021/09/26 13:45:37 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -127,7 +127,7 @@ fn_tilde_expand(const char *txt) } static int -needs_escaping(char c) +needs_escaping(wchar_t c) { switch (c) { case '\'': @@ -612,13 +612,13 @@ find_word_to_complete(const wchar_t * cu for (;;) { if (ctemp <= buffer) break; - if (wcschr(word_break, ctemp[-1])) { - if (ctemp - buffer >= 2 && ctemp[-2] == '\\') { -ctemp -= 2; -continue; - } - break; + if (ctemp - buffer >= 2 && ctemp[-2] == '\\' && + needs_escaping(ctemp[-1])) { + ctemp -= 2; + continue; } + if (wcschr(word_break, ctemp[-1])) + break; if (special_prefixes && wcschr(special_prefixes, ctemp[-1])) break; ctemp--;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Mar 12 15:29:18 UTC 2022 Modified Files: src/lib/libedit: filecomplete.c Log Message: Fix filename autocompletion for strings like a\)b An escaped character should unconditionally be skipped together with the character that does the escaping. For example, in "a\)b" only the ")b" part was skipped but then the loop stopped at the "\" since it's one of the characters listed in word_break. (Piotr P. Stefaniak) To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Feb 19 17:45:02 UTC 2022 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: PR/56695: Walter Lozano: Correct declaration of hook functions. To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/lib/libedit/readline.c cvs rdiff -u -r1.52 -r1.53 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.172 src/lib/libedit/readline.c:1.173 --- src/lib/libedit/readline.c:1.172 Tue Feb 8 10:05:10 2022 +++ src/lib/libedit/readline.c Sat Feb 19 12:45:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $ */ +/* $NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -113,8 +113,8 @@ const char *rl_basic_quote_characters = rl_compentry_func_t *rl_completion_entry_function = NULL; char *(*rl_completion_word_break_hook)(void) = NULL; rl_completion_func_t *rl_attempted_completion_function = NULL; -Function *rl_pre_input_hook = NULL; -Function *rl_startup1_hook = NULL; +rl_hook_func_t *rl_pre_input_hook = NULL; +rl_hook_func_t *rl_startup1_hook = NULL; int (*rl_getc_function)(FILE *) = NULL; char *rl_terminal_name = NULL; int rl_already_prompted = 0; @@ -123,7 +123,7 @@ int rl_ignore_completion_duplicates = 0; int readline_echoing_p = 1; int _rl_print_completions_horizontally = 0; VFunction *rl_redisplay_function = NULL; -Function *rl_startup_hook = NULL; +rl_hook_func_t *rl_startup_hook = NULL; VFunction *rl_completion_display_matches_hook = NULL; VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; @@ -445,7 +445,7 @@ readline(const char *p) if (e == NULL || h == NULL) rl_initialize(); if (rl_startup_hook) { - (*rl_startup_hook)(NULL, 0); + (*rl_startup_hook)(); } tty_init(e); @@ -460,7 +460,7 @@ readline(const char *p) goto out; if (rl_pre_input_hook) - (*rl_pre_input_hook)(NULL, 0); + (*rl_pre_input_hook)(); if (rl_event_hook && !(e->el_flags & NO_TTY)) { el_set(e, EL_GETCFN, _rl_event_read_char); Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.52 src/lib/libedit/readline/readline.h:1.53 --- src/lib/libedit/readline/readline.h:1.52 Tue Feb 8 10:05:10 2022 +++ src/lib/libedit/readline/readline.h Sat Feb 19 12:45:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.52 2022/02/08 15:05:10 christos Exp $ */ +/* $NetBSD: readline.h,v 1.53 2022/02/19 17:45:02 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -127,8 +127,8 @@ extern int rl_completion_query_items; extern const char *rl_special_prefixes; extern int rl_completion_append_character; extern int rl_inhibit_completion; -extern Function *rl_pre_input_hook; -extern Function *rl_startup_hook; +extern rl_hook_func_t *rl_pre_input_hook; +extern rl_hook_func_t *rl_startup_hook; extern char *rl_terminal_name; extern int rl_already_prompted; extern char *rl_prompt;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Feb 19 17:45:02 UTC 2022 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: PR/56695: Walter Lozano: Correct declaration of hook functions. To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/lib/libedit/readline.c cvs rdiff -u -r1.52 -r1.53 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: rillig Date: Tue Feb 8 21:13:22 UTC 2022 Modified Files: src/lib/libedit: chared.c histedit.h Log Message: libedit: fix typos, apply KNF to newly imported code (PR/56693) No binary change. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/lib/libedit/chared.c cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/histedit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: rillig Date: Tue Feb 8 21:13:22 UTC 2022 Modified Files: src/lib/libedit: chared.c histedit.h Log Message: libedit: fix typos, apply KNF to newly imported code (PR/56693) No binary change. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/lib/libedit/chared.c cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/histedit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chared.c diff -u src/lib/libedit/chared.c:1.61 src/lib/libedit/chared.c:1.62 --- src/lib/libedit/chared.c:1.61 Tue Feb 8 15:05:10 2022 +++ src/lib/libedit/chared.c Tue Feb 8 21:13:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $ */ +/* $NetBSD: chared.c,v 1.62 2022/02/08 21:13:22 rillig Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.62 2022/02/08 21:13:22 rillig Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -625,29 +625,29 @@ el_deletestr(EditLine *el, int n) } /* el_deletestr1(): - * Delete characters between starn and end + * Delete characters between start and end */ int el_deletestr1(EditLine *el, int start, int end) { - size_t line_lenght, len; - wchar_t * p1, * p2; + size_t line_length, len; + wchar_t *p1, *p2; if (end <= start) return 0; - line_lenght = (size_t) (el->el_line.lastchar - el->el_line.buffer); + line_length = (size_t)(el->el_line.lastchar - el->el_line.buffer); - if (start >= (int) line_lenght || end >= (int) line_lenght) + if (start >= (int)line_length || end >= (int)line_length) return 0; - len = (size_t) (end - start); - if (len > line_lenght - (size_t) end) - len = line_lenght - (size_t) end; + len = (size_t)(end - start); + if (len > line_length - (size_t)end) + len = line_length - (size_t)end; p1 = el->el_line.buffer + start; p2 = el->el_line.buffer + end; - for (size_t i = 0; i < len; i++){ + for (size_t i = 0; i < len; i++) { *p1++ = *p2++; el->el_line.lastchar--; } Index: src/lib/libedit/histedit.h diff -u src/lib/libedit/histedit.h:1.60 src/lib/libedit/histedit.h:1.61 --- src/lib/libedit/histedit.h:1.60 Tue Feb 8 15:05:10 2022 +++ src/lib/libedit/histedit.h Tue Feb 8 21:13:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.h,v 1.60 2022/02/08 15:05:10 christos Exp $ */ +/* $NetBSD: histedit.h,v 1.61 2022/02/08 21:13:22 rillig Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -179,8 +179,8 @@ void el_resize(EditLine *); const LineInfo *el_line(EditLine *); int el_insertstr(EditLine *, const char *); void el_deletestr(EditLine *, int); -int el_replacestr(EditLine *el, const char *str); -int el_deletestr1(EditLine *el, int start, int end); +int el_replacestr(EditLine *, const char *); +int el_deletestr1(EditLine *, int, int); /* * History
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Feb 8 15:05:10 UTC 2022 Modified Files: src/lib/libedit: chared.c histedit.h readline.c src/lib/libedit/readline: readline.h Log Message: PR/56693: Walter Lozano: Add support for rl_delete_text and rl_set_key To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/chared.c cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/histedit.h cvs rdiff -u -r1.171 -r1.172 src/lib/libedit/readline.c cvs rdiff -u -r1.51 -r1.52 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chared.c diff -u src/lib/libedit/chared.c:1.60 src/lib/libedit/chared.c:1.61 --- src/lib/libedit/chared.c:1.60 Tue Jan 11 13:30:15 2022 +++ src/lib/libedit/chared.c Tue Feb 8 10:05:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $ */ +/* $NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -624,6 +624,40 @@ el_deletestr(EditLine *el, int n) el->el_line.cursor = el->el_line.buffer; } +/* el_deletestr1(): + * Delete characters between starn and end + */ +int +el_deletestr1(EditLine *el, int start, int end) +{ + size_t line_lenght, len; + wchar_t * p1, * p2; + + if (end <= start) + return 0; + + line_lenght = (size_t) (el->el_line.lastchar - el->el_line.buffer); + + if (start >= (int) line_lenght || end >= (int) line_lenght) + return 0; + + len = (size_t) (end - start); + if (len > line_lenght - (size_t) end) + len = line_lenght - (size_t) end; + + p1 = el->el_line.buffer + start; + p2 = el->el_line.buffer + end; + for (size_t i = 0; i < len; i++){ + *p1++ = *p2++; + el->el_line.lastchar--; + } + + if (el->el_line.cursor < el->el_line.buffer) + el->el_line.cursor = el->el_line.buffer; + + return end - start; +} + /* el_wreplacestr(): * Replace the contents of the line with the provided string */ Index: src/lib/libedit/histedit.h diff -u src/lib/libedit/histedit.h:1.59 src/lib/libedit/histedit.h:1.60 --- src/lib/libedit/histedit.h:1.59 Tue Jan 11 13:30:15 2022 +++ src/lib/libedit/histedit.h Tue Feb 8 10:05:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.h,v 1.59 2022/01/11 18:30:15 christos Exp $ */ +/* $NetBSD: histedit.h,v 1.60 2022/02/08 15:05:10 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -180,7 +180,7 @@ const LineInfo *el_line(EditLine *); int el_insertstr(EditLine *, const char *); void el_deletestr(EditLine *, int); int el_replacestr(EditLine *el, const char *str); - +int el_deletestr1(EditLine *el, int start, int end); /* * History Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.171 src/lib/libedit/readline.c:1.172 --- src/lib/libedit/readline.c:1.171 Mon Jan 31 09:44:49 2022 +++ src/lib/libedit/readline.c Tue Feb 8 10:05:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 christos Exp $ */ +/* $NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -2339,6 +2339,16 @@ rl_replace_line(const char * text, int c el_replacestr(e, text); } +int +rl_delete_text(int start, int end) +{ + + if (h == NULL || e == NULL) + rl_initialize(); + + return el_deletestr1(e, start, end); +} + void rl_get_screen_size(int *rows, int *cols) { @@ -2510,6 +2520,14 @@ rl_bind_key_in_map(int key __attribute__ return 0; } +int +rl_set_key(const char *keyseq __attribute__((__unused__)), + rl_command_func_t *function __attribute__((__unused__)), + Keymap k __attribute__((__unused__))) +{ + return 0; +} + /* unsupported, but needed by python */ void rl_cleanup_after_signal(void) Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.51 src/lib/libedit/readline/readline.h:1.52 --- src/lib/libedit/readline/readline.h:1.51 Mon Jan 31 09:44:49 2022 +++ src/lib/libedit/readline/readline.h Tue Feb 8 10:05:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.51 2022/01/31 14:44:49 christos Exp $ */ +/* $NetBSD: readline.h,v 1.52 2022/02/08 15:05:10 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -236,6 +236,7 @@ int rl_crlf(void); int rl_ding(void); char *rl_copy_text(int, int); void rl_replace_line(const char *, int); +int
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Feb 8 15:05:10 UTC 2022 Modified Files: src/lib/libedit: chared.c histedit.h readline.c src/lib/libedit/readline: readline.h Log Message: PR/56693: Walter Lozano: Add support for rl_delete_text and rl_set_key To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/chared.c cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/histedit.h cvs rdiff -u -r1.171 -r1.172 src/lib/libedit/readline.c cvs rdiff -u -r1.51 -r1.52 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Jan 31 14:44:49 UTC 2022 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: PR/56622: Walter Lozano: Improve readline compatibility by adding rl_readline_state support. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/lib/libedit/readline.c cvs rdiff -u -r1.50 -r1.51 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.170 src/lib/libedit/readline.c:1.171 --- src/lib/libedit/readline.c:1.170 Sat Jan 29 15:52:45 2022 +++ src/lib/libedit/readline.c Mon Jan 31 09:44:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.170 2022/01/29 20:52:45 christos Exp $ */ +/* $NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.170 2022/01/29 20:52:45 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -128,7 +128,7 @@ VFunction *rl_completion_display_matches VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; KEYMAP_ENTRY_ARRAY emacs_meta_keymap; -unsigned long rl_readline_state; +unsigned long rl_readline_state = RL_STATE_NONE; int _rl_complete_mark_directories; rl_icppfunc_t *rl_directory_completion_hook; int rl_completion_suppress_append; @@ -311,6 +311,8 @@ rl_initialize(void) if (h != NULL) history_end(h); + RL_UNSETSTATE(RL_STATE_DONE); + if (!rl_instream) rl_instream = stdin; if (!rl_outstream) @@ -2145,6 +2147,7 @@ rl_callback_read_char(void) if (done == 2) { if ((wbuf = strdup(buf)) != NULL) wbuf[count] = '\0'; + RL_SETSTATE(RL_STATE_DONE); } else wbuf = NULL; (*(void (*)(const char *))rl_linefunc)(wbuf); Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.50 src/lib/libedit/readline/readline.h:1.51 --- src/lib/libedit/readline/readline.h:1.50 Fri Jan 14 08:31:05 2022 +++ src/lib/libedit/readline/readline.h Mon Jan 31 09:44:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.50 2022/01/14 13:31:05 christos Exp $ */ +/* $NetBSD: readline.h,v 1.51 2022/01/31 14:44:49 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -94,6 +94,13 @@ typedef KEYMAP_ENTRY *Keymap; #define RL_PROMPT_START_IGNORE '\1' #define RL_PROMPT_END_IGNORE '\2' +#define RL_STATE_NONE 0x00 +#define RL_STATE_DONE 0x01 + +#define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x)) +#define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x)) +#define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x)) + /* global variables used by readline enabled applications */ #ifdef __cplusplus extern "C" {
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Jan 31 14:44:49 UTC 2022 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: PR/56622: Walter Lozano: Improve readline compatibility by adding rl_readline_state support. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/lib/libedit/readline.c cvs rdiff -u -r1.50 -r1.51 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Jan 29 20:52:45 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: Add more refreshes from Walter Lozano. The readline example in http://www.mcld.co.uk/blog/2009/simple-gnu-readline-callback-style-example.html still does not work, but it is better. To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.169 src/lib/libedit/readline.c:1.170 --- src/lib/libedit/readline.c:1.169 Tue Jan 11 13:30:15 2022 +++ src/lib/libedit/readline.c Sat Jan 29 15:52:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.169 2022/01/11 18:30:15 christos Exp $ */ +/* $NetBSD: readline.c,v 1.170 2022/01/29 20:52:45 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.169 2022/01/11 18:30:15 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.170 2022/01/29 20:52:45 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -2149,6 +2149,7 @@ rl_callback_read_char(void) wbuf = NULL; (*(void (*)(const char *))rl_linefunc)(wbuf); } + _rl_update_pos(); } void @@ -2176,6 +2177,7 @@ rl_redisplay(void) a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT]; a[1] = '\0'; el_push(e, a); + rl_forced_update_display(); } int @@ -2355,7 +2357,7 @@ rl_message(const char *format, ...) va_end(args); rl_set_prompt(msg); - rl_redisplay(); + rl_forced_update_display(); } void
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Jan 29 20:52:45 UTC 2022 Modified Files: src/lib/libedit: readline.c Log Message: Add more refreshes from Walter Lozano. The readline example in http://www.mcld.co.uk/blog/2009/simple-gnu-readline-callback-style-example.html still does not work, but it is better. To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit/readline
Module Name:src Committed By: christos Date: Fri Jan 14 13:31:05 UTC 2022 Modified Files: src/lib/libedit/readline: readline.h Log Message: Don't use __printflike, use the explicit attribute so that this works outside NetBSD. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.49 src/lib/libedit/readline/readline.h:1.50 --- src/lib/libedit/readline/readline.h:1.49 Fri Jan 14 07:48:30 2022 +++ src/lib/libedit/readline/readline.h Fri Jan 14 08:31:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.49 2022/01/14 12:48:30 tnn Exp $ */ +/* $NetBSD: readline.h,v 1.50 2022/01/14 13:31:05 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -229,7 +229,8 @@ int rl_crlf(void); int rl_ding(void); char *rl_copy_text(int, int); void rl_replace_line(const char *, int); -void rl_message(const char *format, ...) __printflike(1, 2); +void rl_message(const char *format, ...) +__attribute__((__format__(__printf__, 1, 2))); void rl_save_prompt(void); void rl_restore_prompt(void);
CVS commit: src/lib/libedit/readline
Module Name:src Committed By: christos Date: Fri Jan 14 13:31:05 UTC 2022 Modified Files: src/lib/libedit/readline: readline.h Log Message: Don't use __printflike, use the explicit attribute so that this works outside NetBSD. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit/readline
Module Name:src Committed By: tnn Date: Fri Jan 14 12:48:31 UTC 2022 Modified Files: src/lib/libedit/readline: readline.h Log Message: libedit: rl_message: annotate __printflike To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit/readline
Module Name:src Committed By: tnn Date: Fri Jan 14 12:48:31 UTC 2022 Modified Files: src/lib/libedit/readline: readline.h Log Message: libedit: rl_message: annotate __printflike To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline/readline.h diff -u src/lib/libedit/readline/readline.h:1.48 src/lib/libedit/readline/readline.h:1.49 --- src/lib/libedit/readline/readline.h:1.48 Tue Jan 11 18:30:15 2022 +++ src/lib/libedit/readline/readline.h Fri Jan 14 12:48:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.48 2022/01/11 18:30:15 christos Exp $ */ +/* $NetBSD: readline.h,v 1.49 2022/01/14 12:48:30 tnn Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -229,7 +229,7 @@ int rl_crlf(void); int rl_ding(void); char *rl_copy_text(int, int); void rl_replace_line(const char *, int); -void rl_message(const char *format, ...); +void rl_message(const char *format, ...) __printflike(1, 2); void rl_save_prompt(void); void rl_restore_prompt(void);
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jan 11 18:30:15 UTC 2022 Modified Files: src/lib/libedit: chared.c eln.c histedit.h readline.c src/lib/libedit/readline: readline.h Log Message: PR/56618: Walter Lozano: Improve libedit compatibility with readline by implementing: rl_copy_text, rl_erase_empty_line, rl_message, rl_on_new_line, rl_replace_line, rl_restore_prompt, rl_save_prompt To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/chared.c cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/eln.c cvs rdiff -u -r1.58 -r1.59 src/lib/libedit/histedit.h cvs rdiff -u -r1.168 -r1.169 src/lib/libedit/readline.c cvs rdiff -u -r1.47 -r1.48 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chared.c diff -u src/lib/libedit/chared.c:1.59 src/lib/libedit/chared.c:1.60 --- src/lib/libedit/chared.c:1.59 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/chared.c Tue Jan 11 13:30:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -624,6 +624,35 @@ el_deletestr(EditLine *el, int n) el->el_line.cursor = el->el_line.buffer; } +/* el_wreplacestr(): + * Replace the contents of the line with the provided string + */ +int +el_wreplacestr(EditLine *el, const wchar_t *s) +{ + size_t len; + wchar_t * p; + + if (s == NULL || (len = wcslen(s)) == 0) + return -1; + + if (el->el_line.buffer + len >= el->el_line.limit) { + if (!ch_enlargebufs(el, len)) + return -1; + } + + p = el->el_line.buffer; + for (size_t i = 0; i < len; i++) + *p++ = *s++; + + el->el_line.buffer[len] = '\0'; + el->el_line.lastchar = el->el_line.buffer + len; + if (el->el_line.cursor > el->el_line.lastchar) + el->el_line.cursor = el->el_line.lastchar; + + return 0; +} + /* el_cursor(): * Move the cursor to the left or the right of the current position */ Index: src/lib/libedit/eln.c diff -u src/lib/libedit/eln.c:1.36 src/lib/libedit/eln.c:1.37 --- src/lib/libedit/eln.c:1.36 Sun Aug 15 06:08:41 2021 +++ src/lib/libedit/eln.c Tue Jan 11 13:30:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $ */ +/* $NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $"); +__RCSID("$NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -386,3 +386,9 @@ el_insertstr(EditLine *el, const char *s { return el_winsertstr(el, ct_decode_string(str, >el_lgcyconv)); } + +int +el_replacestr(EditLine *el, const char *str) +{ + return el_wreplacestr(el, ct_decode_string(str, >el_lgcyconv)); +} Index: src/lib/libedit/histedit.h diff -u src/lib/libedit/histedit.h:1.58 src/lib/libedit/histedit.h:1.59 --- src/lib/libedit/histedit.h:1.58 Sun Aug 15 06:08:41 2021 +++ src/lib/libedit/histedit.h Tue Jan 11 13:30:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.h,v 1.58 2021/08/15 10:08:41 christos Exp $ */ +/* $NetBSD: histedit.h,v 1.59 2022/01/11 18:30:15 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -179,6 +179,7 @@ void el_resize(EditLine *); const LineInfo *el_line(EditLine *); int el_insertstr(EditLine *, const char *); void el_deletestr(EditLine *, int); +int el_replacestr(EditLine *el, const char *str); /* @@ -278,6 +279,7 @@ int el_cursor(EditLine *, int); const LineInfoW *el_wline(EditLine *); int el_winsertstr(EditLine *, const wchar_t *); #define el_wdeletestr el_deletestr +int el_wreplacestr(EditLine *, const wchar_t *); /* * History Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.168 src/lib/libedit/readline.c:1.169 --- src/lib/libedit/readline.c:1.168 Fri Sep 10 14:51:36 2021 +++ src/lib/libedit/readline.c Tue Jan 11 13:30:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $ */ +/* $NetBSD: readline.c,v 1.169 2022/01/11 18:30:15 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $"); +__RCSID("$NetBSD: readline.c,v 1.169 2022/01/11 18:30:15 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -43,6 +43,7 @@ __RCSID("$NetBSD:
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jan 11 18:30:15 UTC 2022 Modified Files: src/lib/libedit: chared.c eln.c histedit.h readline.c src/lib/libedit/readline: readline.h Log Message: PR/56618: Walter Lozano: Improve libedit compatibility with readline by implementing: rl_copy_text, rl_erase_empty_line, rl_message, rl_on_new_line, rl_replace_line, rl_restore_prompt, rl_save_prompt To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/chared.c cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/eln.c cvs rdiff -u -r1.58 -r1.59 src/lib/libedit/histedit.h cvs rdiff -u -r1.168 -r1.169 src/lib/libedit/readline.c cvs rdiff -u -r1.47 -r1.48 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 26 13:45:54 UTC 2021 Modified Files: src/lib/libedit: filecomplete.h Log Message: make flag unsigned to match prototype of the function used To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libedit/filecomplete.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.h diff -u src/lib/libedit/filecomplete.h:1.13 src/lib/libedit/filecomplete.h:1.14 --- src/lib/libedit/filecomplete.h:1.13 Sun Mar 28 09:38:10 2021 +++ src/lib/libedit/filecomplete.h Sun Sep 26 09:45:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.h,v 1.13 2021/03/28 13:38:10 christos Exp $ */ +/* $NetBSD: filecomplete.h,v 1.14 2021/09/26 13:45:54 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ int fn_complete2(EditLine *, char **(*)(const char *, int, int), const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, int *, int *, int *, int *, unsigned int); -#define FN_QUOTE_MATCH 1 /* Quote the returned match */ +#define FN_QUOTE_MATCH 1U /* Quote the returned match */ void fn_display_match_list(EditLine *, char **, size_t, size_t, const char *(*)(const char *));
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 26 13:45:54 UTC 2021 Modified Files: src/lib/libedit: filecomplete.h Log Message: make flag unsigned to match prototype of the function used To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libedit/filecomplete.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 26 13:45:37 UTC 2021 Modified Files: src/lib/libedit: filecomplete.c Log Message: - Completion should not add a quote at the end of the line to match an already quoted quote. (Piotr Stefaniak) - fix lint unconst warnings for strchr To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.68 src/lib/libedit/filecomplete.c:1.69 --- src/lib/libedit/filecomplete.c:1.68 Wed May 5 10:49:59 2021 +++ src/lib/libedit/filecomplete.c Sun Sep 26 09:45:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.68 2021/05/05 14:49:59 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.69 2021/09/26 13:45:37 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.68 2021/05/05 14:49:59 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.69 2021/09/26 13:45:37 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -69,20 +69,21 @@ fn_tilde_expand(const char *txt) char pwbuf[1024]; #endif struct passwd *pass; + const char *pos; char *temp; size_t len = 0; if (txt[0] != '~') return strdup(txt); - temp = strchr(txt + 1, '/'); - if (temp == NULL) { + pos = strchr(txt + 1, '/'); + if (pos == NULL) { temp = strdup(txt + 1); if (temp == NULL) return NULL; } else { /* text until string after slash */ - len = (size_t)(temp - txt + 1); + len = (size_t)(pos - txt + 1); temp = el_calloc(len, sizeof(*temp)); if (temp == NULL) return NULL; @@ -212,9 +213,10 @@ escape_filename(EditLine * el, const cha while (temp != el->el_line.cursor) { /* * If we see a single quote but have not seen a double quote - * so far set/unset s_quote + * so far set/unset s_quote, unless it is already quoted */ - if (temp[0] == '\'' && !d_quoted) + if (temp[0] == '\'' && !d_quoted && + (temp == el->el_line.buffer || temp[-1] != '\\')) s_quoted = !s_quoted; /* * vice versa to the above condition @@ -327,14 +329,15 @@ fn_filename_completion_function(const ch static size_t filename_len = 0; struct dirent *entry; char *temp; + const char *pos; size_t len; if (state == 0 || dir == NULL) { - temp = strrchr(text, '/'); - if (temp) { + pos = strrchr(text, '/'); + if (pos) { char *nptr; - temp++; - nptr = el_realloc(filename, (strlen(temp) + 1) * + pos++; + nptr = el_realloc(filename, (strlen(pos) + 1) * sizeof(*nptr)); if (nptr == NULL) { el_free(filename); @@ -342,8 +345,8 @@ fn_filename_completion_function(const ch return NULL; } filename = nptr; - (void)strcpy(filename, temp); - len = (size_t)(temp - text); /* including last slash */ + (void)strcpy(filename, pos); + len = (size_t)(pos - text); /* including last slash */ nptr = el_realloc(dirname, (len + 1) * sizeof(*nptr));
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 26 13:45:37 UTC 2021 Modified Files: src/lib/libedit: filecomplete.c Log Message: - Completion should not add a quote at the end of the line to match an already quoted quote. (Piotr Stefaniak) - fix lint unconst warnings for strchr To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: rillig Date: Fri Sep 10 18:51:36 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: libedit: fix indentation No change to the resulting object files. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: rillig Date: Fri Sep 10 18:51:36 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: libedit: fix indentation No change to the resulting object files. To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.167 src/lib/libedit/readline.c:1.168 --- src/lib/libedit/readline.c:1.167 Fri Sep 10 13:29:06 2021 +++ src/lib/libedit/readline.c Fri Sep 10 18:51:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.167 2021/09/10 13:29:06 christos Exp $ */ +/* $NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.167 2021/09/10 13:29:06 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $"); #endif /* not lint && not SCCSID */ #include @@ -596,7 +596,7 @@ get_history_event(const char *cmd, int * if (sub && cmd[idx] == '?') break; if (!sub && (cmd[idx] == ':' || cmd[idx] == ' ' -|| cmd[idx] == '\t' || cmd[idx] == qchar)) + || cmd[idx] == '\t' || cmd[idx] == qchar)) break; idx++; } @@ -824,7 +824,8 @@ _history_expand_command(const char *comm } else { int qchar; - qchar = (offs > 0 && command[offs - 1] == '"')? '"':0; + qchar = (offs > 0 && command[offs - 1] == '"') + ? '"' : '\0'; ptr = get_history_event(command + offs, , qchar); } has_mods = command[offs + (size_t)idx] == ':'; @@ -902,7 +903,7 @@ _history_expand_command(const char *comm switch (*cmd) { case ':': continue; - case 'h': /* remove trailing path */ + case 'h': /* remove trailing path */ if ((aptr = strrchr(tmp, '/')) != NULL) *aptr = '\0'; continue; @@ -1402,7 +1403,7 @@ read_history(const char *filename) return errno; errno = 0; if (history(h, , H_LOAD, filename) == -1) - return errno ? errno : EINVAL; + return errno ? errno : EINVAL; if (history(h, , H_GETSIZE) == 0) history_length = ev.num; if (history_length < 0) @@ -2080,7 +2081,7 @@ static unsigned char rl_bind_wrapper(EditLine *el __attribute__((__unused__)), unsigned char c) { if (map[c] == NULL) - return CC_ERROR; + return CC_ERROR; _rl_update_pos();
CVS commit: src/lib/libedit/TEST
Module Name:src Committed By: christos Date: Fri Sep 10 13:33:45 UTC 2021 Added Files: src/lib/libedit/TEST: fuzz1.c Log Message: Add an LLVM fuzzing wrapper for the portable libedit (Christian Holler) To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/lib/libedit/TEST/fuzz1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/lib/libedit/TEST/fuzz1.c diff -u /dev/null src/lib/libedit/TEST/fuzz1.c:1.1 --- /dev/null Fri Sep 10 09:33:45 2021 +++ src/lib/libedit/TEST/fuzz1.c Fri Sep 10 09:33:45 2021 @@ -0,0 +1,63 @@ +/* + * build: + * CC=clang CXX=clang++ CFLAGS="-fsanitize=address,fuzzer-no-link -g" \ + * CXXFLAGS="-fsanitize=address,fuzzer-no-link -g" ./configure && make + * run: + * LD_LIBRARY_PATH=../src/.libs/ .libs/fuzz1 -max_len=32 \ + * -use_value_profile=1 -only_ascii=1 + */ +#include +#include +#include +#include +#include +#include + +int init = 0; + +int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (!Size) +return 0; + + if (!init) { +setlocale(LC_CTYPE, ""); +stifle_history(7); +init = 1; + } + + clear_history(); + + size_t lasti = 0; + + for (size_t i = 0;; ++i) { +if (i == Size || Data[i] == '\n') { + if (i - lasti) { +char *s = (char *)malloc(i - lasti + 1); +memcpy(s, [lasti], i - lasti); +s[i - lasti] = '\0'; + +char *expansion; +int result; + +#ifdef DEBUG +fprintf(stderr, "Calling history_expand: >%s<\n", s); +#endif +result = history_expand(s, ); + +if (result < 0 || result == 2) { + /* Errors ignored */ +} else { + add_history(expansion); +} +free(expansion); +free(s); + } + lasti = i + 1; +} + +if (i == Size) + break; + } + + return 0; +}
CVS commit: src/lib/libedit/TEST
Module Name:src Committed By: christos Date: Fri Sep 10 13:33:45 UTC 2021 Added Files: src/lib/libedit/TEST: fuzz1.c Log Message: Add an LLVM fuzzing wrapper for the portable libedit (Christian Holler) To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/lib/libedit/TEST/fuzz1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Sep 10 13:29:06 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: rl_startup_hook should be called each time. From Carlos Henrique Lima Melara To generate a diff of this commit: cvs rdiff -u -r1.166 -r1.167 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.166 src/lib/libedit/readline.c:1.167 --- src/lib/libedit/readline.c:1.166 Thu Sep 9 16:25:30 2021 +++ src/lib/libedit/readline.c Fri Sep 10 09:29:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.166 2021/09/09 20:25:30 christos Exp $ */ +/* $NetBSD: readline.c,v 1.167 2021/09/10 13:29:06 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.166 2021/09/09 20:25:30 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.167 2021/09/10 13:29:06 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -123,7 +123,6 @@ int readline_echoing_p = 1; int _rl_print_completions_horizontally = 0; VFunction *rl_redisplay_function = NULL; Function *rl_startup_hook = NULL; -int rl_did_startup_hook = 0; VFunction *rl_completion_display_matches_hook = NULL; VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; @@ -425,8 +424,7 @@ readline(const char *p) if (e == NULL || h == NULL) rl_initialize(); - if (rl_did_startup_hook == 0 && rl_startup_hook) { - rl_did_startup_hook = 1; + if (rl_startup_hook) { (*rl_startup_hook)(NULL, 0); } tty_init(e);
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Sep 10 13:29:06 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: rl_startup_hook should be called each time. From Carlos Henrique Lima Melara To generate a diff of this commit: cvs rdiff -u -r1.166 -r1.167 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Thu Sep 9 20:25:30 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: fix memory issues found by fuzzing (double frees and buffer overflows) To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.165 src/lib/libedit/readline.c:1.166 --- src/lib/libedit/readline.c:1.165 Fri Sep 3 08:20:38 2021 +++ src/lib/libedit/readline.c Thu Sep 9 16:25:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.165 2021/09/03 12:20:38 christos Exp $ */ +/* $NetBSD: readline.c,v 1.166 2021/09/09 20:25:30 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.165 2021/09/03 12:20:38 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.166 2021/09/09 20:25:30 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -624,8 +624,7 @@ get_history_event(const char *cmd, int * if (sub) { if (pat != last_search_pat) { - if (last_search_pat) -el_free(last_search_pat); + el_free(last_search_pat); last_search_pat = pat; } ret = history_search(pat, -1); @@ -642,9 +641,8 @@ get_history_event(const char *cmd, int * } if (sub && len) { - if (last_search_match && last_search_match != pat) - el_free(last_search_match); - last_search_match = pat; + el_free(last_search_match); + last_search_match = strdup(pat); } if (pat != last_search_pat) @@ -676,7 +674,7 @@ getfrom(const char **cmdp, char **fromp, for (; *cmd && *cmd != delim; cmd++) { if (*cmd == '\\' && cmd[1] == delim) cmd++; - if (len >= size) { + if (len - 1 >= size) { char *nwhat; nwhat = el_realloc(what, (size <<= 1) * sizeof(*nwhat)); if (nwhat == NULL) { @@ -707,6 +705,7 @@ getfrom(const char **cmdp, char **fromp, } if (!*cmd) { el_free(what); + *fromp = NULL; return -1; } @@ -715,6 +714,7 @@ getfrom(const char **cmdp, char **fromp, if (!*cmd) { el_free(what); + *fromp = NULL; return -1; } return 1; @@ -728,6 +728,7 @@ getto(const char **cmdp, char **top, con size_t from_len = strlen(from); const char *cmd = *cmdp; char *with = el_realloc(*top, size * sizeof(*with)); + *top = NULL; if (with == NULL) goto out; @@ -848,7 +849,7 @@ _history_expand_command(const char *comm /* Now parse any word designators */ if (*cmd == '%') /* last word matched by ?pat? */ - tmp = strdup(last_search_match? last_search_match:""); + tmp = strdup(last_search_match ? last_search_match : ""); else if (strchr("^*$-0123456789", *cmd)) { start = end = -1; if (*cmd == '^') @@ -928,26 +929,30 @@ _history_expand_command(const char *comm continue; /*FALLTHROUGH*/ case 's': - delim = *(++cmd), cmd++; /* XXX: check */ - if ((ev = getfrom(, , search, delim)) != 1) { -el_free(tmp); -return ev; - } - if ((ev = getto(, , from, delim)) != 1) { -el_free(tmp); -return ev; - } + ev = -1; + delim = *++cmd; + if (delim == '\0' || *++cmd == '\0') +goto out; + if ((ev = getfrom(, , search, delim)) != 1) +goto out; + if ((ev = getto(, , from, delim)) != 1) +goto out; aptr = _rl_compat_sub(tmp, from, to, g_on); if (aptr) { el_free(tmp); tmp = aptr; } g_on = 0; + cmd--; continue; } } *result = tmp; return p_on ? 2 : 1; +out: + el_free(tmp); + return ev; + }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Thu Sep 9 20:25:30 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: fix memory issues found by fuzzing (double frees and buffer overflows) To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Thu Sep 9 20:24:08 UTC 2021 Modified Files: src/lib/libedit: refresh.c terminal.c Log Message: Add casts to appease conversions between wchar_t and wint_t To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/refresh.c cvs rdiff -u -r1.43 -r1.44 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/refresh.c diff -u src/lib/libedit/refresh.c:1.57 src/lib/libedit/refresh.c:1.58 --- src/lib/libedit/refresh.c:1.57 Mon Mar 30 02:54:37 2020 +++ src/lib/libedit/refresh.c Thu Sep 9 16:24:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.57 2020/03/30 06:54:37 ryo Exp $ */ +/* $NetBSD: refresh.c,v 1.58 2021/09/09 20:24:07 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: refresh.c,v 1.57 2020/03/30 06:54:37 ryo Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.58 2021/09/09 20:24:07 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -105,7 +105,7 @@ re_nextline(EditLine *el) */ if (el->el_refresh.r_cursor.v + 1 >= el->el_terminal.t_size.v) { int i, lins = el->el_terminal.t_size.v; - wchar_t *firstline = el->el_vdisplay[0]; + wint_t *firstline = el->el_vdisplay[0]; for(i = 1; i < lins; i++) el->el_vdisplay[i - 1] = el->el_vdisplay[i]; @@ -334,7 +334,8 @@ re_refresh(EditLine *el) ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv)); for (i = 0; i <= el->el_refresh.r_newcv; i++) { /* NOTE THAT re_update_line MAY CHANGE el_display[i] */ - re_update_line(el, el->el_display[i], el->el_vdisplay[i], i); + re_update_line(el, (wchar_t *)el->el_display[i], + (wchar_t *)el->el_vdisplay[i], i); /* * Copy the new line to be the current one, and pad out with @@ -343,7 +344,8 @@ re_refresh(EditLine *el) * end of the screen line, it won't be a NUL or some old * leftover stuff. */ - re__copy_and_pad(el->el_display[i], el->el_vdisplay[i], + re__copy_and_pad((wchar_t *)el->el_display[i], + (wchar_t *)el->el_vdisplay[i], (size_t) el->el_terminal.t_size.h); } ELRE_DEBUG(1, (__F, @@ -355,7 +357,8 @@ re_refresh(EditLine *el) terminal_move_to_line(el, i); terminal_move_to_char(el, 0); /* This wcslen should be safe even with MB_FILL_CHARs */ - terminal_clear_EOL(el, (int) wcslen(el->el_display[i])); + terminal_clear_EOL(el, + (int) wcslen((const wchar_t *)el->el_display[i])); #ifdef DEBUG_REFRESH terminal_overwrite(el, L"C\b", 2); #endif /* DEBUG_REFRESH */ @@ -1091,7 +1094,7 @@ re_refresh_cursor(EditLine *el) static void re_fastputc(EditLine *el, wint_t c) { - wchar_t *lastline; + wint_t *lastline; int w; w = wcwidth(c); @@ -1126,7 +1129,8 @@ re_fastputc(EditLine *el, wint_t c) el->el_cursor.v++; lastline = el->el_display[++el->el_refresh.r_oldcv]; } - re__copy_and_pad(lastline, L"", (size_t)el->el_terminal.t_size.h); + re__copy_and_pad((wchar_t *)lastline, L"", + (size_t)el->el_terminal.t_size.h); if (EL_HAS_AUTO_MARGINS) { if (EL_HAS_MAGIC_MARGINS) { Index: src/lib/libedit/terminal.c diff -u src/lib/libedit/terminal.c:1.43 src/lib/libedit/terminal.c:1.44 --- src/lib/libedit/terminal.c:1.43 Fri Jul 10 16:34:24 2020 +++ src/lib/libedit/terminal.c Thu Sep 9 16:24:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: terminal.c,v 1.43 2020/07/10 20:34:24 christos Exp $ */ +/* $NetBSD: terminal.c,v 1.44 2021/09/09 20:24:07 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: terminal.c,v 1.43 2020/07/10 20:34:24 christos Exp $"); +__RCSID("$NetBSD: terminal.c,v 1.44 2021/09/09 20:24:07 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -588,7 +588,8 @@ mc_again: * NOTE THAT terminal_overwrite() WILL CHANGE * el->el_cursor.h!!! */ -terminal_overwrite(el, >el_display[ +terminal_overwrite(el, +(wchar_t *)>el_display[ el->el_cursor.v][el->el_cursor.h], (size_t)(where - el->el_cursor.h));
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Thu Sep 9 20:24:08 UTC 2021 Modified Files: src/lib/libedit: refresh.c terminal.c Log Message: Add casts to appease conversions between wchar_t and wint_t To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/refresh.c cvs rdiff -u -r1.43 -r1.44 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Sep 3 12:20:38 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: Try to refactor this in order to correct some of the memory issues reported by Christian Holler. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.164 src/lib/libedit/readline.c:1.165 --- src/lib/libedit/readline.c:1.164 Sat Aug 21 08:38:56 2021 +++ src/lib/libedit/readline.c Fri Sep 3 08:20:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.164 2021/08/21 12:38:56 christos Exp $ */ +/* $NetBSD: readline.c,v 1.165 2021/09/03 12:20:38 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.164 2021/08/21 12:38:56 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.165 2021/09/03 12:20:38 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -460,14 +460,10 @@ readline(const char *p) ret = el_gets(e, ); if (ret && count > 0) { - int lastidx; - buf = strdup(ret); if (buf == NULL) goto out; - lastidx = count - 1; - if (buf[lastidx] == '\n') - buf[lastidx] = '\0'; + buf[strcspn(buf, "\n")] = '\0'; } else buf = NULL; @@ -665,6 +661,120 @@ get_history_event(const char *cmd, int * return rptr; } +static int +getfrom(const char **cmdp, char **fromp, const char *search, int delim) +{ + size_t size = 16; + size_t len = 0; + const char *cmd = *cmdp; + char *what = el_realloc(*fromp, size * sizeof(*what)); + if (what == NULL){ + el_free(*fromp); + *fromp = NULL; + return 0; + } + for (; *cmd && *cmd != delim; cmd++) { + if (*cmd == '\\' && cmd[1] == delim) + cmd++; + if (len >= size) { + char *nwhat; + nwhat = el_realloc(what, (size <<= 1) * sizeof(*nwhat)); + if (nwhat == NULL) { +el_free(what); +el_free(*fromp); +*cmdp = cmd; +*fromp = NULL; +return 0; + } + what = nwhat; + } + what[len++] = *cmd; + } + what[len] = '\0'; + *fromp = what; + *cmdp = cmd; + if (*what == '\0') { + el_free(what); + if (search) { + *fromp = strdup(search); + if (*fromp == NULL) { +return 0; + } + } else { + *fromp = NULL; + return -1; + } + } + if (!*cmd) { + el_free(what); + return -1; + } + + cmd++; /* shift after delim */ + *cmdp = cmd; + + if (!*cmd) { + el_free(what); + return -1; + } + return 1; +} + +static int +getto(const char **cmdp, char **top, const char *from, int delim) +{ + size_t size = 16; + size_t len = 0; + size_t from_len = strlen(from); + const char *cmd = *cmdp; + char *with = el_realloc(*top, size * sizeof(*with)); + if (with == NULL) + goto out; + + for (; *cmd && *cmd != delim; cmd++) { + if (len + from_len + 1 >= size) { + char *nwith; + size += from_len + 1; + nwith = el_realloc(with, size * sizeof(*nwith)); + if (nwith == NULL) +goto out; + with = nwith; + } + if (*cmd == '&') { + /* safe */ + strcpy([len], from); + len += from_len; + continue; + } + if (*cmd == '\\' && (*(cmd + 1) == delim || *(cmd + 1) == '&')) + cmd++; + with[len++] = *cmd; + } + if (!*cmd) + goto out; + with[len] = '\0'; + *top = with; + *cmdp = cmd; + return 1; +out: + el_free(with); + el_free(*top); + *top = NULL; + *cmdp = cmd; + return -1; +} + +static void +replace(char **tmp, int c) +{ + char *aptr; + if ((aptr = strrchr(*tmp, c)) == NULL) + return; + aptr = strdup(aptr + 1); // XXX: check + el_free(*tmp); + *tmp = aptr; +} + /* * the real function doing history expansion - takes as argument command * to do and data upon which the command should be executed @@ -679,11 +789,11 @@ static int _history_expand_command(const char *command, size_t offs, size_t cmdlen, char **result) { - char *tmp, *search = NULL, *aptr; + char *tmp, *search = NULL, *aptr, delim; const char *ptr, *cmd; static char *from = NULL, *to = NULL; int start, end, idx, has_mods = 0; - int p_on = 0, g_on = 0; + int p_on = 0, g_on = 0, ev; *result = NULL; aptr = NULL; @@ -747,7 +857,7 @@ _history_expand_command(const char *comm start = -1, cmd++; else if (*cmd == '*') start = 1, cmd++; - else if (*cmd == '-' || isdigit((unsigned char) *cmd)) { + else if (*cmd == '-' || isdigit((unsigned char) *cmd)) { start = 0; while (*cmd && '0' <= *cmd && *cmd <= '9') start = start * 10 + *cmd++ - '0'; @@ -790,132 +900,54 @@ _history_expand_command(const char *comm } for (; *cmd; cmd++) { - if (*cmd == ':') + switch (*cmd) { + case ':': continue; - else if (*cmd == 'h') { /* remove trailing path */ + case 'h': /* remove trailing path */ if ((aptr = strrchr(tmp, '/')) != NULL) *aptr = '\0'; - } else if (*cmd == 't') { /* remove
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Fri Sep 3 12:20:38 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: Try to refactor this in order to correct some of the memory issues reported by Christian Holler. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Aug 30 09:18:17 UTC 2021 Added Files: src/lib/libedit: ChangeLog Log Message: Add a changes file To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/lib/libedit/ChangeLog Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/lib/libedit/ChangeLog diff -u /dev/null src/lib/libedit/ChangeLog:1.1 --- /dev/null Mon Aug 30 05:18:17 2021 +++ src/lib/libedit/ChangeLog Mon Aug 30 05:18:17 2021 @@ -0,0 +1,6 @@ +2021-08-29 Christos Zoulas + + Change default mappings: + map ^W to ed-delete-prev-word and not kill-region + map ^R to em-inc-search-next and not redisplay +
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Mon Aug 30 09:18:17 UTC 2021 Added Files: src/lib/libedit: ChangeLog Log Message: Add a changes file To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/lib/libedit/ChangeLog Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Aug 29 09:41:59 UTC 2021 Modified Files: src/lib/libedit: map.c Log Message: ^W is traditionally bound to ed-delete-prev-word and not kill-region ^R is traditionally bound to em-inc-search-next and not redisplay This is what mksh, zsh bash, readline do (Baptiste Daroussin) To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/map.c diff -u src/lib/libedit/map.c:1.53 src/lib/libedit/map.c:1.54 --- src/lib/libedit/map.c:1.53 Mon Mar 30 02:54:37 2020 +++ src/lib/libedit/map.c Sun Aug 29 05:41:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: map.c,v 1.53 2020/03/30 06:54:37 ryo Exp $ */ +/* $NetBSD: map.c,v 1.54 2021/08/29 09:41:59 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: map.c,v 1.53 2020/03/30 06:54:37 ryo Exp $"); +__RCSID("$NetBSD: map.c,v 1.54 2021/08/29 09:41:59 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -85,12 +85,12 @@ static const el_action_t el_map_emacs[] /* 15 */ ED_IGNORE, /* ^O */ /* 16 */ ED_PREV_HISTORY, /* ^P */ /* 17 */ ED_IGNORE, /* ^Q */ - /* 18 */ ED_REDISPLAY, /* ^R */ + /* 18 */ EM_INC_SEARCH_PREV, /* ^R */ /* 19 */ ED_IGNORE, /* ^S */ /* 20 */ ED_TRANSPOSE_CHARS, /* ^T */ /* 21 */ EM_KILL_LINE, /* ^U */ /* 22 */ ED_QUOTED_INSERT, /* ^V */ - /* 23 */ EM_KILL_REGION, /* ^W */ + /* 23 */ ED_DELETE_PREV_WORD, /* ^W */ /* 24 */ ED_SEQUENCE_LEAD_IN, /* ^X */ /* 25 */ EM_YANK, /* ^Y */ /* 26 */ ED_IGNORE, /* ^Z */
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Aug 29 09:41:59 UTC 2021 Modified Files: src/lib/libedit: map.c Log Message: ^W is traditionally bound to ed-delete-prev-word and not kill-region ^R is traditionally bound to em-inc-search-next and not redisplay This is what mksh, zsh bash, readline do (Baptiste Daroussin) To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/map.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Aug 21 12:38:56 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: PR/56370: mirabilos: libedit change from 2017 kills history in gdb To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.163 src/lib/libedit/readline.c:1.164 --- src/lib/libedit/readline.c:1.163 Sat Aug 21 08:34:59 2021 +++ src/lib/libedit/readline.c Sat Aug 21 08:38:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.163 2021/08/21 12:34:59 christos Exp $ */ +/* $NetBSD: readline.c,v 1.164 2021/08/21 12:38:56 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.163 2021/08/21 12:34:59 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.164 2021/08/21 12:38:56 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -2078,6 +2078,7 @@ rl_callback_read_char(void) const char *buf = el_gets(e, ); char *wbuf; + el_set(e, EL_UNBUFFERED, 1); if (buf == NULL || count-- <= 0) return; if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF]) @@ -2093,7 +2094,6 @@ rl_callback_read_char(void) } else wbuf = NULL; (*(void (*)(const char *))rl_linefunc)(wbuf); - el_set(e, EL_UNBUFFERED, 1); } } @@ -2111,9 +2111,8 @@ rl_callback_handler_install(const char * void rl_callback_handler_remove(void) { + el_set(e, EL_UNBUFFERED, 0); rl_linefunc = NULL; - el_end(e); - e = NULL; } void
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Aug 21 12:38:56 UTC 2021 Modified Files: src/lib/libedit: readline.c Log Message: PR/56370: mirabilos: libedit change from 2017 kills history in gdb To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sat Aug 21 12:34:59 UTC 2021 Modified Files: src/lib/libedit: readline.c src/lib/libedit/readline: readline.h Log Message: Add more api to make gdb-11 happy (but not gdbtui as usual) To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/lib/libedit/readline.c cvs rdiff -u -r1.46 -r1.47 src/lib/libedit/readline/readline.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/lib/libedit (strncpy->strlcpy)
> This feels not good. > strncpy->strlcpy has repercussions like how strlcpy doesn't zero out the > remaining length and thus leaks uninitialized data. > > There has to be a reasonable way to handle these warnings instead of > rototilling which str*cpy function is used. Please read the code before commenting. Yes, I know that they are not equivalent, but in this case the destination strings are all local variables on the stack used internally only in the functions declared, to be compared or printed with other NUL-terminated strings. It is pointless to zero out the rest of the data. christos signature.asc Description: Message signed with OpenPGP
Re: CVS commit: src/lib/libedit (strncpy->strlcpy)
On Sun, May 31, 2020 at 07:24:24PM -0400, Christos Zoulas wrote: > Module Name: src > Committed By: christos > Date: Sun May 31 23:24:24 UTC 2020 > > Modified Files: > src/lib/libedit: terminal.c tty.c > > Log Message: > use strlcpy() instead of strncpy() for gcc happiness > ... > @@ -1319,10 +1319,8 @@ terminal_settc(EditLine *el, int argc __ > if (argv == NULL || argv[1] == NULL || argv[2] == NULL) > return -1; > > - strncpy(what, ct_encode_string(argv[1], >el_scratch), sizeof(what)); > - what[sizeof(what) - 1] = '\0'; > - strncpy(how, ct_encode_string(argv[2], >el_scratch), sizeof(how)); > - how[sizeof(how) - 1] = '\0'; > + strlcpy(what, ct_encode_string(argv[1], >el_scratch), sizeof(what)); > + strlcpy(how, ct_encode_string(argv[2], >el_scratch), sizeof(how)); > This feels not good. strncpy->strlcpy has repercussions like how strlcpy doesn't zero out the remaining length and thus leaks uninitialized data. There has to be a reasonable way to handle these warnings instead of rototilling which str*cpy function is used.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Nov 12 20:59:46 UTC 2019 Modified Files: src/lib/libedit: terminal.c Log Message: PR/54654: Soren Tempel: Make sure el_cursor.v < el_terminal.t_size.v when moving around. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/terminal.c diff -u src/lib/libedit/terminal.c:1.40 src/lib/libedit/terminal.c:1.41 --- src/lib/libedit/terminal.c:1.40 Sun Sep 15 17:09:11 2019 +++ src/lib/libedit/terminal.c Tue Nov 12 15:59:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: terminal.c,v 1.40 2019/09/15 21:09:11 christos Exp $ */ +/* $NetBSD: terminal.c,v 1.41 2019/11/12 20:59:46 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: terminal.c,v 1.40 2019/09/15 21:09:11 christos Exp $"); +__RCSID("$NetBSD: terminal.c,v 1.41 2019/11/12 20:59:46 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -497,7 +497,7 @@ terminal_move_to_line(EditLine *el, int if (where == el->el_cursor.v) return; - if (where > el->el_terminal.t_size.v) { + if (where >= el->el_terminal.t_size.v) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, "%s: where is ridiculous: %d\r\n", __func__, where); @@ -647,7 +647,8 @@ terminal_overwrite(EditLine *el, const w if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */ if (EL_HAS_AUTO_MARGINS) { /* yes */ el->el_cursor.h = 0; - el->el_cursor.v++; + if (el->el_cursor.v + 1 < el->el_terminal.t_size.v) +el->el_cursor.v++; if (EL_HAS_MAGIC_MARGINS) { /* force the wrap to avoid the "magic" * situation */
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Nov 12 20:59:46 UTC 2019 Modified Files: src/lib/libedit: terminal.c Log Message: PR/54654: Soren Tempel: Make sure el_cursor.v < el_terminal.t_size.v when moving around. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Oct 9 14:31:07 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c readline.c Log Message: add +1 to strlcpy's (Patrick Welche) To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.158 -r1.159 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.60 src/lib/libedit/filecomplete.c:1.61 --- src/lib/libedit/filecomplete.c:1.60 Tue Oct 8 15:21:40 2019 +++ src/lib/libedit/filecomplete.c Wed Oct 9 10:31:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.61 2019/10/09 14:31:07 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.61 2019/10/09 14:31:07 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -86,7 +86,7 @@ fn_tilde_expand(const char *txt) temp = el_calloc(len, sizeof(*temp)); if (temp == NULL) return NULL; - (void)strlcpy(temp, txt + 1, len - 2); + (void)strlcpy(temp, txt + 1, len - 1); } if (temp[0] == 0) { #ifdef HAVE_GETPW_R_POSIX @@ -353,7 +353,7 @@ fn_filename_completion_function(const ch return NULL; } dirname = nptr; - (void)strlcpy(dirname, text, len); + (void)strlcpy(dirname, text, len + 1); } else { el_free(filename); if (*text == 0) @@ -507,7 +507,7 @@ completion_matches(const char *text, cha el_free(match_list); return NULL; } - (void)strlcpy(retstr, match_list[1], max_equal); + (void)strlcpy(retstr, match_list[1], max_equal + 1); match_list[0] = retstr; /* add NULL as last pointer to the array */ Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.158 src/lib/libedit/readline.c:1.159 --- src/lib/libedit/readline.c:1.158 Tue Oct 8 15:17:57 2019 +++ src/lib/libedit/readline.c Wed Oct 9 10:31:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $ */ +/* $NetBSD: readline.c,v 1.159 2019/10/09 14:31:07 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.159 2019/10/09 14:31:07 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -607,7 +607,7 @@ get_history_event(const char *cmd, int * else { if ((pat = el_calloc(len + 1, sizeof(*pat))) == NULL) return NULL; - (void)strlcpy(pat, cmd + begin, len); + (void)strlcpy(pat, cmd + begin, len + 1); } if (history(h, , H_CURR) != 0) { @@ -701,7 +701,7 @@ _history_expand_command(const char *comm if ((aptr = el_calloc(offs + 1, sizeof(*aptr))) == NULL) return -1; - strlcpy(aptr, command, offs); + (void)strlcpy(aptr, command, offs + 1); idx = 1; } else { int qchar; @@ -958,7 +958,7 @@ history_expand(char *str, char **output) } \ result = nresult;\ } \ - (void)strlcpy([idx], what, len); \ + (void)strlcpy([idx], what, len + 1); \ idx += len; \ } @@ -1147,7 +1147,7 @@ history_tokenize(const char *str) el_free(result); return NULL; } - (void)strlcpy(temp, [start], len); + (void)strlcpy(temp, [start], len + 1); result[idx++] = temp; result[idx] = NULL; if (str[i])
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Oct 9 14:31:07 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c readline.c Log Message: add +1 to strlcpy's (Patrick Welche) To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.158 -r1.159 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Oct 8 19:21:40 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c Log Message: remore error(1) comment To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Oct 8 19:21:40 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c Log Message: remore error(1) comment To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.59 src/lib/libedit/filecomplete.c:1.60 --- src/lib/libedit/filecomplete.c:1.59 Tue Oct 8 15:17:57 2019 +++ src/lib/libedit/filecomplete.c Tue Oct 8 15:21:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.59 2019/10/08 19:17:57 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.59 2019/10/08 19:17:57 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -462,7 +462,6 @@ out: */ char ** completion_matches(const char *, char *(*)(const char *, int)); char ** -/*###467 [lint] completion_matches arg 1 declared inconsistently (pointer to const char != pointer to char) filecomplete.c(467) :: readline.c?(53)%%%*/ completion_matches(const char *text, char *(*genfunc)(const char *, int)) { char **match_list = NULL, *retstr, *prevstr;
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Oct 8 19:17:57 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c history.c readline.c Log Message: Change strncpy to either memcpy (when we know the len), or strlcpy (when we used to NUL terminate explicitly. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.62 -r1.63 src/lib/libedit/history.c cvs rdiff -u -r1.157 -r1.158 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.58 src/lib/libedit/filecomplete.c:1.59 --- src/lib/libedit/filecomplete.c:1.58 Sun Sep 8 01:50:58 2019 +++ src/lib/libedit/filecomplete.c Tue Oct 8 15:17:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.58 2019/09/08 05:50:58 abhinav Exp $ */ +/* $NetBSD: filecomplete.c,v 1.59 2019/10/08 19:17:57 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.58 2019/09/08 05:50:58 abhinav Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.59 2019/10/08 19:17:57 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -86,8 +86,7 @@ fn_tilde_expand(const char *txt) temp = el_calloc(len, sizeof(*temp)); if (temp == NULL) return NULL; - (void)strncpy(temp, txt + 1, len - 2); - temp[len - 2] = '\0'; + (void)strlcpy(temp, txt + 1, len - 2); } if (temp[0] == 0) { #ifdef HAVE_GETPW_R_POSIX @@ -354,8 +353,7 @@ fn_filename_completion_function(const ch return NULL; } dirname = nptr; - (void)strncpy(dirname, text, len); - dirname[len] = '\0'; + (void)strlcpy(dirname, text, len); } else { el_free(filename); if (*text == 0) @@ -464,6 +462,7 @@ out: */ char ** completion_matches(const char *, char *(*)(const char *, int)); char ** +/*###467 [lint] completion_matches arg 1 declared inconsistently (pointer to const char != pointer to char) filecomplete.c(467) :: readline.c?(53)%%%*/ completion_matches(const char *text, char *(*genfunc)(const char *, int)) { char **match_list = NULL, *retstr, *prevstr; @@ -509,8 +508,7 @@ completion_matches(const char *text, cha el_free(match_list); return NULL; } - (void)strncpy(retstr, match_list[1], max_equal); - retstr[max_equal] = '\0'; + (void)strlcpy(retstr, match_list[1], max_equal); match_list[0] = retstr; /* add NULL as last pointer to the array */ Index: src/lib/libedit/history.c diff -u src/lib/libedit/history.c:1.62 src/lib/libedit/history.c:1.63 --- src/lib/libedit/history.c:1.62 Thu Sep 13 05:03:40 2018 +++ src/lib/libedit/history.c Tue Oct 8 15:17:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: history.c,v 1.62 2018/09/13 09:03:40 kre Exp $ */ +/* $NetBSD: history.c,v 1.63 2019/10/08 19:17:57 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: history.c,v 1.62 2018/09/13 09:03:40 kre Exp $"); +__RCSID("$NetBSD: history.c,v 1.63 2019/10/08 19:17:57 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -411,21 +411,23 @@ static int history_def_add(void *p, TYPE(HistEvent) *ev, const Char *str) { history_t *h = (history_t *) p; - size_t len; + size_t len, elen, slen; Char *s; HistEventPrivate *evp = (void *)>cursor->ev; if (h->cursor == >list) return history_def_enter(p, ev, str); - len = Strlen(evp->str) + Strlen(str) + 1; + elen = Strlen(evp->str); + slen = Strlen(str); + len = elen + slen + 1; s = h_malloc(len * sizeof(*s)); if (s == NULL) { he_seterrev(ev, _HE_MALLOC_FAILED); return -1; } - (void) Strncpy(s, h->cursor->ev.str, len); + memcpy(s, evp->str, elen * sizeof(*s)); + memcpy(s + elen, str, slen * sizeof(*s)); s[len - 1] = '\0'; - (void) Strncat(s, str, len - Strlen(s) - 1); h_free(evp->str); evp->str = s; *ev = h->cursor->ev; Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.157 src/lib/libedit/readline.c:1.158 --- src/lib/libedit/readline.c:1.157 Wed Aug 21 07:11:48 2019 +++ src/lib/libedit/readline.c Tue Oct 8 15:17:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.157 2019/08/21 11:11:48 christos Exp $ */ +/* $NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.157 2019/08/21 11:11:48 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -521,7 +521,7 @@ _rl_compat_sub(const char *str, const ch s = str; while (*s) { if (*s == *what && !strncmp(s, what, what_len)) { - (void)strncpy(r,
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Oct 8 19:17:57 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c history.c readline.c Log Message: Change strncpy to either memcpy (when we know the len), or strlcpy (when we used to NUL terminate explicitly. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.62 -r1.63 src/lib/libedit/history.c cvs rdiff -u -r1.157 -r1.158 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 15 21:09:11 UTC 2019 Modified Files: src/lib/libedit: chartype.h terminal.c Log Message: Fix type and remove cast (Yuichiro NAITO/FreeBSD). To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/chartype.h cvs rdiff -u -r1.39 -r1.40 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Sep 15 21:09:11 UTC 2019 Modified Files: src/lib/libedit: chartype.h terminal.c Log Message: Fix type and remove cast (Yuichiro NAITO/FreeBSD). To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/chartype.h cvs rdiff -u -r1.39 -r1.40 src/lib/libedit/terminal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chartype.h diff -u src/lib/libedit/chartype.h:1.35 src/lib/libedit/chartype.h:1.36 --- src/lib/libedit/chartype.h:1.35 Mon May 22 15:16:25 2017 +++ src/lib/libedit/chartype.h Sun Sep 15 17:09:11 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.h,v 1.35 2017/05/22 19:16:25 christos Exp $ */ +/* $NetBSD: chartype.h,v 1.36 2019/09/15 21:09:11 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -87,7 +87,7 @@ libedit_private size_t ct_enc_width(wcha /* 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 ((wchar_t)-1) +#define MB_FILL_CHAR ((wint_t)-1) /* Visual width of character c, taking into account ^? , \0177 and \U+n * style visual expansions. */ Index: src/lib/libedit/terminal.c diff -u src/lib/libedit/terminal.c:1.39 src/lib/libedit/terminal.c:1.40 --- src/lib/libedit/terminal.c:1.39 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/terminal.c Sun Sep 15 17:09:11 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: terminal.c,v 1.39 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: terminal.c,v 1.40 2019/09/15 21:09:11 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: terminal.c,v 1.39 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: terminal.c,v 1.40 2019/09/15 21:09:11 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1224,7 +1224,7 @@ terminal__putc(EditLine *el, wint_t c) { char buf[MB_LEN_MAX +1]; ssize_t i; - if (c == (wint_t)MB_FILL_CHAR) + if (c == MB_FILL_CHAR) return 0; if (c & EL_LITERAL) return fputs(literal_get(el, c), el->el_outfile);
CVS commit: src/lib/libedit
Module Name:src Committed By: abhinav Date: Sun Sep 8 05:50:58 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c src/lib/libedit/TEST: test_filecompletion.c Log Message: PR lib/54510: Fix file completion inside quotes which broke in rev 1.53 While there also fix handling character appending in the file completions when inside quotes. For example when inside a quote, if the completion is a directory then append a '/' but don't close the quote. On the other hand when inside a quote if the completion is a file name and it is the only match then we can close the quote. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.4 -r1.5 src/lib/libedit/TEST/test_filecompletion.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.57 src/lib/libedit/filecomplete.c:1.58 --- src/lib/libedit/filecomplete.c:1.57 Sun Jul 28 09:27:29 2019 +++ src/lib/libedit/filecomplete.c Sun Sep 8 05:50:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.57 2019/07/28 09:27:29 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.58 2019/09/08 05:50:58 abhinav Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.57 2019/07/28 09:27:29 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.58 2019/09/08 05:50:58 abhinav Exp $"); #endif /* not lint && not SCCSID */ #include @@ -192,7 +192,8 @@ unescape_string(const wchar_t *string, s } static char * -escape_filename(EditLine * el, const char *filename) +escape_filename(EditLine * el, const char *filename, int single_match, + const char *(*app_func)(const char *)) { size_t original_len = 0; size_t escaped_character_count = 0; @@ -204,6 +205,7 @@ escape_filename(EditLine * el, const cha size_t d_quoted = 0; /* does the input contain a double quote */ char *escaped_str; wchar_t *temp = el->el_line.buffer; + const char *append_char = NULL; if (filename == NULL) return NULL; @@ -246,6 +248,9 @@ escape_filename(EditLine * el, const cha if (s_quoted || d_quoted) newlen++; + if (single_match && app_func) + newlen++; + if ((escaped_str = el_malloc(newlen)) == NULL) return NULL; @@ -285,11 +290,24 @@ escape_filename(EditLine * el, const cha escaped_str[offset++] = c; } - /* close the quotes */ - if (s_quoted) - escaped_str[offset++] = '\''; - else if (d_quoted) - escaped_str[offset++] = '"'; + if (single_match && app_func) { + escaped_str[offset] = 0; + append_char = app_func(escaped_str); + /* we want to append space only if we are not inside quotes */ + if (append_char[0] == ' ') { + if (!s_quoted && !d_quoted) +escaped_str[offset++] = append_char[0]; + } else + escaped_str[offset++] = append_char[0]; + } + + /* close the quotes if single match and the match is not a directory */ + if (single_match && (append_char && append_char[0] == ' ')) { + if (s_quoted) + escaped_str[offset++] = '\''; + else if (d_quoted) + escaped_str[offset++] = '"'; + } escaped_str[offset] = 0; return escaped_str; @@ -596,6 +614,10 @@ find_word_to_complete(const wchar_t * cu if (ctemp - buffer >= 2 && ctemp[-2] == '\\') { ctemp -= 2; continue; + } else if (ctemp - buffer >= 2 && + (ctemp[-2] == '\'' || ctemp[-2] == '"')) { +ctemp--; +continue; } else break; } @@ -605,6 +627,10 @@ find_word_to_complete(const wchar_t * cu } len = (size_t) (cursor - ctemp); + if (len == 1 && (ctemp[0] == '\'' || ctemp[0] == '"')) { + len = 0; + ctemp++; + } *length = len; wchar_t *unescaped_word = unescape_string(ctemp, len); if (unescaped_word == NULL) @@ -689,31 +715,29 @@ fn_complete(EditLine *el, retval = CC_REFRESH; if (matches[0][0] != '\0') { - el_deletestr(el, (int) len); + el_deletestr(el, (int)len); if (!attempted_completion_function) -completion = escape_filename(el, matches[0]); +completion = escape_filename(el, matches[0], +single_match, app_func); else completion = strdup(matches[0]); if (completion == NULL) goto out; if (single_match) { -/* - * We found exact match. Add a space after - * it, unless we do filename completion and the - * object is a directory. Also do necessary escape quoting +/* We found exact match. Add a space after it, + * unless we do filename completion and the + * object is a directory. Also do necessary + * escape quoting */ el_winsertstr(el, - ct_decode_string(completion, >el_scratch)); -el_winsertstr(el, - ct_decode_string((*app_func)(completion), - >el_scratch)); +ct_decode_string(completion, >el_scratch)); } else { -/* - * Only replace the completed
CVS commit: src/lib/libedit
Module Name:src Committed By: abhinav Date: Sun Sep 8 05:50:58 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c src/lib/libedit/TEST: test_filecompletion.c Log Message: PR lib/54510: Fix file completion inside quotes which broke in rev 1.53 While there also fix handling character appending in the file completions when inside quotes. For example when inside a quote, if the completion is a directory then append a '/' but don't close the quote. On the other hand when inside a quote if the completion is a file name and it is the only match then we can close the quote. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.4 -r1.5 src/lib/libedit/TEST/test_filecompletion.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Aug 21 11:11:48 UTC 2019 Modified Files: src/lib/libedit: readline.c Log Message: Increment offset when adding an element to history to keep it aligned with the last element entered (Sandy Li Changqing) To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.156 src/lib/libedit/readline.c:1.157 --- src/lib/libedit/readline.c:1.156 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/readline.c Wed Aug 21 07:11:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.156 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: readline.c,v 1.157 2019/08/21 11:11:48 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.156 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.157 2019/08/21 11:11:48 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -1477,8 +1477,10 @@ add_history(const char *line) (void)history(h, , H_GETSIZE); if (ev.num == history_length) history_base++; - else + else { + history_offset++; history_length = ev.num; + } return 0; }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Wed Aug 21 11:11:48 UTC 2019 Modified Files: src/lib/libedit: readline.c Log Message: Increment offset when adding an element to history to keep it aligned with the last element entered (Sandy Li Changqing) To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Jul 28 09:27:29 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c Log Message: PR/54415: Ricky Zhou: libedit stats completions for non-file completions Use the proper completion function and account for the character appended by the function when computing the number of columns. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.56 src/lib/libedit/filecomplete.c:1.57 --- src/lib/libedit/filecomplete.c:1.56 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/filecomplete.c Sun Jul 28 05:27:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.56 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.57 2019/07/28 09:27:29 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.56 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.57 2019/07/28 09:27:29 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -538,7 +538,7 @@ fn_display_match_list(EditLine * el, cha * Find out how many entries can be put on one line; count * with one space between strings the same way it's printed. */ - cols = (size_t)screenwidth / (width + 1); + cols = (size_t)screenwidth / (width + 2); if (cols == 0) cols = 1; @@ -558,7 +558,7 @@ fn_display_match_list(EditLine * el, cha break; (void)fprintf(el->el_outfile, "%s%s%s", col == 0 ? "" : " ", matches[thisguy], -append_char_function(matches[thisguy])); +(*app_func)(matches[thisguy])); (void)fprintf(el->el_outfile, "%-*s", (int) (width - strlen(matches[thisguy])), ""); }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Sun Jul 28 09:27:29 UTC 2019 Modified Files: src/lib/libedit: filecomplete.c Log Message: PR/54415: Ricky Zhou: libedit stats completions for non-file completions Use the proper completion function and account for the character appended by the function when computing the number of columns. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jul 23 13:10:12 UTC 2019 Modified Files: src/lib/libedit: literal.c Log Message: remove stray brace To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libedit/literal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/literal.c diff -u src/lib/libedit/literal.c:1.4 src/lib/libedit/literal.c:1.5 --- src/lib/libedit/literal.c:1.4 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/literal.c Tue Jul 23 09:10:11 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: literal.c,v 1.4 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: literal.c,v 1.5 2019/07/23 13:10:11 christos Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: literal.c,v 1.4 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: literal.c,v 1.5 2019/07/23 13:10:11 christos Exp $"); #endif /* not lint && not SCCSID */ /* @@ -97,7 +97,7 @@ literal_add(EditLine *el, const wchar_t if (b == NULL) return 0; - for (n = 0, i = 0; i < len; i++) { + for (n = 0, i = 0; i < len; i++) n += ct_encode_char(b + n, (size_t)(w - n), buf[i]); n += ct_encode_char(b + n, (size_t)(w - n), end[1]); b[n] = '\0';
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jul 23 13:10:12 UTC 2019 Modified Files: src/lib/libedit: literal.c Log Message: remove stray brace To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libedit/literal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jul 23 10:19:35 UTC 2019 Modified Files: src/lib/libedit: hist.c Log Message: put the NULL check immediately after the allocation To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/hist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/hist.c diff -u src/lib/libedit/hist.c:1.33 src/lib/libedit/hist.c:1.34 --- src/lib/libedit/hist.c:1.33 Tue Jul 23 06:18:52 2019 +++ src/lib/libedit/hist.c Tue Jul 23 06:19:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hist.c,v 1.33 2019/07/23 10:18:52 christos Exp $ */ +/* $NetBSD: hist.c,v 1.34 2019/07/23 10:19:35 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: hist.c,v 1.33 2019/07/23 10:18:52 christos Exp $"); +__RCSID("$NetBSD: hist.c,v 1.34 2019/07/23 10:19:35 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -60,9 +60,9 @@ hist_init(EditLine *el) el->el_history.fun = NULL; el->el_history.ref = NULL; el->el_history.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_history.buf)); - el->el_history.sz = EL_BUFSIZ; if (el->el_history.buf == NULL) return -1; + el->el_history.sz = EL_BUFSIZ; el->el_history.last = el->el_history.buf; return 0; }
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jul 23 10:19:35 UTC 2019 Modified Files: src/lib/libedit: hist.c Log Message: put the NULL check immediately after the allocation To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/hist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libedit
Module Name:src Committed By: christos Date: Tue Jul 23 10:18:52 UTC 2019 Modified Files: src/lib/libedit: chared.c chartype.c el.c el.h filecomplete.c hist.c keymacro.c literal.c map.c parse.c read.c readline.c search.c terminal.c vi.c Log Message: PR/54399: S�ren Tempel: Uninitialized memory access in libedit history. Initialize the buffer using calloc. While here change all malloc(a * sizeof(b)) to calloc(a, sizeof(b)). XXX: should fix realloc similarly. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/lib/libedit/chared.c cvs rdiff -u -r1.34 -r1.35 src/lib/libedit/chartype.c cvs rdiff -u -r1.98 -r1.99 src/lib/libedit/el.c cvs rdiff -u -r1.44 -r1.45 src/lib/libedit/el.h cvs rdiff -u -r1.55 -r1.56 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.32 -r1.33 src/lib/libedit/hist.c cvs rdiff -u -r1.23 -r1.24 src/lib/libedit/keymacro.c cvs rdiff -u -r1.3 -r1.4 src/lib/libedit/literal.c cvs rdiff -u -r1.51 -r1.52 src/lib/libedit/map.c cvs rdiff -u -r1.41 -r1.42 src/lib/libedit/parse.c cvs rdiff -u -r1.105 -r1.106 src/lib/libedit/read.c cvs rdiff -u -r1.155 -r1.156 src/lib/libedit/readline.c cvs rdiff -u -r1.48 -r1.49 src/lib/libedit/search.c cvs rdiff -u -r1.38 -r1.39 src/lib/libedit/terminal.c cvs rdiff -u -r1.62 -r1.63 src/lib/libedit/vi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libedit/chared.c diff -u src/lib/libedit/chared.c:1.58 src/lib/libedit/chared.c:1.59 --- src/lib/libedit/chared.c:1.58 Tue Jul 23 05:47:16 2019 +++ src/lib/libedit/chared.c Tue Jul 23 06:18:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.58 2019/07/23 09:47:16 christos Exp $ */ +/* $NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.58 2019/07/23 09:47:16 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -396,26 +396,22 @@ cv__endword(wchar_t *p, wchar_t *high, i libedit_private int ch_init(EditLine *el) { - el->el_line.buffer = el_malloc(EL_BUFSIZ * + el->el_line.buffer = el_calloc(EL_BUFSIZ, sizeof(*el->el_line.buffer)); if (el->el_line.buffer == NULL) return -1; - (void) memset(el->el_line.buffer, 0, EL_BUFSIZ * - sizeof(*el->el_line.buffer)); el->el_line.cursor = el->el_line.buffer; el->el_line.lastchar = el->el_line.buffer; el->el_line.limit = >el_line.buffer[EL_BUFSIZ - EL_LEAVE]; - el->el_chared.c_undo.buf = el_malloc(EL_BUFSIZ * + el->el_chared.c_undo.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_chared.c_undo.buf)); if (el->el_chared.c_undo.buf == NULL) return -1; - (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ * - sizeof(*el->el_chared.c_undo.buf)); el->el_chared.c_undo.len = -1; el->el_chared.c_undo.cursor = 0; - el->el_chared.c_redo.buf = el_malloc(EL_BUFSIZ * + el->el_chared.c_redo.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_chared.c_redo.buf)); if (el->el_chared.c_redo.buf == NULL) return -1; @@ -426,12 +422,10 @@ ch_init(EditLine *el) el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.pos = el->el_line.buffer; - el->el_chared.c_kill.buf = el_malloc(EL_BUFSIZ * + el->el_chared.c_kill.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_chared.c_kill.buf)); if (el->el_chared.c_kill.buf == NULL) return -1; - (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ * - sizeof(*el->el_chared.c_kill.buf)); el->el_chared.c_kill.mark = el->el_line.buffer; el->el_chared.c_kill.last = el->el_chared.c_kill.buf; el->el_chared.c_resizefun = NULL; Index: src/lib/libedit/chartype.c diff -u src/lib/libedit/chartype.c:1.34 src/lib/libedit/chartype.c:1.35 --- src/lib/libedit/chartype.c:1.34 Sun Nov 25 11:20:28 2018 +++ src/lib/libedit/chartype.c Tue Jul 23 06:18:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.c,v 1.34 2018/11/25 16:20:28 christos Exp $ */ +/* $NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: chartype.c,v 1.34 2018/11/25 16:20:28 christos Exp $"); +__RCSID("$NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -157,7 +157,7 @@ ct_decode_argv(int argc, const char *arg if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1) return NULL; - wargv = el_malloc((size_t)(argc + 1) * sizeof(*wargv)); + wargv = el_calloc((size_t)(argc + 1), sizeof(*wargv)); for (i = 0, p = conv->wbuff; i < argc; ++i) { if (!argv[i]) { /* don't pass null pointers to mbstowcs */ Index: src/lib/libedit/el.c diff -u src/lib/libedit/el.c:1.98 src/lib/libedit/el.c:1.99 ---