Branch: Tag:

1997-01-28

1997-01-28 02:58:20 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

bugs fixed

Rev: src/encode.c:1.2

26:   #include <netinet/in.h>   #endif    + #include <math.h> +    struct encode_data   {    struct svalue counter;
39:   /* Current encoding: ¶ik0 */   #define T_AGAIN 15   #define T_MASK 15 - #define T_NEG 32 - #define T_SMALL 64 + #define T_NEG 16 + #define T_SMALL 32   #define SIZE_SHIFT 6   #define MAX_SMALL (1<<(8-SIZE_SHIFT))   #define COUNTER_START -MAX_SMALL
116:    code_entry(T_FLOAT,0,data);    }else{    INT32 x,y; -  y=(int)ceil(log(val->u.float_number)/log(2.0))-31; +  y=(int)ceil(log(val->u.float_number)/log(2.0))-30;    x=(int)((val->u.float_number)*pow(2.0,(float)-y));    while(x && y && !(x&1))    {
126:    code_entry(T_FLOAT,x,data);    code_entry(T_FLOAT,y,data);    } +  break;    }       case T_ARRAY:
212:      static int my_extract_char(struct decode_data *data)   { -  if(data->len >= data->ptr) +  if(data->ptr >= data->len)    error("Format error, not enough data in string.\n");    return data->data [ data->ptr++ ];   }
263:    case T_STRING:    tmp=data->counter;    data->counter.u.integer++; -  if(data->ptr + num >= data->len) +  if(data->ptr + num > data->len)    error("Failed to decode string. (string range error)\n");    push_string(make_shared_binary_string(data->data + data->ptr, num));    data->ptr+=num;
280:    push_float(num2 * pow(2.0, (double) num));    break;    } +     case T_ARRAY:    {    struct array *a=allocate_array(num);
386:    data->len=tmp->len;    data->ptr=0;    -  +  if(data->len < 5) return 0;    if(GETC() != 182 ||    GETC() != 'k' ||    GETC() != 'e' ||