1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

11 commits

Author SHA1 Message Date
Daniel Llorens
3bfd4aaa6e Fix sort, sort! for arrays with nonzero lower bound
* module/ice-9/arrays.scm (array-copy): New function, export.
* module/Makefile.am: Install (ice-9 arrays).
* doc/ref/api-data.texi: Add documentation for (ice-9 arrays).
* libguile/quicksort.i.c: Use signed bounds throughout.
* libguile/sort.c (scm_restricted_vector_sort_x): Fix error calls. Fix
  calls to quicksort.
* test-suite/tests/sort.test: Actually test that the sorted results
  match the original data. Test cases for non-zero base index arrays for
  sort, sort!, and stable-sort!.
2017-10-31 13:23:17 +01:00
Daniel Llorens
4212f29655 Allow scm_XXX_writable_elements on empty vectors, even if immutable
* libguile/array-handle.c (initialize_vector_handle): Set both element
  pointers to NULL if the vector is empty.
* libguile/array-map.c (racp): Ignore immutability if destination is
  empty.
* test-suite/tests/sort.test: Check empty/mutable/immutable vectors with
  sort!.
* test-suite/tests/array-map.test: Check array-copy! with
  empty/immutable destination.
2017-10-31 13:23:17 +01:00
Daniel Llorens
fa40c288ca Support typed arrays in some sort functions
* libguile/sort.c (sort!, sort, restricted-vector-sort!, sorted?):
  Support arrays of rank 1, whatever the type.

* libguile/quicksort.i.c: Fix accessors to handle typed arrays.

* test-suite/tests/sort.test: Test also with typed arrays.
2016-11-23 11:49:35 +01:00
Andreas Rottmann
589bc528bd Fix likely crash in `stable-sort!'
* libguile/sort.c (scm_stable_sort_x): Properly handle zero-length
  vectors.
* test-suite/tests/sort.test ("stable-sort"): Add test for this case.
2011-06-09 22:11:02 +02:00
Andy Wingo
95e5998204 gut trampolines
* libguile/eval.c: Gut the trampoline implementation. We'll be doing
  much more clever things here that will obviate the need for the
  procedure arg of map and for-each to be allocated in many cases...
  trampolines were a noble attempt at optimizing in the wrong place.

* srfi/srfi-1.c (scm_srfi1_lset_difference_x): Validate that we get a
  proc, because the trampoline won't do it for us.

* test-suite/tests/sort.test ("sort"):
* test-suite/tests/srfi-1.test ("count", "fold", "list-index"):
  Change expected exceptions, due to trampoline functions not doing any
  computation.
2009-12-01 21:00:23 +01:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Kevin Ryde
004be623c4 merge from 1.8 branch 2007-03-07 23:00:22 +00:00
Kevin Ryde
6e7d5622ee merge from 1.8 branch 2006-04-16 23:37:40 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Marius Vollmer
42fc3f2c76 New tests, especially for sorting non-contigous and
negative-incrementing vectors.
2005-01-02 21:03:12 +00:00
Dirk Herrmann
d339981a5a * test-suite/tests/sort.test: Added. Both tests in that file did
fail (one even with a segfault) with CVS guile before the recent
	changes to libguile/sort.c.

	* libguile/sort.c: Replaced hand-made trampline code by the new
	official mechanism from eval.c.  This fixes a segfault in the new
	test file test-suite/tests/sort.test.

	(quicksort, compare_function, scm_restricted_vector_sort_x,
	scm_sorted_p, scm_merge, scm_merge_list_x, scm_merge_x,
	scm_merge_list_step, scm_sort_x, scm_sort, scm_merge_vector_x,
	scm_merge_vector_step, scm_stable_sort_x, scm_stable_sort,
	scm_sort_list_x, scm_sort_list): Use trampoline mechanism from
	eval.c.

	(subr2less, lsubrless, closureless, applyless, scm_cmp_function,
	cmp_fun_t): Removed.

	(compare_function): Added.

	* libguile/sort.c (quicksort, SWAP, stack_node): Replaced pointer
	arithmetics with index arithmetics.  Changed quicksort to work on
	an array of SCM values instead of an array of characters.  Avoid
	bytewise copying of SCM elements.  Avoid allocating memory on the
	stack with alloca.  Fixed some comments.
2003-04-22 23:32:40 +00:00