diff --git a/libguile/read.c b/libguile/read.c index ff507354d..17c0534c4 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -582,12 +582,21 @@ scm_read_mixed_case_symbol (int chr, SCM port) if (scm_is_pair (str)) { + size_t len; + str = scm_string_concatenate (scm_reverse_x (str, SCM_EOL)); - result = scm_string_to_symbol (str); + len = scm_c_string_length (str); /* Per SRFI-88, `:' alone is an identifier, not a keyword. */ - if (postfix && ends_with_colon && (scm_c_string_length (result) > 1)) - result = scm_symbol_to_keyword (result); + if (postfix && ends_with_colon && (len > 1)) + { + /* Strip off colon. */ + str = scm_c_substring (str, 0, len-1); + result = scm_string_to_symbol (str); + result = scm_symbol_to_keyword (result); + } + else + result = scm_string_to_symbol (str); } else { diff --git a/test-suite/tests/reader.test b/test-suite/tests/reader.test index b068c716d..0b6f9a468 100644 --- a/test-suite/tests/reader.test +++ b/test-suite/tests/reader.test @@ -165,6 +165,11 @@ (with-read-options '(keywords postfix) (lambda () (read-string "keyword:"))))) + (pass-if "long postfix keywords" + (eq? #:keyword0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + (with-read-options '(keywords postfix) + (lambda () + (read-string "keyword0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789:"))))) (pass-if "`:' is not a postfix keyword (per SRFI-88)" (eq? ': (with-read-options '(keywords postfix)