NetBSD Problem Report #56693
From www@netbsd.org Sat Feb 5 23:54:14 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 9D31C1A9239
for <gnats-bugs@gnats.NetBSD.org>; Sat, 5 Feb 2022 23:54:14 +0000 (UTC)
Message-Id: <20220205235412.EFEB21A923B@mollari.NetBSD.org>
Date: Sat, 5 Feb 2022 23:54:12 +0000 (UTC)
From: walter.lozano@collabora.com
Reply-To: walter.lozano@collabora.com
To: gnats-bugs@NetBSD.org
Subject: Add support for rl_delete_text and rl_set_key
X-Send-Pr-Version: www-1.0
>Number: 56693
>Category: lib
>Synopsis: Add support for rl_delete_text and rl_set_key
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Feb 05 23:55:00 +0000 2022
>Closed-Date: Sun May 15 08:34:03 +0000 2022
>Last-Modified: Sun May 15 08:34:03 +0000 2022
>Originator: Walter Lozano
>Release:
>Organization:
Collabora
>Environment:
>Description:
The current implementation of libedit does not support rl_delete_text and rl_set_key.
>How-To-Repeat:
>Fix:
Here is a proposed implementation for rl_delete_text and rl_set_key.
cvs diff: Diffing .
Index: chared.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/chared.c,v
retrieving revision 1.60
diff -u -r1.60 chared.c
--- chared.c 11 Jan 2022 18:30:15 -0000 1.60
+++ chared.c 5 Feb 2022 23:50:49 -0000
@@ -624,6 +624,40 @@
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: histedit.h
===================================================================
RCS file: /cvsroot/src/lib/libedit/histedit.h,v
retrieving revision 1.59
diff -u -r1.59 histedit.h
--- histedit.h 11 Jan 2022 18:30:15 -0000 1.59
+++ histedit.h 5 Feb 2022 23:50:49 -0000
@@ -180,7 +180,7 @@
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: readline.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/readline.c,v
retrieving revision 1.171
diff -u -r1.171 readline.c
--- readline.c 31 Jan 2022 14:44:49 -0000 1.171
+++ readline.c 5 Feb 2022 23:50:50 -0000
@@ -2339,6 +2339,16 @@
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 @@
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)
cvs diff: Diffing TEST
cvs diff: Diffing readline
Index: readline/readline.h
===================================================================
RCS file: /cvsroot/src/lib/libedit/readline/readline.h,v
retrieving revision 1.51
diff -u -r1.51 readline.h
--- readline/readline.h 31 Jan 2022 14:44:49 -0000 1.51
+++ readline/readline.h 5 Feb 2022 23:50:50 -0000
@@ -236,6 +236,7 @@
int rl_ding(void);
char *rl_copy_text(int, int);
void rl_replace_line(const char *, int);
+int rl_delete_text(int, int);
void rl_message(const char *format, ...)
__attribute__((__format__(__printf__, 1, 2)));
void rl_save_prompt(void);
@@ -250,6 +251,7 @@
Keymap rl_make_bare_keymap(void);
int rl_generic_bind(int, const char *, const char *, Keymap);
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
+int rl_set_key(const char *, rl_command_func_t *, Keymap);
void rl_cleanup_after_signal(void);
void rl_free_line_state(void);
int rl_set_keyboard_input_timeout(int);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56693 CVS commit: src/lib/libedit
Date: Tue, 8 Feb 2022 10:05:10 -0500
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.
From: "Roland Illig" <rillig@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56693 CVS commit: src/lib/libedit
Date: Tue, 8 Feb 2022 21:13:22 +0000
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.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 15 May 2022 08:34:03 +0000
State-Changed-Why:
Christos committed it
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.