pike.git / src / opcodes.c

version» Context lines:

pike.git/src/opcodes.c:8:   #include <math.h>   #include <ctype.h>   #include "interpret.h"   #include "svalue.h"   #include "array.h"   #include "stralloc.h"   #include "mapping.h"   #include "multiset.h"   #include "opcodes.h"   #include "object.h" - #include "error.h" + #include "pike_error.h"   #include "pike_types.h"   #include "pike_memory.h"   #include "fd_control.h"   #include "cyclic.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "security.h"   #include "bignum.h"   #include "operators.h"    - RCSID("$Id: opcodes.c,v 1.94 2000/11/29 13:14:18 mirar Exp $"); + RCSID("$Id: opcodes.c,v 1.95 2000/12/01 08:09:51 hubbe Exp $");      void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)   {    INT32 i;      #ifdef PIKE_SECURITY    if(what->type <= MAX_COMPLEX)    if(!CHECK_DATA_SECURITY(what->u.array, SECURITY_BIT_INDEX)) -  error("Index permission denied.\n"); +  Pike_error("Index permission denied.\n");   #endif       switch(what->type)    {   #ifdef AUTO_BIGNUM    case T_INT:    {    INT_TYPE val = what->u.integer;       convert_svalue_to_bignum(what);    index_no_free(to, what, ind);    if(IS_UNDEFINED(to)) {    if (val) { -  error("Indexing the integer %d with an unknown method.\n", val); +  Pike_error("Indexing the integer %d with an unknown method.\n", val);    } else {    if(ind->type == T_STRING) -  error("Indexing the NULL value with \"%s\".\n", ind->u.string->str); +  Pike_error("Indexing the NULL value with \"%s\".\n", ind->u.string->str);    else -  error("Indexing the NULL value.\n"); +  Pike_error("Indexing the NULL value.\n");    }    }    }    break;   #endif /* AUTO_BIGNUM */       case T_ARRAY:    simple_array_index_no_free(to,what->u.array,ind);    break;   
pike.git/src/opcodes.c:82:       case T_STRING:    if(ind->type==T_INT)    {    i=ind->u.integer;    if(i<0)    i+=what->u.string->len;    if(i<0 || i>=what->u.string->len)    {    if(what->u.string->len == 0) -  error("Attempt to index the empty string with %d.\n", i); +  Pike_error("Attempt to index the empty string with %d.\n", i);    else -  error("Index %d is out of string range 0 - %ld.\n", +  Pike_error("Index %d is out of string range 0 - %ld.\n",    i, PTRDIFF_T_TO_LONG(what->u.string->len - 1));    } else    i=index_shared_string(what->u.string,i);    to->type=T_INT;    to->subtype=NUMBER_NUMBER;    to->u.integer=i;    break;    }else{ -  error("Index is not an integer.\n"); +  Pike_error("Index is not an integer.\n");    }       case T_PROGRAM:    program_index_no_free(to, what->u.program, ind);    break;       case T_FUNCTION:    {    struct program *p = program_from_svalue(what);    if (p) {    program_index_no_free(to, p, ind);    break;    }    }    /* FALL THROUGH */       default: -  error("Indexing a basic type.\n"); +  Pike_error("Indexing a basic type.\n");    }   }      void o_index(void)   {    struct svalue s;    index_no_free(&s,sp-2,sp-1);    pop_n_elems(2);    *sp=s;    dmalloc_touch_svalue(sp);
pike.git/src/opcodes.c:140:    {    if(run_time_type == T_MIXED)    return;       if(sp[-1].type == T_OBJECT)    {    struct pike_string *s;    s=describe_type(type);    push_string(s);    if(!sp[-2].u.object->prog) -  error("Cast called on destructed object.\n"); +  Pike_error("Cast called on destructed object.\n");    if(FIND_LFUN(sp[-2].u.object->prog,LFUN_CAST) == -1) -  error("No cast method in object.\n"); +  Pike_error("No cast method in object.\n");    apply_lfun(sp[-2].u.object, LFUN_CAST, 1);    free_svalue(sp-2);    sp[-2]=sp[-1];    sp--;    dmalloc_touch_svalue(sp);    }else       switch(run_time_type)    {    default: -  error("Cannot perform cast to that type.\n"); +  Pike_error("Cannot perform cast to that type.\n");       case T_MIXED:    return;       case T_MULTISET:    switch(sp[-1].type)    {    case T_ARRAY:    {    extern void f_mkmultiset(INT32);    f_mkmultiset(1);    break;    }       default: -  error("Cannot cast %s to multiset.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to multiset.\n",get_name_of_type(sp[-1].type));    }    break;       case T_MAPPING:    switch(sp[-1].type)    {    case T_ARRAY:    {    struct array *a=sp[-1].u.array;    struct array *b;    struct mapping *m;    INT32 i;    m=allocate_mapping(a->size); /* MAP_SLOTS(a->size) */    push_mapping(m);    for (i=0; i<a->size; i++)    {    if (ITEM(a)[i].type!=T_ARRAY) -  error("Cast array to mapping: " +  Pike_error("Cast array to mapping: "    "element %d is not an array\n", i);    b=ITEM(a)[i].u.array;    if (b->size!=2) -  error("Cast array to mapping: " +  Pike_error("Cast array to mapping: "    "element %d is not an array of size 2\n", i);    mapping_insert(m,ITEM(b)+0,ITEM(b)+1);    }    stack_swap();    pop_n_elems(1);    break;    }       default: -  error("Cannot cast %s to mapping.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to mapping.\n",get_name_of_type(sp[-1].type));    }    break;       case T_ARRAY:    switch(sp[-1].type)    {    case T_MAPPING:    {    struct array *a=mapping_to_array(sp[-1].u.mapping);    pop_stack();
pike.git/src/opcodes.c:225:       case T_STRING:    f_values(1);    break;       case T_MULTISET:    f_indices(1);    break;       default: -  error("Cannot cast %s to array.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to array.\n",get_name_of_type(sp[-1].type));       }    break;       case T_INT:    switch(sp[-1].type)    {    case T_FLOAT:    i=DO_NOT_WARN((int)(sp[-1].u.float_number));   #ifdef AUTO_BIGNUM
pike.git/src/opcodes.c:275:    */   #else    i=STRTOL(sp[-1].u.string->str,0,10);    free_string(sp[-1].u.string);    sp[-1].type=T_INT;    sp[-1].u.integer=i;   #endif /* AUTO_BIGNUM */    break;       default: -  error("Cannot cast %s to int.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to int.\n",get_name_of_type(sp[-1].type));    }       break;       case T_FLOAT:    {    FLOAT_TYPE f = 0.0;       switch(sp[-1].type)    {
pike.git/src/opcodes.c:297:    f=(FLOAT_TYPE)(sp[-1].u.integer);    break;       case T_STRING:    f=STRTOD_PCHARP(MKPCHARP(sp[-1].u.string->str,    sp[-1].u.string->size_shift),0);    free_string(sp[-1].u.string);    break;       default: -  error("Cannot cast %s to float.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to float.\n",get_name_of_type(sp[-1].type));    }       sp[-1].type=T_FLOAT;    sp[-1].u.float_number=f;    break;    }       case T_STRING:    {    char buf[200];
pike.git/src/opcodes.c:328:    case T_ARRAY:    {    int i;    struct array *a = sp[-1].u.array;    struct pike_string *s;    int shift = 0;       for(i = a->size; i--; ) {    unsigned INT32 val;    if (a->item[i].type != T_INT) { -  error("cast: Item %d is not an integer.\n", i); +  Pike_error("cast: Item %d is not an integer.\n", i);    }    val = (unsigned INT32)a->item[i].u.integer;    if (val > 0xff) {    shift = 1;    if (val > 0xffff) {    shift = 2;    while(i--)    if (a->item[i].type != T_INT) -  error("cast: Item %d is not an integer.\n", i); +  Pike_error("cast: Item %d is not an integer.\n", i);    break;    }    while(i--) {    if (a->item[i].type != T_INT) { -  error("cast: Item %d is not an integer.\n", i); +  Pike_error("cast: Item %d is not an integer.\n", i);    }    val = (unsigned INT32)a->item[i].u.integer;    if (val > 0xffff) {    shift = 2;    while(i--)    if (a->item[i].type != T_INT) -  error("cast: Item %d is not an integer.\n", i); +  Pike_error("cast: Item %d is not an integer.\n", i);    break;    }    }    break;    }    }    s = begin_wide_shared_string(a->size, shift);    switch(shift) {    case 0:    for(i = a->size; i--; ) {
pike.git/src/opcodes.c:392:    break;    }    s = end_shared_string(s);    pop_stack();    push_string(s);    return;    }    break;       default: -  error("Cannot cast %s to string.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to string.\n",get_name_of_type(sp[-1].type));    }       sp[-1].type=T_STRING;    sp[-1].u.string=make_shared_string(buf);    break;    }       case T_OBJECT:    switch(sp[-1].type)    {
pike.git/src/opcodes.c:419:    push_int(0);    }    APPLY_MASTER("cast_to_object",2);    return;       case T_FUNCTION:    sp[-1].type = T_OBJECT;    break;       default: -  error("Cannot cast %s to object.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to object.\n",get_name_of_type(sp[-1].type));    }    break;       case T_PROGRAM:    switch(sp[-1].type)    {    case T_STRING:    if(Pike_fp->pc)    {    INT32 lineno;
pike.git/src/opcodes.c:453:    pop_stack();    push_program(p);    }else{    pop_stack();    push_int(0);    }    }    return;       default: -  error("Cannot cast %s to a program.\n",get_name_of_type(sp[-1].type)); +  Pike_error("Cannot cast %s to a program.\n",get_name_of_type(sp[-1].type));    }    }    }       if(run_time_type != sp[-1].type)    {    if(sp[-1].type == T_OBJECT && sp[-1].u.object->prog)    {    int f=FIND_LFUN(sp[-1].u.object->prog, LFUN__IS_TYPE);    if( f != -1)    {    push_text(get_name_of_type(run_time_type));    apply_low(sp[-2].u.object, f, 1);    f=!IS_ZERO(sp-1);    pop_stack();    if(f) goto emulated_type_ok;    }    } -  error("Cast failed, wanted %s, got %s\n", +  Pike_error("Cast failed, wanted %s, got %s\n",    get_name_of_type(run_time_type),    get_name_of_type(sp[-1].type));    }       emulated_type_ok:       if (!type) return;       switch(run_time_type)    {
pike.git/src/opcodes.c:643: Inside #if defined(PIKE_DEBUG)
  {   #ifdef PIKE_DEBUG    struct svalue *save_sp=sp;    if(sp[-2].type != T_STRING)    fatal("Cast expression destroyed stack or left droppings!\n");   #endif    o_cast(sp[-2].u.string,    compile_type_to_runtime_type(sp[-2].u.string));   #ifdef PIKE_DEBUG    if(save_sp != sp) -  fatal("Internal error: o_cast() left droppings on stack.\n"); +  fatal("Internal Pike_error: o_cast() left droppings on stack.\n");   #endif    free_svalue(sp-2);    sp[-2]=sp[-1];    sp--;    dmalloc_touch_svalue(sp);   }         /*    flags:
pike.git/src/opcodes.c:692:   static ptrdiff_t PIKE_CONCAT(read_set,SIZE) ( \    PIKE_CONCAT(p_wchar,SIZE) *match, \    ptrdiff_t cnt, \    struct sscanf_set *set, \    ptrdiff_t match_len) \   { \    size_t e, last = 0; \    CHAROPT( int set_size=0; ) \    \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    \    MEMSET(set->c, 0, sizeof(set->c)); \    set->a=0; \    \    if(match[cnt]=='^') \    { \    set->neg=1; \    cnt++; \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    }else{ \    set->neg=0; \    } \    \    if(match[cnt]==']' || match[cnt]=='-') \    { \    set->c[last=match[cnt]]=1; \    cnt++; \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    } \    \    for(;match[cnt]!=']';cnt++) \    { \    if(match[cnt]=='-') \    { \    cnt++; \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    \    if(match[cnt]==']') \    { \    set->c['-']=1; \    break; \    } \    \    if(last >= match[cnt]) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    \   CHAROPT( \    if(last < (size_t)sizeof(set->c)) \    { \    if(match[cnt] < (size_t)sizeof(set->c)) \    { \   ) \    for(e=last;e<=match[cnt];e++) set->c[e]=1; \   CHAROPT( \    }else{ \
pike.git/src/opcodes.c:789:    INT32 *order; \    set->a=aggregate_array(set_size*2); \    order=get_switch_order(set->a); \    for(e=0;e<(size_t)set->a->size;e+=2) \    { \    if(order[e]+1 != order[e+1]) \    { \    free_array(set->a); \    set->a=0; \    free((char *)order); \ -  error("Overlapping ranges in sscanf not supported.\n"); \ +  Pike_error("Overlapping ranges in sscanf not supported.\n"); \    } \    } \    \    order_array(set->a,order); \    free((char *)order); \    } \   ) \    return cnt; \   }   
pike.git/src/opcodes.c:1061:    fatal("Error in sscanf.\n"); \    } \    ); \    \    no_assign=0; \    field_length=-1; \    minus_flag=0; \    \    cnt++; \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    \    while(1) \    { \    switch(match[cnt]) \    { \    case '*': \    no_assign=1; \    cnt++; \    if(cnt>=match_len) \ -  error("Error in sscanf format string.\n"); \ +  Pike_error("Error in sscanf format string.\n"); \    continue; \    \    case '0': case '1': case '2': case '3': case '4': \    case '5': case '6': case '7': case '8': case '9': \    { \    PCHARP t; \    field_length = STRTOL_PCHARP(MKPCHARP(match+cnt, MATCH_SHIFT), \    &t,10); \    cnt = SUBTRACT_PCHARP(t, MKPCHARP(match, MATCH_SHIFT)); \    continue; \
pike.git/src/opcodes.c:1097:    continue; \    \    case '{': \    { \    ONERROR err; \    ptrdiff_t tmp; \    for(e=cnt+1,tmp=1;tmp;e++) \    { \    if(e>=match_len) \    { \ -  error("Missing %%} in format string.\n"); \ +  Pike_error("Missing %%} in format string.\n"); \    break; /* UNREACHED */ \    } \    if(match[e]=='%') \    { \    switch(match[e+1]) \    { \    case '%': e++; break; \    case '}': tmp--; break; \    case '{': tmp++; break; \    } \
pike.git/src/opcodes.c:1300:    } \    eye=t-input; \    sval.type=T_FLOAT; \    DO_IF_CHECKER(sval.subtype=0); \    break; \    } \    \    case 'F': \    if(field_length == -1) field_length = 4; \    if(field_length != 4 && field_length != 8) \ -  error("Invalid IEEE width %ld in sscanf format string.\n", \ +  Pike_error("Invalid IEEE width %ld in sscanf format string.\n", \    PTRDIFF_T_TO_LONG(field_length)); \    if(eye+field_length > input_len) \    { \    chars_matched[0]=eye; \    return matches; \    } \    sval.type=T_FLOAT; \    DO_IF_CHECKER(sval.subtype=0); \    switch(field_length) { \    case 4: \
pike.git/src/opcodes.c:1373:    s++; \    if(*s=='*') s++; \    set.neg=0; \    switch(*s) \    { \    case 'n': \    s++; \    goto test_again; \    \    case 's': \ -  error("Illegal to have two adjecent %%s.\n"); \ +  Pike_error("Illegal to have two adjecent %%s.\n"); \    return 0; /* make gcc happy */ \    \    /* sscanf("foo-bar","%s%d",a,b) might not work as expected */ \    case 'd': \    MEMSET(set.c, 1, sizeof(set.c)); \    for(e='0';e<='9';e++) set.c[e]=0; \    set.c['-']=0; \    goto match_set; \    \    case 'o': \
pike.git/src/opcodes.c:1527:    INPUT_SHIFT)(input+e,eye-e); \    break; \    \    case 'n': \    sval.type=T_INT; \    sval.subtype=NUMBER_NUMBER; \    sval.u.integer=TO_INT32(eye); \    break; \    \    default: \ -  error("Unknown sscanf token %%%c(0x%02x)\n", \ +  Pike_error("Unknown sscanf token %%%c(0x%02x)\n", \    match[cnt], match[cnt]); \    } \    break; \    } \    matches++; \    \    if(no_assign) \    { \    free_svalue(&sval); \    }else{ \
pike.git/src/opcodes.c:1597: Inside #if defined(PIKE_DEBUG)
  {   #ifdef PIKE_DEBUG    extern int t_flag;   #endif    INT32 e, i=0;    int x;    ptrdiff_t matched_chars;    struct svalue *save_sp=sp;       if(sp[-args].type != T_STRING) -  error("Bad argument 1 to sscanf().\n"); +  Pike_error("Bad argument 1 to sscanf().\n");       if(sp[1-args].type != T_STRING) -  error("Bad argument 1 to sscanf().\n"); +  Pike_error("Bad argument 1 to sscanf().\n");       switch(sp[-args].u.string->size_shift*3 + sp[1-args].u.string->size_shift) {    /* input_shift : match_shift */    case 0:    /* 0 : 0 */    i=very_low_sscanf_0_0(STR0(sp[-args].u.string),    sp[-args].u.string->len,    STR0(sp[1-args].u.string),    sp[1-args].u.string->len,    &matched_chars,
pike.git/src/opcodes.c:1686:    case 8:    /* 2 : 2 */    i=very_low_sscanf_2_2(STR2(sp[-args].u.string),    sp[-args].u.string->len,    STR2(sp[1-args].u.string),    sp[1-args].u.string->len,    &matched_chars,    &x);    break;    default: -  error("Unsupported shift-combination to sscanf(): %d:%d\n", +  Pike_error("Unsupported shift-combination to sscanf(): %d:%d\n",    sp[-args].u.string->size_shift, sp[1-args].u.string->size_shift);    break;    }       if(sp-save_sp > args/2-1) -  error("Too few arguments for sscanf format.\n"); +  Pike_error("Too few arguments for sscanf format.\n");       for(x=0;x<sp-save_sp;x++)    assign_lvalue(save_sp-args+2+x*2,save_sp+x);    pop_n_elems(sp-save_sp +args);      #ifdef PIKE_DEBUG    if(t_flag >2)    {    int nonblock;    if((nonblock=query_nonblocking(2)))
pike.git/src/opcodes.c:1810:    case 8:    /* 2 : 2 */    i=very_low_sscanf_2_2(STR2(sp[-args].u.string),    sp[-args].u.string->len,    STR2(sp[1-args].u.string),    sp[1-args].u.string->len,    &matched_chars,    &x);    break;    default: -  error("Unsupported shift-combination to sscanf(): %d:%d\n", +  Pike_error("Unsupported shift-combination to sscanf(): %d:%d\n",    sp[-args].u.string->size_shift, sp[1-args].u.string->size_shift);    break;    }       a = aggregate_array(DO_NOT_WARN(sp - save_sp));    pop_n_elems(args);    push_array(a);   }