1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-13 15:10:34 +02:00

Regression, scm_string fails to test for circular lists

* libguile/string.c (scm_string): Restores the functionality
  where scm_string tests for circular lists

* test-suite/tests/strings.test: add test for circular lists
This commit is contained in:
Michael Gran 2009-08-12 09:21:37 -07:00
parent bd4911efd2
commit 3c7cf7f5c0
2 changed files with 12 additions and 1 deletions

View file

@ -1015,10 +1015,11 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
/* Verify that this is a list of chars. */ /* Verify that this is a list of chars. */
i = scm_ilength (chrs); i = scm_ilength (chrs);
SCM_ASSERT (i >= 0, chrs, SCM_ARG1, FUNC_NAME);
len = (size_t) i; len = (size_t) i;
rest = chrs; rest = chrs;
SCM_ASSERT (len >= 0, chrs, SCM_ARG1, FUNC_NAME);
while (len > 0 && scm_is_pair (rest)) while (len > 0 && scm_is_pair (rest))
{ {
SCM elt = SCM_CAR (rest); SCM elt = SCM_CAR (rest);

View file

@ -447,6 +447,16 @@
(string-set! s 4 (integer->char #x010300)) (string-set! s 4 (integer->char #x010300))
(char=? (string-ref s 4) (integer->char #x010300))))) (char=? (string-ref s 4) (integer->char #x010300)))))
;;
;; list->string
;;
(with-test-prefix "string"
(pass-if-exception "convert circular list to string"
exception:wrong-type-arg
(let ((foo (list #\a #\b #\c)))
(set-cdr! (cddr foo) (cdr foo))
(apply string foo))))
(with-test-prefix "string-split" (with-test-prefix "string-split"