Branch: Tag:

2003-05-07

2003-05-07 12:31:52 by Martin Stjernholm <mast@lysator.liu.se>

Fixed glob() to not be limited by the pike stack when filtering arrays.

Rev: src/builtin_functions.c:1.492

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: builtin_functions.c,v 1.491 2003/04/29 00:46:25 nilsson Exp $ + || $Id: builtin_functions.c,v 1.492 2003/05/07 12:31:52 mast Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.491 2003/04/29 00:46:25 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.492 2003/05/07 12:31:52 mast Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
4535:    case T_ARRAY:    a=Pike_sp[1-args].u.array;    matches=0; -  check_stack(a->size); +  check_stack(120); +  BEGIN_AGGREGATE_ARRAY (MINIMUM (a->size, 120)) {    for(i=0;i<a->size;i++)    {    if(ITEM(a)[i].type != T_STRING)
4543:       if(does_match(ITEM(a)[i].u.string,0,glob,0))    { -  add_ref(ITEM(a)[i].u.string); -  push_string(ITEM(a)[i].u.string); +  ref_push_string(ITEM(a)[i].u.string);    matches++; -  +  DO_AGGREGATE_ARRAY (120);    }    } -  f_aggregate(matches); -  tmp=Pike_sp[-1]; -  Pike_sp--; -  dmalloc_touch_svalue(Pike_sp); -  pop_n_elems(2); -  Pike_sp[0]=tmp; -  Pike_sp++; +  } END_AGGREGATE_ARRAY; +  Pike_sp[-1].u.array->type_field = BIT_STRING; +  stack_pop_n_elems_keep_top (2);    break;       default: -  SIMPLE_BAD_ARG_ERROR("glob", 1, "string|array(string)"); +  SIMPLE_BAD_ARG_ERROR("glob", 2, "string|array(string)");    }   }