diff --git a/src/modules/files/efuns.c b/src/modules/files/efuns.c index 63a226996382fbcedba6a0549e20e71e02d71796..ddf4667108f17cb31ba7f55532ff149f3ad1b322 100644 --- a/src/modules/files/efuns.c +++ b/src/modules/files/efuns.c @@ -293,9 +293,16 @@ void f_filesystem_stat(INT32 args) void f_werror(INT32 args) { if(!args) - error("Too few arguments to perror.\n"); + error("Too few arguments to werror.\n"); if(sp[-args].type != T_STRING) - error("Bad argument 1 to perror().\n"); + error("Bad argument 1 to werror().\n"); + + if(args> 1) + { + extern void f_sprintf(INT32); + f_sprintf(args); + args=1; + } write_to_stderr(sp[-args].u.string->str, sp[-args].u.string->len); pop_n_elems(args); @@ -720,7 +727,7 @@ void init_files_efuns(void) "function(string:mapping(string:string|int))", OPT_EXTERNAL_DEPEND); #endif /* HAVE_STATVFS || HAVE_STATFS */ add_efun("errno",f_errno,"function(:int)",OPT_EXTERNAL_DEPEND); - add_efun("werror",f_werror,"function(string:void)",OPT_SIDE_EFFECT); + add_efun("werror",f_werror,"function(string,void|mixed...:void)",OPT_SIDE_EFFECT); add_efun("rm",f_rm,"function(string:int)",OPT_SIDE_EFFECT); add_efun("mkdir",f_mkdir,"function(string,void|int:int)",OPT_SIDE_EFFECT); add_efun("mv", f_mv, "function(string,string:int)", OPT_SIDE_EFFECT); diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 4717cac8563754792c0dce0c3b8d9885ac70e195..a7f4970a6b753fe221829772de4055fa726e8292 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -6,7 +6,7 @@ #define READ_BUFFER 8192 #include "global.h" -RCSID("$Id: file.c,v 1.75 1998/02/11 00:54:35 hubbe Exp $"); +RCSID("$Id: file.c,v 1.76 1998/02/20 01:08:58 hubbe Exp $"); #include "fdlib.h" #include "interpret.h" #include "svalue.h" @@ -449,6 +449,13 @@ static void file_write(INT32 args) if(args<1 || sp[-args].type != T_STRING) error("Bad argument 1 to file->write().\n"); + if(args > 1) + { + extern void f_sprintf(INT32); + f_sprintf(args); + args=1; + } + if(FD < 0) error("File not open for write.\n"); @@ -1562,8 +1569,8 @@ static void file_lsh(INT32 args) if(sp[-1].type != T_STRING) { - push_string(string_type_string); - string_type_string->refs++; + ref_push_string(string_type_string); + stack_swap(); f_cast(); } @@ -1791,7 +1798,7 @@ void pike_module_init(void) add_function("open",file_open,"function(string,string:int)",0); add_function("close",file_close,"function(string|void:int)",0); add_function("read",file_read,"function(int|void,int|void:int|string)",0); - add_function("write",file_write,"function(string:int)",0); + add_function("write",file_write,"function(string,void|mixed...:int)",0); add_function("seek",file_seek,"function(int:int)",0); add_function("tell",file_tell,"function(:int)",0);