pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:18:   #include "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.64 2000/08/10 09:51:51 per Exp $"); + RCSID("$Id: encode.c,v 1.65 2000/08/10 13:23:59 grubba 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:56:   #define sp Pike_sp   #undef STACK_POINTER_WAS_DEFINED   #endif /* STACKPOINTER_WAS_DEFINED */      #ifdef HAVE_FREXP   #define FREXP frexp   #else   double FREXP(double x, int *exp)   {    double ret; -  *exp=(int)ceil(log(fabs(x))/log(2.0)); -  ret=(x*pow(2.0,(FLOAT_TYPE)-*exp)); +  *exp = DO_NOT_WARN((int)ceil(log(fabs(x))/log(2.0))); +  ret = (x*pow(2.0,(double)-*exp));    return ret;   }   #endif      #if HAVE_LDEXP   #define LDEXP ldexp   #else   double LDEXP(double x, int exp)   {    return x * pow(2.0,(double)exp);
pike.git/src/encode.c:215:    num-=(256 << (t<<3));    else    break;    }       tag |= t << SIZE_SHIFT;    addchar(tag);       switch(t)    { -  case 3: addchar((num >> 24)&0xff); -  case 2: addchar((num >> 16)&0xff); -  case 1: addchar((num >> 8)&0xff); -  case 0: addchar(num&0xff); +  case 3: addchar(DO_NOT_WARN((num >> 24)&0xff)); +  case 2: addchar(DO_NOT_WARN((num >> 16)&0xff)); +  case 1: addchar(DO_NOT_WARN((num >> 8)&0xff)); +  case 0: addchar(DO_NOT_WARN(num&0xff));    }   }      static void code_number(ptrdiff_t num, struct encode_data *data)   { -  code_entry(num & 15, num >> 4, data); +  code_entry(DO_NOT_WARN(num & 15), +  num >> 4, data);   }      #ifdef _REENTRANT   static void do_enable_threads(void)   {    exit_threads_disable(NULL);   }   #endif    - static int encode_type(char *t, struct encode_data *data) + 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("error in type string.\n");    /*NOTREACHED*/   
pike.git/src/encode.c:383:    {    if(val->u.float_number==0.0)    {    code_entry(TAG_FLOAT,0,data);    code_entry(TAG_FLOAT,0,data);    }else{    INT32 x;    int y;    double tmp;    -  tmp=FREXP((double)val->u.float_number, &y); -  x=(INT32)((1<<30)*tmp); +  tmp = FREXP((double)val->u.float_number, &y); +  x = DO_NOT_WARN((INT32)((1<<30)*tmp));    y-=30;   #if 0    while(x && y && !(x&1))    {    x>>=1;    y++;    }   #endif    code_entry(TAG_FLOAT,x,data);    code_entry(TAG_FLOAT,y,data);
pike.git/src/encode.c:734:       free_mapping(data->encoded);       pop_n_elems(args);    push_string(low_free_buf(&data->buf));   }      struct decode_data   {    unsigned char *data; -  INT32 len; -  INT32 ptr; +  ptrdiff_t len; +  ptrdiff_t ptr;    struct mapping *decoded;    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)   {
pike.git/src/encode.c:784:      #define decode_entry(X,Y,Z) \    do { \    INT32 what, e, num; \    DECODE("decode_entry"); \    if((what & TAG_MASK) != (X)) error("Failed to decode, wrong bits (%d).\n", what & TAG_MASK);\    (Y)=num; \    } while(0);      #define getdata2(S,L) do { \ -  if(data->ptr + (long)(sizeof(S[0])*(L)) > data->len) \ +  if(data->ptr + (ptrdiff_t)(sizeof(S[0])*(L)) > data->len) \    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:1309:    error("Failed to decode program.\n");    }    /* Remove the extra entry from the stack. */    stack_swap();    pop_stack();    break;    }    case 1:    {    int d; -  SIZE_T size=0; +  size_t size=0;    char *dat;    struct program *p;    ONERROR err1;    ONERROR err2;      #ifdef _REENTRANT    ONERROR err;    low_init_threads_disable();    SET_ONERROR(err, do_enable_threads, 0);   #endif
pike.git/src/encode.c:1613:    if((j & ~8) > 4)    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, INT32 *l)   { -  INT32 t,i; +  ptrdiff_t t, i;    -  i=extract_int(v,l); -  t=extract_int(v,l); +  i = extract_int(v,l); +  t = extract_int(v,l);    switch(i)    { -  case TAG_INT: push_int(t); return; +  case TAG_INT: +  push_int(DO_NOT_WARN(t)); +  return;       case TAG_FLOAT: -  if(sizeof(INT32) < sizeof(float)) /* FIXME FIXME FIXME FIXME */ +  if(sizeof(ptrdiff_t) < sizeof(FLOAT_TYPE)) /* FIXME FIXME FIXME FIXME */    error("Float architecture not supported.\n"); -  push_int(t); /* WARNING! */ +  push_int(DO_NOT_WARN(t)); /* WARNING! */    Pike_sp[-1].type = T_FLOAT;    return;       case TAG_TYPE:    error("Format error:decoding of the type type not supported yet.\n");    return;       case TAG_STRING:    if(t<0) error("Format error, length of string is negative.\n");    if(*l < t) error("Format error, string to short\n");    push_string(make_shared_binary_string(*v, t)); -  (*l)-= t; (*v)+= t; +  (*l)-= t; +  (*v)+= t;    return;       case TAG_ARRAY:    if(t<0) 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(t);    return;       case TAG_MULTISET: