pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:18:   #include "pike_error.h"   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"    - RCSID("$Id: encode.c,v 1.78 2000/12/01 08:09:46 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.79 2000/12/05 21:08:17 per Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   #define EDB(X) X   #else   #define EDB(X)   #endif      /* The sp macro conflicts with Solaris 2.5.1's <sys/conf.h>. */
pike.git/src/encode.c:264:   #endif      static ptrdiff_t encode_type(char *t, struct encode_data *data)   {    char *q=t;   one_more_type:    addchar(EXTRACT_UCHAR(t));    switch(EXTRACT_UCHAR(t++))    {    default: -  fatal("Pike_error in type string.\n"); +  fatal("error in type string.\n");    /*NOTREACHED*/       break;       case T_ASSIGN:    addchar(EXTRACT_UCHAR(t++));    goto one_more_type;       case T_FUNCTION:    while(EXTRACT_UCHAR(t)!=T_MANY)
pike.git/src/encode.c:790:    struct svalue counter;    struct object *codec;    int pickyness;   };      static void decode_value2(struct decode_data *data);      static int my_extract_char(struct decode_data *data)   {    if(data->ptr >= data->len) -  Pike_error("Format Pike_error, not enough data in string.\n"); +  Pike_error("Format error, not enough data in string.\n");    return data->data [ data->ptr++ ];   }      #define GETC() my_extract_char(data)      #define DECODE(Z) do { \    EDB( \    fprintf(stderr,"decode(%s) at %d: ",(Z),__LINE__)); \    what=GETC(); \    e=what>>SIZE_SHIFT; \
pike.git/src/encode.c:840:    do { \    INT32 what, e, num, numh; \    DECODE("decode_entry"); \    if((what & TAG_MASK) != (X)) \    Pike_error("Failed to decode, wrong bits (%d).\n", what & TAG_MASK); \    (Y)=num; \    } while(0);      #define getdata2(S,L) do { \    if(data->ptr + (ptrdiff_t)(sizeof(S[0])*(L)) > data->len) \ -  Pike_error("Failed to decode string. (string range Pike_error)\n"); \ +  Pike_error("Failed to decode string. (string range error)\n"); \    MEMCPY((S),(data->data + data->ptr), sizeof(S[0])*(L)); \    data->ptr+=sizeof(S[0])*(L); \    }while(0)      #if BYTEORDER == 4123   #define BITFLIP(S)   #else   #define BITFLIP(S) \    switch(what) \    { \
pike.git/src/encode.c:863:    }   #endif      #define get_string_data(STR,LEN, data) do { \    if((LEN) == -1) \    { \    INT32 what, e, num, numh; \    DECODE("get_string_data"); \    what &= TAG_MASK; \    if(data->ptr + num > data->len || num <0) \ -  Pike_error("Failed to decode string. (string range Pike_error)\n"); \ +  Pike_error("Failed to decode string. (string range error)\n"); \    if(what<0 || what>2) \    Pike_error("Failed to decode string. (Illegal size shift)\n"); \    STR=begin_wide_shared_string(num, what); \    MEMCPY(STR->str, data->data + data->ptr, num << what); \    data->ptr+=(num << what); \    BITFLIP(STR); \    STR=end_shared_string(STR); \    }else{ \    if(data->ptr + (LEN) > data->len || (LEN) <0) \ -  Pike_error("Failed to decode string. (string range Pike_error)\n"); \ +  Pike_error("Failed to decode string. (string range error)\n"); \    STR=make_shared_binary_string((char *)(data->data + data->ptr), (LEN)); \    data->ptr+=(LEN); \    } \   }while(0)      #define getdata(X) do { \    long length; \    decode_entry(TAG_STRING, length,data); \    get_string_data(X, length, data); \    }while(0)
pike.git/src/encode.c:956:       SET_ONERROR(err1, restore_type_stack, Pike_compiler->type_stackp);    SET_ONERROR(err2, restore_type_mark, Pike_compiler->pike_type_mark_stackp);      one_more_type:    tmp = GETC();    push_type(tmp);    switch(tmp)    {    default: -  fatal("Pike_error in type string.\n"); +  fatal("error in type string.\n");    /*NOTREACHED*/    break;       case T_ASSIGN:    push_type(GETC());    goto one_more_type;       case T_FUNCTION:    while(GETC()!=T_MANY)    {
pike.git/src/encode.c:1351:    switch(num)    {    case 0:    {    struct svalue *prog_code;       tmp=data->counter;    data->counter.u.integer++;    decode_value2(data);    -  /* Keep the value so that we can make a good Pike_error-message. */ +  /* Keep the value so that we can make a good error-message. */    prog_code = Pike_sp-1;    stack_dup();       if(data->codec)    {    apply(data->codec,"programof", 1);    }else{    ref_push_mapping(get_builtin_constants());    stack_swap();    f_index(2);
pike.git/src/encode.c:1403:    debug_malloc_touch(p);    tmp.type=T_PROGRAM;    tmp.u.program=p;    mapping_insert(data->decoded, & data->counter, &tmp);    data->counter.u.integer++;    p->refs--;       decode_value2(data);    f_version(0);    if(!is_eq(Pike_sp-1,Pike_sp-2)) -  Pike_error("Cannot decode programs encoded with other driver version.\n"); +  Pike_error("Cannot decode programs encoded with other pike version.\n");    pop_n_elems(2);       decode_number(p->flags,data);    p->flags &= ~(PROGRAM_FINISHED | PROGRAM_OPTIMIZED);    p->flags |= PROGRAM_AVOID_CHECK;    decode_number(p->storage_needed,data);    decode_number(p->alignment_needed,data);    decode_number(p->timestamp.tv_sec,data);    decode_number(p->timestamp.tv_usec,data);   
pike.git/src/encode.c:1661:    decode_value2(data);    UNSET_ONERROR(err);    free_mapping(data->decoded);    return 1;   }      /* Compatibilidy decoder */      static unsigned char extract_char(char **v, ptrdiff_t *l)   { -  if(!*l) Pike_error("Format Pike_error, not enough place for char.\n"); +  if(!*l) Pike_error("Format error, not enough place for char.\n");    else (*l)--;    (*v)++;    return ((unsigned char *)(*v))[-1];   }      static ptrdiff_t extract_int(char **v, ptrdiff_t *l)   {    INT32 j;    ptrdiff_t i;       j=extract_char(v,l);    if(j & 0x80) return (j & 0x7f);       if((j & ~8) > 4) -  Pike_error("Format Error: Error in format string, invalid integer.\n"); +  Pike_error("Format error: Error in format string, invalid integer.\n");    i=0;    while(j & 7) { i=(i<<8) | extract_char(v,l); j--; }    if(j & 8) return -i;    return i;   }      static void rec_restore_value(char **v, ptrdiff_t *l)   {    ptrdiff_t t, i;   
pike.git/src/encode.c:1703:    return;       case TAG_FLOAT:    if(sizeof(ptrdiff_t) < sizeof(FLOAT_TYPE)) /* FIXME FIXME FIXME FIXME */    Pike_error("Float architecture not supported.\n");    push_int(DO_NOT_WARN(t)); /* WARNING! */    Pike_sp[-1].type = T_FLOAT;    return;       case TAG_TYPE: -  Pike_error("Format Pike_error:decoding of the type type not supported yet.\n"); +  Pike_error("Format error: decoding of the type type not supported yet.\n");    return;       case TAG_STRING: -  if(t<0) Pike_error("Format Pike_error, length of string is negative.\n"); -  if(*l < t) Pike_error("Format Pike_error, string to short\n"); +  if(t<0) Pike_error("Format error: length of string is negative.\n"); +  if(*l < t) Pike_error("Format error: string to short\n");    push_string(make_shared_binary_string(*v, t));    (*l)-= t;    (*v)+= t;    return;       case TAG_ARRAY: -  if(t<0) Pike_error("Format Pike_error, length of array is negative.\n"); +  if(t<0) Pike_error("Format error: length of array is negative.\n");    check_stack(t);    for(i=0;i<t;i++) rec_restore_value(v,l);    f_aggregate(DO_NOT_WARN(t));    return;       case TAG_MULTISET: -  if(t<0) Pike_error("Format Pike_error, length of multiset is negative.\n"); +  if(t<0) Pike_error("Format error: length of multiset is negative.\n");    check_stack(t);    for(i=0;i<t;i++) rec_restore_value(v,l);    f_aggregate_multiset(DO_NOT_WARN(t));    return;       case TAG_MAPPING: -  if(t<0) Pike_error("Format Pike_error, length of mapping is negative.\n"); +  if(t<0) Pike_error("Format error: length of mapping is negative.\n");    check_stack(t*2);    for(i=0;i<t;i++)    {    rec_restore_value(v,l);    rec_restore_value(v,l);    }    f_aggregate_mapping(DO_NOT_WARN(t*2));    return;       case TAG_OBJECT: -  if(t<0) Pike_error("Format Pike_error, length of object is negative.\n"); -  if(*l < t) Pike_error("Format Pike_error, string to short\n"); +  if(t<0) Pike_error("Format error: length of object is negative.\n"); +  if(*l < t) Pike_error("Format error: string to short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("objectof", 1);    return;       case TAG_FUNCTION: -  if(t<0) Pike_error("Format Pike_error, length of function is negative.\n"); -  if(*l < t) Pike_error("Format Pike_error, string to short\n"); +  if(t<0) Pike_error("Format error: length of function is negative.\n"); +  if(*l < t) Pike_error("Format error: string to short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("functionof", 1);    return;       case TAG_PROGRAM: -  if(t<0) Pike_error("Format Pike_error, length of program is negative.\n"); -  if(*l < t) Pike_error("Format Pike_error, string to short\n"); +  if(t<0) Pike_error("Format error: length of program is negative.\n"); +  if(*l < t) Pike_error("Format error: string to short\n");    push_string(make_shared_binary_string(*v, t));    (*l) -= t; (*v) += t;    APPLY_MASTER("programof", 1);    return;       default: -  Pike_error("Format Pike_error. Unknown type tag %ld:%ld\n", +  Pike_error("Format error: Unknown type tag %ld:%ld\n",    PTRDIFF_T_TO_LONG(i), PTRDIFF_T_TO_LONG(t));    }   }      void f_decode_value(INT32 args)   {    struct pike_string *s;    struct object *codec;       check_all_args("decode_value", args,