pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
2001-05-31
2001-05-31 22:20:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>
364f52300767375457cbf6db8bbfc5fad07e5c7a (
38
lines) (+
31
/-
7
)
[
Show
|
Annotate
]
Branch:
7.2
Backported fix for [bug
1711 (#1711)
] from Pike 7.3.
Rev: src/builtin_functions.c:1.338
5:
\*/ /**/ #include "global.h"
-
RCSID("$Id: builtin_functions.c,v 1.
337
2001/05/
22
12
:
08
:
41
per
Exp $");
+
RCSID("$Id: builtin_functions.c,v 1.
338
2001/05/
31
22:
20
:
09
grubba
Exp $");
#include "interpret.h" #include "svalue.h" #include "pike_macros.h"
3072:
} }
+
node *optimize_replace(node *n)
+
{
+
node **arg0 = my_get_arg(&_CDR(n), 0);
+
struct pike_string *array_zero;
+
struct pike_string *mapping_zero;
+
+
MAKE_CONSTANT_SHARED_STRING(array_zero, tArr(tZero));
+
MAKE_CONSTANT_SHARED_STRING(mapping_zero, tMap(tZero, tZero));
+
+
if (arg0 &&
+
(pike_types_le(array_zero, (*arg0)->type) ||
+
pike_types_le(mapping_zero, (*arg0)->type))) {
+
/* First argument might be an array or a mapping.
+
*
+
* replace() is destructive on arrays and mappings.
+
*/
+
n->node_info |= OPT_SIDE_EFFECT;
+
n->tree_info |= OPT_SIDE_EFFECT;
+
}
+
return NULL;
+
}
+
/*! @decl program compile(string source, object|void handler, *! int|void major, int|void minor) *!
7541:
ADD_EFUN("random_string",f_random_string, tFunc(tInt,tString),0);
-
ADD_
EFUN
("replace",f_replace,
+
ADD_
EFUN2
("replace",
f_replace,
tOr5(tFunc(tStr tStr tStr,tStr), tFunc(tStr tArr(tStr) tArr(tStr),tStr), tFunc(tStr tMap(tStr,tStr),tStr), tFunc(tSetvar(0,tArray) tMix tMix,tVar(0)),
-
tFunc(tSetvar(1,tMapping) tMix tMix,tVar(1))) , 0);
+
tFunc(tSetvar(1,tMapping) tMix tMix,tVar(1)))
,
+
OPT_TRY_OPTIMIZE
,
optimize_replace,
0);
/* function(int:int)|function(string:string)|function(0=array:0) */ ADD_EFUN("reverse",f_reverse,