summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2008-09-22 22:51:36 +0200
committerLudovic Courtès <ludo@gnu.org>2008-09-23 18:44:27 +0200
commitfd2b17b9cb7aaa6b550ad9b6a3efe3c53c94ccce (patch)
tree02aa2b139dcf907ded34e5e03477f5dcaedf806c
parent1dd797921c950f0a4d396faa6d7326ec6928e771 (diff)
downloadguile-fd2b17b9cb7aaa6b550ad9b6a3efe3c53c94ccce.tar.gz
Make `symbol->string' return a read-only string.
* libguile/strings.c (scm_i_symbol_substring): Return a read-only string since R5RS requires `symbol->string' to return a read-only string. Reported by Bill Schottstaedt <bil@ccrma.Stanford.EDU>. * test-suite/tests/symbols.test: Add `define-module' clause. (exception:immutable-string): Adjust to current exception. ("symbol->string")["result is an immutable string"]: Use `pass-if-exception' instead of `expect-fail-exception'. * NEWS: Update.
-rw-r--r--NEWS1
-rw-r--r--libguile/strings.c2
-rw-r--r--test-suite/tests/symbols.test12
3 files changed, 8 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 3e7c6df3f..f9d3095e1 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ available: Guile is now always configured in "maintainer mode".
* Bugs fixed
+** `symbol->string' now returns a read-only string, as per R5RS
** `guile-config link' now prints `-L$libdir' before `-lguile'
** Fix memory corruption involving GOOPS' `class-redefinition'
** Fix possible deadlock in `mutex-lock'
diff --git a/libguile/strings.c b/libguile/strings.c
index 4d387fb51..7399d8831 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -491,7 +491,7 @@ scm_i_symbol_substring (SCM sym, size_t start, size_t end)
scm_i_pthread_mutex_lock (&stringbuf_write_mutex);
SET_STRINGBUF_SHARED (buf);
scm_i_pthread_mutex_unlock (&stringbuf_write_mutex);
- return scm_double_cell (STRING_TAG, SCM_UNPACK(buf),
+ return scm_double_cell (RO_STRING_TAG, SCM_UNPACK (buf),
(scm_t_bits)start, (scm_t_bits) end - start);
}
diff --git a/test-suite/tests/symbols.test b/test-suite/tests/symbols.test
index b57667f7f..3fe3402f8 100644
--- a/test-suite/tests/symbols.test
+++ b/test-suite/tests/symbols.test
@@ -1,6 +1,6 @@
;;;; symbols.test --- test suite for Guile's symbols -*- scheme -*-
;;;;
-;;;; Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+;;;; Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@@ -17,17 +17,17 @@
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;;;; Boston, MA 02110-1301 USA
-(use-modules (ice-9 documentation))
+(define-module (test-suite test-symbols)
+ #:use-module (test-suite lib)
+ #:use-module (ice-9 documentation))
;;;
;;; miscellaneous
;;;
-;; FIXME: As soon as guile supports immutable strings, this has to be
-;; replaced with the appropriate error type and message.
(define exception:immutable-string
- (cons 'some-error-type "^trying to modify an immutable string"))
+ (cons 'misc-error "^string is read-only"))
(define (documented? object)
(not (not (object-documentation object))))
@@ -55,7 +55,7 @@
(with-test-prefix "symbol->string"
- (expect-fail-exception "result is an immutable string"
+ (pass-if-exception "result is an immutable string"
exception:immutable-string
(string-set! (symbol->string 'abc) 1 #\space)))