diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 402597124..13e0836a3 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,10 @@ +2007-01-19 Ludovic Courtès + + * struct.c (scm_i_struct_equalp): Skip comparison if both FIELD1 + is equal to S1 and FIELD2 is equal to S2. This avoids infinite + recursion when comparing `s' fields, as the REQUIRED_VTABLE_FIELDS + added by `make-vtable-vtable'. Reported by Marco Maggi. + 2007-01-16 Kevin Ryde * feature.c, feature.h (scm_set_program_arguments_scm): New function, @@ -104,13 +111,13 @@ * posix.c (scm_crypt): Check for NULL return from crypt(), which the linux man page says is a possibility. -2006-12-12 Ludovic Courtès +2006-12-12 Ludovic Courtès * libguile/unif.c (read_decimal_integer): Let RESP be SIGN * RES - instead of RES (reported by Gyula Szavai). This allows the use of + instead of RES (reported by Szavai Gyula). This allows the use of negative lower bounds. (scm_i_read_array): Make sure LEN is non-negative (reported by - Gyula Szavai). + Szavai Gyula). (scm_array_in_bounds_p): Iterate over S instead of always comparing indices with the bounds of S[0]. This fixes @@ -131,7 +138,7 @@ Makefile stopped it having any effect. Use just $(AWK), which can be overridden with "make AWK=xxx" in the usual way if desired. -2006-11-29 Ludovic Courtès +2006-11-29 Ludovic Courtès * libguile/vectors.c (scm_vector_to_list): Fixed list construction: elements were not copied when INC is zero (see @@ -185,7 +192,7 @@ * numbers.c, numbers.h (scm_log, scm_log10, scm_exp, scm_sqrt): New functions. -2006-09-20 Ludovic Courtès +2006-09-20 Ludovic Courtès * srfi-14.c: Include . Define `_GNU_SOURCE'. (make_predset, define_predset, make_strset, define_strset, false, @@ -261,7 +268,7 @@ arrangements and avoid an illegal instruction during call-with-current-continuation. -2006-07-12 Ludovic Courtès +2006-07-12 Ludovic Courtès * numbers.c (guile_ieee_init): Use regular ANSI C casts rather than C++-style `X_CAST ()'. Patch posted by by Mike Gran. @@ -285,7 +292,7 @@ (scm_strptime): Use tm_gmtoff from the strptime result when that field exists, it's set by glibc strptime "%s". -2006-06-13 Ludovic Courtès +2006-06-13 Ludovic Courtès * eq.c: Include "struct.h", "goops.h" and "objects.h". (scm_equal_p): Invoke `scm_i_struct_equalp ()' on structures that @@ -423,7 +430,7 @@ 2006-04-06 Kevin Ryde * fports.c (scm_setvbuf): Fix for not _IOLBF, clear SCM_BUFLINE - instead of toggling it. Reported by Ludovic Courtès. + instead of toggling it. Reported by Ludovic Courtès. 2006-03-26 Marius Vollmer @@ -435,7 +442,7 @@ * gc_os_dep.c (scm_get_stack_base): Abort when the machine type is unknown instead of returning NULL. -2006-03-21 Ludovic Courtès +2006-03-21 Ludovic Courtès * numbers.c (scm_i_mem2number): Renamed to scm_c_locale_stringn_to_number. @@ -494,7 +501,7 @@ scm_t_uint64 and scm_t_uint32 instead of scm_t_int64 and scm_t_int32. -2006-02-14 Ludovic Courtès +2006-02-14 Ludovic Courtès * strings.c (scm_i_take_stringbufn): Register LEN+1 bytes instead of LEN. Without this, too much collectable memory gets unregistered, @@ -612,7 +619,7 @@ * inline.h, pairs.c (scm_is_pair): Moved scm_is_pair from pairs.c to inline.h to make it inline. -2005-12-19 Ludovic Courtès +2005-12-19 Ludovic Courtès * strings.c (scm_i_take_stringbufn): New. (scm_i_c_take_symbol): New. @@ -645,7 +652,7 @@ 2005-12-29 Neil Jerram - * fluids.c (next_fluid_num): [From Ludovic Courtès:] Don't trigger + * fluids.c (next_fluid_num): [From Ludovic Courtès:] Don't trigger the GC when allocated_fluids_len is zero. 2005-12-14 Neil Jerram @@ -677,7 +684,7 @@ * srfi-4.h, srfi-4.c, srfi-4.i.c (take_uvec): Make BASE pointer non-const. - (scm_take_u8vector, etc): Likewise. Thanks to Ludovic Courtès! + (scm_take_u8vector, etc): Likewise. Thanks to Ludovic Courtès! * threads.h, threads.c (scm_t_guile_ticket, scm_leave_guile, scm_enter_guile): Removed from public API. See comment at @@ -692,7 +699,7 @@ * eval.c (scm_m_cond): Recognize SRFI 61 cond syntax. (CEVAL): Evaluate SRFI 61 cond clauses. -2005-12-06 Ludovic Courtès +2005-12-06 Ludovic Courtès * gc-card.c (scm_i_card_statistics): Return if BITVEC is NULL. This was typically hit when running `gc-live-object-stats' right @@ -706,7 +713,7 @@ 2005-11-26 Kevin Ryde * gc-mark.c (scm_mark_all): Change C++ comment to C comment. Reported - by Ludovic Courtès. + by Ludovic Courtès. * list.c (list): Should be "primitive" in SCM_SNARF_DOCS, not "register". @@ -718,7 +725,7 @@ * socket.c (scm_fill_sockaddr): Remove SCM_C_INLINE_KEYWORD, this is much too big to want to inline. -2005-11-17 Ludovic Courtès +2005-11-17 Ludovic Courtès * print.c (EXIT_NESTED_DATA): Before popping from the stack, reset the value at its top. This fixes a reference leak. @@ -726,14 +733,14 @@ `PSTATE_STACK_SET ()' in order to avoid undesired potential side effects. -2005-11-12 Ludovic Courtès +2005-11-12 Ludovic Courtès * gc.c (scm_weak_vectors): Removed. 2005-11-12 Kevin Ryde * socket.c (scm_setsockopt): Missing @defvar in docstring. Reported - by Ludovic Courtès. + by Ludovic Courtès. 2005-11-07 Marius Vollmer @@ -755,7 +762,7 @@ * debug.h (SCM_CHEAPTRAPS_P): Removed. -2005-10-27 Ludovic Courtès +2005-10-27 Ludovic Courtès * socket.c (scm_fill_sockaddr): No need to check NULL from scm_malloc. (scm_connect, scm_bind, scm_sendto): Accept sockaddr object. @@ -1063,7 +1070,7 @@ 2005-05-11 Neil Jerram - Fix C99isms reported by Ludovic Courtès: + Fix C99isms reported by Ludovic Courtès: * threads.c (s_scm_lock_mutex): Don't declare msg in middle of code. @@ -1178,7 +1185,7 @@ 2005-03-18 Kevin Ryde * arbiters.c (FETCH_STORE) [generic C]: Should be - scm_i_scm_pthread_mutex_lock/unlock now. Reported by Ludovic Courtès. + scm_i_scm_pthread_mutex_lock/unlock now. Reported by Ludovic Courtès. 2005-03-13 Kevin Ryde @@ -2324,7 +2331,7 @@ 2004-11-02 Marius Vollmer - Mac OS X and OpenBSD compatibility patches from Andreas Vögele. + Mac OS X and OpenBSD compatibility patches from Andreas Vögele. Thanks! * backtrace.c (scm_display_backtrace_with_highlights): Join the @@ -2768,7 +2775,7 @@ * numbers.h, numbers.c: Include in numbers.h, not in numbers.c. (scm_to_mpz, scm_from_mpz): New. - Thanks to Andreas Vögele! + Thanks to Andreas Vögele! * read.c (skip_scsh_block_comment): Recognize "!#" everywhere, not just on a line of its own. @@ -2777,7 +2784,7 @@ scm_string_tabulate, string_upcase_x, string_down_case_x, string_titlecase_x, string_reverse_x, scm_string_tokenize): Use size_t instead of int for indices into strings. Make sure that no - over- or underflow occurs. Thanks to Andreas Vögele! + over- or underflow occurs. Thanks to Andreas Vögele! (scm_xsubstring, scm_string_xcopy_x): Use ints for 'extended' indices, which can also be negative. @@ -2799,7 +2806,7 @@ * filesys.c, stime.c (_POSIX_C_SOURCE): Use this only on hpux, it causes too many problems elsewhere (glibc, freebsd, mingw). Reported - by Andreas Vögele. + by Andreas Vögele. 2004-09-08 Marius Vollmer @@ -3634,7 +3641,7 @@ * gc_os_dep.c: update ifdefery for macosx. (scm_get_stack_base): separate result initialization from declaration to slience warnings with macosx and hp-ux using gcc - 3.3. Thanks to Andreas Vögele. + 3.3. Thanks to Andreas Vögele. 2004-06-13 Han-Wen Nienhuys @@ -3844,10 +3851,10 @@ 2004-05-02 Kevin Ryde * eval.c (scm_macroexp): Add prototype, since it's not in eval.h under - --disable-deprecated. Reported by Andreas Vögele. + --disable-deprecated. Reported by Andreas Vögele. * filesys.c (_POSIX_C_SOURCE): Define to 199506L to get readdir_r (in - particular on HP-UX). Reported by Andreas Vögele. + particular on HP-UX). Reported by Andreas Vögele. * list.c (varargs.h): Remove, leave just stdarg.h which is all the code has support for. Fixes building with AIX cc, which is ansi but @@ -3858,14 +3865,14 @@ 2004-05-01 Kevin Ryde * continuations.c (scm_dynthrow): Use >= instead of SCM_PTR_GE which - is now gone. Reported by Andreas Vögele. + is now gone. Reported by Andreas Vögele. 2004-04-28 Kevin Ryde * backtrace.c (display_frame_expr), numbers.c (XDIGIT2UINT, mem2uinteger, mem2decimal_from_point, mem2ureal): Cast char to int for ctype.h tests, to avoid warnings from gcc on HP-UX about char as array - subscript. Reported by Andreas Vögele. + subscript. Reported by Andreas Vögele. Also cast through unsigned char to avoid passing negatives to those macros if input contains 8-bit values. @@ -3879,17 +3886,17 @@ * numbers.c (scm_bit_extract): Use min instead of MIN. (MIN): Remove, this conflicts with similar macro defined by limits.h - on HP-UX. Reported by Andreas Vögele. + on HP-UX. Reported by Andreas Vögele. * stime.c (_POSIX_C_SOURCE): Define to 199506L to get gmtime_r (in - particular on HP-UX). Reported by Andreas Vögele. + particular on HP-UX). Reported by Andreas Vögele. * threads.c (scm_threads_mark_stacks): Correction sizet -> size_t. - Reported by Andreas Vögele. + Reported by Andreas Vögele. * threads-plugin.h (SCM_MUTEX_MAXSIZE): Increase to 25*sizeof(long), for the benefit of hpux11 where pthread_mutex_t is 88 bytes. Reported - by Andreas Vögele. + by Andreas Vögele. 2004-04-22 Dirk Herrmann @@ -7742,7 +7749,7 @@ 2002-08-26 Marius Vollmer * script.c (scm_compile_shell_switches): Added "2002" to Copyright - years. Thanks to Martin Grabmüller! + years. Thanks to Martin Grabmüller! 2002-08-25 Han-Wen Nienhuys @@ -9658,7 +9665,7 @@ * deprecation.c (scm_include_deprecated_features): Simplified. * eval.c (EVALCAR, unmemocopy), eval.h (SCM_XEVALCAR): Use - `SCM_IMP' instead of `!SCM_CELLP´. + `SCM_IMP' instead of `!SCM_CELLP´. * eval.c (unmemocopy): Eliminate redundant SCM_CELLP tests. Extract side-effecting operations from macros. @@ -10699,7 +10706,7 @@ 2001-06-09 Marius Vollmer * ports.c (scm_lfwrite): Maintain columnd and row count in port. - Thanks to Matthias Köppe! + Thanks to Matthias Köppe! 2001-06-08 Michael Livshin @@ -10707,7 +10714,7 @@ space-happy C preprocessors. * filter-doc-snarfage.c, guile-snarf.in: try to cope with spaces - inside cookies. thanks to Matthias Köppe! + inside cookies. thanks to Matthias Köppe! 2001-06-08 Dirk Herrmann @@ -11282,7 +11289,7 @@ SCM_VARIABLE_INIT since that it what it used to be. * deprecation.c (scm_include_deprecated_features): Make docstring - ANSIsh. Thanks to Matthias Köppe! + ANSIsh. Thanks to Matthias Köppe! 2001-05-21 Marius Vollmer @@ -11636,7 +11643,7 @@ 2001-05-15 Marius Vollmer * values.c (print_values): Print as a unreadable object, not as - multiple lines. Thanks to Matthias Köppe! + multiple lines. Thanks to Matthias Köppe! 2001-05-14 Dirk Herrmann @@ -11668,7 +11675,7 @@ 2001-05-09 Michael Livshin - from Matthias Köppe (thanks!): + from Matthias Köppe (thanks!): * ports.c (scm_c_read): pointer arithmetic on void pointers isn't portable. @@ -13525,7 +13532,7 @@ 2001-01-11 Michael Livshin - from Matthias Köppe: + from Matthias Köppe: * objects.h (SCM_SET_ENTITY_SETTER): new macro. SCM_ENTITY_SETTER casts its result, so doesn't yield an lvalue per ANSI C. @@ -13594,3 +13601,7 @@ (write_all): new helper procedure. The ChangeLog continues in the file: "ChangeLog-2000" + +;; Local Variables: +;; coding: utf-8 +;; End: diff --git a/libguile/struct.c b/libguile/struct.c index de8667d45..69ec7e634 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -564,10 +564,15 @@ scm_i_struct_equalp (SCM s1, SCM s2) field1 = scm_struct_ref (s1, s_field_num); field2 = scm_struct_ref (s2, s_field_num); - if (scm_is_false (scm_equal_p (field1, field2))) - return SCM_BOOL_F; + /* Self-referencing fields (type `s') must be skipped to avoid infinite + recursion. */ + if (!(scm_is_eq (field1, s1) && (scm_is_eq (field2, s2)))) + if (scm_is_false (scm_equal_p (field1, field2))) + return SCM_BOOL_F; } + /* FIXME: Tail elements should be tested for equality. */ + return SCM_BOOL_T; } #undef FUNC_NAME diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 0751dbd10..248645452 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,11 @@ +2007-01-19 Ludovic Courtès + + * tests/eval.test (values): New test prefix. Values are structs, + and `equal?' on structs with `s' fields used to yield infinite + recursion. + * tests/structs.test (equal?): New test prefix. Added tests that + used to show the infinite recursion problem. + 2007-01-16 Kevin Ryde * tests/regexp.test (regexp-exec): Further tests, in particular #\nul @@ -11,7 +19,7 @@ * tests/numbers.test (*): Exercise multiply by exact 0 giving exact 0. -2006-12-12 Ludovic Courtès +2006-12-12 Ludovic Courtès * tests/unif.test (syntax): New test prefix. Check syntax for negative lower bounds and negative lengths (reported by Gyula @@ -38,13 +46,13 @@ ensure intended exact vs inexact is checked. Reported by Aaron M. Ucko, Debian bug 396119. -2006-11-29 Ludovic Courtès +2006-11-29 Ludovic Courtès * test-suite/tests/vectors.test: Use `define-module'. (vector->list): New test prefix. "Shared array" test contributed by Szavai Gyula. -2006-10-26 Ludovic Courtès +2006-10-26 Ludovic Courtès * tests/srfi-14.test (Latin-1)[char-set:punctuation]: Fixed a typo: `thrown' instead of `throw'. @@ -75,7 +83,7 @@ the error+thread tests seem ok now (previously were upset by something leaking out of syntax.test). -2006-09-20 Ludovic Courtès +2006-09-20 Ludovic Courtès * tests/srfi-14.test: Use `define-module'. Use modules `(srfi srfi-1)' and `(test-suite lib)'. @@ -120,7 +128,7 @@ * tests/time.test (localtime, mktime, strptime): More tests. -2006-06-13 Ludovic Courtès +2006-06-13 Ludovic Courtès * Makefile.am (SCM_TESTS): Added `tests/structs.test'. * tests/structs.test: New file. @@ -183,7 +191,7 @@ * tests/unif.test (make-shared-array): Add example usages from the manual, two of which currently fail. -2006-03-04 Ludovic Courtès +2006-03-04 Ludovic Courtès * test-suite/tests/modules.test: New file. * test-suite/Makefile.am (SCM_TESTS): Added it. @@ -231,7 +239,7 @@ * tests/srfi-1.test (lset-difference!): More tests. -2005-10-27 Ludovic Courtès +2005-10-27 Ludovic Courtès * tests/socket.test (make-socket-address): New tests. (connect, bind, sendto): Exercise sockaddr object. @@ -762,7 +770,7 @@ * lib.scm (exception:numerical-overflow): New define. * tests/numbers.test (modulo-expt): Use it and exception:wrong-type-arg, avoiding empty "" regexp which is invalid on - BSD. Reported by Andreas Vögele. + BSD. Reported by Andreas Vögele. 2004-05-29 Dirk Herrmann @@ -787,12 +795,12 @@ * tests/srfi-19.test (test-dst, string->date local DST): Test with "EST5EDT" instead of "CET", since HP-UX doesn't know CET. Reported by - Andreas Vögele. + Andreas Vögele. 2004-05-03 Kevin Ryde * tests/time.test (strftime): Force tm:isdst to 0 for the test, for - the benefit of HP-UX. Reported by Andreas Vögele. + the benefit of HP-UX. Reported by Andreas Vögele. Use set-tm:zone rather than a hard coded vector offset. 2004-04-29 Dirk Herrmann @@ -1733,7 +1741,7 @@ 2001-06-16 Marius Vollmer - Thanks to Matthias Köppe! + Thanks to Matthias Köppe! * tests/ports.test: New test for output port line counts. * tests/format.test, tests/optargs.test, tests/srfi-19.test: New @@ -2327,3 +2335,7 @@ Fri Dec 17 12:14:10 1999 Greg J. Badros * lib.scm, guile-test, paths.scm: Log begins. + +;; Local Variables: +;; coding: utf-8 +;; End: diff --git a/test-suite/tests/eval.test b/test-suite/tests/eval.test index 99beca418..519e2c0a1 100644 --- a/test-suite/tests/eval.test +++ b/test-suite/tests/eval.test @@ -1,5 +1,5 @@ ;;;; eval.test --- tests guile's evaluator -*- scheme -*- -;;;; Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. +;;;; Copyright (C) 2000, 2001, 2006, 2007 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 @@ -315,5 +315,20 @@ '(a b c d e f g h i j k l m n o p q r s t u v w x y z)))) +;;; +;;; values +;;; + +(with-test-prefix "values" + + (pass-if "single value" + (equal? 1 (values 1))) + + (pass-if "call-with-values" + (equal? (call-with-values (lambda () (values 1 2 3 4)) list) + '(1 2 3 4))) + + (pass-if "equal?" + (equal? (values 1 2 3 4) (values 1 2 3 4)))) ;;; eval.test ends here diff --git a/test-suite/tests/structs.test b/test-suite/tests/structs.test index 050eb4224..5df4665a3 100644 --- a/test-suite/tests/structs.test +++ b/test-suite/tests/structs.test @@ -1,7 +1,7 @@ ;;;; structs.test --- Test suite for Guile's structures. -*- Scheme -*- ;;;; Ludovic Courtès , 2006-06-12. ;;;; -;;;; Copyright (C) 2006 Free Software Foundation, Inc. +;;;; Copyright (C) 2006, 2007 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 @@ -18,7 +18,8 @@ ;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;;;; Boston, MA 02110-1301 USA -(use-modules (test-suite lib)) +(define-module (test-suite test-structs) + :use-module (test-suite lib)) @@ -80,15 +81,27 @@ (pass-if "struct-set!" (let ((ball (make-ball green "Bob"))) (set-owner! ball "Bill") - (string=? (owner ball) "Bill"))) + (string=? (owner ball) "Bill")))) - (pass-if "equal?" + +(with-test-prefix "equal?" + + (pass-if "simple structs" + (let* ((vtable (make-vtable-vtable "pr" 0)) + (s1 (make-struct vtable 0 "hello")) + (s2 (make-struct vtable 0 "hello"))) + (equal? s1 s2))) + + (pass-if "more complex structs" (let ((first (make-ball red (string-copy "Bob"))) - (second (make-ball red (string-copy "Bob")))) + (second (make-ball red (string-copy "Bob")))) (equal? first second))) (pass-if "not-equal?" - (not (or (equal? (make-ball red "Bob") (make-ball green "Bill")) + (not (or (equal? (make-ball red "Bob") (make-ball green "Bob")) (equal? (make-ball red "Bob") (make-ball red "Bill")))))) +;;; Local Variables: +;;; coding: latin-1 +;;; End: