[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Symbols and keywords longer than 128 chars cause exception
From: |
Mike Gran |
Subject: |
[PATCH] Symbols and keywords longer than 128 chars cause exception |
Date: |
Fri, 24 Apr 2009 22:47:05 -0700 |
In master
* test-suite/tests/reader.test ("read-options"): Add test
for long postfix keywords.
* libguile/read.c (scm_read_mixed_case_symbol): Fix
exception on symbols are greater than 128 chars. Also,
colons are not stripped from long postfix keywords.
---
libguile/read.c | 15 ++++++++++++---
test-suite/tests/reader.test | 5 +++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/libguile/read.c b/libguile/read.c
index 47b8004..61806f2 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -552,12 +552,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 b068c71..0b6f9a4 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)
--
1.6.0.6
- [PATCH] Symbols and keywords longer than 128 chars cause exception,
Mike Gran <=