aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorEli Zaretskii2014-02-01 13:53:10 +0200
committerEli Zaretskii2014-02-01 13:53:10 +0200
commit9ef58a52ac97a160e2818e69e7cd146e52fbdacf (patch)
tree572142e04cbf44d0e5452ca2372bd144ad0645ca /src/print.c
parent2f31004a737e5443ba96fd60733e9eda818abfe2 (diff)
downloademacs-9ef58a52ac97a160e2818e69e7cd146e52fbdacf.tar.gz
emacs-9ef58a52ac97a160e2818e69e7cd146e52fbdacf.zip
Fix bug #16448 with non-ASCII error messages in batch mode.
src/print.c (Fexternal_debugging_output): If the argument character is non-ASCII, encode it with the current locale's encoding before writing the result to the terminal.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/print.c b/src/print.c
index 71fa30da93e..f6d2baa6cd1 100644
--- a/src/print.c
+++ b/src/print.c
@@ -709,17 +709,36 @@ You can call print while debugging emacs, and pass it this function
709to make it write to the debugging output. */) 709to make it write to the debugging output. */)
710 (Lisp_Object character) 710 (Lisp_Object character)
711{ 711{
712 CHECK_NUMBER (character); 712 unsigned int ch;
713 putc (XINT (character) & 0xFF, stderr);
714 713
715#ifdef WINDOWSNT 714 CHECK_NUMBER (character);
716 /* Send the output to a debugger (nothing happens if there isn't one). */ 715 ch = XINT (character);
717 if (print_output_debug_flag) 716 if (ASCII_CHAR_P (ch))
718 { 717 {
719 char buf[2] = {(char) XINT (character), '\0'}; 718 putc (ch, stderr);
720 OutputDebugString (buf); 719#ifdef WINDOWSNT
720 /* Send the output to a debugger (nothing happens if there isn't
721 one). */
722 if (print_output_debug_flag)
723 {
724 char buf[2] = {(char) XINT (character), '\0'};
725 OutputDebugString (buf);
726 }
727#endif
721 } 728 }
729 else
730 {
731 unsigned char mbstr[MAX_MULTIBYTE_LENGTH];
732 ptrdiff_t len = CHAR_STRING (ch, mbstr);
733 Lisp_Object encoded_ch =
734 ENCODE_SYSTEM (make_multibyte_string (mbstr, 1, len));
735
736 fwrite (SSDATA (encoded_ch), SBYTES (encoded_ch), 1, stderr);
737#ifdef WINDOWSNT
738 if (print_output_debug_flag)
739 OutputDebugString (SSDATA (encoded_ch));
722#endif 740#endif
741 }
723 742
724 return character; 743 return character;
725} 744}