unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44320: [PATH] [27.1] Make sure send-string-to-terminal send all contents
@ 2020-10-29 23:01 Lin Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-10-30  0:36 ` Lin Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-10-30  8:06 ` Eli Zaretskii
  0 siblings, 2 replies; 30+ messages in thread
From: Lin Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-10-29 23:01 UTC (permalink / raw)
  To: larsi, eliz, 44320

[-- Attachment #1: Type: text/html, Size: 1473 bytes --]

[-- Attachment #2: 0001-Make-sure-send-string-to-terminal-send-all-contents.patch --]
[-- Type: application/octet-stream, Size: 1523 bytes --]

From 72ae35b1fdc7bc3d87e0b829079f61fc961a860d Mon Sep 17 00:00:00 2001
From: Lin Sun <lin.sun@zoom.us>
Date: Fri, 30 Oct 2020 06:25:56 +0800
Subject: [PATCH] Make sure send-string-to-terminal send all contents

* src/dispnew.c: send-string-to-terminal: the 'fwrite' return the
number of items written, loop it to make sure all contents are writed.
---
 src/dispnew.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/dispnew.c b/src/dispnew.c
index 1ae59e3..df5e0c9 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5881,6 +5881,8 @@ DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
 {
   struct terminal *t = decode_live_terminal (terminal);
   FILE *out;
+  const unsigned char *buf;
+  ptrdiff_t nbytes;
 
   /* ??? Perhaps we should do something special for multibyte strings here.  */
   CHECK_STRING (string);
@@ -5904,7 +5906,24 @@ DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
 	}
       out = tty->output;
     }
-  fwrite (SDATA (string), 1, SBYTES (string), out);
+  buf = SDATA (string);
+  nbytes = SBYTES (string) + 1;
+  do
+    {
+      size_t ret = fwrite (buf, 1, nbytes, out);
+      if (ret > 0)
+        {
+          buf += ret;
+          nbytes -= ret;
+        }
+      else
+        {
+          error ("failed to write %" pD "d bytes to terminal: %s", nbytes,
+                 emacs_strerror (errno));
+          break;
+        }
+    }
+  while (nbytes > 0);
   fflush (out);
   unblock_input ();
   return Qnil;
-- 
2.2.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2020-11-09  2:27 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 23:01 bug#44320: [PATH] [27.1] Make sure send-string-to-terminal send all contents Lin Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-10-30  0:36 ` Lin Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-10-30  8:06 ` Eli Zaretskii
2020-10-30 12:38   ` Lars Ingebrigtsen
2020-10-30 13:25     ` Eli Zaretskii
2020-11-02  2:58       ` LinSun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-02  3:11         ` LinSun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-02 15:31           ` Eli Zaretskii
2020-11-02 15:49             ` Andreas Schwab
2020-11-02 16:14               ` Eli Zaretskii
2020-11-02 16:41                 ` Andreas Schwab
2020-11-02 17:10                   ` Eli Zaretskii
2020-11-02 17:36                     ` Andreas Schwab
2020-11-02 17:59                       ` Eli Zaretskii
2020-11-02 18:02                         ` Andreas Schwab
2020-11-02 18:12                           ` Eli Zaretskii
2020-11-02 18:22                             ` Andreas Schwab
2020-11-02 18:35                               ` Eli Zaretskii
2020-11-02 18:58                                 ` Andreas Schwab
2020-11-02 19:31                                   ` Eli Zaretskii
2020-11-02 20:26                                     ` Andreas Schwab
     [not found]                                       ` <4BD75783-F561-4DB8-A733-13A3D924C8C1@hxcore.ol>
2020-11-03 15:29                                         ` Eli Zaretskii
2020-11-05  0:14                                           ` LinSun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-07  9:28                                             ` Eli Zaretskii
2020-11-09  2:27                                               ` LinSun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-05 15:59                                       ` Eli Zaretskii
2020-11-05 16:07                                         ` Andreas Schwab
2020-11-02 15:22         ` Lars Ingebrigtsen
2020-11-02 16:07           ` Eli Zaretskii
2020-11-02 16:30             ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).