From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#30005: 27.0.50; call-interactively doesn't work correctly if the interactive specification has an embedded null byte Date: Tue, 23 Jan 2018 17:55:41 +0200 Message-ID: <83shawzi0y.fsf@gnu.org> References: <83y3ksspp9.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1516722882 21517 195.159.176.226 (23 Jan 2018 15:54:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 23 Jan 2018 15:54:42 +0000 (UTC) Cc: 30005@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 23 16:54:38 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee0u2-0004bI-PO for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 16:54:26 +0100 Original-Received: from localhost ([::1]:36920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee0w1-00021T-MP for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 10:56:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee0vc-0001rP-El for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 10:56:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee0vb-0001bz-IC for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 10:56:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60133) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ee0vb-0001bs-EV for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 10:56:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ee0vb-0000m4-5y for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 10:56:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Jan 2018 15:56:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30005 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30005-submit@debbugs.gnu.org id=B30005.15167229622969 (code B ref 30005); Tue, 23 Jan 2018 15:56:03 +0000 Original-Received: (at 30005) by debbugs.gnu.org; 23 Jan 2018 15:56:02 +0000 Original-Received: from localhost ([127.0.0.1]:39796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee0va-0000lm-0n for submit@debbugs.gnu.org; Tue, 23 Jan 2018 10:56:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee0vY-0000lT-RA for 30005@debbugs.gnu.org; Tue, 23 Jan 2018 10:56:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee0vQ-0001RU-HE for 30005@debbugs.gnu.org; Tue, 23 Jan 2018 10:55:55 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee0vQ-0001RD-EB; Tue, 23 Jan 2018 10:55:52 -0500 Original-Received: from [176.228.60.248] (port=4567 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ee0vP-0000N3-9c; Tue, 23 Jan 2018 10:55:51 -0500 In-reply-to: (message from Philipp Stephani on Mon, 22 Jan 2018 22:25:39 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142430 Archived-At: > From: Philipp Stephani > Date: Mon, 22 Jan 2018 22:25:39 +0000 > Cc: 30005@debbugs.gnu.org > > Does the patch below look right, and give good results? > > Yes, thanks. Just some minor nits inline to make the code shorter. Thanks for the review. I eventually pushed the changes as presented here, for the reasons I explain below. > Lisp_Object prefix_arg; > - char *string; > + char *string, *string_end; > + ptrdiff_t string_len; > > I think these days (where we require C99) we always declare variables when we first use them. That's not my understanding of the preferred style. My understanding, and what I do in practice, is that variables used only in a small portion of a function should be declared before the use, so that all the references to those variables are localized to the fragment where they are used. By contrast, in this case these variables are used all over the function, so it makes much less sense to delay their declaration. > - tem = strchr (tem, '\n'); > + tem = memchr (tem, '\n', string_len - (tem - string)); > > You can write the third argument as string_end - tem. Yes, but IMO the above is easier to convince the reader that the code is correct, and an optimizing compiler will produce the same code from both. > - visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); > + char *pnl = memchr (tem + 1, '\n', string_len - (tem + 1 - string)); > > Here you can write the third argument as string_end - (tem + 1). Same here: I find the code I used easier to understand and verify its correctness. > + ptrdiff_t sz = pnl ? pnl - (tem + 1) : string_end - (tem + 1); > > You can write the RHS as (pnl ? pnl : string_end) - (tem + 1). Same here. Thanks.