diff --git a/libguile/read.c b/libguile/read.c index 4cdde4ab2..dcd37e1d9 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -580,13 +580,7 @@ scm_read_string (int chr, SCM port) scm_i_string_set_x (str, c_str_len++, c); scm_i_string_stop_writing (); } - - if (c_str_len > 0) - { - return scm_i_substring_copy (str, 0, c_str_len); - } - - return scm_nullstr; + return scm_i_substring_copy (str, 0, c_str_len); } #undef FUNC_NAME diff --git a/test-suite/tests/srfi-13.test b/test-suite/tests/srfi-13.test index 5575a700f..de6df8e52 100644 --- a/test-suite/tests/srfi-13.test +++ b/test-suite/tests/srfi-13.test @@ -1,7 +1,7 @@ ;;;; srfi-13.test --- Test suite for Guile's SRFI-13 functions. -*- scheme -*- ;;;; Martin Grabmueller, 2001-05-07 ;;;; -;;;; Copyright (C) 2001, 2004, 2005, 2006, 2011 Free Software Foundation, Inc. +;;;; Copyright (C) 2001, 2004, 2005, 2006, 2011, 2012 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -561,13 +561,15 @@ (with-test-prefix "substring/shared" (pass-if "empty string" - (eq? "" (substring/shared "" 0))) - - (pass-if "non-empty string" - (string=? "foo" (substring/shared "foo-bar" 0 3))) + (let ((s "")) + (eq? s (substring/shared s 0)))) (pass-if "non-empty string, not eq?" - (string=? "foo-bar" (substring/shared "foo-bar" 0 7)))) + (string=? "foo" (substring/shared "foo-bar" 0 3))) + + (pass-if "shared copy of non-empty string is eq?" + (let ((s "foo-bar")) + (eq? s (substring/shared s 0 7))))) (with-test-prefix "string-copy!"