pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:1549:      past_identifier:    if (p != *pos) {    *pos = p;    return finish_string_builder (&sb);    }    free_string_builder (&sb);    return NULL;   }    - /* devours one reference to 'name'! */ +    /* The reference to the define is held by the stack on return. */   static struct define_struct *alloc_empty_define(struct pike_string *name)   {    struct define_struct *def;    struct object *o;       push_object(o = clone_object(define_program, 0));    def = (struct define_struct *)get_storage(o, define_program); -  def->name = name; -  debug_malloc_touch(name); +  add_ref(def->name = name);    return def;   }      /*! @directive #undef    *! @directive #undefine    *!    *! This removes the effect of a @[#define], all subsequent occurances of    *! the undefined identifier will not be replaced by anything.    *!    *! @note
pike.git/src/cpp.cmod:1651:    return finish_string_builder(&s);    }    return make_shared_string(name);   }      static struct define_struct *do_magic_define(struct cpp *this,    const char *name,    magic_define_fun fun)   {    struct define_struct* def; -  def = alloc_empty_define(make_define_name(this, name)); +  struct pike_string *name_str = make_define_name(this, name); +  def = alloc_empty_define(name_str); +  free_string(name_str);    def->magic=fun;    mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();    return def;   }      static void add_define(struct cpp *this,    struct pike_string *name,    struct pike_string *what)   {    struct define_struct* def; -  add_ref (name); +     def=alloc_empty_define(name);    ref_push_string(what);    f_aggregate(1);    def->parts = Pike_sp[-1].u.array;    Pike_sp--;    mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();   }      static void simple_add_define(struct cpp *this,    const char *name,    const char *what)   { -  add_define(this, make_define_name(this, name), make_shared_string(what)); +  +  struct pike_string *name_str = make_define_name(this, name); +  add_define(this, name_str, make_shared_string(what)); +  free_string(name_str);   }      static struct pike_string *recode_string(struct cpp *this, struct pike_string *data)   {    /* Observations:    *    * * At least a prefix of two bytes need to be 7bit in a valid    * Pike program.    *    * * NUL isn't valid in a Pike program.
pike.git/src/cpp.cmod:3483:    NEW_MAPPING_LOOP (predefs->data) {    if (TYPEOF(k->val) == T_STRING)    add_define (&this, k->ind.u.string, k->val.u.string);    else if(TYPEOF(k->val) == T_FUNCTION || TYPEOF(k->val) == T_OBJECT)    {    struct define_struct *def;    if( index_shared_string( k->ind.u.string, k->ind.u.string->len-1) == ')' )    {    struct pike_string *s = string_slice( k->ind.u.string, 0, k->ind.u.string->len-2);    def = alloc_empty_define(s); +  free_string(s);    def->magic = insert_callback_define;    def->varargs=1;    def->args=1;    }    else    {    def = alloc_empty_define(k->ind.u.string); -  k->ind.u.string->refs++; +     def->magic = insert_callback_define_no_args;    }    mapping_string_insert(this.defines, def->name, Pike_sp-1);    pop_stack();    }    else    add_define (&this, k->ind.u.string, empty_pike_string);    }    free_mapping (predefs);    }
pike.git/src/cpp.cmod:3581:    struct svalue s;       efun_str = make_shared_string ("efun");    constant_str = make_shared_string ("constant");    defined_str = make_shared_string ("defined");       use_initial_predefs = 1;       INIT;    -  defined_macro = alloc_empty_define(make_shared_string("defined")); +  defined_macro = alloc_empty_define(defined_str);    defined_macro->magic=check_defined;    defined_macro->args=1;    defined_macro_sval = Pike_sp[-1];    Pike_sp--;       ADD_INT_CONSTANT("__HAVE_CPP_PREFIX_SUPPORT__", 1, 0);       /* Somewhat tricky to add a _constant_ function in _static_modules.Builtin. */    SET_SVAL(s, T_FUNCTION, FUNCTION_BUILTIN, efun,    make_callable (f__take_over_initial_predefines,