fix '(a #{.} b)
* libguile/read.c (scm_read_sexp): Don't confuse `#{.}#' with `.' for
the purpose of reading dotted pairs. Thanks to CRLF0710 for the
report.
* test-suite/tests/reader.test ("#{}#"): Add test.
This commit is contained in:
parent
b8441577f9
commit
1f7945a768
2 changed files with 9 additions and 3 deletions
|
|
@ -376,8 +376,12 @@ scm_read_sexp (scm_t_wchar chr, SCM port)
|
||||||
return SCM_EOL;
|
return SCM_EOL;
|
||||||
|
|
||||||
scm_ungetc (c, port);
|
scm_ungetc (c, port);
|
||||||
if (scm_is_eq (scm_sym_dot,
|
tmp = scm_read_expression (port);
|
||||||
(tmp = scm_read_expression (port))))
|
|
||||||
|
/* Note that it is possible for scm_read_expression to return
|
||||||
|
scm_sym_dot, but not as part of a dotted pair: as in #{.}#. So
|
||||||
|
check that it's a real dot by checking `c'. */
|
||||||
|
if (c == '.' && scm_is_eq (scm_sym_dot, tmp))
|
||||||
{
|
{
|
||||||
ans = scm_read_expression (port);
|
ans = scm_read_expression (port);
|
||||||
if (terminating_char != (c = flush_ws (port, FUNC_NAME)))
|
if (terminating_char != (c = flush_ws (port, FUNC_NAME)))
|
||||||
|
|
@ -401,7 +405,8 @@ scm_read_sexp (scm_t_wchar chr, SCM port)
|
||||||
scm_ungetc (c, port);
|
scm_ungetc (c, port);
|
||||||
tmp = scm_read_expression (port);
|
tmp = scm_read_expression (port);
|
||||||
|
|
||||||
if (scm_is_eq (scm_sym_dot, tmp))
|
/* See above note about scm_sym_dot. */
|
||||||
|
if (c == '.' && scm_is_eq (scm_sym_dot, tmp))
|
||||||
{
|
{
|
||||||
SCM_SETCDR (tl, tmp = scm_read_expression (port));
|
SCM_SETCDR (tl, tmp = scm_read_expression (port));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,7 @@
|
||||||
|
|
||||||
(with-test-prefix "#{}#"
|
(with-test-prefix "#{}#"
|
||||||
(pass-if (equal? (read-string "#{}#") '#{}#))
|
(pass-if (equal? (read-string "#{}#") '#{}#))
|
||||||
|
(pass-if (not (equal? (read-string "(a #{.}# b)") '(a . b))))
|
||||||
(pass-if (equal? (read-string "#{a}#") 'a))
|
(pass-if (equal? (read-string "#{a}#") 'a))
|
||||||
(pass-if (equal? (read-string "#{a b}#") '#{a b}#))
|
(pass-if (equal? (read-string "#{a b}#") '#{a b}#))
|
||||||
(pass-if-exception "#{" exception:eof-in-symbol
|
(pass-if-exception "#{" exception:eof-in-symbol
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue