pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:1:
/*\ ||| This file a part of Pike, and is copyright by Fredrik Hubinette ||| Pike is distributed as GPL (General Public License) ||| See the files COPYING and DISCLAIMER for more information. \*/ /**/ #include "global.h" #include <math.h>
-
RCSID("$Id: operators.c,v 1.
93
2000/
07
/
28
17:
16
:
55
hubbe
Exp $");
+
RCSID("$Id: operators.c,v 1.
94
2000/
08
/
03
17:
20
:
28
grubba
Exp $");
#include "interpret.h" #include "svalue.h" #include "multiset.h" #include "mapping.h" #include "array.h" #include "stralloc.h" #include "opcodes.h" #include "operators.h" #include "language.h" #include "pike_memory.h"
pike.git/src/operators.c:2296:
sp[-1].u.integer = - sp[-1].u.integer; return; default: PIKE_ERROR("`-", "Bad argument to unary minus.\n", sp, 1); } } PMOD_EXPORT void o_range(void) {
-
INT32
from,to;
+
ptrdiff_t
from,to;
if(sp[-3].type==T_OBJECT) { CALL_OPERATOR(LFUN_INDEX, 3); return; } if(sp[-2].type != T_INT) PIKE_ERROR("`[]", "Bad argument 2 to [ .. ]\n", sp, 3); if(sp[-1].type != T_INT) PIKE_ERROR("`[]", "Bad argument 3 to [ .. ]\n", sp, 3);
-
from=sp[-2].u.integer;
-
if(from<0) from=0;
-
to=sp[-1].u.integer;
-
if(to<from-1) to=from-1;
+
from
=
sp[-2].u.integer;
+
if(from<0) from
=
0;
+
to
=
sp[-1].u.integer;
+
if(to<from-1) to
=
from-1;
sp-=2; switch(sp[-1].type) { case T_STRING: { struct pike_string *s;
-
if(
to
>=sp[-1].u.string->len
-1
)
+
if(
to+1
>=sp[-1].u.string->len)
{ if(from==0) return;
-
to=sp[-1].u.string->len-1;
+
to
=
sp[-1].u.string->len-1;
if(from>to+1) from=to+1; } #ifdef PIKE_DEBUG if(from < 0 || (to-from+1) < 0) fatal("Error in o_range.\n"); #endif s=string_slice(sp[-1].u.string, from, to-from+1); free_string(sp[-1].u.string); sp[-1].u.string=s; break; } case T_ARRAY: { struct array *a;
-
if(
to
>=sp[-1].u.array->size
-1
)
+
if(
to+1
>=
sp[-1].u.array->size)
{
-
to=sp[-1].u.array->size-1;
+
to
=
sp[-1].u.array->size-1;
if(from>to+1) from=to+1; } a=slice_array(sp[-1].u.array,from,to+1); free_array(sp[-1].u.array); sp[-1].u.array=a; break; }