From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: richardeng Newsgroups: gmane.emacs.bugs Subject: bug#1523: [Ivan Shmakov] process-send-string apparently mangles \r into \n Date: Tue, 13 Jan 2009 01:24:20 +0800 Message-ID: <496B7CC4.8000101@foxmail.com> References: <873agxxd6q.fsf@turtle.gmx.de> Reply-To: richardeng , 1523@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1231782376 3248 80.91.229.12 (12 Jan 2009 17:46:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Jan 2009 17:46:16 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Sven Joachim , 1523@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 12 18:47:26 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LMQse-0000pq-HB for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Jan 2009 18:47:19 +0100 Original-Received: from localhost ([127.0.0.1]:52470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LMQrO-0005Oa-4Z for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Jan 2009 12:45:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LMQp2-0004ZM-7Q for bug-gnu-emacs@gnu.org; Mon, 12 Jan 2009 12:43:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LMQoz-0004Xj-ID for bug-gnu-emacs@gnu.org; Mon, 12 Jan 2009 12:43:31 -0500 Original-Received: from [199.232.76.173] (port=45125 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LMQoz-0004Xf-9K for bug-gnu-emacs@gnu.org; Mon, 12 Jan 2009 12:43:29 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:56400) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LMQoy-0001Ph-MN for bug-gnu-emacs@gnu.org; Mon, 12 Jan 2009 12:43:29 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0CHhPVJ024821; Mon, 12 Jan 2009 09:43:26 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n0CHU4L7021351; Mon, 12 Jan 2009 09:30:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: richardeng Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Mon, 12 Jan 2009 17:30:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 1523 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1523-submit@emacsbugs.donarmstrong.com id=B1523.123178107720018 (code B ref 1523); Mon, 12 Jan 2009 17:30:03 +0000 Original-Received: (at 1523) by emacsbugs.donarmstrong.com; 12 Jan 2009 17:24:37 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from smtpbg3.foxmail.com (smtpbg3.foxmail.com [121.14.102.33]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id n0CHOWQF020010 for <1523@emacsbugs.donarmstrong.com>; Mon, 12 Jan 2009 09:24:33 -0800 Original-Received: from 172.16.81.120 (foxmail.com [172.16.81.120]) by smtpbg3 (foxmail.com) with SMTP id xRFhKaJE; Tue, 13 Jan 2009 01:24:21 +0800 (envelope-from richardeng@foxmail.com) X-QQ-mid: esmtp2123178106153932228 Original-Received: from [192.168.1.111] (unknown [58.25.221.212]) by smtp.foxmail.com (Postfix) with ESMTP id ; Tue, 13 Jan 2009 01:24:21 +0800 (CST) User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) In-Reply-To: <873agxxd6q.fsf@turtle.gmx.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Mon, 12 Jan 2009 12:43:30 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:24032 Archived-At: Sven Joachim wrote: > I received the following report via the Debian bug tracking system. > It is reproducible in the trunk. > > > > ------------------------------------------------------------------------ > > Subject: > Bug#508300: process-send-string apparently mangles \r into \n > From: > Ivan Shmakov > Date: > Wed, 10 Dec 2008 01:14:09 +0600 > To: > submit@bugs.debian.org > > To: > submit@bugs.debian.org > CC: > Ivan Shmakov > > > Package: emacs22 > Version: 22.2+2-5 > > After running the following program: > > (let* ((coding-system-for-read 'binary) > (coding-system-for-write 'binary) > (p (start-process "foo" "*foo*" "od" "-td1"))) > (process-send-string p "\r\n") > (process-send-eof p)) > ;; => # > > the `*foo*' buffer contains: > > --cut: *foo*-- > 0000000 10 10 > 0000002 > > Process foo finished > --cut: *foo*-- > > While I'd expect the following instead: > > --cut: *foo*-- > 0000000 13 10 > 0000002 > > Process foo finished > --cut: *foo*-- > > Compare: > > (let ((coding-system-for-read 'binary) > (coding-system-for-write 'binary)) > (save-excursion > (set-buffer "*foo*") > (let* ((start (point)) > (end (progn (insert "\r\n") (point)))) > (call-process-region start end "od" t t t "-td1")))) > > --cut: *foo*-- > 0000000 13 10 > 0000002 > --cut: *foo*-- > > > (start-process "foo" "*foo*" "od" "-td1") // pty is used, pty driver will map '\r' <-> '\n' (call-process-region start end "od" t t t "-td1") // temp file is used, no such problem --- process.c.~1.577.~ 2009-01-03 07:03:59.000000000 -0800 +++ process.c 2009-01-13 01:18:08.000000000 -0800 @@ -1871,6 +1871,13 @@ forkin = forkout = -1; #endif /* not USG, or USG_SUBTTY_WORKS */ pty_flag = 1; + { + struct emacs_tty settings; + EMACS_GET_TTY(outchannel, &settings); + settings.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ + settings.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ + EMACS_SET_TTY(outchannel, &settings, 1); + } } else #endif /* HAVE_PTYS */