From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Shmakov Newsgroups: gmane.emacs.bugs Subject: bug#18370: insert-file-contents: forbids also beg, end for non-regular (special) files Date: Sun, 31 Aug 2014 19:50:09 +0000 Message-ID: <87y4u4tp5a.fsf@violet.siamics.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409514700 899 80.91.229.3 (31 Aug 2014 19:51:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Aug 2014 19:51:40 +0000 (UTC) To: 18370@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 31 21:51:34 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XOB9v-00079s-Ey for geb-bug-gnu-emacs@m.gmane.org; Sun, 31 Aug 2014 21:51:31 +0200 Original-Received: from localhost ([::1]:50877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOB9u-0006Aa-VC for geb-bug-gnu-emacs@m.gmane.org; Sun, 31 Aug 2014 15:51:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOB9j-000695-3n for bug-gnu-emacs@gnu.org; Sun, 31 Aug 2014 15:51:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOB9S-0001Vb-Pe for bug-gnu-emacs@gnu.org; Sun, 31 Aug 2014 15:51:19 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOB9S-0001VW-H1 for bug-gnu-emacs@gnu.org; Sun, 31 Aug 2014 15:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XOB9S-0006HQ-1h for bug-gnu-emacs@gnu.org; Sun, 31 Aug 2014 15:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Shmakov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Aug 2014 19:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18370 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: submit@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.140951462324088 (code B ref -1); Sun, 31 Aug 2014 19:51:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Aug 2014 19:50:23 +0000 Original-Received: from localhost ([127.0.0.1]:55139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XOB8o-0006GS-Pj for submit@debbugs.gnu.org; Sun, 31 Aug 2014 15:50:23 -0400 Original-Received: from fely.am-1.org ([78.47.74.50]:52783) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XOB8l-0006GG-Ll for submit@debbugs.gnu.org; Sun, 31 Aug 2014 15:50:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net; s=a2013295; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Sender:Subject:To:From; bh=A8TI6hGnaamNfbsOOl4KSGZF3IG+BN/jxJ531Fy8rmo=; b=mOmBOELefW/XfLqkfgRAOMj1rG30/LCLFm/rmJJWLlvdnoFQCjtqZMK3AMJ/slj7ZgNt6gqjmSwsLREb8zevqIIY8CR/rdaBmnKeDSBzKv8bUZyhKBikl9Hqd/C9nyMEbJtuTAba7xdx/ehjfzBomMrtvERxTrZiMZOyospVPJM=; Original-Received: from [2a02:2560:6d4:26ca::1:1d] (helo=violet.siamics.net) by fely.am-1.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XOB8j-00038s-Pm for submit@debbugs.gnu.org; Sun, 31 Aug 2014 19:50:17 +0000 Original-Received: from localhost ([::1] helo=violet.siamics.net) by violet.siamics.net with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XOB8c-0001Ae-Jq for submit@debbugs.gnu.org; Mon, 01 Sep 2014 02:50:10 +0700 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92898 Archived-At: Package: emacs Severity: minor As currently implemented, insert-file-contents disallows not only (as per (elisp.info) Reading from Files) the case of either =E2=80=98visit=E2=80=99 or =E2=80=98replace=E2=80=99 arguments being non-n= il, but also when non-nil are either =E2=80=98beg=E2=80=99 or =E2=80=98end=E2=80=99 (or both= ): 3506 /* This code will need to be changed in order to work on named 3507 pipes, and it's probably just not worth it. So we should at 3508 least signal an error. */ 3509 if (!S_ISREG (st.st_mode)) 3510 { 3511 not_regular =3D 1; =E2=8B=AF 3516 if (! NILP (replace) || ! NILP (beg) || ! NILP (end)) 3517 xsignal2 (Qfile_error, 3518 build_string ("not a regular file"), orig_filename); 3519 } This, however, precludes the use of insert-file-contents not only on named pipes, but also on /dev/cdrom, /dev/random, and the like, =E2=80=93 for (and especially in the case of the latter) the =E2=80=98end=E2=80=99 argument gets rather essential here, as otherwise the function is likely to read much more than the caller will be able to handle at any single time. Instead, I=E2=80=99d suggest that =E2=80=98end=E2=80=99 is always allowed,= and =E2=80=98beg=E2=80=99 is allowed when the file in question is /seekable/, =E2=80=93 which, ISTR, is possible to check beforehand (lseek (fd, 0, SEEK_CUR) < 0?) From a glance over the code, this new behavior wouldn=E2=80=99t be all that hard to implement (some not_regular checks will have to be replaced with the ones against beg_offset, end_offset, etc.), but from what I read, =E2=80=93 it=E2=80=99s already going to be more than= I can test right now. So no .diff this time, alas. --=20 FSF associate member #7257 http://boycottsystemd.org/ =E2=80=A6 3013 B6A0= 230E 334A