print: In R7RS |...| symbols, print most graphic characters unescaped.
authorMark H Weaver <mhw@netris.org>
Wed, 15 Jan 2014 04:29:50 +0000 (23:29 -0500)
committerMark H Weaver <mhw@netris.org>
Wed, 15 Jan 2014 04:46:45 +0000 (23:46 -0500)
* 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
test-suite/tests/print.test

index 71bb89f..ae98af4 100644 (file)
@@ -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,
index a33776c..01bc994 100644 (file)
          "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)