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 <math.h> #include "global.h"
-
RCSID("$Id: operators.c,v 1.
5
1997/01/
27
01
:
27
:
13
hubbe Exp $");
+
RCSID("$Id: operators.c,v 1.
6
1997/01/
28
03
:
10
:
22
hubbe 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 "memory.h"
pike.git/src/operators.c:1096:
return; default: error("Bad argument to unary minus\n"); } } void o_range() { INT32 from,to;
+
+
if(sp[-3].type==T_OBJECT)
+
{
+
CALL_OPERATOR(LFUN_INDEX, 2);
+
return;
+
}
+
if(sp[-2].type != T_INT) error("Bad argument 1 to [ .. ]\n"); if(sp[-1].type != T_INT) error("Bad argument 2 to [ .. ]\n"); 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_OBJECT:
-
CALL_OPERATOR(LFUN_INDEX, 2);
-
break;
-
+
case T_STRING: { struct pike_string *s; if(to>=sp[-1].u.string->len-1) { if(from==0) return; to=sp[-1].u.string->len-1; if(from>to+1) from=to+1; }