pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
1998-04-09
1998-04-09 20:47:21 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
05459a9a780d5f2eab2c558cac3c8079eb42fa76 (
39
lines) (+
27
/-
12
)
[
Show
|
Annotate
]
Branch:
7.9
combine_path() now take any amount of arguments
Rev: src/builtin_functions.c:1.90
4:
||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h"
-
RCSID("$Id: builtin_functions.c,v 1.
89
1998/04/
01
14
:
25
:
51
grubba
Exp $");
+
RCSID("$Id: builtin_functions.c,v 1.
90
1998/04/
09
20
:
47
:
21
hubbe
Exp $");
#include "interpret.h" #include "svalue.h" #include "pike_macros.h"
491:
void f_combine_path(INT32 args) {
-
char *path;
-
if(args<
2
)
+
char *path
=0
;
+
int e,dofree=0;
+
struct pike_string *ret;
+
+
if(args<
1
)
error("Too few arguments to combine_path.\n"); if(sp[-args].type != T_STRING) error("Bad argument 1 to combine_path.\n");
-
if(
sp[
1
-args].
type != T_STRING)
-
error("Bad argument 2 to combine_path
.
\n")
;
+
path=
sp[-args].
u
.
string->str
;
-
path
=
combine_path
(sp[-args].
u.string->str,sp[1-args].u.string->str
);
-
pop_n_elems
(
args
);
+
for(e
=
1;e<args;e++)
+
{
+
char *newpath;
+
if
(sp[
e
-args].
type != T_STRING
)
+
{
+
if(dofree) free(path)
;
+
error("Bad argument %d to combine
_
path.\n",e
);
+
}
-
sp-
>
u.string
=make_shared_string
(path);
-
sp->type
=
T_STRING
;
-
sp++;
-
free(path)
;
+
newpath=combine_path(path,
sp
[e
-
args].
u.string
->str);
+
if
(
dofree) free(
path);
+
path
=
newpath
;
+
dofree=1
;
}
-
+
ret=make_shared_string(path);
+
if(dofree) free(path);
+
pop_n_elems(args);
+
push_string(ret);
+
}
+
void f_function_object(INT32 args) { if(args < 1)
2524:
add_efun("backtrace",f_backtrace,"function(:array(array(function|int|string)))",OPT_EXTERNAL_DEPEND); add_efun("column",f_column,"function(array,mixed:array)",0);
-
add_efun("combine_path",f_combine_path,"function(string
,string
:string)",0);
+
add_efun("combine_path",f_combine_path,"function(string
...
:string)",0);
add_efun("compile",f_compile,"function(string:program)",OPT_EXTERNAL_DEPEND); add_efun("copy_value",f_copy_value,"function(1=mixed:1)",0); add_efun("crypt",f_crypt,"function(string:string)|function(string,string:int)",OPT_EXTERNAL_DEPEND);