aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-21 02:18:19 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-21 02:30:37 +0200
commit7e37a9711aa163fb6683c4724abe0e2be2bc8a01 (patch)
tree0e75aa24449a3fe1437c6b712e5cc2505c43b495
parentabfbeb17e56bd9abc275de0f7ace6c197e00e3bf (diff)
downloadsciteco-7e37a9711aa163fb6683c4724abe0e2be2bc8a01.tar.gz
GTK/Win32: fixed clipboard retrieval (trailing nulls)
* Contrary to the Gtk documentation, the gtk_selection_data_get_length() already includes a trailing null, so we always inserted a bogus null char when using G~ or ^EQ~.
-rw-r--r--src/interface-gtk/interface.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 843ad15..8cf0aab 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -717,6 +717,11 @@ teco_interface_get_clipboard(const gchar *name, gchar **str, gsize *len, GError
}
*len = gtk_selection_data_get_length(contents);
+#ifdef G_OS_WIN32
+ /* the length always contains a trailing null byte on Windows */
+ if (*len > 0)
+ (*len)--;
+#endif
if (str) {
/* gtk_selection_data_get_text() does not work with embedded nulls */
*str = memcpy(g_malloc(*len+1), gtk_selection_data_get_data(contents), *len);