pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:208:      static void encode_value2(struct svalue *val, struct encode_data *data, int force_encode);      #ifdef ENCODE_DEBUG   static void debug_dump_mem(size_t offset, const unsigned char *bytes,    size_t len)   {    size_t i;    for (i = 0; i < len; i += 8) {    size_t j; -  fprintf(stderr, " %08x: ", offset + i); +  fprintf(stderr, " %08lx: ", offset + i);    for (j = 0; (i+j < len) && (j < 8); j++) {    fprintf(stderr, "%02x", bytes[i+j]);    }    fprintf(stderr, " ");    for (j = 0; (i+j < len) && (j < 8); j++) {    int c = bytes[i+j];    if (((c & 0177) < ' ') || (c == 0177)) {    /* Control or DEL */    c = '.';    }
pike.git/src/encode.c:235: Inside #if defined(ENCODE_DEBUG)
   }    }    fprintf(stderr, "\n");    }   }   static void low_addstr(struct byte_buffer *buf, const char *bytes,    size_t len, int edb)   {    if (edb >= 6) {    debug_dump_mem(buf->length - (((char *)buf->end) - ((char *)buf->dst)), -  bytes, len); +  (const unsigned char *)bytes, len);    }    buffer_memcpy(buf, bytes, len);   }   static void low_addchar(struct byte_buffer *buf, int c, int edb)   {    char byte = c;    low_addstr(buf, &byte, 1, edb);   }   #define addstr(s, l) low_addstr(&(data->buf), (s), (l), data->debug)   #define addchar(t) low_addchar(&(data->buf), (t), data->debug)
pike.git/src/encode.c:361:    {    case 3: addchar_unsafe((char)((num >> 24)&0xff)); /* FALLTHRU */    case 2: addchar_unsafe((char)((num >> 16)&0xff)); /* FALLTHRU */    case 1: addchar_unsafe((char)((num >> 8)&0xff)); /* FALLTHRU */    case 0: addchar_unsafe((char)(num&0xff));    }   }      static void code_number(ptrdiff_t num, struct encode_data *data)   { -  EDB(5, fprintf(stderr, "%*scode_number(%d)\n", +  EDB(5, fprintf(stderr, "%*scode_number(%ld)\n",    data->depth, "", num));    code_entry(num & 15, num >> 4, data);   }      /* NOTE: Take care to encode it exactly as the corresponing    * type string would have been encoded (cf T_FUNCTION, T_MANY,    * T_STRING, PIKE_T_NSTRING).    */   static void encode_type(struct pike_type *t, struct encode_data *data)   {
pike.git/src/encode.c:607:    !val->u.object->prog)    val = &dested;       if((tmp=low_mapping_lookup(data->encoded, val)))    {    entry_id = *tmp; /* It's always a small integer. */    if (entry_id.u.integer < COUNTER_START)    entry_id.u.integer = CONVERT_ENTRY_ID (entry_id.u.integer);    if (force_encode && tmp->u.integer < COUNTER_START) {    EDB(1, -  fprintf(stderr, "%*sEncoding delayed thing to <%d>: ", +  fprintf(stderr, "%*sEncoding delayed thing to <%ld>: ",    data->depth, "", entry_id.u.integer);    if(data->debug == 1)    {    fprintf(stderr,"TAG%d", TYPEOF(*val));    }else{    print_svalue(stderr, val);    }    fputc('\n', stderr););    code_entry (TAG_DELAYED, entry_id.u.integer, data);    tmp->u.integer = entry_id.u.integer;    EDB(1, {    ENCODE_WERR(".tag delayed, %ld", entry_id.u.integer);    });    }    else { -  EDB(1,fprintf(stderr, "%*sEncoding TAG_AGAIN from <%d>\n", +  EDB(1,fprintf(stderr, "%*sEncoding TAG_AGAIN from <%ld>\n",    data->depth, "", entry_id.u.integer));    code_entry(TAG_AGAIN, entry_id.u.integer, data);    EDB(1, {    ENCODE_WERR(".tag again, %ld", entry_id.u.integer);    });    goto encode_done;    }    }else {   #ifdef PIKE_DEBUG    if (force_encode == 2)    Pike_fatal ("Didn't find old entry for delay encoded thing.\n");   #endif    if (TYPEOF(*val) != T_TYPE) {    entry_id = data->counter; /* It's always a small integer. */ -  EDB(1,fprintf(stderr, "%*sEncoding to <%d>: ", +  EDB(1,fprintf(stderr, "%*sEncoding to <%ld>: ",    data->depth, "", entry_id.u.integer);    if(data->debug == 1)    {    fprintf(stderr,"TAG%d", TYPEOF(*val));    }else{    print_svalue(stderr, val);    }    fputc('\n', stderr););    EDB(1, {    ENCODE_WERR("# Encoding to tag #%ld", entry_id.u.integer);
pike.git/src/encode.c:717:    */    if (data->canonic)    Pike_error("Canonical encoding of the type type not supported.\n");       code_entry(TAG_TYPE, 0, data); /* Type encoding #0 */    EDB(1, {    ENCODE_WERR(".entry type");    });       encode_type(val->u.type, data); -  EDB(2,fprintf(stderr, "%*sEncoded type to <%d>: ", +  EDB(2,fprintf(stderr, "%*sEncoded type to <%ld>: ",    data->depth, "", data->counter.u.integer);    print_svalue(stderr, val);    fputc('\n', stderr););    mapping_insert(data->encoded, val, &data->counter);    data->counter.u.integer++;    break;       case T_FLOAT:    {    double d = val->u.float_number;
pike.git/src/encode.c:859:    INT64 x;    int y;    double tmp;       tmp = frexp(d, &y);    x = (INT64)((((INT64)1)<<(sizeof(INT64)*8 - 2))*tmp);    y -= sizeof(INT64)*8 - 2;       EDB(2,fprintf(stderr,    "Encoding float... tmp: %10g, x: 0x%016llx, y: %d\n", -  tmp, x, y)); +  tmp, (long long)x, y));       x >>= 32;    y += 32;       EDB(2,fprintf(stderr,    "Reducing float... x: 0x%08llx, y: %d\n", -  x, y)); +  (long long)x, y));    code_entry(TAG_FLOAT,x,data);    code_entry(TAG_FLOAT,y,data);    EDB(1, {    ENCODE_WERR(".float %ld, %ld", x, y);    });    }    break;    }       case T_ARRAY:
pike.git/src/encode.c:2922:    data->depth += 2;   #endif       check_c_stack(1024);       DECODE("decode_value2");       switch(what & TAG_MASK)    {    case TAG_DELAYED: -  EDB (2, fprintf(stderr, "%*sDecoding delay encoded from <%d>\n", +  EDB (2, fprintf(stderr, "%*sDecoding delay encoded from <%ld>\n",    data->depth, "", num););    SET_SVAL(entry_id, T_INT, NUMBER_NUMBER, integer, num);    if (!(delayed_enc_val = low_mapping_lookup (data->decoded, &entry_id)))    decode_error (data, NULL, "Failed to find previous record of " -  "delay encoded entry <%d>.\n", num); +  "delay encoded entry <%ld>.\n", num);    DECODE ("decode_value2");    break;       case TAG_AGAIN: -  EDB (1, fprintf(stderr, "%*sDecoding TAG_AGAIN from <%d>\n", +  EDB (1, fprintf(stderr, "%*sDecoding TAG_AGAIN from <%ld>\n",    data->depth, "", num););    SET_SVAL(entry_id, T_INT, NUMBER_NUMBER, integer, num);    if((tmp2=low_mapping_lookup(data->decoded, &entry_id)))    {    push_svalue(tmp2);    }else{ -  decode_error(data, NULL, "Failed to decode TAG_AGAIN entry <%d>.\n", +  decode_error(data, NULL, "Failed to decode TAG_AGAIN entry <%ld>.\n",    num);    }    goto decode_done;       default:    entry_id = data->counter;    data->counter.u.integer++;    /* Fall through. */       case TAG_TYPE: -  EDB (2, fprintf(stderr, "%*sDecoding to <%d>: TAG%d (%d)\n", -  data->depth, "", entry_id.u.integer , +  EDB (2, fprintf(stderr, "%*sDecoding to <%ld>: TAG%d (%ld)\n", +  data->depth, "", entry_id.u.integer,    what & TAG_MASK, num););    /* Types are added to the encoded mapping AFTER they have been    * encoded. */    delayed_enc_val = NULL;    break;    }       check_stack(1);       switch(what & TAG_MASK)
pike.git/src/encode.c:2988:       EDB(2,fprintf(stderr, "Decoding float... num:0x%016" PRINTINT64 "x\n",    num));       res = (double)num;       EDB(2,fprintf(stderr, "Mantissa: %10g\n", res));       DECODE("float");    -  EDB(2,fprintf(stderr, "Exponent: %d\n", num)); +  EDB(2,fprintf(stderr, "Exponent: %ld\n", num));       if(!res)    {    switch(num)    {    case Pike_FP_SNAN: /* Signal Not A Number */    case Pike_FP_QNAN: /* Quiet Not A Number */    push_float((FLOAT_TYPE)MAKE_NAN());    break;   
pike.git/src/encode.c:3046:    struct array *a;    TYPE_FIELD types;    if(num < 0)    decode_error(data, NULL,    "Failed to decode array (array size is negative).\n");       /* Heruetical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode array (not enough data).\n");    -  EDB(2,fprintf(stderr, "%*sDecoding array of size %d to <%d>\n", +  EDB(2,fprintf(stderr, "%*sDecoding array of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer));       SETUP_DECODE_MEMOBJ(T_ARRAY, array, a, allocate_array(num),    free_svalues(ITEM(a), a->size, a->type_field));       types = 0;    for(e=0;e<num;e++)    {    decode_value2(data);    stack_pop_to_no_free (ITEM(a) + e);
pike.git/src/encode.c:3076:    struct mapping *m;    if(num<0)    decode_error(data, NULL, "Failed to decode mapping "    "(mapping size is negative).\n");       /* Heuristical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode mapping "    "(not enough data).\n");    -  EDB(2,fprintf(stderr, "%*sDecoding mapping of size %d to <%d>\n", +  EDB(2,fprintf(stderr, "%*sDecoding mapping of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer));       SETUP_DECODE_MEMOBJ(T_MAPPING, mapping, m, allocate_mapping(num), ; );       for(e=0;e<num;e++)    {    decode_value2(data);    decode_value2(data);    mapping_insert(m, Pike_sp-2, Pike_sp-1);    pop_n_elems(2);
pike.git/src/encode.c:3108:    decode_error(data, NULL, "Failed to decode multiset "    "(multiset size is negative).\n");       /* Heruetical */    if(num > data->len - data->ptr)    decode_error(data, NULL, "Failed to decode multiset "    "(not enough data).\n");       /* NOTE: This code knows stuff about the implementation of multisets...*/    -  EDB(2,fprintf(stderr, "%*sDecoding multiset of size %d to <%d>\n", +  EDB(2,fprintf(stderr, "%*sDecoding multiset of size %ld to <%ld>\n",    data->depth, "", num, entry_id.u.integer));    SETUP_DECODE_MEMOBJ (T_MULTISET, multiset, m,    allocate_multiset (0, 0, NULL), ;);    /* FIXME: This array could be avoided by building the multiset directly. */    a = low_allocate_array (num, 0);       types = 0;    for(e=0;e<num;e++)    {    decode_value2(data);
pike.git/src/encode.c:3161:    /* decode_value_clone_object does not call __INIT, so    * we want to do that ourselves...    */    struct object *o=decode_value_clone_object(Pike_sp-1);       if (!o) {    if (data->pickyness)    decode_error (data, NULL,    "Failed to decode program for object. Got: %O\n",    Pike_sp - 1); -  EDB(1,fprintf(stderr, "%*sDecoded a failed object to <%d>: ", +  EDB(1,fprintf(stderr, "%*sDecoded a failed object to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););    decode_value2(data);    pop_n_elems(2);    push_undefined();    break;    }       debug_malloc_touch(o);
pike.git/src/encode.c:3189:    int lfun = FIND_LFUN(o->prog, LFUN___INIT);    if (lfun >= 0) {    apply_low(o, lfun, 0);    pop_stack();    }    /* FIXME: Should call LFUN_CREATE here in <= 7.2    * compatibility mode. */    }else{    struct unfinished_obj_link *ol=ALLOC_STRUCT(unfinished_obj_link);    EDB(2,fprintf(stderr, -  "%*sDecoded an unfinished object to <%d>: ", +  "%*sDecoded an unfinished object to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););    add_ref(ol->o = o);    ol->next=data->unfinished_objects;    SET_SVAL(ol->decode_arg, PIKE_T_INT, NUMBER_UNDEFINED,    integer, 0);    data->unfinished_objects=ol;    decode_value2(data);    assign_svalue(&ol->decode_arg, Pike_sp-1);    pop_stack();    break;    }    }    -  EDB(2,fprintf(stderr, "%*sDecoded an object to <%d>: ", +  EDB(2,fprintf(stderr, "%*sDecoded an object to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););       ref_push_object(o);    decode_value2(data);       fun = find_identifier("decode_object", decoder_codec (data)->prog);    if (fun < 0)    decode_error(data, Pike_sp - 1,
pike.git/src/encode.c:3364:    decode_error(data, Pike_sp - 2,    "Failed to decode function. Got: %O\n", Pike_sp - 1);       stack_pop_keep_top();       break;          case TAG_PROGRAM:    EDB(3, -  fprintf(stderr, "%*s TAG_PROGRAM(%d)\n", +  fprintf(stderr, "%*s TAG_PROGRAM(%ld)\n",    data->depth, "", num));    switch(num)    {    case 0:    {    struct program *p;       decode_value2(data);    apply(decoder_codec (data),"programof", 1);   
pike.git/src/encode.c:3442:    "Expected integer, got: %O\n", Pike_sp - 1);    }    break;       case 5: { /* Forward reference for new-style encoding. */    struct program *p = low_allocate_program();       push_program (p);    EDB(2,    fprintf (stderr, "%*sInited an embryo for a delay encoded program " -  "to <%d>: ", +  "to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue (stderr, Pike_sp - 1);    fputc ('\n', stderr););       data->delay_counter++;       break;    }       case 4: /* New-style encoding. */
pike.git/src/encode.c:3576:    }       copy_shared_string(save_current_file, c->lex.current_file);    save_current_line = c->lex.current_line;       SET_ONERROR(err2, restore_current_file, save_current_file);       if (!delayed_enc_val) {    struct svalue prog;    SET_SVAL(prog, T_PROGRAM, 0, program, p); -  EDB(2,fprintf(stderr, "%*sDecoding a program to <%d>: ", +  EDB(2,fprintf(stderr, "%*sDecoding a program to <%ld>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, &prog);    fputc('\n', stderr););    mapping_insert(data->decoded, &entry_id, &prog);    debug_malloc_touch(p);    } else {    data->delay_counter--;    }       debug_malloc_touch(p);
pike.git/src/encode.c:3890:       /* Expected identifier offset */    decode_number(no, data);       EDB(5, {    INT_TYPE line;    struct pike_string *file =    get_line(func.offset + p->program, p, &line);    fprintf(stderr,    "%*sdefine_function(\"%s\", X, 0x%04x, 0x%04x,\n" -  "%*s 0x%04x, 0x%04x)\n" +  "%*s 0x%04lx, 0x%04x)\n"    "%*s @ %s:%ld\n",    data->depth, "",    Pike_sp[-2].u.string->str, id_flags, func_flags,    data->depth, "",    func.offset, opt_flags,    data->depth, "",    file->str, (long)line);    });       /* Alters
pike.git/src/encode.c:4317:    break;       default:    decode_error(data, NULL, "Failed to restore string (illegal type %d).\n",    what & TAG_MASK);    }       mapping_insert(data->decoded, &entry_id, Pike_sp-1);      decode_done:; -  EDB(2,fprintf(stderr, "%*sDecoded to <%d>: ", data->depth, "", entry_id.u.integer); +  EDB(2,fprintf(stderr, "%*sDecoded to <%ld>: ", data->depth, "", entry_id.u.integer);    print_svalue(stderr, Pike_sp-1);    fputc('\n', stderr););   #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif   }      static struct decode_data *current_decode = NULL;      static void free_decode_data (struct decode_data *data, int delay,