unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Symbols and keywords longer than 128 chars cause exception
@ 2009-04-25  5:47 Mike Gran
  2009-04-28 20:14 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Gran @ 2009-04-25  5:47 UTC (permalink / raw)
  To: Guile Devel

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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-28 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-25  5:47 [PATCH] Symbols and keywords longer than 128 chars cause exception Mike Gran
2009-04-28 20:14 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).