From 5ece8d5d8a03536f45756ae6d629896d19cfe233 Mon Sep 17 00:00:00 2001 From: Henrik Wallin <hedda@lysator.liu.se> Date: Tue, 14 Apr 1998 17:48:09 +0200 Subject: [PATCH] Transpose rewritten in C. splice and everynth added. And it know even compile at Idonex too :-) Rev: src/builtin_functions.c:1.95 --- src/builtin_functions.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/builtin_functions.c b/src/builtin_functions.c index b24d1af402..49a79e249b 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.94 1998/04/14 15:08:44 hedda Exp $"); +RCSID("$Id: builtin_functions.c,v 1.95 1998/04/14 15:48:09 hedda Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -2567,11 +2567,12 @@ void f_splice(INT32 args) } if (i<0) + { if (sp[i].type!=T_ARRAY) error("Illegal argument 1 to splice.\n"); else sizein=sp[i].u.array->size; - + } for(++i; i<0; i++) if (sp[i].type!=T_ARRAY) error("Illegal argument to splice.\n"); @@ -2630,6 +2631,7 @@ void f_everynth(INT32 args) if (n<1) n=1; if (args>2) + { if (sp[2-args].type!=T_INT) error("Illegal argument 3 to everynth.\n"); else @@ -2638,6 +2640,7 @@ void f_everynth(INT32 args) if (start<0) start=0; } + } } a=allocate_array(((size=ina->size)-start+n-1)/n); for(; start<size; start+=n) @@ -2710,6 +2713,7 @@ void f_transpose(INT32 args) struct svalue * tva; outinner=allocate_array(sizein); outinner->type_field=type; + outinner->refs++; /*FIXME Should this be here?*/ ett=outinner->item; tva=in->item; for(i=0; i<sizein; i++) @@ -2717,7 +2721,7 @@ void f_transpose(INT32 args) assign_svalue_no_free(ett+i, (tva+i)->u.array->item+j); } - out->item[j].u= outinner; + out->item[j].u.array=outinner; out->item[j].type=T_ARRAY; } -- GitLab