Make literal strings (i.e., returned by `read') read-only.
authorLudovic Courtès <ludo@gnu.org>
Mon, 22 Sep 2008 21:03:20 +0000 (23:03 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 23 Sep 2008 16:45:27 +0000 (18:45 +0200)
commitfb2f8886c4d537b0c7d3e9e78a8d4e5e272a36f4
tree16d6bbddb4c7ef0078f727dfb991e23fda94a79a
parentfd2b17b9cb7aaa6b550ad9b6a3efe3c53c94ccce
Make literal strings (i.e., returned by `read') read-only.

* libguile/read.c (scm_read_string): Use `scm_i_make_read_only_string ()' to
  return a read-only string, as mandated by R5RS.  Reported by Bill
  Schottstaedt <bil@ccrma.Stanford.EDU>.

* libguile/strings.c (scm_i_make_read_only_string): New function.
  (scm_i_shared_substring_read_only): Special-case the empty string
  so that the read-only and read-write empty strings are `eq?'.  This
  optimization is relied on by the `substring/shared' `empty string'
  test case in `srfi-13.test'.

* libguile/strings.h (scm_i_make_read_only_string): New declaration.

* test-suite/tests/strings.test ("string-set!")["literal string"]: New test.

* NEWS: Update.
NEWS
libguile/read.c
libguile/strings.c
libguile/strings.h
test-suite/tests/strings.test