pike.git / src / error.c

version» Context lines:

pike.git/src/error.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: error.c,v 1.103 2003/03/28 18:18:48 mast Exp $ + || $Id: error.c,v 1.104 2003/03/28 22:00:46 mast Exp $   */      #define NO_PIKE_SHORTHAND   #include "global.h"   #include "svalue.h"   #include "pike_macros.h"   #include "pike_error.h"   #include "interpret.h"   #include "stralloc.h"   #include "builtin_functions.h"   #include "array.h"   #include "object.h"   #include "main.h"   #include "builtin_functions.h"   #include "backend.h"   #include "operators.h"   #include "module_support.h"   #include "threads.h"   #include "gc.h"    - RCSID("$Id: error.c,v 1.103 2003/03/28 18:18:48 mast Exp $"); + RCSID("$Id: error.c,v 1.104 2003/03/28 22:00:46 mast Exp $");      #undef ATTRIBUTE   #define ATTRIBUTE(X)      PMOD_EXPORT const char msg_fatal_error[] =    "%s:%d: Fatal error:\n";   #ifdef PIKE_DEBUG   PMOD_EXPORT const char msg_unsetjmp_nosync_1[] =    "UNSETJMP out of sync! (last SETJMP at %s)!\n";   PMOD_EXPORT const char msg_unsetjmp_nosync_2[] =
pike.git/src/error.c:40: Inside #if defined(PIKE_DEBUG)
  PMOD_EXPORT const char msg_unset_onerr_nosync_1[] =    "UNSET_ONERROR out of sync (%p != %p).\n"    "Last SET_ONERROR is from %s\n";   PMOD_EXPORT const char msg_unset_onerr_nosync_2[] =    "UNSET_ONERROR out of sync. No Pike_interpreter.recoveries left.\n";   PMOD_EXPORT const char msg_assert_onerr[] =    "%s ASSERT_ONERROR(%p) failed\n";   #endif   PMOD_EXPORT const char msg_bad_arg[] =    "Bad argument %d to %s(). Expected %s.\n"; - PMOD_EXPORT const char msg_too_few_args[] = -  "Too few arguments to %s(). Expected at least %d.\n"; - PMOD_EXPORT const char msg_wrong_num_args[] = -  "Invalid number of arguments to %s(). Expected %d.\n"; + PMOD_EXPORT const char msg_bad_arg_2[] = +  "Bad argument %d to %s(). %s\n";   PMOD_EXPORT const char msg_out_of_mem[] =    "Out of memory.\n";   PMOD_EXPORT const char msg_div_by_zero[] =    "Division by zero.\n";      /*    * Attempt to inhibit throwing of errors if possible.    * Used by exit_on_error() to avoid infinite sprintf() loops.    */   int Pike_inhibit_errors = 0;
pike.git/src/error.c:761:    }else{    ERROR_STRUCT(bad_arg,o)->got.type=PIKE_T_INT;    ERROR_STRUCT(bad_arg,o)->got.subtype=NUMBER_UNDEFINED;    ERROR_STRUCT(bad_arg,o)->got.u.integer=0;    }    DWERROR((stderr, "%s():Bad arg %d (expected %s)\n",    func, which_arg, expected_type));    ERROR_DONE(generic);   }    + /* This one doesn't record an expected type. */ + PMOD_EXPORT DECLSPEC(noreturn) void bad_arg_error_2( +  const char *func, +  struct svalue *base_sp, int args, +  int which_arg, +  struct svalue *got, +  const char *desc, ...) ATTRIBUTE((noreturn,format (printf, 7, 8))) + { +  INIT_ERROR(bad_arg); +  ERROR_COPY(bad_arg, which_arg); +  ERROR_STRUCT(bad_arg,o)->expected_type=NULL; +  if(got) +  { +  ERROR_COPY_SVALUE(bad_arg, got); +  }else{ +  ERROR_STRUCT(bad_arg,o)->got.type=PIKE_T_INT; +  ERROR_STRUCT(bad_arg,o)->got.subtype=NUMBER_UNDEFINED; +  ERROR_STRUCT(bad_arg,o)->got.u.integer=0; +  } +  DWERROR((stderr, "%s():Bad arg %d\n", +  func, which_arg)); +  ERROR_DONE(generic); + } +    PMOD_EXPORT DECLSPEC(noreturn) void math_error(    const char *func,    struct svalue *base_sp, int args,    struct svalue *number,    const char *desc, ...) ATTRIBUTE((noreturn,format (printf, 5, 6)))   {    INIT_ERROR(math);    if(number)    {    ERROR_COPY_SVALUE(math, number);
pike.git/src/error.c:807:    const char *desc, ...) ATTRIBUTE((noreturn, format(printf, 5, 6)))   {    INIT_ERROR(permission);    ERROR_STRUCT(permission,o)->permission_type=    make_shared_string(permission_type);    ERROR_DONE(generic);   }      PMOD_EXPORT void wrong_number_of_args_error(const char *name, int args, int expected)   { -  char *msg; +     if(expected>args)    { -  msg="Too few arguments.\n"; -  }else{ -  msg="Too many arguments.\n"; +  bad_arg_error_2 (name, Pike_sp-args, args, expected, NULL, +  "Too few arguments to %s(). Expected at least %d.\n", +  name, expected); +  }else { +  bad_arg_error_2 (name, Pike_sp-args, args, expected, NULL, +  "Too many arguments to %s(). Expected at most %d.\n", +  name, expected);    } -  -  new_error(name, msg, Pike_sp-args, args, 0,0); +    }      #ifdef PIKE_DEBUG   static void gc_check_throw_value(struct callback *foo, void *bar, void *gazonk)   {    debug_gc_xmark_svalues(&throw_value,1," in the throw value");   }   #endif      void init_error(void)