pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1:   /*   || 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.266 2008/05/16 18:20:07 grubba Exp $ + || $Id: encode.c,v 1.267 2008/05/17 13:36:56 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"
pike.git/src/encode.c:2458:      static void cleanup_new_program_decode (void *ignored)   {    debug_malloc_touch(Pike_compiler->new_program);    debug_malloc_touch(Pike_compiler->new_program->parent);    /* The program is consistent enough to be freed... */    Pike_compiler->new_program->flags &= ~PROGRAM_AVOID_CHECK;    end_first_pass(0);   }    + static void restore_current_file(void *save_current_file) + { +  struct compilation *c = THIS_COMPILATION; +  free_string(c->lex.current_file); +  c->lex.current_file = save_current_file; + } +    static DECLSPEC(noreturn) void decode_error (struct svalue *decoding,    struct svalue *other,    char *msg, ...)    ATTRIBUTE((noreturn,format (printf, 3, 4)));      static DECLSPEC(noreturn) void decode_error (struct svalue *decoding,    struct svalue *other,    char *msg, ...)   {    int n = 0;
pike.git/src/encode.c:3760:    enter_compiler(NULL, 0);       c = THIS_COMPILATION;       /* We don't want to be affected by #pragma save_parent or    * __pragma_save_parent__.    */    old_pragmas = c->lex.pragmas;    c->lex.pragmas = (old_pragmas & ~ID_SAVE_PARENT)|ID_DONT_SAVE_PARENT;    -  copy_shared_string(save_current_file, c->lex.current_file); -  save_current_line = c->lex.current_line; -  +     /* Start the new program. */    low_start_new_program(p, 1, NULL, 0, NULL);    p = Pike_compiler->new_program;   #if TWO_PASS_DECODE_WORKS    if(! data->supporter.prog)    data->supporter.prog = p;   #endif       p->flags = p_flags;       /* Kludge to get end_first_pass() to free the program. */    Pike_compiler->num_parse_error++;       SET_ONERROR(err, cleanup_new_program_decode, NULL);       debug_malloc_touch(p);    -  +  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;    prog.type=T_PROGRAM;    prog.u.program=p;    EDB(2,fprintf(stderr, "%*sDecoding a program to <%d>: ",    data->depth, "", entry_id.u.integer);    print_svalue(stderr, &prog);    fputc('\n', stderr););    mapping_insert(data->decoded, &entry_id, &prog);    debug_malloc_touch(p);
pike.git/src/encode.c:4407:    pop_n_elems(3);    }    break;    default:    Pike_error("Unsupported id entry type: %d\n", entry_type);    }    decode_number(entry_type, data);    }       /* Restore c->lex. */ -  free_string(c->lex.current_file); -  c->lex.current_file = save_current_file; +  CALL_AND_UNSET_ONERROR(err2);    c->lex.current_line = save_current_line;      #ifdef ENCODE_DEBUG    data->depth-=2;   #endif       UNSET_ONERROR(err);       /* De-kludge to get end_first_pass() to free the program. */    Pike_compiler->num_parse_error--;