unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mike Gran <spk121@yahoo.com>
To: Guile Devel <guile-devel@gnu.org>
Subject: [PATCH] Symbols and keywords longer than 128 chars cause exception
Date: Fri, 24 Apr 2009 22:47:05 -0700	[thread overview]
Message-ID: <1240638425.3133.182.camel@localhost.localdomain> (raw)

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





             reply	other threads:[~2009-04-25  5:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-25  5:47 Mike Gran [this message]
2009-04-28 20:14 ` [PATCH] Symbols and keywords longer than 128 chars cause exception Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1240638425.3133.182.camel@localhost.localdomain \
    --to=spk121@yahoo.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).