aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorBastien2017-07-03 09:06:29 +0200
committerBastien2017-07-03 09:06:29 +0200
commit5ca1888fe670aee7febd4d42665d7372ab2ffebc (patch)
tree1f7f8d8a7580e556fc83cf3a6aaeec567b33a090 /src/print.c
parent20e006ffee41062f1b551a92c24d9edc53cd0f56 (diff)
parent1b4f0a92ff3505ef9a465b9b391756e3a73a6443 (diff)
downloademacs-5ca1888fe670aee7febd4d42665d7372ab2ffebc.tar.gz
emacs-5ca1888fe670aee7febd4d42665d7372ab2ffebc.zip
Merge branch 'master' into scratch/org-mode-merge
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/print.c b/src/print.c
index aaec5b04956..50c75d7712c 100644
--- a/src/print.c
+++ b/src/print.c
@@ -228,7 +228,7 @@ printchar_to_stream (unsigned int ch, FILE *stream)
228 { 228 {
229 if (ASCII_CHAR_P (ch)) 229 if (ASCII_CHAR_P (ch))
230 { 230 {
231 putc (ch, stream); 231 putc_unlocked (ch, stream);
232#ifdef WINDOWSNT 232#ifdef WINDOWSNT
233 /* Send the output to a debugger (nothing happens if there 233 /* Send the output to a debugger (nothing happens if there
234 isn't one). */ 234 isn't one). */
@@ -246,7 +246,7 @@ printchar_to_stream (unsigned int ch, FILE *stream)
246 if (encode_p) 246 if (encode_p)
247 encoded_ch = code_convert_string_norecord (encoded_ch, 247 encoded_ch = code_convert_string_norecord (encoded_ch,
248 coding_system, true); 248 coding_system, true);
249 fwrite (SSDATA (encoded_ch), 1, SBYTES (encoded_ch), stream); 249 fwrite_unlocked (SSDATA (encoded_ch), 1, SBYTES (encoded_ch), stream);
250#ifdef WINDOWSNT 250#ifdef WINDOWSNT
251 if (print_output_debug_flag && stream == stderr) 251 if (print_output_debug_flag && stream == stderr)
252 OutputDebugString (SSDATA (encoded_ch)); 252 OutputDebugString (SSDATA (encoded_ch));
@@ -298,7 +298,7 @@ printchar (unsigned int ch, Lisp_Object fun)
298 if (DISP_TABLE_P (Vstandard_display_table)) 298 if (DISP_TABLE_P (Vstandard_display_table))
299 printchar_to_stream (ch, stdout); 299 printchar_to_stream (ch, stdout);
300 else 300 else
301 fwrite (str, 1, len, stdout); 301 fwrite_unlocked (str, 1, len, stdout);
302 noninteractive_need_newline = 1; 302 noninteractive_need_newline = 1;
303 } 303 }
304 else 304 else
@@ -350,7 +350,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
350 } 350 }
351 } 351 }
352 else 352 else
353 fwrite (ptr, 1, size_byte, stdout); 353 fwrite_unlocked (ptr, 1, size_byte, stdout);
354 354
355 noninteractive_need_newline = 1; 355 noninteractive_need_newline = 1;
356 } 356 }
@@ -801,7 +801,7 @@ append to existing target file. */)
801 report_file_error ("Cannot open debugging output stream", file); 801 report_file_error ("Cannot open debugging output stream", file);
802 } 802 }
803 803
804 fflush (stderr); 804 fflush_unlocked (stderr);
805 if (dup2 (fd, STDERR_FILENO) < 0) 805 if (dup2 (fd, STDERR_FILENO) < 0)
806 report_file_error ("dup2", file); 806 report_file_error ("dup2", file);
807 if (fd != stderr_dup) 807 if (fd != stderr_dup)
@@ -1870,21 +1870,36 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1870 } 1870 }
1871 else 1871 else
1872 { 1872 {
1873 bool still_need_nonhex = false;
1873 /* If we just had a hex escape, and this character 1874 /* If we just had a hex escape, and this character
1874 could be taken as part of it, 1875 could be taken as part of it,
1875 output `\ ' to prevent that. */ 1876 output `\ ' to prevent that. */
1876 if (need_nonhex && c_isxdigit (c)) 1877 if (c_isxdigit (c))
1877 print_c_string ("\\ ", printcharfun); 1878 {
1878 1879 if (need_nonhex)
1879 if (c == '\n' && print_escape_newlines 1880 print_c_string ("\\ ", printcharfun);
1880 ? (c = 'n', true) 1881 printchar (c, printcharfun);
1881 : c == '\f' && print_escape_newlines 1882 }
1882 ? (c = 'f', true) 1883 else if (c == '\n' && print_escape_newlines
1883 : c == '\"' || c == '\\') 1884 ? (c = 'n', true)
1884 printchar ('\\', printcharfun); 1885 : c == '\f' && print_escape_newlines
1885 1886 ? (c = 'f', true)
1886 printchar (c, printcharfun); 1887 : c == '\0' && print_escape_control_characters
1887 need_nonhex = false; 1888 ? (c = '0', still_need_nonhex = true)
1889 : c == '\"' || c == '\\')
1890 {
1891 printchar ('\\', printcharfun);
1892 printchar (c, printcharfun);
1893 }
1894 else if (print_escape_control_characters && c_iscntrl (c))
1895 {
1896 char outbuf[1 + 3 + 1];
1897 int len = sprintf (outbuf, "\\%03o", c + 0u);
1898 strout (outbuf, len, len, printcharfun);
1899 }
1900 else
1901 printchar (c, printcharfun);
1902 need_nonhex = still_need_nonhex;
1888 } 1903 }
1889 } 1904 }
1890 printchar ('\"', printcharfun); 1905 printchar ('\"', printcharfun);
@@ -2329,6 +2344,11 @@ A value of nil means no limit. See also `eval-expression-print-level'. */);
2329Also print formfeeds as `\\f'. */); 2344Also print formfeeds as `\\f'. */);
2330 print_escape_newlines = 0; 2345 print_escape_newlines = 0;
2331 2346
2347 DEFVAR_BOOL ("print-escape-control-characters", print_escape_control_characters,
2348 doc: /* Non-nil means print control characters in strings as `\\OOO'.
2349\(OOO is the octal representation of the character code.)*/);
2350 print_escape_control_characters = 0;
2351
2332 DEFVAR_BOOL ("print-escape-nonascii", print_escape_nonascii, 2352 DEFVAR_BOOL ("print-escape-nonascii", print_escape_nonascii,
2333 doc: /* Non-nil means print unibyte non-ASCII chars in strings as \\OOO. 2353 doc: /* Non-nil means print unibyte non-ASCII chars in strings as \\OOO.
2334\(OOO is the octal representation of the character code.) 2354\(OOO is the octal representation of the character code.)
@@ -2418,6 +2438,7 @@ priorities. */);
2418 DEFSYM (Qprint_escape_newlines, "print-escape-newlines"); 2438 DEFSYM (Qprint_escape_newlines, "print-escape-newlines");
2419 DEFSYM (Qprint_escape_multibyte, "print-escape-multibyte"); 2439 DEFSYM (Qprint_escape_multibyte, "print-escape-multibyte");
2420 DEFSYM (Qprint_escape_nonascii, "print-escape-nonascii"); 2440 DEFSYM (Qprint_escape_nonascii, "print-escape-nonascii");
2441 DEFSYM (Qprint_escape_control_characters, "print-escape-control-characters");
2421 2442
2422 print_prune_charset_plist = Qnil; 2443 print_prune_charset_plist = Qnil;
2423 staticpro (&print_prune_charset_plist); 2444 staticpro (&print_prune_charset_plist);