From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jakub Wojciech" Newsgroups: gmane.lisp.guile.bugs Subject: bug#45339: Readline filename completion Date: Sun, 20 Dec 2020 11:37:56 +0100 Message-ID: <87mty87okl.fsf@riseup.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31954"; mail-complaints-to="usenet@ciao.gmane.io" To: 45339@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sun Dec 20 15:55:09 2020 Return-path: Envelope-to: guile-bugs@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 1kr072-0008D4-RU for guile-bugs@m.gmane-mx.org; Sun, 20 Dec 2020 15:55:09 +0100 Original-Received: from localhost ([::1]:42670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kr071-0003Wa-T7 for guile-bugs@m.gmane-mx.org; Sun, 20 Dec 2020 09:55:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kr06w-0003UY-S2 for bug-guile@gnu.org; Sun, 20 Dec 2020 09:55:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kr06w-00068F-KD for bug-guile@gnu.org; Sun, 20 Dec 2020 09:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kr06w-0006CN-IV for bug-guile@gnu.org; Sun, 20 Dec 2020 09:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Jakub Wojciech" Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 20 Dec 2020 14:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45339 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160847605823705 (code B ref -1); Sun, 20 Dec 2020 14:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Dec 2020 14:54:18 +0000 Original-Received: from localhost ([127.0.0.1]:44002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kr06E-0006AB-2w for submit@debbugs.gnu.org; Sun, 20 Dec 2020 09:54:18 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:52442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kqw7w-0006Ct-BL for submit@debbugs.gnu.org; Sun, 20 Dec 2020 05:39:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqw7w-0006Gp-47 for bug-guile@gnu.org; Sun, 20 Dec 2020 05:39:48 -0500 Original-Received: from mx1.riseup.net ([198.252.153.129]:34758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqw7t-0007Ih-Tc for bug-guile@gnu.org; Sun, 20 Dec 2020 05:39:47 -0500 Original-Received: from bell.riseup.net (bell-pn.riseup.net [10.0.1.178]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4CzJxy0C2pzFcvZ for ; Sun, 20 Dec 2020 02:39:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1608460774; bh=Gn9sxlAuXqCLfR4rLR+1+6cyM0f+2VjaC1lZsfhybOg=; h=From:To:Subject:Date:From; b=J2rVs4PX/sGH84PRIfzclsOP8ap/GjP1pFa2Kcc3SGYIQ7BYjAPHIJI7pfybbY8v2 OtOLqYQtK0CbJ88v5nbVD1q2lPeyHDEU/Pm0QRhOFb1IbWpSFvrO5s9Sw+2aX5JKJm B5ElVYtHvzdUOOnAjc2yYRpF9UKwFL0gwU3UWpqE= X-Riseup-User-ID: 5840FB214276934E05141F57DC92843292448C1F6A8C6A878753E2EA54C606DC Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by bell.riseup.net (Postfix) with ESMTPSA id 4CzJxx1M2RzJnKW for ; Sun, 20 Dec 2020 02:39:32 -0800 (PST) Received-SPF: pass client-ip=198.252.153.129; envelope-from=jakub-w@riseup.net; helo=mx1.riseup.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 20 Dec 2020 09:54:16 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9938 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hi. Filename completion just doesn't work at all. Using filename-completion-function as a completer for readline always throws an error. Minimal example: (use-modules (ice-9 readline)) (with-readline-completion-function filename-completion-function readline) Hitting TAB when prompted results in: File: Backtrace: In ice-9/boot-9.scm: 1736:10 8 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _) In unknown file: 7 (apply-smob/0 #) In ice-9/boot-9.scm: 718:2 6 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 5 (_ #(#(#))) In ice-9/boot-9.scm: 2806:4 4 (save-module-excursion _) 4351:12 3 (_) In ice-9/readline.scm: 213:4 2 (with-readline-completion-function _ #) In unknown file: 1 (%readline "File: " # # #) 0 (filename-completion-function "" #t) ERROR: In procedure filename-completion-function: In procedure scm_from_stringn: NULL string pointer My version of Guile is 3.0.4 but I expect it to fail on every version. It results in an error because the scm_filename_completion_function() calls readline's rl_filename_completion_function() and doesn't check if it returned NULL instead of a string. Readline's info manual states: "The generator function returns '(char *)NULL' to inform 'rl_completion_matches()' that there are no more possibilities left." So it's impossible for the current implementation to work, since scm_filename_completion_function() throws an error every time NULL is returned. I'm attaching a patch. Jakub --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fixed-filename-completion-function-for-readline-comp.patch Content-Transfer-Encoding: quoted-printable From=201f8fce206dc657a04694f8b546df5d1fe1ca1856 Mon Sep 17 00:00:00 2001 From: Jakub Wojciech Date: Sun, 20 Dec 2020 10:56:51 +0100 Subject: [PATCH] Fixed filename-completion-function for readline completion * guile-readline/readline.c (scm_filename_completion_function): A completion function should return #f when there's no more candidates. Since the result of readline's rl_filename_completion_function was never checked it was impossible for it to work as intended and instead of #f it threw an error from trying to convert NULL to an scm string. =2D-- guile-readline/readline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guile-readline/readline.c b/guile-readline/readline.c index 5c4a32689..7bb2394ba 100644 =2D-- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -386,8 +386,11 @@ SCM_DEFINE (scm_filename_completion_function, "filenam= e-completion-function", 2, #else s =3D filename_completion_function (c_text, scm_is_true (continuep)); #endif =2D ans =3D scm_take_locale_string (s); free (c_text); + if (!s) { + return SCM_BOOL_F; + } + ans =3D scm_take_locale_string (s); return ans; } #undef FUNC_NAME =2D- 2.29.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFHBAEBCAAxFiEEjyJ5FFWW4Y1mdT0FcTDfCUiwZWUFAl/fKcITHGpha3ViLXdA cmlzZXVwLm5ldAAKCRBxMN8JSLBlZYdgB/9I60dpM0gdiyWuAkfSHvnWqHKWY1DS zYHtFYYRGMriL5UTu6vWWWj8QS9fjy5u66AbHIgIypnQkB1avFIe4kaaU8RJl/j0 pHsvExrSmE3Wa17Sd7U4VOqrB0/KgTXjm07pxlA75z3wFw9x5wdRfLZlnkwwVXuy xnY3jjkWCa+3TEczSNa834rtXADzlMW5ucQODQrBlzZKtBDQ/Yxc7Gl4EAwkGVn2 dByTBKSS8XDq7tHYYCvaZglyzaCSZJSYIu/xlA9khpLjmil+seNWI0BlyqC4fznI b+EkItYjyfWK1cPgE1nGj63kK+PGpADESjIhlyzjjf9+YTVTbTxl7uQt =/HFP -----END PGP SIGNATURE----- --==-=-=--