pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:3423:
free_array(THIS->from); THIS->from = NULL; } if (THIS->to) { free_array(THIS->to); THIS->to = NULL; } if (THIS->ctx.v) free_replace_many_context(&THIS->ctx);
-
switch(args)
-
{
-
case 0:
-
return;
-
-
case 1:
-
if (
TYPEOF(*from
_arg)
!= T_MAPPING)
-
Pike_error
(
"Illegal arguments to create().\n");
-
THIS->
from
= mapping
_
indices(from_
arg
->u.mapping);
-
THIS->to = mapping_values
(
from_arg->u.mapping);
-
break;
-
-
case 2:
-
if (
TYPEOF(*from_arg) != T_ARRAY) {
+
if (
to
_arg)
{
+
if
(
!
from_arg
||
(TYPEOF(*from_arg) != T_ARRAY)
)
{
SIMPLE_ARG_TYPE_ERROR("replace", 1, "array(string)|mapping(string:string)"); } if (TYPEOF(*to_arg) == T_STRING) { push_int(from_arg->u.array->size); stack_swap(); f_allocate(2);
-
+
to_arg = Pike_sp - 1;
} if (TYPEOF(*to_arg) != T_ARRAY) { SIMPLE_ARG_TYPE_ERROR("replace", 2, "array(string)|string"); } if (from_arg->u.array->size != to_arg->u.array->size) { Pike_error("Replace must have equal-sized from and to arrays.\n"); } add_ref(THIS->from = from_arg->u.array); add_ref(THIS->to = to_arg->u.array);
-
+
} else if (from_arg) {
+
if (TYPEOF(*from_arg) != T_MAPPING)
+
Pike_error("Illegal arguments to create().\n");
+
THIS->from = mapping_indices(from_arg->u.mapping);
+
THIS->to = mapping_values(from_arg->u.mapping);
+
} else {
+
return;
} if (!THIS->from->size) { /* Enter no-op mode. */ return; } if( (THIS->from->type_field & ~BIT_STRING) && (array_fix_type_field(THIS->from) & ~BIT_STRING) ) SIMPLE_ARG_TYPE_ERROR("replace", 1,