1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

print: In R7RS |...| symbols, print most graphic characters unescaped.

* libguile/print.c (print_r7rs_extended_symbol): Print any unicode
  graphic character other than '|' or '\' unescaped.  Escape any spacing
  character other than ASCII space.
This commit is contained in:
Mark H Weaver 2014-01-14 23:29:50 -05:00
parent 6e504a7b44
commit 1fc651e3a5
2 changed files with 11 additions and 2 deletions

View file

@ -462,8 +462,12 @@ print_r7rs_extended_symbol (SCM sym, SCM port)
case '\\': scm_lfwrite ("\\x5c;", 5, port); break; case '\\': scm_lfwrite ("\\x5c;", 5, port); break;
default: default:
if (uc_is_general_category_withtable (c, if (uc_is_general_category_withtable (c,
SUBSEQUENT_IDENTIFIER_MASK UC_CATEGORY_MASK_L
| UC_CATEGORY_MASK_Zs)) | UC_CATEGORY_MASK_M
| UC_CATEGORY_MASK_N
| UC_CATEGORY_MASK_P
| UC_CATEGORY_MASK_S)
|| (c == ' '))
{ {
if (!display_character (c, port, strategy)) if (!display_character (c, port, strategy))
scm_encoding_error ("print_r7rs_extended_symbol", errno, scm_encoding_error ("print_r7rs_extended_symbol", errno,

View file

@ -63,6 +63,11 @@
"bar | backslash \\ alarm \a backspace \b tab \t newline \n cr \r null \0 del " "bar | backslash \\ alarm \a backspace \b tab \t newline \n cr \r null \0 del "
(string #\del))))) (string #\del)))))
(pass-if-equal "brackets"
"|()[]{}|"
(write-with-options '(r7rs-symbols)
(string->symbol "()[]{}")))
(pass-if-equal "starts with bar" (pass-if-equal "starts with bar"
"|\\|foo|" "|\\|foo|"
(write-with-options '(r7rs-symbols) (write-with-options '(r7rs-symbols)