Sat Feb 19 17:45:02 2022 UTC ()
PR/56695: Walter Lozano: Correct declaration of hook functions.


(christos)
diff -r1.172 -r1.173 src/lib/libedit/readline.c
diff -r1.52 -r1.53 src/lib/libedit/readline/readline.h

cvs diff -r1.172 -r1.173 src/lib/libedit/readline.c (expand / switch to unified diff)

--- src/lib/libedit/readline.c 2022/02/08 15:05:10 1.172
+++ src/lib/libedit/readline.c 2022/02/19 17:45:02 1.173
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $ */ 1/* $NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "config.h" 32#include "config.h"
33#if !defined(lint) && !defined(SCCSID) 33#if !defined(lint) && !defined(SCCSID)
34__RCSID("$NetBSD: readline.c,v 1.172 2022/02/08 15:05:10 christos Exp $"); 34__RCSID("$NetBSD: readline.c,v 1.173 2022/02/19 17:45:02 christos Exp $");
35#endif /* not lint && not SCCSID */ 35#endif /* not lint && not SCCSID */
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/stat.h> 38#include <sys/stat.h>
39#include <ctype.h> 39#include <ctype.h>
40#include <dirent.h> 40#include <dirent.h>
41#include <errno.h> 41#include <errno.h>
42#include <fcntl.h> 42#include <fcntl.h>
43#include <limits.h> 43#include <limits.h>
44#include <pwd.h> 44#include <pwd.h>
45#include <setjmp.h> 45#include <setjmp.h>
46#include <stdarg.h> 46#include <stdarg.h>
47#include <stdint.h> 47#include <stdint.h>
@@ -103,37 +103,37 @@ char history_subst_char = '^'; @@ -103,37 +103,37 @@ char history_subst_char = '^';
103char *history_no_expand_chars = expand_chars; 103char *history_no_expand_chars = expand_chars;
104Function *history_inhibit_expansion_function = NULL; 104Function *history_inhibit_expansion_function = NULL;
105char *history_arg_extract(int start, int end, const char *str); 105char *history_arg_extract(int start, int end, const char *str);
106 106
107int rl_inhibit_completion = 0; 107int rl_inhibit_completion = 0;
108int rl_attempted_completion_over = 0; 108int rl_attempted_completion_over = 0;
109const char *rl_basic_word_break_characters = break_chars; 109const char *rl_basic_word_break_characters = break_chars;
110char *rl_completer_word_break_characters = NULL; 110char *rl_completer_word_break_characters = NULL;
111const char *rl_completer_quote_characters = NULL; 111const char *rl_completer_quote_characters = NULL;
112const char *rl_basic_quote_characters = "\"'"; 112const char *rl_basic_quote_characters = "\"'";
113rl_compentry_func_t *rl_completion_entry_function = NULL; 113rl_compentry_func_t *rl_completion_entry_function = NULL;
114char *(*rl_completion_word_break_hook)(void) = NULL; 114char *(*rl_completion_word_break_hook)(void) = NULL;
115rl_completion_func_t *rl_attempted_completion_function = NULL; 115rl_completion_func_t *rl_attempted_completion_function = NULL;
116Function *rl_pre_input_hook = NULL; 116rl_hook_func_t *rl_pre_input_hook = NULL;
117Function *rl_startup1_hook = NULL; 117rl_hook_func_t *rl_startup1_hook = NULL;
118int (*rl_getc_function)(FILE *) = NULL; 118int (*rl_getc_function)(FILE *) = NULL;
119char *rl_terminal_name = NULL; 119char *rl_terminal_name = NULL;
120int rl_already_prompted = 0; 120int rl_already_prompted = 0;
121int rl_filename_completion_desired = 0; 121int rl_filename_completion_desired = 0;
122int rl_ignore_completion_duplicates = 0; 122int rl_ignore_completion_duplicates = 0;
123int readline_echoing_p = 1; 123int readline_echoing_p = 1;
124int _rl_print_completions_horizontally = 0; 124int _rl_print_completions_horizontally = 0;
125VFunction *rl_redisplay_function = NULL; 125VFunction *rl_redisplay_function = NULL;
126Function *rl_startup_hook = NULL; 126rl_hook_func_t *rl_startup_hook = NULL;
127VFunction *rl_completion_display_matches_hook = NULL; 127VFunction *rl_completion_display_matches_hook = NULL;
128VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; 128VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
129VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; 129VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
130KEYMAP_ENTRY_ARRAY emacs_meta_keymap; 130KEYMAP_ENTRY_ARRAY emacs_meta_keymap;
131unsigned long rl_readline_state = RL_STATE_NONE; 131unsigned long rl_readline_state = RL_STATE_NONE;
132int _rl_complete_mark_directories; 132int _rl_complete_mark_directories;
133rl_icppfunc_t *rl_directory_completion_hook; 133rl_icppfunc_t *rl_directory_completion_hook;
134int rl_completion_suppress_append; 134int rl_completion_suppress_append;
135int rl_sort_completion_matches; 135int rl_sort_completion_matches;
136int _rl_completion_prefix_display_length; 136int _rl_completion_prefix_display_length;
137int _rl_echoing_p; 137int _rl_echoing_p;
138int history_max_entries; 138int history_max_entries;
139char *rl_display_prompt; 139char *rl_display_prompt;
@@ -435,42 +435,42 @@ rl_initialize(void) @@ -435,42 +435,42 @@ rl_initialize(void)
435char * 435char *
436readline(const char *p) 436readline(const char *p)
437{ 437{
438 HistEvent ev; 438 HistEvent ev;
439 const char * volatile prompt = p; 439 const char * volatile prompt = p;
440 int count; 440 int count;
441 const char *ret; 441 const char *ret;
442 char *buf; 442 char *buf;
443 static int used_event_hook; 443 static int used_event_hook;
444 444
445 if (e == NULL || h == NULL) 445 if (e == NULL || h == NULL)
446 rl_initialize(); 446 rl_initialize();
447 if (rl_startup_hook) { 447 if (rl_startup_hook) {
448 (*rl_startup_hook)(NULL, 0); 448 (*rl_startup_hook)();
449 } 449 }
450 tty_init(e); 450 tty_init(e);
451 451
452 452
453 rl_done = 0; 453 rl_done = 0;
454 454
455 (void)setjmp(topbuf); 455 (void)setjmp(topbuf);
456 buf = NULL; 456 buf = NULL;
457 457
458 /* update prompt accordingly to what has been passed */ 458 /* update prompt accordingly to what has been passed */
459 if (rl_set_prompt(prompt) == -1) 459 if (rl_set_prompt(prompt) == -1)
460 goto out; 460 goto out;
461 461
462 if (rl_pre_input_hook) 462 if (rl_pre_input_hook)
463 (*rl_pre_input_hook)(NULL, 0); 463 (*rl_pre_input_hook)();
464 464
465 if (rl_event_hook && !(e->el_flags & NO_TTY)) { 465 if (rl_event_hook && !(e->el_flags & NO_TTY)) {
466 el_set(e, EL_GETCFN, _rl_event_read_char); 466 el_set(e, EL_GETCFN, _rl_event_read_char);
467 used_event_hook = 1; 467 used_event_hook = 1;
468 } 468 }
469 469
470 if (!rl_event_hook && used_event_hook) { 470 if (!rl_event_hook && used_event_hook) {
471 el_set(e, EL_GETCFN, EL_BUILTIN_GETCFN); 471 el_set(e, EL_GETCFN, EL_BUILTIN_GETCFN);
472 used_event_hook = 0; 472 used_event_hook = 0;
473 } 473 }
474 474
475 rl_already_prompted = 0; 475 rl_already_prompted = 0;
476 476

cvs diff -r1.52 -r1.53 src/lib/libedit/readline/readline.h (expand / switch to unified diff)

--- src/lib/libedit/readline/readline.h 2022/02/08 15:05:10 1.52
+++ src/lib/libedit/readline/readline.h 2022/02/19 17:45:02 1.53
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: readline.h,v 1.52 2022/02/08 15:05:10 christos Exp $ */ 1/* $NetBSD: readline.h,v 1.53 2022/02/19 17:45:02 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -117,28 +117,28 @@ extern int max_input_history; @@ -117,28 +117,28 @@ extern int max_input_history;
117extern const char *rl_basic_quote_characters; 117extern const char *rl_basic_quote_characters;
118extern const char *rl_basic_word_break_characters; 118extern const char *rl_basic_word_break_characters;
119extern char *rl_completer_word_break_characters; 119extern char *rl_completer_word_break_characters;
120extern const char *rl_completer_quote_characters; 120extern const char *rl_completer_quote_characters;
121extern rl_compentry_func_t *rl_completion_entry_function; 121extern rl_compentry_func_t *rl_completion_entry_function;
122extern char *(*rl_completion_word_break_hook)(void); 122extern char *(*rl_completion_word_break_hook)(void);
123extern rl_completion_func_t *rl_attempted_completion_function; 123extern rl_completion_func_t *rl_attempted_completion_function;
124extern int rl_attempted_completion_over; 124extern int rl_attempted_completion_over;
125extern int rl_completion_type; 125extern int rl_completion_type;
126extern int rl_completion_query_items; 126extern int rl_completion_query_items;
127extern const char *rl_special_prefixes; 127extern const char *rl_special_prefixes;
128extern int rl_completion_append_character; 128extern int rl_completion_append_character;
129extern int rl_inhibit_completion; 129extern int rl_inhibit_completion;
130extern Function *rl_pre_input_hook; 130extern rl_hook_func_t *rl_pre_input_hook;
131extern Function *rl_startup_hook; 131extern rl_hook_func_t *rl_startup_hook;
132extern char *rl_terminal_name; 132extern char *rl_terminal_name;
133extern int rl_already_prompted; 133extern int rl_already_prompted;
134extern char *rl_prompt; 134extern char *rl_prompt;
135extern int rl_done; 135extern int rl_done;
136/* 136/*
137 * The following is not implemented 137 * The following is not implemented
138 */ 138 */
139extern unsigned long rl_readline_state; 139extern unsigned long rl_readline_state;
140extern int rl_catch_signals; 140extern int rl_catch_signals;
141extern int rl_catch_sigwinch; 141extern int rl_catch_sigwinch;
142extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, 142extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
143 emacs_meta_keymap, 143 emacs_meta_keymap,
144 emacs_ctlx_keymap; 144 emacs_ctlx_keymap;