pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:6570:    loc.parent_identifier = Pike_fp->fun;    loc.inherit = Pike_fp->context;    find_external_context(&loc, 1);    return (struct List_struct *)(loc.o->storage +    loc.inherit->storage_offset);    }       INIT    {    add_ref(THIS->cur = HEAD_SENTINEL(List__get_iterator_find_parent())); -  THIS->ind = 0; +  THIS->ind = -1;    }       EXIT    gc_trivial;    {    if (THIS->cur) {    free_list_node(THIS->cur);    THIS->cur = NULL;    }    }
pike.git/src/builtin.cmod:6801:       /* Find our parent. */    loc.o = Pike_fp->current_object;    loc.parent_identifier = Pike_fp->fun;    loc.inherit = INHERIT_FROM_INT(loc.o->prog, loc.parent_identifier);    find_external_context(&loc, 1);    parent = (struct List_struct *)(loc.o->storage +    loc.inherit->storage_offset);    free_list_node(THIS->cur);    add_ref(THIS->cur = HEAD_SENTINEL(parent)); -  THIS->ind = 0; +  THIS->ind = -1;    pop_n_elems(args);    if (parent->head->next) {    push_int(1);    } else {    push_undefined();    }    }       /*! @decl protected mixed _iterator_next()    *!
pike.git/src/builtin.cmod:6825:    *! Returns the new element on success, and @[UNDEFINED]    *! at the end of the list.    *!    *! @seealso    *! @[prev()]    */    PIKEFUN mixed _iterator_next()    flags ID_PROTECTED;    {    struct pike_list_node *next; -  if ((next = THIS->cur->next)) { +  if (!THIS->cur) { +  add_ref(THIS->cur = List__get_iterator_find_parent()->head); +  THIS->ind = 0; +  } else if ((next = THIS->cur->next)) {    free_list_node(THIS->cur);    add_ref(THIS->cur = next);    THIS->ind++;    } else {    /* We are at the tail sentinel. */    next = TAIL_TO_LIST(THIS->cur)->head;    free_list_node(THIS->cur);    add_ref(THIS->cur = next);    THIS->ind = 0;    }
pike.git/src/builtin.cmod:6857:    *! @returns    *! Returns @expr{1@} on success, and @expr{0@} (zero)    *! at the end of the list.    *!    *! @seealso    *! @[prev()]    */    PIKEFUN int(0..1) next() /* Compat. */    {    struct pike_list_node *next; -  if ((next = THIS->cur->next)) { +  if (!THIS->cur) { +  add_ref(THIS->cur = List__get_iterator_find_parent()->head); +  THIS->ind = 0; +  } else if ((next = THIS->cur->next)) {    free_list_node(THIS->cur);    add_ref(THIS->cur = next);    THIS->ind++; -  if (next->next) +  } +  if (THIS->cur->next) {    RETURN 1;    } -  +  /* End sentinel. */ +  free_list_node(THIS->cur); +  THIS->cur = NULL; +  THIS->ind = -1;    RETURN 0;    }       /*! @decl int(0..1) prev()    *!    *! Retrace to the previous element in the list.    *!    *! @returns    *! Returns @expr{1@} on success, and @expr{0@} (zero)    *! at the beginning of the list.