From: Po Lu Date: Tue, 10 May 2022 02:38:08 +0000 (+0800) Subject: Simplify XDND code X-Git-Tag: emacs-29.0.90~1910^2~859 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=20b27d475f1c2de97c7cd94eece986ed16e83cc8;p=emacs.git Simplify XDND code * src/xfns.c (Fx_begin_drag): Use SAFE_ALLOCA_STRING and encode strings in the right coding system. --- diff --git a/src/xfns.c b/src/xfns.c index 7dbf1e16c3a..5522684170f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6822,14 +6822,12 @@ mouse buttons are released on top of FRAME. */) { struct frame *f = decode_window_system_frame (frame); int ntargets = 0, nnames = 0; - ptrdiff_t len; char *target_names[2048]; Atom *target_atoms; Lisp_Object lval, original, tem, t1, t2; Atom xaction; Atom action_list[2048]; char *name_list[2048]; - char *scratch; USE_SAFE_ALLOCA; @@ -6843,10 +6841,8 @@ mouse buttons are released on top of FRAME. */) if (ntargets < 2048) { - scratch = SSDATA (XCAR (targets)); - len = strlen (scratch); - target_names[ntargets] = SAFE_ALLOCA (len + 1); - strncpy (target_names[ntargets], scratch, len + 1); + SAFE_ALLOCA_STRING (target_names[ntargets], + XCAR (targets)); ntargets++; } else @@ -6896,10 +6892,8 @@ mouse buttons are released on top of FRAME. */) else signal_error ("Invalid drag-and-drop action", tem); - scratch = SSDATA (ENCODE_UTF_8 (t2)); - len = strlen (scratch); - name_list[nnames] = SAFE_ALLOCA (len + 1); - strncpy (name_list[nnames], scratch, len + 1); + SAFE_ALLOCA_STRING (name_list[nnames], + ENCODE_SYSTEM (t2)); nnames++; }