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.109 2001/07/12 23:14:16 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.110 2001/07/12 23:41:20 hubbe 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 if (data->debug>=N) {X;} while (0)   #else   #define EDB(N,X) do {} while (0)   #endif
pike.git/src/encode.c:737:       if (data->canonic)    Pike_error("Canonical encoding of objects not supported.\n");    push_svalue(val);    apply(data->codec, "nameof", 1);    switch(Pike_sp[-1].type)    {    case T_INT:    if(Pike_sp[-1].subtype == NUMBER_UNDEFINED)    { +  int to_change = data->buf.s.len;    pop_stack();    push_svalue(val);    f_object_program(1);    -  /* FIXME: -  * If we want to be more backwards compatible, then -  * we could follow the following steps: -  * 1) do a code_entry(TAG_OBJECT, 1, data); -  * 2) remove ourselves from the cache -  * 3) code the program -  * 4) if val is present in the cache, goto 7 -  * 5) call encode_object -  * 6) break; -  * (This is the hard part...) -  * 7) change code_entry in (1) to code_entry(TAG_OBJECT,3 data) -  * 8) push_svalue(val) -  * 9) break; -  * -  * -Hubbe -  */ -  -  if(low_mapping_lookup(data->encoded, Pike_sp-1)) -  { -  code_entry(TAG_OBJECT, 1,data); -  encode_value2(Pike_sp-1, data); -  pop_stack(); -  -  push_svalue(val); -  apply(data->codec,"encode_object",1); -  }else{ -  /* We have to remove ourself from the cache permanently */ +  /* We have to remove ourself from the cache */    map_delete(data->encoded, val);       /* Code the program */    code_entry(TAG_OBJECT, 3,data);    encode_value2(Pike_sp-1, data);    pop_stack();    -  /* Code the object */ +     push_svalue(val); -  +  +  /* If we do not exist in cache, use backwards- +  * compatible method, otherwise use newfangled +  * style=3. -Hubbe +  */ +  if(!low_mapping_lookup(data->encoded, val)) +  { +  /* 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);    }    break;    }    /* FALL THROUGH */       default:    code_entry(TAG_OBJECT, 0,data);    break;    }    encode_value2(Pike_sp-1, data);