1998-04-10
1998-04-10 16:36:01 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
7cc831180cea2f113f1257441c9347fc0e529e09
(215 lines)
(+109/-106)
[
Show
| Annotate
]
Branch: 7.9
Changed most error()'s to use ERROR() instead.
Rev: src/builtin_functions.c:1.92
4:
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include "global.h"
- RCSID("$Id: builtin_functions.c,v 1.91 1998/04/09 22:03:39 hubbe Exp $");
+ RCSID("$Id: builtin_functions.c,v 1.92 1998/04/10 16:36:01 grubba Exp $");
#include "interpret.h"
#include "svalue.h"
#include "pike_macros.h"
51:
void f_equal(INT32 args)
{
int i;
- if(args < 2)
- error("Too few arguments to equal.\n");
+ if(args != 2)
+ ERROR("equal", "Bad number of arguments.\n", sp, args);
i=is_equal(sp-2,sp-1);
pop_n_elems(args);
83:
{
INT32 i;
if(!args)
- error("Too few arguments to hash()\n");
+ ERROR("hash", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to hash()\n");
+ ERROR("hash", "Bad argument 1.\n", sp, args);
i=hashstr((unsigned char *)sp[-args].u.string->str,100);
if(args > 1)
{
if(sp[1-args].type != T_INT)
- error("Bad argument 2 to hash()\n");
+ ERROR("hash", "Bad argument 2.\n", sp, args);
if(!sp[1-args].u.integer)
- error("Modulo by zero in hash()\n");
+ ERROR("hash", "Modulo by zero.\n", sp, args);
i%=(unsigned INT32)sp[1-args].u.integer;
}
105:
void f_copy_value(INT32 args)
{
if(!args)
- error("Too few arguments to copy_value()\n");
+ ERROR("copy_value", "Too few arguments.\n", sp, 0);
pop_n_elems(args-1);
copy_svalues_recursively_no_free(sp,sp-1,1,0);
117:
{
time_t i;
if(!args)
- error("Too few arguments to ctime()\n");
+ ERROR("ctime", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_INT)
- error("Bad argument 1 to ctime()\n");
+ ERROR("ctime", "Bad argument 1.\n", sp, args);
i=(time_t)sp[-args].u.integer;
pop_n_elems(args);
push_string(make_shared_string(ctime(&i)));
130:
INT32 i;
struct pike_string *ret;
if(!args)
- error("Too few arguments to lower_case()\n");
+ ERROR("lower_case", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to lower_case()\n");
+ ERROR("lower_case", "Bad argument 1.\n", sp, args);
ret=begin_shared_string(sp[-args].u.string->len);
MEMCPY(ret->str, sp[-args].u.string->str,sp[-args].u.string->len);
150:
INT32 i;
struct pike_string *ret;
if(!args)
- error("Too few arguments to upper_case()\n");
+ ERROR("upper_case", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to upper_case()\n");
+ ERROR("upper_case", "Bad argument 1.\n", sp, args);
ret=begin_shared_string(sp[-args].u.string->len);
MEMCPY(ret->str, sp[-args].u.string->str,sp[-args].u.string->len);
168:
void f_random(INT32 args)
{
if(!args)
- error("Too few arguments to random()\n");
+ ERROR("random", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_INT)
- error("Bad argument 1 to random()\n");
+ ERROR("random", "Bad argument 1.\n", sp, args);
if(sp[-args].u.integer <= 0)
{
184:
void f_random_seed(INT32 args)
{
if(!args)
- error("Too few arguments to random_seed()\n");
+ ERROR("random_seed", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_INT)
- error("Bad argument 1 to random_seed()\n");
+ ERROR("random_seed", "Bad argument 1.\n", sp, args);
my_srand(sp[-args].u.integer);
pop_n_elems(args);
203:
INT32 start;
if(args < 2)
- error("Too few arguments to search().\n");
+ ERROR("search", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
212:
char *ptr;
INT32 len;
if(sp[1-args].type != T_STRING)
- error("Bad argument 2 to search()\n");
+ ERROR("search", "Bad argument 2.\n", sp, args);
start=0;
if(args > 2)
{
if(sp[2-args].type!=T_INT)
- error("Bad argument 3 to search()\n");
+ ERROR("search", "Bad argument 3.\n", sp, args);
start=sp[2-args].u.integer;
if(start<0)
- error("Start must be greater or equal to zero.\n");
+ ERROR("search", "Start must be greater or equal to zero.\n", sp, args);
}
len=sp[-args].u.string->len - start;
if(len<0)
- error("Start must not be greater than the length of the string.\n");
+ ERROR("search", "Start must not be greater than the length of the string.\n", sp, args);
if(len>0 && (ptr=my_memmem(sp[1-args].u.string->str,
sp[1-args].u.string->len,
248:
if(args > 2)
{
if(sp[2-args].type!=T_INT)
- error("Bad argument 3 to search()\n");
+ ERROR("search", "Bad argument 3.\n", sp, args);
start=sp[2-args].u.integer;
}
268:
return;
default:
- error("Bad argument 1 to search()\n");
+ ERROR("search", "Bad argument 1.\n", sp, args);
}
}
286:
sp->u.array=a=allocate_array_no_init(frames,0);
sp++;
+ /* NOTE: The first frame is ignored, since it is the call to backtrace(). */
of=0;
for(f=fp;f;f=(of=f)->parent_frame)
{
348:
void f_add_constant(INT32 args)
{
if(args<1)
- error("Too few arguments to add_efun.\n");
+ ERROR("add_constant", "Too few arguments.\n", sp, args);
if(sp[-args].type!=T_STRING)
- error("Bad argument 1 to add_efun.\n");
+ ERROR("add_constant", "Bad argument 1.\n", sp, args);
if(args>1)
{
496:
struct pike_string *ret;
if(args<1)
- error("Too few arguments to combine_path.\n");
+ ERROR("combine_path", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to combine_path.\n");
+ ERROR("combine_path", "Bad argument 1.\n", sp, args);
path=sp[-args].u.string->str;
527:
void f_function_object(INT32 args)
{
if(args < 1)
- error("Too few arguments to function_object()\n");
+ ERROR("function_object", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_FUNCTION)
- error("Bad argument 1 to function_object.\n");
+ ERROR("function_object", "Bad argument 1.\n", sp, args);
if(sp[-args].subtype == FUNCTION_BUILTIN)
{
545:
{
struct pike_string *s;
if(args < 1)
- error("Too few arguments to function_object()\n");
+ ERROR("function_name", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_FUNCTION)
- error("Bad argument 1 to function_object.\n");
+ ERROR("function_name", "Bad argument 1.\n", sp, args);
if(sp[-args].subtype == FUNCTION_BUILTIN)
{
555:
push_int(0);
}else{
if(!sp[-args].u.object->prog)
- error("function_name on destructed object.\n");
+ ERROR("function_name", "Destructed object.\n", sp, args);
copy_shared_string(s,ID_FROM_INT(sp[-args].u.object->prog,
sp[-args].subtype)->name);
570:
void f_zero_type(INT32 args)
{
if(args < 1)
- error("Too few arguments to zero_type()\n");
+ ERROR("zero_type", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_INT)
{
pop_n_elems(args);
602:
struct array *a;
if(args < 1)
- error("Too few arguments to allocate.\n");
+ ERROR("allocate", "Too few arguments.\n", sp, args);
if(sp[-args].type!=T_INT)
- error("Bad argument 1 to allocate.\n");
+ ERROR("allocate", "Bad argument 1.\n", sp, args);
size=sp[-args].u.integer;
if(size < 0)
- error("Allocate on negative number.\n");
+ ERROR("allocate", "Can't allocate array of negative size.\n", sp, args);
a=allocate_array(size);
if(args>1)
{
629:
pop_n_elems(args);
rus=low_rusage();
if(!rus)
- error("System rusage information not available.\n");
+ ERROR("rusage", "System rusage information not available.\n", sp, args);
v=allocate_array_no_init(29,0);
for(e=0;e<29;e++)
661:
void f_throw(INT32 args)
{
if(args < 1)
- error("Too few arguments to throw()\n");
+ ERROR("throw", "Too few arguments.\n", sp, args);
assign_svalue(&throw_value,sp-args);
pop_n_elems(args);
throw_severity=0;
671:
void f_exit(INT32 args)
{
if(args < 1)
- error("Too few arguments to exit.\n");
+ ERROR("exit", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_INT)
- error("Bad argument 1 to exit.\n");
+ ERROR("exit", "Bad argument 1.\n", sp, args);
assign_svalue(&throw_value, sp-args);
throw_severity=THROW_EXIT;
684:
void f__exit(INT32 args)
{
if(args < 1)
- error("Too few arguments to _exit.\n");
+ ERROR("_exit", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_INT)
- error("Bad argument 1 to _exit.\n");
+ ERROR("_exit", "Bad argument 1.\n", sp, args);
exit(sp[-1].u.integer);
}
708:
"cbhisjKlm4k65p7qrJfLMNQOPxwzyAaBDFgnoWXYCZ0123tvdHueEGISRTUV89./";
if(args < 1)
- error("Too few arguments to crypt()\n");
+ ERROR("crypt", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to crypt()\n");
+ ERROR("crypt", "Bad argument 1.\n", sp, args);
if(args>1)
760:
if(args)
{
if(sp[-args].type != T_OBJECT)
- error("Bad arguments 1 to destruct()\n");
+ ERROR("destruct", "Bad arguments 1.\n", sp, args);
o=sp[-args].u.object;
}else{
if(!fp)
- error("Destruct called without argument from callback function.\n");
+ ERROR("destruct", "Destruct called without argument from callback function.\n", sp, args);
o=fp->current_object;
}
778:
INT32 size;
struct array *a;
if(args < 1)
- error("Too few arguments to indices()\n");
+ ERROR("indices", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
812:
break;
default:
- error("Bad argument 1 to indices()\n");
+ ERROR("indices", "Bad argument 1.\n", sp, args);
return; /* make apcc happy */
}
pop_n_elems(args);
824:
INT32 size;
struct array *a;
if(args < 1)
- error("Too few arguments to values()\n");
+ ERROR("values", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
863:
break;
default:
- error("Bad argument 1 to values()\n");
+ ERROR("values", "Bad argument 1.\n", sp, args);
return; /* make apcc happy */
}
pop_n_elems(args);
878:
o=first_object;
}else{
if(sp[-args].type != T_OBJECT)
- error("Bad argument 1 to next_object()\n");
+ ERROR("next_object", "Bad argument 1.\n", sp, args);
o=sp[-args].u.object->next;
}
pop_n_elems(args);
894:
void f_object_program(INT32 args)
{
if(args < 1)
- error("Too few argumenets to object_program()\n");
+ ERROR("object_program", "Too few arguments.\n", sp, args);
if(sp[-args].type == T_OBJECT)
{
928:
void f_reverse(INT32 args)
{
if(args < 1)
- error("Too few arguments to reverse()\n");
+ ERROR("reverse", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
969:
}
default:
- error("Bad argument 1 to reverse()\n");
+ ERROR("reverse", "Bad argument 1.\n", sp, args);
}
}
1080:
void f_replace(INT32 args)
{
if(args < 3)
- error("Too few arguments to replace()\n");
+ ERROR("replace", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
1104:
switch(sp[1-args].type)
{
default:
- error("Bad argument 2 to replace()\n");
+ ERROR("replace", "Bad argument 2.\n", sp, args);
case T_STRING:
if(sp[2-args].type != T_STRING)
- error("Bad argument 3 to replace()\n");
+ ERROR("replace", "Bad argument 3.\n", sp, args);
s=string_replace(sp[-args].u.string,
sp[1-args].u.string,
1117:
case T_ARRAY:
if(sp[2-args].type != T_ARRAY)
- error("Bad argument 3 to replace()\n");
+ ERROR("replace", "Bad argument 3.\n", sp, args);
s=replace_many(sp[-args].u.string,
sp[1-args].u.array,
1130:
}
default:
- error("Bad argument 1 to replace().\n");
+ ERROR("replace", "Bad argument 1.\n", sp, args);
}
}
1139:
struct program *p;
if(args < 1)
- error("Too few arguments to compile()\n");
+ ERROR("compile", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_STRING)
- error("Bad argument 1 to compile()\n");
+ ERROR("compile", "Bad argument 1.\n", sp, args);
p=compile(sp[-args].u.string);
pop_n_elems(args);
1155:
struct array *a,*b;
get_all_args("mkmapping",args,"%a%a",&a,&b);
if(a->size != b->size)
- error("mkmapping called on arrays of different sizes\n");
+ ERROR("mkmapping", "mkmapping called on arrays of different sizes\n",
+ sp, args);
m=mkmapping(sp[-args].u.array, sp[1-args].u.array);
pop_n_elems(args);
1164:
void f_objectp(INT32 args)
{
- if(args<1) error("Too few arguments to objectp.\n");
+ if(args<1) ERROR("objectp", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_OBJECT || !sp[-args].u.object->prog)
{
pop_n_elems(args);
1177:
void f_functionp(INT32 args)
{
- if(args<1) error("Too few arguments to functionp.\n");
+ if(args<1) ERROR("functionp", "Too few arguments.\n", sp, args);
if(sp[-args].type != T_FUNCTION ||
(sp[-args].subtype != FUNCTION_BUILTIN && !sp[-args].u.object->prog))
{
1195: Inside #if defined(HAVE_POLL)
int ms;
if(!args)
- error("Too few arguments to sleep.\n");
+ ERROR("sleep", "Too few arguments.\n", sp, args);
switch(sp[-args].type) {
case T_INT:
1205: Inside #if defined(HAVE_POLL)
ms = (int)(sp[-args].u.float_number * 1000.0);
break;
default:
- error("Bad argument 1 to sleep.\n");
+ ERROR("sleep", "Bad argument 1.\n", sp, args);
break;
}
1218:
INT32 a,b;
if(!args)
- error("Too few arguments to sleep.\n");
+ ERROR("sleep", "Too few arguments.\n", sp, args);
GETTIMEOFDAY(&t1);
1239:
}
default:
- error("Bad argument 1 to sleep.\n");
+ ERROR("sleep", "Bad argument 1.\n", sp, args);
}
my_add_timeval(&t1, &t2);
1283:
void ID(INT32 args) \
{ \
int t; \
- if(args<1) error("Too few arguments to %s.\n",NAME); \
+ if(args<1) ERROR(NAME, "Too few arguments.\n", sp, args); \
t=sp[-args].type == TYPE; \
pop_n_elems(args); \
push_int(t); \
1293:
void f_programp(INT32 args)
{
if(args<1)
- error("Too few arguments to programp()\n");
+ ERROR("programp", "Too few arguments.\n", sp, args);
switch(sp[-args].type)
{
case T_PROGRAM:
1355:
struct array *a,*tmp;
if(args < 2)
- error("Too few arguments to rows().\n");
+ ERROR("rows", "Too few arguments.\n", sp, args);
if(sp[1-args].type!=T_ARRAY)
- error("Bad argument 1 to rows().\n");
+ ERROR("rows", "Bad argument 1.\n", sp, args);
tmp=sp[1-args].u.array;
push_array(a=allocate_array(tmp->size));
1378:
DECLARE_CYCLIC();
if(args < 2)
- error("Too few arguments to column().\n");
+ ERROR("column", "Too few arguments.\n", sp, args);
if(sp[-args].type!=T_ARRAY)
- error("Bad argument 1 to column().\n");
+ ERROR("column", "Bad argument 1.\n", sp, args);
tmp=sp[-args].u.array;
if((a=(struct array *)BEGIN_CYCLIC(tmp,0)))
1431: Inside #if defined(HAVE_LOCALTIME)
struct tm *tm;
time_t t;
if (args<1 || sp[-1].type!=T_INT)
- error("Illegal argument to localtime");
+ ERROR("localtime", "Bad argument to localtime", sp, args);
t=sp[-1].u.integer;
tm=localtime(&t);
1483: Inside #if defined(HAVE_MKTIME)
struct svalue * r;
int retval;
if (args<1)
- error ("Too few arguments to mktime().\n");
+ ERROR("mktime", "Too few arguments.\n", sp, args);
if(args == 1)
{
1537:
#endif
if (retval == -1)
- error ("mktime: Cannot convert.\n");
+ ERROR("mktime", "Cannot convert.\n", sp, args);
pop_n_elems(args);
push_int(retval);
}
1583:
struct pike_string *glob;
if(args < 2)
- error("Too few arguments to glob().\n");
+ ERROR("glob", "Too few arguments.\n", sp, args);
if(args > 2) pop_n_elems(args-2);
args=2;
if (sp[-args].type!=T_STRING)
- error("Bad argument 2 to glob().\n");
+ ERROR("glob", "Bad argument 2.\n", sp, args);
glob=sp[-args].u.string;
1610:
for(i=0;i<a->size;i++)
{
if(ITEM(a)[i].type != T_STRING)
- error("Bad argument 2 to glob()\n");
+ ERROR("glob", "Bad argument 2.\n", sp, args);
if(does_match(ITEM(a)[i].u.string->str,
ITEM(a)[i].u.string->len,
1631:
break;
default:
- error("Bad argument 2 to glob().\n");
+ ERROR("glob", "Bad argument 2.\n", sp, args);
}
}
1727:
/* THREADS_DISALLOW(); */
if (!a) {
- error("Array.longest_ordered_sequence():Out of memory");
+ ERROR("Array.longest_ordered_sequence", "Out of memory", sp, args);
}
pop_n_elems(args);
1947:
stack = malloc(sizeof(struct diff_magic_link*)*cmptbl->size);
- if (!stack) error("out of memory\n");
+ if (!stack) error("diff_longest_sequence(): Out of memory\n");
/* NB: marks is used for optimization purposes only */
marks = calloc(blen,1);
if (!marks) {
free(stack);
- error("Out of memory\n");
+ error("diff_longest_sequence(): Out of memory\n");
}
#ifdef DIFF_DEBUG
2040:
{
dml_free_pools(pools);
free(stack);
- error("out of memory\n");
+ error("diff_longest_sequence(): Out of memory\n");
}
dml->x = x;
2073:
{
dml_free_pools(pools);
free(stack);
- error("out of memory\n");
+ error("diff_longest_sequence: Out of memory\n");
}
dml->x = x;
2200:
struct array *diff;
if (args<2)
- error("Too few arguments to diff().\n");
+ ERROR("diff", "Too few arguments.\n", sp, args);
if (sp[-args].type!=T_ARRAY ||
sp[1-args].type!=T_ARRAY)
- error("Illegal arguments to diff().\n");
+ ERROR("diff", "Bad arguments.\n", sp, args);
cmptbl=diff_compare_table(sp[-args].u.array,sp[1-args].u.array);
push_array(cmptbl);
2222:
struct array *cmptbl;
if (args<2)
- error("Too few arguments to diff().\n");
+ ERROR("diff_compare_table", "Too few arguments.\n", sp, args);
if (sp[-args].type!=T_ARRAY ||
sp[1-args].type!=T_ARRAY)
- error("Illegal arguments to diff().\n");
+ ERROR("diff_compare_table", "Bad arguments.\n", sp, args);
cmptbl=diff_compare_table(sp[-args].u.array,sp[1-args].u.array);
2241:
struct array *diff;
if (args<2)
- error("Too few arguments to diff().\n");
+ ERROR("diff_longest_sequence", "Too few arguments.\n", sp, args);
if (sp[-args].type!=T_ARRAY ||
sp[1-args].type!=T_ARRAY)
- error("Illegal arguments to diff().\n");
+ ERROR("diff_longest_sequence", "Bad arguments.\n", sp, args);
cmptbl=diff_compare_table(sp[-args].u.array,sp[1-args].u.array);
push_array(cmptbl);
2331:
{
struct svalue tmp;
if(!args)
- error("Too few arguments to _next()\n");
+ ERROR("_next", "Too few arguments.\n", sp, args);
pop_n_elems(args-1);
tmp=sp[-1];
2344:
case T_PROGRAM: tmp.u.program=tmp.u.program->next; break;
case T_STRING: tmp.u.string=tmp.u.string->next; break;
default:
- error("Bad argument 1 to _next()\n");
+ ERROR("_next", "Bad argument 1.\n", sp, args);
}
if(tmp.u.refs)
{
2359:
{
struct svalue tmp;
if(!args)
- error("Too few arguments to _next()\n");
+ ERROR("_prev", "Too few arguments.\n", sp, args);
pop_n_elems(args-1);
tmp=sp[-1];
2371:
case T_MULTISET:tmp.u.multiset=tmp.u.multiset->prev; break;
case T_PROGRAM: tmp.u.program=tmp.u.program->prev; break;
default:
- error("Bad argument 1 to _prev()\n");
+ ERROR("_prev", "Bad argument 1.\n", sp, args);
}
if(tmp.u.refs)
{
2385:
void f__refs(INT32 args)
{
INT32 i;
- if(!args) error("Too few arguments to _refs()\n");
+ if(!args) ERROR("_refs", "Too few arguments.\n", sp, args);
if(sp[-args].type > MAX_REF_TYPE)
- error("Bad argument 1 to _refs()\n");
+ ERROR("refs", "Bad argument 1.\n", sp, args);
i=sp[-args].u.refs[0];
pop_n_elems(args);
2397:
void f_replace_master(INT32 args)
{
if(!args)
- error("Too few arguments to replace_master()\n");
+ ERROR("replace_master", "Too few arguments.\n", sp, 0);
if(sp[-args].type != T_OBJECT)
- error("Bad argument 1 to replace_master()\n");
+ ERROR("replace_master", "Bad argument 1.\n", sp, args);
if(!sp[-args].u.object->prog)
- error("replace_master() called with destructed object.\n");
+ ERROR("replace_master", "Called with destructed object.\n", sp, args);
free_object(master_object);
master_object=sp[-args].u.object;
2459: Inside #if defined(PROFILING)
int i;
if (!args) {
- error("get_profiling_info(): Too few arguments\n");
+ ERROR("get_profiling_info", "Too few arguments.\n", sp, args);
}
prog = program_from_svalue(sp-args);
- if(!prog) error("get_profiling_info(): Bad argument 1\n");
+ if(!prog) ERROR("get_profiling_info", "Bad argument 1.\n", sp, args);
prog->refs++;
2498:
get_all_args("variablep",args,"%o%S",&o, &s);
if(!o->prog)
- error("variablep() called on destructed object.\n");
+ ERROR("variablep", "Called on destructed object.\n", sp, args);
ret=find_shared_string_identifier(s,o->prog);
if(ret!=-1)