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.136 2002/01/16 02:54:10 nilsson Exp $"); + RCSID("$Id: encode.c,v 1.137 2002/02/13 13:35:36 grubba Exp $");      /* #define ENCODE_DEBUG */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)   #else   #define EDB(N,X) do { debug_malloc_touch(data); } while (0)   #endif
pike.git/src/encode.c:847: Inside #if defined(AUTO_BIGNUM)
   encode_value2(Pike_sp-1, data);    pop_stack();    break;    }   #endif       if (data->canonic)    Pike_error("Canonical encoding of objects not supported.\n");    push_svalue(val);    apply(data->codec, "nameof", 1); +  EDB(5, fprintf(stderr, "%*s->nameof: ", data->depth, ""); +  print_svalue(stderr, Pike_sp-1); +  fputc('\n', stderr););    switch(Pike_sp[-1].type)    {    case T_INT:    if(Pike_sp[-1].subtype == NUMBER_UNDEFINED)    {    int to_change = data->buf.s.len;    struct svalue tmp=data->counter;    tmp.u.integer--;    -  +  EDB(5,fprintf(stderr, "%*s(UNDEFINED)\n", data->depth, "")); +     /* We have to remove ourself from the cache */    map_delete(data->encoded, val);       pop_stack();    push_svalue(val);    f_object_program(1);       /* Code the program */    code_entry(TAG_OBJECT, 3,data);    encode_value2(Pike_sp-1, data);
pike.git/src/encode.c:886:    EDB(1,fprintf(stderr, "%*sZapping 3 -> 1 in TAG_OBJECT\n",    data->depth, ""));       /* This causes the code_entry above to    * become: code_entry(TAG_OBJECT, 1, data);    * -Hubbe    */    data->buf.s.str[to_change] = 99;    apply(data->codec,"encode_object",1);    +  if ((Pike_sp[-1].type == T_INT) && +  (!Pike_sp[-1].u.integer) && +  (Pike_sp[-1].subtype)) { +  /* encode_object() returned UNDEFINED (aka failed). */ +  Pike_error("Failed to encode object.\n"); +  } +     /* Put value back in cache for future reference -Hubbe */    mapping_insert(data->encoded, val, &tmp);    }    break;    }    /* FALL THROUGH */       default:    code_entry(TAG_OBJECT, 0,data);    break;
pike.git/src/encode.c:1182:    *!    *! @seealso    *! @[decode_value()], @[sprintf()], @[encode_value_canonic()]    */   void f_encode_value(INT32 args)   {    ONERROR tmp;    struct encode_data d, *data;    data=&d;    - #ifdef ENCODE_DEBUG +     check_all_args("encode_value", args, BIT_MIXED, BIT_VOID | BIT_OBJECT,    BIT_VOID | BIT_INT, 0); - #else -  check_all_args("encode_value", args, BIT_MIXED, BIT_VOID | BIT_OBJECT, 0); - #endif +        initialize_buf(&data->buf);    data->canonic = 0;    data->encoded=allocate_mapping(128);    data->counter.type=T_INT;    data->counter.u.integer=COUNTER_START;    if(args > 1)    {    data->codec=Pike_sp[1-args].u.object;    }else{
pike.git/src/encode.c:1240:    *!    *! @seealso    *! @[encode_value()], @[decode_value()]    */   void f_encode_value_canonic(INT32 args)   {    ONERROR tmp;    struct encode_data d, *data;    data=&d;    - #ifdef ENCODE_DEBUG +     check_all_args("encode_value_canonic", args, BIT_MIXED, BIT_VOID | BIT_OBJECT,    BIT_VOID | BIT_INT, 0); - #else -  check_all_args("encode_value_canonic", args, BIT_MIXED, BIT_VOID | BIT_OBJECT, 0); - #endif +        initialize_buf(&data->buf);    data->canonic = 1;    data->encoded=allocate_mapping(128);    data->counter.type=T_INT;    data->counter.u.integer=COUNTER_START;    if(args > 1)    {    data->codec=Pike_sp[1-args].u.object;    }else{
pike.git/src/encode.c:3052:    *! @seealso    *! @[encode_value()], @[encode_value_canonic()]    */   void f_decode_value(INT32 args)   {    struct pike_string *s;    struct object *codec;      #ifdef ENCODE_DEBUG    int debug; + #endif /* ENCODE_DEBUG */ +     check_all_args("decode_value", args, -  BIT_STRING, BIT_VOID | BIT_OBJECT | BIT_INT, BIT_VOID | BIT_INT, 0); +  BIT_STRING, BIT_VOID | BIT_OBJECT | BIT_INT, +  BIT_VOID | BIT_INT, 0); +  + #ifdef ENCODE_DEBUG    debug = args > 2 ? Pike_sp[2-args].u.integer : 0; - #else -  check_all_args("decode_value", args, -  BIT_STRING, BIT_VOID | BIT_OBJECT | BIT_INT, 0); - #endif + #endif /* ENCODE_DEBUG */       s = Pike_sp[-args].u.string;    if(args<2)    {    codec=get_master();    }    else if(Pike_sp[1-args].type == T_OBJECT)    {    codec=Pike_sp[1-args].u.object;    }