1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-17 03:00:21 +02:00

Symbols longer than 128 chars can cause an exception. Also, the terminating colon of long postfix keywords are not handled correctly.

* 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.
This commit is contained in:
Michael Gran 2009-04-24 22:23:13 -07:00 committed by Ludovic Courtès
parent 1011599792
commit 93c0c75658
2 changed files with 17 additions and 3 deletions

View file

@ -582,13 +582,22 @@ scm_read_mixed_case_symbol (int chr, SCM port)
if (scm_is_pair (str)) if (scm_is_pair (str))
{ {
size_t len;
str = scm_string_concatenate (scm_reverse_x (str, SCM_EOL)); 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. */ /* Per SRFI-88, `:' alone is an identifier, not a keyword. */
if (postfix && ends_with_colon && (scm_c_string_length (result) > 1)) 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); result = scm_symbol_to_keyword (result);
} }
else
result = scm_string_to_symbol (str);
}
else else
{ {
/* For symbols smaller than `sizeof (buffer)', we don't need to recur /* For symbols smaller than `sizeof (buffer)', we don't need to recur

View file

@ -165,6 +165,11 @@
(with-read-options '(keywords postfix) (with-read-options '(keywords postfix)
(lambda () (lambda ()
(read-string "keyword:"))))) (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)" (pass-if "`:' is not a postfix keyword (per SRFI-88)"
(eq? ': (eq? ':
(with-read-options '(keywords postfix) (with-read-options '(keywords postfix)