pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:1721:    ADD_FD_EVENTS2 (f, 1 << event, flags);    }   }      #undef CBFUNCS      #define CBFUNCS(CB, EVENT) \    static void PIKE_CONCAT(file_set_,CB) (INT32 args) \    { \    if(!args) \ -  SIMPLE_TOO_FEW_ARGS_ERROR("set_" #CB, 1); \ +  SIMPLE_WRONG_NUM_ARGS_ERROR("set_" #CB, 1); \    set_fd_event_cb (THIS, Pike_sp-args, EVENT, 0); \    }      #define CBFUNCS2(CB, EVENT) \    static void PIKE_CONCAT(file_set_,CB) (INT32 args) \    { \    if(args<2) \ -  SIMPLE_TOO_FEW_ARGS_ERROR("set_" #CB, 2); \ +  SIMPLE_WRONG_NUM_ARGS_ERROR("set_" #CB, 2); \    if (TYPEOF(Pike_sp[1-args]) != PIKE_T_INT) \    SIMPLE_ARG_TYPE_ERROR("set_" #CB, 2, "int"); \    set_fd_event_cb (THIS, Pike_sp-args, EVENT, \    Pike_sp[1-args].u.integer); \    }      CBFUNCS(read_callback, PIKE_FD_READ)   CBFUNCS(write_callback, PIKE_FD_WRITE)   CBFUNCS(read_oob_callback, PIKE_FD_READ_OOB)   CBFUNCS(write_oob_callback, PIKE_FD_WRITE_OOB)
pike.git/src/modules/_Stdio/file.c:2674:    */   static void file_open(INT32 args)   {    int flags,fd;    int access;    int err;    struct pike_string *str, *flag_str;    close_fd();       if(args < 2) -  SIMPLE_TOO_FEW_ARGS_ERROR("open", 2); +  SIMPLE_WRONG_NUM_ARGS_ERROR("open", 2);       if(TYPEOF(Pike_sp[-args]) != PIKE_T_STRING &&    TYPEOF(Pike_sp[-args]) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR("open", 1, "string|int");       if(TYPEOF(Pike_sp[1-args]) != PIKE_T_STRING)    SIMPLE_ARG_TYPE_ERROR("open", 2, "string");       if (args > 2)    {
pike.git/src/modules/_Stdio/file.c:2834: Inside #if !defined(__NT__) && (defined(HAVE_POSIX_OPENPT) || defined(PTY_MASTER_PATHNAME))
   */   static void file_openpt(INT32 args)   {    int flags,fd;   #ifdef HAVE_POSIX_OPENPT    struct pike_string *flag_str;   #endif    close_fd();       if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("openpt", 2); +  SIMPLE_WRONG_NUM_ARGS_ERROR("openpt", 1);       if(TYPEOF(Pike_sp[-args]) != PIKE_T_STRING)    SIMPLE_ARG_TYPE_ERROR("openpt", 1, "string");      #ifdef HAVE_POSIX_OPENPT    flags = parse((flag_str = Pike_sp[-args].u.string)->str);       if(!( flags & (FILE_READ | FILE_WRITE)))    Pike_error("Must open file for at least one of read and write.\n");   
pike.git/src/modules/_Stdio/file.c:3033:   static void file_seek(INT32 args)   {   #ifdef SEEK64    INT64 to = 0;   #else    off_t to = 0;   #endif    int how = SEEK_SET;       if( args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("seek", 1); +  SIMPLE_WRONG_NUM_ARGS_ERROR("seek", 1);      #if defined (SEEK64)    if(is_bignum_object_in_svalue(&Pike_sp[-args])) {    if (!int64_from_bignum(&to, Pike_sp[-args].u.object))    Pike_error ("Bad argument 1 to Stdio.File->seek(). Offset too large.\n");    }    else   #endif    if(TYPEOF(Pike_sp[-args]) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR("seek", 1, "int");
pike.git/src/modules/_Stdio/file.c:3143:    */   static void file_truncate(INT32 args)   {   #if defined(INT64)    INT64 len = 0;   #else    off_t len = 0;   #endif    int res;    -  if(args<1) -  SIMPLE_TOO_FEW_ARGS_ERROR("truncate", 1); +  if(args!=1) +  SIMPLE_WRONG_NUM_ARGS_ERROR("truncate", 1);      #if defined (INT64)   #if defined (HAVE_FTRUNCATE64) || SIZEOF_OFF_T > SIZEOF_INT_TYPE    if(is_bignum_object_in_svalue(&Pike_sp[-args])) {    if (!int64_from_bignum(&len, Pike_sp[-args].u.object))    Pike_error ("Bad argument 1 to Stdio.File->truncate(). Length too large.\n");    }    else   #endif   #endif
pike.git/src/modules/_Stdio/file.c:3727:    *! Also, this object does not keep a reference to the backend.    *!    *! @seealso    *! @[query_backend], @[set_nonblocking], @[set_read_callback], @[set_write_callback], @[set_fs_event_callback]    */   static void file_set_backend (INT32 args)   {    struct my_file *f = THIS;    struct Backend_struct *backend;    -  if (!args) -  SIMPLE_TOO_FEW_ARGS_ERROR ("set_backend", 1); +  if (args!=1) +  SIMPLE_WRONG_NUM_ARGS_ERROR ("set_backend", 1);    if (TYPEOF(Pike_sp[-args]) != PIKE_T_OBJECT)    SIMPLE_ARG_TYPE_ERROR ("set_backend", 1, "Pike.Backend");    backend = get_storage (Pike_sp[-args].u.object, Backend_program);    if (!backend)    SIMPLE_ARG_TYPE_ERROR ("set_backend", 1, "Pike.Backend");       /* FIXME: Only allow set_backend() if the file is open? */      #ifdef __NT__    if ((THIS->box.fd >= 0) &&
pike.git/src/modules/_Stdio/file.c:3830:    *! calling exec().    *!    *! Default is that the file WILL be closed on exec except for    *! stdin, stdout and stderr.    *!    *! @seealso    *! @[Process.create_process()], @[exec()]    */   static void file_set_close_on_exec(INT32 args)   { -  if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("set_close_on_exec", 1); +  if(args != 1) +  SIMPLE_WRONG_NUM_ARGS_ERROR("set_close_on_exec", 1);    if(FD <0)    Pike_error("File not open.\n");       if(UNSAFE_IS_ZERO(Pike_sp-args))    {    my_set_close_on_exec(FD,0);    }else{    my_set_close_on_exec(FD,1);    }   }
pike.git/src/modules/_Stdio/file.c:3906:    *! Rehooks the given file descriptor number to be associated with    *! this object. As opposed to using @[open] with a file descriptor    *! number, it will be closed by this object upon destruct or when    *! @[close] is called.    *!    *! @seealso    *! @[release_fd()]    */   static void file_take_fd(INT32 args)   { -  if (args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR ("take_fd", 1); +  if (args != 1) +  SIMPLE_WRONG_NUM_ARGS_ERROR ("take_fd", 1);    if (TYPEOF(Pike_sp[-args]) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR ("take_fd", 0, "int");    change_fd_for_box(&THIS->box, Pike_sp[-args].u.integer);   }      PMOD_EXPORT struct object *file_make_object_from_fd(int fd, int mode, int guess)   {    struct object *o;    struct my_file *f;    if (Pike_fp->context->prog == file_program) {
pike.git/src/modules/_Stdio/file.c:4012:    *! @seealso    *! @[open_socket()], @[accept()]    */   static void file_set_buffer(INT32 args)   {    INT32 bufsize;    int flags;       if(FD==-1)    Pike_error("Stdio.File->set_buffer() on closed file.\n"); -  if(!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("set_buffer", 1); +  if(args!=1) +  SIMPLE_WRONG_NUM_ARGS_ERROR("set_buffer", 1);    if(TYPEOF(Pike_sp[-args]) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR("set_buffer", 1, "int");       bufsize=Pike_sp[-args].u.integer;    if(bufsize < 0)    Pike_error("Bufsize must be larger than zero.\n");       if(args>1)    {    if(TYPEOF(Pike_sp[1-args]) != PIKE_T_STRING)
pike.git/src/modules/_Stdio/file.c:4547:    *! as this object.    *!    *! @seealso    *! @[assign()], @[dup()]    */   static void file_dup2(INT32 args)   {    struct object *o;    struct my_file *fd;    -  if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("dup2", 1); +  if(args != 1) +  SIMPLE_WRONG_NUM_ARGS_ERROR("dup2", 1);       if(FD < 0)    Pike_error("File not open.\n");       if(TYPEOF(Pike_sp[-args]) != PIKE_T_OBJECT)    SIMPLE_ARG_TYPE_ERROR("dup2", 1, "Stdio.File");       o=Pike_sp[-args].u.object;       fd=get_file_storage(o);
pike.git/src/modules/_Stdio/file.c:4884:    *! @note    *! @[path] had a quite restrictive length limit (~100 characters)    *! prior to Pike 7.8.334.    */   static void file_connect_unix( INT32 args )   {    struct sockaddr_un *name;    int addr_len;    int tmp;    -  if( args < 1 ) -  SIMPLE_TOO_FEW_ARGS_ERROR("connect_unix", 1); +  if( args != 1 ) +  SIMPLE_WRONG_NUM_ARGS_ERROR("connect_unix", 1);    if( (TYPEOF(Pike_sp[-args]) != PIKE_T_STRING) ||    (Pike_sp[-args].u.string->size_shift) )    Pike_error("Illegal argument. Expected string(8bit)\n");       /* NOTE: Some operating systems (eg Linux 2.6) do not support    * paths longer than what fits into a plain struct sockaddr_un.    */    addr_len = sizeof(struct sockaddr_un) + Pike_sp[-args].u.string->len + 1 -    sizeof(name->sun_path);    name = xalloc(addr_len);
pike.git/src/modules/_Stdio/file.c:5221:    *!    *! @note    *! Throws an error if not all data could be written.    *!    *! @seealso    *! @[write()]    */   static void file_lsh(INT32 args)   {    ptrdiff_t len; -  if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("`<<", 1); -  if(args > 1) -  pop_n_elems(args-1); +  if(args != 1) +  SIMPLE_WRONG_NUM_ARGS_ERROR("`<<", 1);       if(TYPEOF(Pike_sp[-1]) != PIKE_T_STRING)    {    ref_push_type_value(string_type_string);    stack_swap();    f_cast();    }       len=Pike_sp[-1].u.string->len;    file_write(1);
pike.git/src/modules/_Stdio/file.c:5915: Inside #if defined(HAVE_TERMIOS_H)
  /* void file_tcflow(INT32 args); */   /* void file_tcgetpgrp(INT32 args); */   /* void file_tcsetpgrp(INT32 args); */   #endif      static void fd__sprintf(INT32 args)   {    INT_TYPE type;       if(args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2); +  SIMPLE_WRONG_NUM_ARGS_ERROR("_sprintf",2);    if(TYPEOF(Pike_sp[-args]) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR("_sprintf",0,"int");       type = Pike_sp[-args].u.integer;    pop_n_elems(args);    switch( type )    {    case 'O':    {    /* NB: A signed 64-bit int maxes out at 21 characters. */