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 <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;
}