summaryrefslogtreecommitdiff
path: root/libguile/generalized-arrays.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-01-07 16:40:13 +0100
committerAndy Wingo <wingo@pobox.com>2010-01-07 16:40:13 +0100
commitcf9a806dbd8fc58caafefbb4a5328fac2d322cee (patch)
treeaade284ae33d0563f456c0e49b8f6cb100effd6b /libguile/generalized-arrays.c
parent8ffcf6e725f97a4f3480ef6583743d7786e42997 (diff)
downloadguile-cf9a806dbd8fc58caafefbb4a5328fac2d322cee.tar.gz
fix array->list
* libguile/generalized-arrays.c (array_to_list): Fix buggy implementation. Thanks to Daniel Llorens del Río for the bug repor.
Diffstat (limited to 'libguile/generalized-arrays.c')
-rw-r--r--libguile/generalized-arrays.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libguile/generalized-arrays.c b/libguile/generalized-arrays.c
index 8bbbed4d1..ea5388d83 100644
--- a/libguile/generalized-arrays.c
+++ b/libguile/generalized-arrays.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 2009, 2010 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 License
@@ -243,14 +243,13 @@ array_to_list (scm_t_array_handle *h, size_t dim, unsigned long pos)
{
SCM res = SCM_EOL;
long inc;
- size_t i, lbnd;
+ size_t i;
- i = h->dims[dim].ubnd;
- lbnd = h->dims[dim].lbnd;
+ i = h->dims[dim].ubnd - h->dims[dim].lbnd + 1;
inc = h->dims[dim].inc;
- pos += (i - h->dims[dim].ubnd) * inc;
+ pos += (i - 1) * inc;
- for (; i >= lbnd; i--, pos -= inc)
+ for (; i > 0; i--, pos -= inc)
res = scm_cons (array_to_list (h, dim + 1, pos), res);
return res;
}