aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/print.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/print.c b/src/print.c
index 6bf8af9ef93..50c75d7712c 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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);