summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-04 06:51:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-04 06:51:17 +0000
commit612b2ed6a751629b2809e58a8f42a56e8690e8c7 (patch)
tree6dce132edc9cddce0c13dd14f135c6a081f737c8 /array.c
parent137edebc4a25c1483ba38f905b2171c8612fe54b (diff)
* array.c (rb_ary_permutation): remove C99 dependency.
[ruby-dev:31934] * array.c (rb_ary_product): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/array.c b/array.c
index 2d99d14956..a75def20b8 100644
--- a/array.c
+++ b/array.c
@@ -3019,10 +3019,11 @@ permute0(long n, long r, long *p, long index, int *used, VALUE values)
static VALUE
rb_ary_permutation(VALUE ary, VALUE num)
{
+ long r, n, i;
+
RETURN_ENUMERATOR(ary, 1, &num); /* Return enumerator if no block */
- long r = NUM2LONG(num); /* Permutation size from argument */
- long n = RARRAY_LEN(ary); /* Array length */
- long i;
+ r = NUM2LONG(num); /* Permutation size from argument */
+ n = RARRAY_LEN(ary); /* Array length */
if (r < 0 || n < r) {
/* no permutations: yield nothing */
@@ -3151,8 +3152,10 @@ static VALUE
rb_ary_product(int argc, VALUE *argv, VALUE ary)
{
int n = argc+1; /* How many arrays we're operating on */
- VALUE arrays[n]; /* The arrays we're computing the product of */
- int counters[n]; /* The current position in each one */
+ volatile VALUE t0 = rb_str_new(0, n*sizeof(VALUE));
+ volatile VALUE t1 = rb_str_new(0, n*sizeof(int));
+ VALUE *arrays = (VALUE*)RSTRING_PTR(t0); /* The arrays we're computing the product of */
+ int *counters = (int*)RSTRING_PTR(t1); /* The current position in each one */
VALUE result; /* The array we'll be returning */
long i,j;