pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.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: builtin_functions.c,v 1.543 2004/04/29 19:23:20 nilsson Exp $ + || $Id: builtin_functions.c,v 1.544 2004/04/29 21:25:59 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.543 2004/04/29 19:23:20 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.544 2004/04/29 21:25:59 nilsson Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:4754:    switch(Pike_sp[1-args].type)    {    case T_STRING:    i=does_match(Pike_sp[1-args].u.string,0,glob,0);    pop_n_elems(2);    push_int(i);    break;       case T_ARRAY:    a=Pike_sp[1-args].u.array; +  +  if(a->type_field & ~BIT_STRING) { +  array_fix_type_field(a); +  if(a->type_field & ~BIT_STRING) +  SIMPLE_BAD_ARG_ERROR("glob", 2, "string|array(string)"); +  } +     matches=0;    check_stack(120);    BEGIN_AGGREGATE_ARRAY (MINIMUM (a->size, 120)) {    for(i=0;i<a->size;i++) -  { -  if(ITEM(a)[i].type != T_STRING) -  SIMPLE_BAD_ARG_ERROR("glob", 2, "string|array(string)"); -  +     if(does_match(ITEM(a)[i].u.string,0,glob,0))    {    ref_push_string(ITEM(a)[i].u.string);    matches++;    DO_AGGREGATE_ARRAY (120);    } -  } +     } 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", 2, "string|array(string)");    }   }   
pike.git/src/builtin_functions.c:4798:    *! Returns an array with offsets that describe how to shift the    *! rows of @[tab] so that only at most one non-zero value exists in    *! every column.    */   static void f_interleave_array(INT32 args)   {    struct array *arr = NULL;    struct array *min = NULL;    struct array *order = NULL;    int max = 0; -  int ok; +     int nelems = 0;    int i;       get_all_args("interleave_array", args, "%a", &arr);       /* We're not interrested in any other arguments. */    pop_n_elems(args-1);    -  if ((ok = arr->type_field & BIT_MAPPING) && -  (arr->type_field & ~BIT_MAPPING)) { -  /* Might be ok, but do some more checking... */ -  for(i = 0; i < arr->size; i++) { -  if (ITEM(arr)[i].type != T_MAPPING) { -  ok = 0; -  break; -  } -  } -  } -  if (!ok) { +  if(arr->type_field & ~BIT_MAPPING) { +  array_fix_type_field(arr); +  if(arr->type_field & ~BIT_MAPPING)    SIMPLE_BAD_ARG_ERROR("interleave_array", 1, "array(mapping(int:mixed))");    }       /* The order array */    ref_push_array(arr);    f_indices(1);    order = Pike_sp[-1].u.array;       /* The min array */    push_array(min = allocate_array(arr->size));
pike.git/src/builtin_functions.c:4892:    size = (nelems + max) * 8; /* Initial size */    if (!(tab = malloc(size + max))) {    SIMPLE_OUT_OF_MEMORY_ERROR("interleave_array", size+max);    }    MEMSET(tab, 0, size + max);       for (i = 0; i < order->size; i++) {    int low = ITEM(min)[i].u.integer;    int j = ITEM(order)[i].u.integer;    int offset = 0; +  int ok = 0;    struct mapping *m;    struct mapping_data *md;    INT32 e;    struct keypair *k;       if (! m_sizeof(m = ITEM(arr)[j].u.mapping)) {    /* Not available */    ITEM(min)[i].u.integer = -1;    continue;    }       if (low < minfree) {    offset = minfree - low;    } else {    minfree = offset;    }       md = m->data; -  ok = 0; +     while (!ok) {    ok = 1;    NEW_MAPPING_LOOP(md) {    int ind = k->ind.u.integer;    if (tab[offset + ind]) {    ok = 0;    while (tab[++offset + ind])    ;    }    }
pike.git/src/builtin_functions.c:6698:    {    pop_n_elems(args);    out=allocate_array(0);    push_array(out);    return;    }       if(in->type_field != BIT_ARRAY)    {    array_fix_type_field(in); -  if(!in->type_field || in->type_field & ~BIT_ARRAY) -  Pike_error("The array given as argument 1 to transpose must contain arrays only.\n"); +  if(in->type_field != BIT_ARRAY) +  SIMPLE_BAD_ARG_ERROR("transpose", 1, "array(array)");    }       sizeininner=in->item->u.array->size;       for(i=1 ; i<sizein; i++)    if (sizeininner!=(in->item+i)->u.array->size)    Pike_error("The array given as argument 1 to transpose must contain arrays of the same size.\n");       out=allocate_array(sizeininner);