From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#20481: 24.5; , Newlines in message-box output don't work on Windows Date: Mon, 19 Aug 2024 20:44:50 +0300 Message-ID: <86v7zwwgod.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25785"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 20481@debbugs.gnu.org To: Cecilio Pardo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 19 19:45:49 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sg6Rx-0006YD-9f for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Aug 2024 19:45:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sg6RZ-0007Ls-0U; Mon, 19 Aug 2024 13:45:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sg6RU-0007LX-86 for bug-gnu-emacs@gnu.org; Mon, 19 Aug 2024 13:45:20 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sg6RT-0003E9-Uk for bug-gnu-emacs@gnu.org; Mon, 19 Aug 2024 13:45:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=84B9nx5ZcESbu6/Q6J3l4Caqk/HiR5yCrDu7/wKoPsg=; b=Qmy5GLOdhW2sYPOaoHb/xLWDFCW7BcuK1y/wHtpHCSwfDgNzh7nECSykPtDplraNEi7dye9Lq9nad+622O0DdRyLAq60nM3Lrt9Dclr5uskaxVgERuTo2WVYp9ZeBbkrEglixcK2YApc+2j4v3Jy9YG3hi7+FUVOzkNiBkiKN+cu3LDdwiQpFj4/rPV3M8V0NTSOVZTgR7MfHny+724PAMpSYp/ULbB8n6x3ZJ1v9N3avfCLrvszDgchdUNKBQsP+4Z3Ii+YM617A1lwKUNDU/smjyYikobJ0Buc/J1lcHipZ3eezYQkv4qV4gsz3o01R1o0otLtIDHaj/3pMV5Dmg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sg6S9-0003SK-KC for bug-gnu-emacs@gnu.org; Mon, 19 Aug 2024 13:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Aug 2024 17:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20481 X-GNU-PR-Package: emacs Original-Received: via spool by 20481-submit@debbugs.gnu.org id=B20481.172408955313264 (code B ref 20481); Mon, 19 Aug 2024 17:46:01 +0000 Original-Received: (at 20481) by debbugs.gnu.org; 19 Aug 2024 17:45:53 +0000 Original-Received: from localhost ([127.0.0.1]:59147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sg6S1-0003Rs-2R for submit@debbugs.gnu.org; Mon, 19 Aug 2024 13:45:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sg6Rz-0003RY-28 for 20481@debbugs.gnu.org; Mon, 19 Aug 2024 13:45:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sg6RD-00037b-7S; Mon, 19 Aug 2024 13:45:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=84B9nx5ZcESbu6/Q6J3l4Caqk/HiR5yCrDu7/wKoPsg=; b=buQpI794YJpJ QyAQqfJVft0NJY+rlLEefQNe3v8uffcY0VslAjhyqZmaKf70VQuCEerzwL64Y252doHWd2slWKE70 Loutaahox3EXMWifXmxoDhfIexvE3N8TnD9+2vC8QSacK5lxPlCyx6Vv2+1sHmuX7puGLkr2G00tW JfDBuIYqnLd1lJb35lLKO8qavDSXr7Wv6IxNL8VuY4xJNjXDVbh8nCXbLr3b+9aYHTU3q14UugFn6 u0DP0QIvfz5Qedc2VF3jA8HR9y9Z4qzN96tILlhTSkyRT8IG6aPtJC7qltNlzESklKt9CcDTgfgkv kk9gefXLMpsV5etLzx3+Sw==; In-Reply-To: (message from Cecilio Pardo on Mon, 19 Aug 2024 18:13:31 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290410 Archived-At: > Date: Mon, 19 Aug 2024 18:13:31 +0200 > From: Cecilio Pardo > > This patch adds support on Windows Vista an later for dialog boxes using > TaskDialog. Thanks. First, to accept a contribution of this size we'll need a copyright-assignment paperwork from you. Should I send you the form to fill with instructions to go with it, so you could start the paperwork rolling? A few comments about the patch: > + void *task_dialog_indirect = > + get_proc_addr (GetModuleHandle ("comctl32.dll"), "TaskDialogIndirect"); > + > + if (task_dialog_indirect) A minor optimization is to call get_proc_addr only once and save the result in a static variable. We use this technique in many places in Emacs, and I see no reason not to do that here. > + /* Get the title as a UTF-16 string. */ > + CHECK_STRING (XCAR (contents)); > + char *title = SSDATA (XCAR (contents)); > + int wide_length = sizeof(WCHAR) * > + pMultiByteToWideChar (CP_UTF8, 0, title, -1, NULL, 0); > + WCHAR *title_text_wide = alloca (wide_length); > + pMultiByteToWideChar (CP_UTF8, 0, title, -1, > + title_text_wide, wide_length); The text of Lisp strings is stored by Emacs in a super-set of UTF-8, so it cannot be safely passed to MultiByteToWideChar. You need to encode it in UTF-8 first (use ENCODE_UTF_8). > + CHECK_STRING (item_name); > + > + int wide_length = sizeof(WCHAR) * > + pMultiByteToWideChar (CP_UTF8, 0, SSDATA (item_name), -1, > + NULL, 0); > + buttons[button_count].pszButtonText = alloca (wide_length); > + pMultiByteToWideChar (CP_UTF8, 0, SSDATA (item_name), -1, > + (LPWSTR) > + buttons[button_count].pszButtonText, > + wide_length); Same here. > + else if (NILP (item)) > + { > + /* A nil item means to put all following items on the > + right. We ignore this. */ ^^ ^^ Our convention is to leave two spaces between sentences in documentation, comments, and strings. We also leave two spaces at the end of C comments, before the closing "*/" (here and elsewhere in the patch). > + else if (STRINGP(item)) ^^ Another stylistic nit: please leave one space between the name of a function/macro and the opening parenthesis that follows it (here and elsewhere in the patch). > + /* A string item means an unselectable button. We add a > + button, an then need to disable it on the callback. > + We use ids based on 2000 to mark these buttons */ > + int wide_length = sizeof(WCHAR) * > + pMultiByteToWideChar (CP_UTF8, 0, SSDATA (item), -1, NULL, 0); > + buttons[button_count].pszButtonText = alloca (wide_length); > + pMultiByteToWideChar (CP_UTF8, 0, SSDATA (item), -1, > + (LPWSTR) > + buttons[button_count].pszButtonText, > + wide_length); UTF-8 encoding again.