From 1fc651e3a5249fa35d143628d27243e96b90a0bd Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 14 Jan 2014 23:29:50 -0500 Subject: [PATCH] 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. --- libguile/print.c | 8 ++++++-- test-suite/tests/print.test | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libguile/print.c b/libguile/print.c index 71bb89fde..ae98af405 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -462,8 +462,12 @@ print_r7rs_extended_symbol (SCM sym, SCM port) case '\\': scm_lfwrite ("\\x5c;", 5, port); break; default: if (uc_is_general_category_withtable (c, - SUBSEQUENT_IDENTIFIER_MASK - | UC_CATEGORY_MASK_Zs)) + UC_CATEGORY_MASK_L + | UC_CATEGORY_MASK_M + | UC_CATEGORY_MASK_N + | UC_CATEGORY_MASK_P + | UC_CATEGORY_MASK_S) + || (c == ' ')) { if (!display_character (c, port, strategy)) scm_encoding_error ("print_r7rs_extended_symbol", errno, diff --git a/test-suite/tests/print.test b/test-suite/tests/print.test index a33776c91..01bc9945d 100644 --- a/test-suite/tests/print.test +++ b/test-suite/tests/print.test @@ -63,6 +63,11 @@ "bar | backslash \\ alarm \a backspace \b tab \t newline \n cr \r null \0 del " (string #\del))))) + (pass-if-equal "brackets" + "|()[]{}|" + (write-with-options '(r7rs-symbols) + (string->symbol "()[]{}"))) + (pass-if-equal "starts with bar" "|\\|foo|" (write-with-options '(r7rs-symbols)