]> code.delx.au - gnu-emacs/commitdiff
(encode_terminal_code): Use safe_terminal_coding if
authorKenichi Handa <handa@m17n.org>
Sun, 10 Aug 1997 04:13:19 +0000 (04:13 +0000)
committerKenichi Handa <handa@m17n.org>
Sun, 10 Aug 1997 04:13:19 +0000 (04:13 +0000)
terminal_coding seems to encode Emacs' internal code as is.
(write_glyphs): Likewise.

src/term.c

index efed87e52eaab8d2e6df56816b7fe2eee9abc57a..dd1c8be804eebbaddf92bddabfaca0f417c68f1b 100644 (file)
@@ -828,8 +828,14 @@ encode_terminal_code (src, dst, src_len, dst_len, consumed)
              buf = GLYPH_STRING (tbase, g);
            }
          
-         produced = encode_coding (&terminal_coding, buf, dst,
-                                    len, dst_end - dst, &processed);
+         if (CODING_MAY_REQUIRE_NO_CONVERSION (&terminal_coding))
+           /* We had better avoid sending Emacs' internal code to
+               terminal.  */
+           produced = encode_coding (&safe_terminal_coding, buf, dst,
+                                     len, dst_end - dst, &processed);
+         else
+           produced = encode_coding (&terminal_coding, buf, dst,
+                                     len, dst_end - dst, &processed);
          if (processed < len)
            /* We get a carryover because the remaining output
               buffer is too short.  We must break the loop here
@@ -897,17 +903,21 @@ write_glyphs (string, len)
       string += consumed;
     }
   /* We may have to output some codes to terminate the writing.  */
-  terminal_coding.last_block = 1;
-  produced = encode_coding (&terminal_coding, (char *)0, conversion_buffer,
-                           0, conversion_buffer_size,
-                           &consumed);
-  if (produced > 0)
+  if (!CODING_MAY_REQUIRE_NO_CONVERSION (&terminal_coding))
     {
-      fwrite (conversion_buffer, 1, produced, stdout);
-      if (ferror (stdout))
-       clearerr (stdout);
-      if (termscript)
-       fwrite (conversion_buffer, 1, produced, termscript);
+      terminal_coding.last_block = 1;
+      produced = encode_coding (&terminal_coding, (char *)0, conversion_buffer,
+                               0, conversion_buffer_size,
+                               &consumed);
+
+      if (produced > 0)
+       {
+         fwrite (conversion_buffer, 1, produced, stdout);
+         if (ferror (stdout))
+           clearerr (stdout);
+         if (termscript)
+           fwrite (conversion_buffer, 1, produced, termscript);
+       }
     }
   cmcheckmagic ();
 }