Add R6RS backslash string escape
authorMichael Gran <spk121@yahoo.com>
Sun, 10 Jan 2010 23:39:55 +0000 (15:39 -0800)
committerMichael Gran <spk121@yahoo.com>
Sun, 10 Jan 2010 23:39:55 +0000 (15:39 -0800)
R6RS suggests that '\b' should be a string escape for the backslash
character.

* libguile/read.c (scm_read_string): parse backspace escape

* test-suite/tests/strings.test (R6RS backslash escapes): new test
  (Guile extensions backslash escapes): remove R6RS escapes from test.

* doc/ref/api-data.texi (Strings): document new string escape

doc/ref/api-data.texi
libguile/read.c
test-suite/tests/strings.test

index 3fc34c2..bf25c59 100755 (executable)
@@ -2649,6 +2649,9 @@ Tab character (ASCII 9).
 @item @nicode{\v}
 Vertical tab character (ASCII 11).
 
+@item @nicode{\b}
+Backspace character (ASCII 8).
+
 @item @nicode{\xHH}
 Character code given by two hexadecimal digits.  For example
 @nicode{\x7f} for an ASCII DEL (127).
index dedfed2..25aed54 100644 (file)
@@ -477,6 +477,9 @@ scm_read_string (int chr, SCM port)
             case 'v':
               c = '\v';
               break;
+            case 'b':
+              c = '\010';
+              break;
             case 'x':
               {
                 scm_t_wchar a, b;
index 984178d..e04c026 100644 (file)
   (pass-if "R5RS backslash escapes"
     (string=? "\"\\" (string #\" #\\)))
 
+  (pass-if "R6RS backslash escapes"
+    (string=? "\a\b\t\n\v\f\r"
+              (string #\alarm #\backspace #\tab #\newline #\vtab
+                      #\page #\return)))
+
   (pass-if "Guile extensions backslash escapes"
-    (string=? "\0\a\f\n\r\t\v"
-              (apply string (map integer->char '(0 7 12 10 13 9 11))))))
+    (string=? "\0" (string #\nul))))
 
 ;;
 ;; string?