pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1:   /* -*- c -*-   || 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: builtin.cmod,v 1.207 2008/06/18 20:50:59 mast Exp $ + || $Id: builtin.cmod,v 1.208 2008/06/19 14:23:47 mast Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin.cmod:2181:    *! are given to the create method as a @i{from@} and @i{to@} array    *! and are then analyzed. The @expr{`()@} is then called with a    *! string and the replace rules in the Replace object will be    *! applied. The Replace object is used internally by the Pike    *! optimizer and need not be used manually.    */   PIKECLASS multi_string_replace   {    CVAR struct replace_many_context ctx;    /* NOTE: from and to are only kept for _encode()'s use. */ -  CVAR struct array *from; -  CVAR struct array *to; +  PIKEVAR array from flags ID_STATIC; +  PIKEVAR array to flags ID_STATIC;       /*! @decl void create(array(string)|mapping(string:string)|void from, @    *! array(string)|string|void to)    */    PIKEFUN void create(array(string)|mapping(string:string)|void from_arg,    array(string)|string|void to_arg)    {    if (THIS->from) {    free_array(THIS->from);    THIS->from = NULL;    }    if (THIS->to) {    free_array(THIS->to);    THIS->to = NULL;    } -  if (THIS->ctx.v) { +  if (THIS->ctx.v)    free_replace_many_context(&THIS->ctx); -  THIS->ctx.v = NULL; -  } +        if (!args) {    push_int(0);    return;    }    if (from_arg && from_arg->type == T_MAPPING) {    if (to_arg) {    Pike_error("Bad number of arguments to create().\n");    }    THIS->from = mapping_indices(from_arg->u.mapping);
pike.git/src/builtin.cmod:2315:    stack_swap();    }    pop_stack();       f_multi_string_replace_create(i);    }       INIT    {    MEMSET(&THIS->ctx, 0, sizeof(struct replace_many_context)); -  THIS->from = NULL; -  THIS->to = NULL; +     }       EXIT    gc_trivial;    { -  if (THIS->from) free_array(THIS->from); -  if (THIS->to) free_array(THIS->to); +     free_replace_many_context(&THIS->ctx);    }   }      /*! @endclass    */      /*! @class SingleReplace    *!    *! This is a "compiled" version of the @[replace] function applied on