read: Accept "\|" in string literals.
authorMark H Weaver <mhw@netris.org>
Sun, 12 Jan 2014 09:36:29 +0000 (04:36 -0500)
committerMark H Weaver <mhw@netris.org>
Tue, 14 Jan 2014 07:24:37 +0000 (02:24 -0500)
* libguile/read.c (scm_read_string): Accept "\|" in string literals.

* doc/ref/api-data.texi (String Syntax): Add "\|" to the list of
  supported backslash escapes.

* test-suite/tests/reader.test ("reading"): Add test.

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

index 198854b..109b228 100644 (file)
@@ -2938,9 +2938,10 @@ The read syntax for strings is an arbitrarily long sequence of
 characters enclosed in double quotes (@nicode{"}).
 
 Backslash is an escape character and can be used to insert the following
-special characters.  @nicode{\"} and @nicode{\\} are R5RS standard, the
-next seven are R6RS standard --- notice they follow C syntax --- and the
-remaining four are Guile extensions.
+special characters.  @nicode{\"} and @nicode{\\} are R5RS standard,
+@nicode{\|} is R7RS standard, the next seven are R6RS standard ---
+notice they follow C syntax --- and the remaining four are Guile
+extensions.
 
 @table @asis
 @item @nicode{\\}
@@ -2950,6 +2951,9 @@ Backslash character.
 Double quote character (an unescaped @nicode{"} is otherwise the end
 of the string).
 
+@item @nicode{\|}
+Vertical bar character.
+
 @item @nicode{\a}
 Bell character (ASCII 7).
 
index 03a53aa..eead368 100644 (file)
@@ -624,6 +624,7 @@ scm_read_string (int chr, SCM port, scm_t_read_opts *opts)
             case EOF:
               goto str_eof;
             case '"':
+            case '|':
             case '\\':
               break;
             case '\n':
index 448ae1b..56f6346 100644 (file)
     (not (equal? (imag-part (read-string "-nan.0-1i"))
                  (imag-part (read-string "-nan.0+1i")))))
 
+  (pass-if-equal "'\|' in string literals"
+      "a|b"
+    (read-string "\"a\\|b\""))
+
   (pass-if-equal "#true"
       '(a #t b)
     (read-string "(a #true b)"))