Branch: Tag:

2010-11-22

2010-11-22 21:22:46 by Martin Stjernholm <mast@lysator.liu.se>

Fixed some bitrot in ENCODE_DEBUG.

It's now again somewhat possible to use it to force programs through
decode_value even if the codec returns completely bogus things.

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: encode.c,v 1.294 2010/07/01 11:25:18 grubba Exp $ + || $Id$   */      #include "global.h"
39: Inside #if defined(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. */ +  * encode_value_canonic and decode_value to activate this debug. It +  * both enables debug messages and also lessens the pickyness to +  * sort-of be able to decode programs with the wrong codec. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)   #ifndef PIKE_DEBUG   #error ENCODE_DEBUG requires PIKE_DEBUG
3196:       decode_value2(data);    push_compact_version(); -  if(!is_eq(Pike_sp-1,Pike_sp-2)) +  if(!is_eq(Pike_sp-1,Pike_sp-2) + #ifdef ENCODE_DEBUG +  && !data->debug + #endif +  )    Pike_error("Cannot decode programs encoded with other pike version.\n");    pop_n_elems(2);    -  + #ifdef ENCODE_DEBUG +  if (!data->debug) + #endif    data->pickyness++;       debug_malloc_touch(p);
3238:    p->parent=program_from_svalue(Pike_sp-1);    break;    default: +  if (data->pickyness)    decode_error(NULL, Pike_sp - 1, "Program decode failed. Got: "); -  +  p->parent = 0; +  break;    }    if(p->parent) {    add_ref(p->parent);
3578:    }    }    + #ifdef ENCODE_DEBUG +  if (!data->debug) + #endif    data->pickyness--;       if(placeholder)
3947:    /* Check the version. */    decode_value2(data);    push_compact_version(); -  if(!is_eq(Pike_sp-1,Pike_sp-2)) +  if(!is_eq(Pike_sp-1,Pike_sp-2) + #ifdef ENCODE_DEBUG +  && !data->debug + #endif +  )    Pike_error("Cannot decode programs encoded with other pike version.\n");    pop_n_elems(2);       debug_malloc_touch(p);    -  + #ifdef ENCODE_DEBUG +  if (!data->debug) + #endif    data->pickyness++;       /* parent */
4101:    decode_value2(data);    switch(entry_type) {    case ID_ENTRY_EFUN_CONSTANT: -  if ((Pike_sp[-1].type != T_FUNCTION) || -  (Pike_sp[-1].subtype != FUNCTION_BUILTIN)) { +  if (((Pike_sp[-1].type != T_FUNCTION) || +  (Pike_sp[-1].subtype != FUNCTION_BUILTIN)) && +  data->pickyness) {    ref_push_program (p);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Expected efun constant: ");    }    break;    case ID_ENTRY_TYPE_CONSTANT: -  if (Pike_sp[-1].type != T_TYPE) { +  if (Pike_sp[-1].type != T_TYPE && data->pickyness) {    ref_push_program (p);    decode_error(Pike_sp - 1, Pike_sp - 2,    "Expected type constant: ");    }    break;    default: -  +  if (data->pickyness)    Pike_error("Internal error: Unsupported early constant (%d)\n",    entry_type);    break;
4665:    e, get_name_of_type(constant->sval.type)));    }    + #ifdef ENCODE_DEBUG +  if (!data->debug) + #endif    data->pickyness--;       /* The program should be consistent now. */