pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:72:
case T_STRING: if(TYPEOF(*ind) == T_INT) { ptrdiff_t len = what->u.string->len; INT_TYPE p = ind->u.integer; INT_TYPE i = p < 0 ? p + len : p; if(i<0 || i>=len) { if(len == 0)
-
Pike
_error("Attempt to index the empty string with %"PRINTPIKEINT"d.\n", i);
+
index
_error(
NULL, 0, what, ind,
+
"Attempt to index the empty string with %"PRINTPIKEINT"d.\n", i);
else
-
Pike
_error("Index %"PRINTPIKEINT"d is out of string range "
+
index
_error(
NULL, 0, what, ind,
+
"Index %"PRINTPIKEINT"d is out of string range "
"%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n", i, -len, len - 1); } else i=index_shared_string(what->u.string,i); SET_SVAL(*to, T_INT, NUMBER_NUMBER, integer, i); break; }else{
-
if (TYPEOF(*ind) == T
_
STRING)
-
Pike_
error
(
"Expected
integer as string index
,
got \"%S\".\n"
,
-
ind
->u.string);
-
else
-
Pike_error ("Expected integer as string index
,
got %s.\n",
-
get_name_of_type (TYPEOF(*ind
)
))
;
+
index
_error(
NULL,
0
,
what
, ind,
NULL
);
} case T_FUNCTION: case T_PROGRAM: if (program_index_no_free(to, what, ind)) break; goto index_error; case T_INT: if (TYPEOF(*ind) == T_STRING && !IS_UNDEFINED (what)) { INT_TYPE val = what->u.integer; convert_svalue_to_bignum(what); index_no_free(to, what, ind); if(IS_UNDEFINED(to)) { if (val) {
-
Pike
_error("Indexing the integer %"PRINTPIKEINT"d "
+
index
_error(
NULL, 0, what, ind,
+
"Indexing the integer %"PRINTPIKEINT"d "
"with unknown method \"%S\".\n", val, ind->u.string); } else {
-
Pike
_error(
"Indexing the
NULL
value
with \"%S\".\n"
,
-
ind
->u.string
);
+
index
_error(NULL
,
0,
what,
ind
,
NULL
);
} } break; } /* FALLTHRU */ default: index_error:
-
if (TYPEOF(*ind) == T_INT)
-
Pike_error ("Cannot
index
%s with %"PRINTPIKEINT"d.\n",
-
(TYPEOF(*what) == T
_
INT && !what->u.integer)?
-
"the NULL value":get_name_of_type(TYPEOF(*what)),
-
ind->u.integer);
-
else if (TYPEOF(*ind) == T_FLOAT)
-
Pike_
error
(
"Cannot index %s with %"PRINTPIKEFLOAT"e.\n",
-
(TYPEOF(*what) == T_INT && !what->u.integer)?
-
"the
NULL
value":get_name_of_type(TYPEOF(*what))
,
-
ind->u.float_number);
-
else if (TYPEOF(*ind) == T_STRING)
-
Pike_error ("Cannot index %s with \"%S\".\n"
,
-
(TYPEOF(*
what
) == T_INT && !what->u.integer)?
-
"the NULL value":get_name_of_type(TYPEOF(*what))
,
-
ind
->u.string);
-
else
-
Pike_error ("Cannot index %s with %s.\n"
,
-
(TYPEOF(*what) == T_INT && !what->u.integer)?
-
"the
NULL
value":get_name_of_type(TYPEOF(*what
)
),
-
get_name_of_type (TYPEOF(*ind)))
;
+
index_error(NULL,
0
, what, ind, NULL);
} } PMOD_EXPORT void o_index(void) { struct svalue s; index_no_free(&s,Pike_sp-2,Pike_sp-1); pop_n_elems(2); *Pike_sp=s; dmalloc_touch_svalue(Pike_sp);