Subject: bug#6800: closed (Re: bug#6800: 23.1; EOT / ^D inserted into comint input string)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 12 Aug 2016 18:38:02 +0000

Your bug report

#6800: 23.1; EOT / ^D inserted into comint input string

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6800: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6800
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6800: 23.1; EOT / ^D inserted into comint input string
From: Alan Third <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked], David Fox <[email-masked]>
Date: Fri, 12 Aug 2016 19:36:52 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Stefan Monnier <[email-masked]> writes:

>> When an input longer than 255 characters is typed into comint (or
>> shell) an EOT character (ascii 4, ^D) is inserted into the string.
>> This can cause an error depending how the sub process handles these
>> extra characters.  For example, GHC doesn't like it when an EOT
>> appears inside of a string:
>
> I believe this bug is fixed on the Emacs trunk (to become Emacs-24), but
> the fix may introduce other problems.  Apparently nobody knows how to
> fix it right and there is about as much as no documentation at all on
> this part of the behavior of ttys.

IIRC this code is no longer in Emacs. I'll close this bug.

-- 
Alan Third

Subject: 23.1; EOT / ^D inserted into comint input string
From: David Fox <[email-masked]>
To: [email-masked]
Date: Thu, 5 Aug 2010 07:58:13 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

When an input longer than 255 characters is typed into comint (or
shell) an EOT character (ascii 4, ^D) is inserted into the string.
This can cause an error depending how the sub process handles these
extra characters.  For example, GHC doesn't like it when an EOT
appears inside of a string:

 ghci
 > Prelude> putStrLn "<a 241 character string>"
works fine, but
 > Prelude> putStrLn "<a 242 character string>"
<interactive>:1:255: lexical error at character '\EOT'

I inserted a function to break up the input into comint-send-string to work
around the problem:

(require 'comint)

(defun comint-send-string (process string)
  "Like `process-send-string', but also does extra bookkeeping for Comint
mode."
  (if process
      (with-current-buffer (if (processp process)
                   (process-buffer process)
                 (get-buffer process))
    (comint-snapshot-last-prompt))
    (comint-snapshot-last-prompt))
  (my-process-send-string process string))

;; Break up the string so that we don't get EOT characters in our input
stream.
(defun my-process-send-string (process string)
  (if (> (length string) 200)
      (progn (process-send-string process (substring string 0 200))
(my-process-send-string process (substring string 200)))
    (process-send-string process string)))