all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: 30005@debbugs.gnu.org
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	[thread overview]
Message-ID: <83shawzi0y.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkR4NiBPfwaAs2e=SL8Fmws3t=uFumhRssNDH2o=kDtLJg@mail.gmail.com> (message from Philipp Stephani on Mon, 22 Jan 2018 22:25:39 +0000)

> From: Philipp Stephani <p.stephani2@gmail.com>
> 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.





  reply	other threads:[~2018-01-23 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-06 11:39 bug#30005: 27.0.50; call-interactively doesn't work correctly if the interactive specification has an embedded null byte Philipp
2018-01-20 12:02 ` Eli Zaretskii
2018-01-22 22:25   ` Philipp Stephani
2018-01-23 15:55     ` Eli Zaretskii [this message]
2018-01-23 18:06       ` Richard Stallman
2018-02-03 21:48       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83shawzi0y.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=30005@debbugs.gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.