aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2025-04-16 20:16:43 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2025-04-16 20:18:02 +0000
commitb3884193b7bd3977acc44790b6278b60517ad097 (patch)
treed3a58576a5bbfb38982096462194e26a33aca620
parent5a36c82614102a8c3926bca0bdb9d44149691be8 (diff)
-rw-r--r--Makefile14
-rw-r--r--chared.c6
-rw-r--r--chartype.c12
-rw-r--r--common.c7
-rw-r--r--edit.expsym204
-rw-r--r--editline.34
-rw-r--r--editline.76
-rw-r--r--el.c5
-rw-r--r--el.h5
-rw-r--r--eln.c12
-rw-r--r--emacs.c10
-rw-r--r--filecomplete.c6
-rw-r--r--filecomplete.h5
-rw-r--r--history.c13
-rw-r--r--keymacro.c8
-rw-r--r--libedit.pc12
-rw-r--r--literal.c6
-rw-r--r--map.c5
-rw-r--r--read.c5
-rw-r--r--readline.c24
-rw-r--r--readline/readline.h38
-rw-r--r--refresh.c14
-rw-r--r--search.c7
-rw-r--r--sig.c6
-rw-r--r--sys.h4
-rw-r--r--tokenizer.c10
26 files changed, 350 insertions, 98 deletions
diff --git a/Makefile b/Makefile
index 105a6a92e0ee..f7cd3baf885f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.66 2019/10/13 07:28:10 mrg Exp $
+# $NetBSD: Makefile,v 1.70 2023/08/03 14:56:36 rin Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@@ -21,6 +21,12 @@ SRCS = chared.c chartype.c common.c el.c eln.c emacs.c filecomplete.c \
MAN= editline.3 editrc.5 editline.7
+FILES+= libedit.pc
+FILESOWN_libedit.pc= ${BINOWN}
+FILESGRP_libedit.pc= ${BINGRP}
+FILESMODE_libedit.pc= ${NONBINMODE}
+FILESDIR_libedit.pc= /usr/lib/pkgconfig
+
MLINKS= \
editline.3 el_deletestr.3 \
editline.3 el_end.3 \
@@ -138,6 +144,6 @@ COPTS.tokenizer.c+= -Wno-cast-qual
COPTS.tokenizern.c+= -Wno-cast-qual
.endif
-COPTS.history.c+= ${GCC_NO_STRINGOP_OVERFLOW}
-COPTS.historyn.c+= ${GCC_NO_STRINGOP_OVERFLOW}
-COPTS.readline.c+= ${GCC_NO_STRINGOP_TRUNCATION} ${GCC_NO_STRINGOP_OVERFLOW}
+COPTS.history.c+= ${CC_WNO_STRINGOP_OVERFLOW}
+COPTS.historyn.c+= ${CC_WNO_STRINGOP_OVERFLOW}
+COPTS.readline.c+= ${CC_WNO_STRINGOP_TRUNCATION} ${CC_WNO_STRINGOP_OVERFLOW}
diff --git a/chared.c b/chared.c
index 03d31ddeec85..72d84e46740f 100644
--- a/chared.c
+++ b/chared.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.63 2022/10/30 19:11:31 christos Exp $ */
+/* $NetBSD: chared.c,v 1.64 2024/06/29 14:13:14 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.63 2022/10/30 19:11:31 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.64 2024/06/29 14:13:14 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -319,6 +319,8 @@ cv_prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t))
test = (*wtest)(*p);
while ((p >= low) && (*wtest)(*p) == test)
p--;
+ if (p < low)
+ return low;
}
p++;
diff --git a/chartype.c b/chartype.c
index 9c74cfeb677a..b731d63bafb5 100644
--- a/chartype.c
+++ b/chartype.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.36 2022/10/30 19:11:31 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.37 2023/08/10 20:38:00 mrg 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.36 2022/10/30 19:11:31 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.37 2023/08/10 20:38:00 mrg Exp $");
#endif /* not lint && not SCCSID */
#include <ctype.h>
@@ -235,17 +235,17 @@ ct_visual_string(const wchar_t *s, ct_buffer_t *conv)
}
/* failed to encode, need more buffer space */
- used = dst - conv->wbuff;
+ uintptr_t sused = (uintptr_t)dst - (uintptr_t)conv->wbuff;
if (ct_conv_wbuff_resize(conv, conv->wsize + CT_BUFSIZ) == -1)
return NULL;
- dst = conv->wbuff + used;
+ dst = conv->wbuff + sused;
}
if (dst >= (conv->wbuff + conv->wsize)) { /* sigh */
- used = dst - conv->wbuff;
+ uintptr_t sused = (uintptr_t)dst - (uintptr_t)conv->wbuff;
if (ct_conv_wbuff_resize(conv, conv->wsize + CT_BUFSIZ) == -1)
return NULL;
- dst = conv->wbuff + used;
+ dst = conv->wbuff + sused;
}
*dst = L'\0';
diff --git a/common.c b/common.c
index f33c29650d79..e038956464c4 100644
--- a/common.c
+++ b/common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.49 2020/03/30 06:54:37 ryo Exp $ */
+/* $NetBSD: common.c,v 1.50 2024/06/30 16:29:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: common.c,v 1.49 2020/03/30 06:54:37 ryo Exp $");
+__RCSID("$NetBSD: common.c,v 1.50 2024/06/30 16:29:42 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -222,7 +222,8 @@ ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
return CC_REFRESH;
}
#ifdef VI_MOVE
- el->el_line.cursor--;
+ if (el->el_line.cursor > el->el_line.buffer)
+ el->el_line.cursor--;
#endif
}
return CC_CURSOR;
diff --git a/edit.expsym b/edit.expsym
new file mode 100644
index 000000000000..c5d021b31a65
--- /dev/null
+++ b/edit.expsym
@@ -0,0 +1,204 @@
+_el_fn_complete
+_el_fn_sh_complete
+_rl_abort_internal
+_rl_complete_mark_directories
+_rl_completion_prefix_display_length
+_rl_echoing_p
+_rl_erase_entire_line
+_rl_print_completions_horizontally
+_rl_qsort_string_compare
+add_history
+append_history
+clear_history
+completion_matches
+ct_decode_string
+ct_encode_string
+current_history
+el_beep
+el_cursor
+el_deletestr
+el_deletestr1
+el_end
+el_get
+el_getc
+el_gets
+el_init
+el_init_fd
+el_insertstr
+el_line
+el_parse
+el_push
+el_replacestr
+el_reset
+el_resize
+el_set
+el_source
+el_wget
+el_wgetc
+el_wgets
+el_winsertstr
+el_wline
+el_wparse
+el_wpush
+el_wreplacestr
+el_wset
+emacs_ctlx_keymap
+emacs_meta_keymap
+emacs_standard_keymap
+filename_completion_function
+fn_complete
+fn_complete2
+fn_display_match_list
+fn_filename_completion_function
+fn_tilde_expand
+free_history_entry
+get_history_event
+history
+history_arg_extract
+history_base
+history_end
+history_expand
+history_expansion_char
+history_get
+history_get_history_state
+history_inhibit_expansion_function
+history_init
+history_is_stifled
+history_length
+history_list
+history_max_entries
+history_no_expand_chars
+history_offset
+history_search
+history_search_pos
+history_search_prefix
+history_set_pos
+history_subst_char
+history_tokenize
+history_total_bytes
+history_truncate_file
+history_w
+history_wend
+history_winit
+max_input_history
+next_history
+previous_history
+read_history
+readline
+readline_echoing_p
+remove_history
+replace_history_entry
+rl_abort
+rl_add_defun
+rl_already_prompted
+rl_attempted_completion_function
+rl_attempted_completion_over
+rl_basic_quote_characters
+rl_basic_word_break_characters
+rl_bind_key
+rl_bind_key_in_map
+rl_callback_handler_install
+rl_callback_handler_remove
+rl_callback_read_char
+rl_catch_signals
+rl_catch_sigwinch
+rl_cleanup_after_signal
+rl_complete
+rl_completer_quote_characters
+rl_completer_word_break_characters
+rl_completion_append_character
+rl_completion_display_matches_hook
+rl_completion_entry_function
+rl_completion_matches
+rl_completion_query_items
+rl_completion_suppress_append
+rl_completion_type
+rl_completion_word_break_hook
+rl_copy_text
+rl_crlf
+rl_delete_text
+rl_deprep_term_function
+rl_deprep_terminal
+rl_ding
+rl_directory_completion_hook
+rl_display_match_list
+rl_display_prompt
+rl_done
+rl_echo_signal_char
+rl_end
+rl_erase_empty_line
+rl_event_hook
+rl_filename_completion_desired
+rl_filename_completion_function
+rl_forced_update_display
+rl_free_line_state
+rl_generic_bind
+rl_get_keymap
+rl_get_previous_history
+rl_get_screen_size
+rl_getc_function
+rl_ignore_completion_duplicates
+rl_inhibit_completion
+rl_initialize
+rl_insert
+rl_insert_text
+rl_instream
+rl_kill_text
+rl_library_version
+rl_line_buffer
+rl_linefunc
+rl_make_bare_keymap
+rl_message
+rl_newline
+rl_on_new_line
+rl_outstream
+rl_parse_and_bind
+rl_point
+rl_pre_input_hook
+rl_prep_term_function
+rl_prep_terminal
+rl_prompt
+rl_prompt_saved
+rl_read_init_file
+rl_read_key
+rl_readline_name
+rl_readline_state
+rl_readline_version
+rl_redisplay
+rl_redisplay_function
+rl_replace_line
+rl_reset_after_signal
+rl_reset_terminal
+rl_resize_terminal
+rl_restore_prompt
+rl_save_prompt
+rl_set_key
+rl_set_keyboard_input_timeout
+rl_set_keymap
+rl_set_keymap_name
+rl_set_prompt
+rl_set_screen_size
+rl_sort_completion_matches
+rl_special_prefixes
+rl_startup1_hook
+rl_startup_hook
+rl_stuff_char
+rl_terminal_name
+rl_variable_bind
+stifle_history
+tilde_expand
+tok_end
+tok_init
+tok_line
+tok_reset
+tok_str
+tok_wend
+tok_winit
+tok_wline
+tok_wreset
+tok_wstr
+unstifle_history
+username_completion_function
+using_history
+where_history
+write_history
diff --git a/editline.3 b/editline.3
index f104dcc07c7a..465af0e655df 100644
--- a/editline.3
+++ b/editline.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.101 2021/08/15 10:12:54 wiz Exp $
+.\" $NetBSD: editline.3,v 1.102 2024/02/04 18:47:27 andvar Exp $
.\"
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -512,7 +512,7 @@ If the
.Fa flag
argument is non-zero, then
.Nm editline
-attempts to recover from read errors, ignoring the first interrrupted
+attempts to recover from read errors, ignoring the first interrupted
error, and trying to reset the input file descriptor to reset non-blocking I/O.
This is disabled by default, and desirable only when
.Nm editline
diff --git a/editline.7 b/editline.7
index 863bab96d519..9a96fca47fa5 100644
--- a/editline.7
+++ b/editline.7
@@ -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 <schwarze@openbsd.org>
@@ -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 at the end of the edit
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.
diff --git a/el.c b/el.c
index 2c06e32de9ff..577fda821870 100644
--- a/el.c
+++ b/el.c
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.101 2022/10/30 19:11:31 christos Exp $ */
+/* $NetBSD: el.c,v 1.102 2025/01/03 00:40:08 rillig 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.101 2022/10/30 19:11:31 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.102 2025/01/03 00:40:08 rillig Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -274,7 +274,6 @@ el_wset(EditLine *el, int op, ...)
default:
rv = -1;
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
- break;
}
break;
}
diff --git a/el.h b/el.h
index 757137839eb8..a1e9cea11747 100644
--- a/el.h
+++ b/el.h
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.46 2021/08/15 10:08:41 christos Exp $ */
+/* $NetBSD: el.h,v 1.48 2025/01/03 00:40:08 rillig 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 */
@@ -152,7 +153,7 @@ libedit_private EditLine *el_init_internal(const char *, FILE *, FILE *,
__FILE__, __LINE__); \
fprintf a; \
abort(); \
- } while( /*CONSTCOND*/0);
+ } while (0)
#else
#define EL_ABORT(a) abort()
#endif
diff --git a/eln.c b/eln.c
index 563ec2a672a9..660e1988cc26 100644
--- a/eln.c
+++ b/eln.c
@@ -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 <errno.h>
@@ -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->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;
}
diff --git a/emacs.c b/emacs.c
index 0636c28b26fc..19a9cf191168 100644
--- a/emacs.c
+++ b/emacs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emacs.c,v 1.36 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: emacs.c,v 1.38 2024/06/29 17:28:07 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: emacs.c,v 1.36 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: emacs.c,v 1.38 2024/06/29 17:28:07 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -134,11 +134,11 @@ em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
return CC_ERROR;
el->el_chared.c_kill.mark = el->el_line.cursor;
- cp = el->el_line.cursor;
/* open the space, */
c_insert(el,
(int)(el->el_chared.c_kill.last - el->el_chared.c_kill.buf));
+ cp = el->el_line.cursor;
/* copy the chars */
for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
*cp++ = *kp;
@@ -448,12 +448,12 @@ em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.buffer)
return CC_ERROR;
- oldc = el->el_line.cursor;
/* does a bounds check */
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
el->el_state.argument, ce__isword);
- c_insert(el, (int)(oldc - cp));
+ c_insert(el, (int)(el->el_line.cursor - cp));
+ oldc = el->el_line.cursor;
for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
*dp++ = *cp;
diff --git a/filecomplete.c b/filecomplete.c
index ee017fb406d5..a2001a4be955 100644
--- a/filecomplete.c
+++ b/filecomplete.c
@@ -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 <sys/types.h>
@@ -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))
{
diff --git a/filecomplete.h b/filecomplete.h
index 796ae7ab3276..884586c438f7 100644
--- a/filecomplete.h
+++ b/filecomplete.h
@@ -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 *, char **, size_t, size_t,
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
diff --git a/history.c b/history.c
index 73cfa6b8ead9..8395b329784d 100644
--- a/history.c
+++ b/history.c
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.63 2019/10/08 19:17:57 christos Exp $ */
+/* $NetBSD: history.c,v 1.64 2024/07/11 05:41:24 kre 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.63 2019/10/08 19:17:57 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.64 2024/07/11 05:41:24 kre Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -45,6 +45,7 @@ __RCSID("$NetBSD: history.c,v 1.63 2019/10/08 19:17:57 christos Exp $");
* hist.c: TYPE(History) access functions
*/
#include <sys/stat.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -842,8 +843,6 @@ history_save_fp(TYPE(History) *h, size_t nelem, FILE *fp)
static ct_buffer_t conv;
#endif
- if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
- goto done;
if (ftell(fp) == 0 && fputs(hist_cookie, fp) == EOF)
goto done;
ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
@@ -891,7 +890,11 @@ history_save(TYPE(History) *h, const char *fname)
FILE *fp;
int i;
- if ((fp = fopen(fname, "w")) == NULL)
+ if ((i = open(fname, O_WRONLY|O_CREAT|O_TRUNC,
+ S_IRUSR|S_IWUSR)) == -1)
+ return -1;
+
+ if ((fp = fdopen(i, "w")) == NULL)
return -1;
i = history_save_fp(h, (size_t)-1, fp);
diff --git a/keymacro.c b/keymacro.c
index cef24a1752e6..38ae9be58df9 100644
--- a/keymacro.c
+++ b/keymacro.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keymacro.c,v 1.24 2019/07/23 10:18:52 christos Exp $ */
+/* $NetBSD: keymacro.c,v 1.25 2025/01/03 00:40:08 rillig Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: keymacro.c,v 1.24 2019/07/23 10:18:52 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.25 2025/01/03 00:40:08 rillig Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -346,7 +346,6 @@ node__try(EditLine *el, keymacro_node_t *ptr, const wchar_t *str,
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n",
ptr->type));
- break;
}
switch (ptr->type = ntype) {
@@ -359,7 +358,6 @@ node__try(EditLine *el, keymacro_node_t *ptr, const wchar_t *str,
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
- break;
}
} else {
/* still more chars to go */
@@ -444,7 +442,6 @@ node__put(EditLine *el, keymacro_node_t *ptr)
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ptr->type));
- break;
}
el_free(ptr);
}
@@ -614,7 +611,6 @@ keymacro_kprint(EditLine *el, const wchar_t *key, keymacro_value_t *val,
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
- break;
}
else
(void) fprintf(el->el_outfile, fmt, ct_encode_string(key,
diff --git a/libedit.pc b/libedit.pc
new file mode 100644
index 000000000000..c08a8ba70b12
--- /dev/null
+++ b/libedit.pc
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libedit
+Description: command line editor library providing generic line editing, history, and tokenization functions.
+Version: 3.1
+Requires:
+Libs: -Wl,-R${libdir} -L${libdir} -ledit
+Libs.private: -ltermcap
+Cflags: -I${includedir} -I${includedir}/readline
diff --git a/literal.c b/literal.c
index f6eac26937e8..f6f63cb3fb06 100644
--- a/literal.c
+++ b/literal.c
@@ -1,4 +1,4 @@
-/* $NetBSD: literal.c,v 1.5 2019/07/23 13:10:11 christos Exp $ */
+/* $NetBSD: literal.c,v 1.6 2024/12/05 22:21:53 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.5 2019/07/23 13:10:11 christos Exp $");
+__RCSID("$NetBSD: literal.c,v 1.6 2024/12/05 22:21:53 christos Exp $");
#endif /* not lint && not SCCSID */
/*
@@ -85,7 +85,7 @@ literal_add(EditLine *el, const wchar_t *buf, const wchar_t *end, int *wp)
w = wcwidth(end[1]); /* column width of the visible char */
*wp = (int)w;
- if (w <= 0) /* we require something to be printed */
+ if (w < 0) /* non-printable characters are negative */
return 0;
len = (size_t)(end - buf);
diff --git a/map.c b/map.c
index 57d3038ab2e9..2ac661993baf 100644
--- a/map.c
+++ b/map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.55 2022/10/30 19:11:31 christos Exp $ */
+/* $NetBSD: map.c,v 1.56 2025/01/03 00:40:08 rillig 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.55 2022/10/30 19:11:31 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.56 2025/01/03 00:40:08 rillig Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1390,7 +1390,6 @@ map_bind(EditLine *el, int argc, const wchar_t **argv)
/* coverity[dead_error_begin] */
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
- break;
}
return 0;
}
diff --git a/read.c b/read.c
index 8026ca4a209b..4d068e9f4097 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.108 2022/10/30 19:11:31 christos Exp $ */
+/* $NetBSD: read.c,v 1.109 2025/01/03 00:40:08 rillig Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.108 2022/10/30 19:11:31 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.109 2025/01/03 00:40:08 rillig Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -265,7 +265,6 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, wchar_t *ch)
return -1;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type \n"));
- break;
}
}
} while (cmd == ED_SEQUENCE_LEAD_IN);
diff --git a/readline.c b/readline.c
index ef3abd4b6daa..3b9b6ac6afcb 100644
--- a/readline.c
+++ b/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 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.178 2022/12/02 19:23:15 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.182 2024/03/26 18:02:04 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -51,7 +51,9 @@ __RCSID("$NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $");
#include <unistd.h>
#include <vis.h>
+#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;
@@ -122,11 +124,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;
@@ -400,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.
@@ -1978,7 +1980,7 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
_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, &wbreak_conv),
@@ -1986,7 +1988,7 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
_rl_completion_append_character_function,
(size_t)rl_completion_query_items,
&rl_completion_type, &rl_attempted_completion_over,
- &rl_point, &rl_end);
+ &rl_point, &rl_end, 0);
}
@@ -2573,7 +2575,7 @@ void
rl_reset_after_signal(void)
{
if (rl_prep_term_function)
- (*rl_prep_term_function)();
+ (*rl_prep_term_function)(1);
}
void
diff --git a/readline/readline.h b/readline/readline.h
index 2bd0b7e80ab6..03e2d2eb8e1e 100644
--- a/readline/readline.h
+++ b/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.53 2022/02/19 17:45:02 christos Exp $ */
+/* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -37,12 +37,13 @@
/* list of readline stuff supported by editline library's readline wrapper */
/* typedefs */
-typedef int Function(const char *, int);
-typedef char *CPFunction(const char *, int);
-typedef void VFunction(void);
+typedef int rl_linebuf_func_t(const char *, int);
+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 **);
@@ -64,7 +65,7 @@ typedef struct _keymap_entry {
#define ISFUNC 0
#define ISKMAP 1
#define ISMACR 2
- Function *function;
+ rl_linebuf_func_t *function;
} KEYMAP_ENTRY;
#define KEYMAP_SIZE 256
@@ -111,9 +112,7 @@ extern const char *rl_readline_name;
extern FILE *rl_instream;
extern FILE *rl_outstream;
extern char *rl_line_buffer;
-extern int rl_point, rl_end;
-extern int history_base, history_length;
-extern int max_input_history;
+extern int rl_point, rl_end;
extern const char *rl_basic_quote_characters;
extern const char *rl_basic_word_break_characters;
extern char *rl_completer_word_break_characters;
@@ -127,12 +126,23 @@ extern int rl_completion_query_items;
extern const char *rl_special_prefixes;
extern int rl_completion_append_character;
extern int rl_inhibit_completion;
-extern rl_hook_func_t *rl_pre_input_hook;
-extern rl_hook_func_t *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;
extern int rl_done;
+extern rl_vcpfunc_t *rl_linefunc;
+extern rl_hook_func_t *rl_startup1_hook;
+extern char *rl_prompt_saved;
+extern int history_base, history_length;
+extern int history_offset;
+extern char history_expansion_char;
+extern char history_subst_char;
+extern char *history_no_expand_chars;
+extern rl_linebuf_func_t *history_inhibit_expansion_function;
+extern int max_input_history;
+
/*
* The following is not implemented
*/
@@ -145,10 +155,10 @@ extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
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;
diff --git a/refresh.c b/refresh.c
index 26a49fe751c6..ae62f88f0bea 100644
--- a/refresh.c
+++ b/refresh.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.58 2021/09/09 20:24:07 christos Exp $ */
+/* $NetBSD: refresh.c,v 1.60 2024/12/05 22:21:53 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.58 2021/09/09 20:24:07 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.60 2024/12/05 22:21:53 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -168,7 +168,7 @@ re_putliteral(EditLine *el, const wchar_t *begin, const wchar_t *end)
int i, w;
c = literal_add(el, begin, end, &w);
- if (c == 0 || w <= 0)
+ if (c == 0 || w < 0)
return;
el->el_vdisplay[cur->v][cur->h] = c;
@@ -178,7 +178,7 @@ re_putliteral(EditLine *el, const wchar_t *begin, const wchar_t *end)
while (--i > 0)
el->el_vdisplay[cur->v][cur->h + i] = MB_FILL_CHAR;
- cur->h += w;
+ cur->h += w ? w : 1;
if (cur->h >= sizeh) {
/* assure end of line */
el->el_vdisplay[cur->v][sizeh] = '\0';
@@ -212,7 +212,7 @@ re_putc(EditLine *el, wint_t c, int shift)
if (!shift)
return;
- cur->h += w; /* advance to next place */
+ cur->h += w ? w : 1; /* advance to next place */
if (cur->h >= sizeh) {
/* assure end of line */
el->el_vdisplay[cur->v][sizeh] = '\0';
@@ -1155,6 +1155,10 @@ re_fastaddc(EditLine *el)
wchar_t c;
int rhdiff;
+ if (el->el_line.cursor == el->el_line.buffer) {
+ re_refresh(el);
+ return;
+ }
c = el->el_line.cursor[-1];
if (c == '\t' || el->el_line.cursor != el->el_line.lastchar) {
diff --git a/search.c b/search.c
index e909d1475725..585a73876841 100644
--- a/search.c
+++ b/search.c
@@ -1,4 +1,4 @@
-/* $NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $ */
+/* $NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $");
+__RCSID("$NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -295,6 +295,9 @@ ce_inc_search(EditLine *el, int dir)
for (cp = &el->el_search.patbuf[LEN];; cp++)
if (cp >= &el->el_search.patbuf[
el->el_search.patlen]) {
+ if (el->el_line.cursor ==
+ el->el_line.buffer)
+ break;
el->el_line.cursor +=
el->el_search.patlen - LEN - 1;
cp = c__next_word(el->el_line.cursor,
diff --git a/sig.c b/sig.c
index 7e7486980253..d2b77e77af1a 100644
--- a/sig.c
+++ b/sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.c,v 1.27 2023/02/03 19:47:38 christos Exp $ */
+/* $NetBSD: sig.c,v 1.28 2024/12/18 15:38:52 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.27 2023/02/03 19:47:38 christos Exp $");
+__RCSID("$NetBSD: sig.c,v 1.28 2024/12/18 15:38:52 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -167,7 +167,7 @@ sig_set(EditLine *el)
struct sigaction osa, nsa;
nsa.sa_handler = sig_handler;
- nsa.sa_flags = 0;
+ nsa.sa_flags = SA_ONSTACK;
sigemptyset(&nsa.sa_mask);
sel = el;
diff --git a/sys.h b/sys.h
index 5395531a298f..67bfcb535939 100644
--- a/sys.h
+++ b/sys.h
@@ -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 <sys/cdefs.h>
#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
diff --git a/tokenizer.c b/tokenizer.c
index 18532240dbb9..fe98fab6b68a 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -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, const TYPE(LineInfo) *line,
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, const TYPE(LineInfo) *line,
if (cursoro != NULL)
*cursoro = co;
FUN(tok,finish)(tok);
- *argv = (const Char **)tok->argv;
+ *argv = tok->argv;
*argc = (int)tok->argc;
return 0;
}