From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 8764544: Treat control characters in JSON strings as invalid Date: Fri, 29 Sep 2017 20:50:52 +0000 Message-ID: References: <20170818000543.9841.93700@vcs0.savannah.gnu.org> <20170818000544.84B5E2052C@vcs0.savannah.gnu.org> <20170818141330.GA848@holos.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a11408cbad9e64e055a5a2e05" X-Trace: blaine.gmane.org 1506718272 26877 195.159.176.226 (29 Sep 2017 20:51:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Sep 2017 20:51:12 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 29 22:51:09 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dy2FU-0006J2-4H for ged-emacs-devel@m.gmane.org; Fri, 29 Sep 2017 22:51:04 +0200 Original-Received: from localhost ([::1]:37063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dy2Fb-00083s-Cd for ged-emacs-devel@m.gmane.org; Fri, 29 Sep 2017 16:51:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dy2FV-00083n-0k for emacs-devel@gnu.org; Fri, 29 Sep 2017 16:51:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dy2FU-00066O-5C for emacs-devel@gnu.org; Fri, 29 Sep 2017 16:51:05 -0400 Original-Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:53882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dy2FT-00065b-Us for emacs-devel@gnu.org; Fri, 29 Sep 2017 16:51:04 -0400 Original-Received: by mail-oi0-x229.google.com with SMTP id j126so1305402oia.10 for ; Fri, 29 Sep 2017 13:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m4wqYH+LhajDgckkKWlehnMEBZ0GeIRGPDRzQhMbX1M=; b=HdhEBcU62Jwg3v3gjtzX3Y0laiDRcma24S2gp9+pECOi5GEsuSo6nMzMFHZIM1AXJB zyciY3ewXjX/FlrfatSyWir3flp1q1ufL0NCG80Tdtn20DVdRDCFR2pMTOrlEHIy5Sgb eAVkESWsfg9hoAV6ewQtKFVMbllFwgoEMbn1cnszCN6zPqorK0hwavG3NSuGnVcvalE2 9C+mT6rU7F88Zz6Z+8D5my/NzWZVbarK7tcDs/FhFiqs5IRlOsPOp6h1/aRVisj5jDRF +CTRp6vK7frjCAMo2cYV51VeykRL6aAx4X51ixVNlEi+qlpxugRBti6izgoMqukWAtSm ASjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m4wqYH+LhajDgckkKWlehnMEBZ0GeIRGPDRzQhMbX1M=; b=L6LaRzQsh43HgZqwN0r11YDCHCW2Qd8T584dLstFq95jA03cKnuTzHFmhQRoYJ5rgy 1w+PvaxbLkBmR49LCW0GkA37W2saxQSNzBuvcr21830x+0j+V7l+k/3/9miGJsvZbMMX +6yH57gjJHSqQxoJ81fd4tjHZuyB8EdxMN/apKIbRgev45qHHvK2tRHB4EzKFYPZIvLa U5XEadL5s7T+3HAAHJhexMDrvHIJz/8uvxBCTbVYh64gEM9Co8cFmU0JRvKb4ScDXT4h hL9JIPopP8rwRI2iEnsnGJp7mMMp0G3kwGnxy0tkzFe/cAQB/FSI6ktqd4oBr9jtANnc Khhw== X-Gm-Message-State: AHPjjUhq8R3Sj/hpRfVP/9gzWgB+HI8+Af8hEZna5K/O7qlKsh6L6O5C LKjw2b50hrKoMvoa65eUWaL8lYC6Fh62qhPFwPc= X-Google-Smtp-Source: AOwi7QB9FFBnZxOhKEuuYTLwXsWm5A6QCB8afSYXcf0k2DSE0vi+ptvv/Mhl0vzB7CVcSdWp8RdzhV2xpsjqbJWZ9QA= X-Received: by 10.202.229.210 with SMTP id c201mr3033941oih.134.1506718263139; Fri, 29 Sep 2017 13:51:03 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218950 Archived-At: --001a11408cbad9e64e055a5a2e05 Content-Type: text/plain; charset="UTF-8" Stefan Monnier schrieb am Do., 28. Sep. 2017 um 23:22 Uhr: > >> >>> - (or (char-after (point)) :json-eof)) > >> >> I wonder why it used :json-eof instead of using nil ? > >> >> Any idea? > >> > Not sure--it has been there since json.el was added to Emacs. > >> Then why use 0 now instead of nil? > > Because `following-char' returns 0 at EOB. "At the end of the buffer or > > accessible region, return 0." > > But it also returns 0 in other cases. E.g. if you had changed > > (or (char-after (point)) :json-eof) > to > (char-after) > > it would give you nil at EOB (instead of 0). > > Agreed. I'm wondering what the purpose of `following-char' is. Even in the rare cases where you want to treat EOB and a following null character identically it would be cleaner to write (or (char-after) 0). --001a11408cbad9e64e055a5a2e05 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Stefan= Monnier <monnier@iro.umontr= eal.ca> schrieb am Do., 28. Sep. 2017 um 23:22=C2=A0Uhr:
>> >>> -=C2=A0 (or (char-after = (point)) :json-eof))
>> >> I wonder why it used :json-eof instead of using nil ?
>> >> Any idea?
>> > Not sure--it has been there since json.el was added to Emacs.=
>> Then why use 0 now instead of nil?
> Because `following-char' returns 0 at EOB. "At the end of the= buffer or
> accessible region, return 0."

But it also returns 0 in other cases.=C2=A0 E.g. if you had changed

=C2=A0 =C2=A0 (or (char-after (point)) :json-eof)
to
=C2=A0 =C2=A0 (char-after)

it would give you nil at EOB (instead of 0).


Agreed.
I'm wondering wh= at the purpose of `following-char' is. Even in the rare cases where you= want to treat EOB and a following null character identically it would be c= leaner to write (or (char-after) 0).
--001a11408cbad9e64e055a5a2e05--