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.553 2004/05/13 16:31:06 nilsson Exp $ + || $Id: builtin_functions.c,v 1.554 2004/05/13 23:31:04 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.553 2004/05/13 16:31:06 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.554 2004/05/13 23:31:04 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:628:   }      /*! @decl string random_string(int len)    *!    *! Returns a string of random characters 0-255 with the length @[len].    */   PMOD_EXPORT void f_random_string(INT32 args)   {    struct pike_string *ret;    INT_TYPE len, e; -  get_all_args("random_string",args,"%i",&len); +  get_all_args("random_string",args,"%+",&len);    ret = begin_shared_string(len);    for(e=0;e<len;e++) ret->str[e] = DO_NOT_WARN((char)my_rand());    pop_n_elems(args);    push_string(end_shared_string(ret));   }      /*! @decl void random_seed(int seed)    *!    *! This function sets the initial value for the random generator.    *!
pike.git/src/builtin_functions.c:3048:       if(from->size != to->size)    Pike_error("Replace must have equal-sized from and to arrays.\n");       if(!from->size)    {    reference_shared_string(str);    return str;    }    -  if(from->type_field & ~BIT_STRING) { -  array_fix_type_field(from); -  if(from->type_field & ~BIT_STRING) +  if( (from->type_field & ~BIT_STRING) && +  (array_fix_type_field(from) & ~BIT_STRING) )    Pike_error("replace: from array not array(string).\n"); -  } +     -  if(to->type_field & ~BIT_STRING) { -  array_fix_type_field(to); -  if(to->type_field & ~BIT_STRING) +  if( (to->type_field & ~BIT_STRING) && +  (array_fix_type_field(to) & ~BIT_STRING) )    Pike_error("replace: to array not array(string).\n"); -  } +        ctx.v=(struct tupel *)xalloc(sizeof(struct tupel)*from->size);    init_string_builder(&ctx.ret,str->size_shift);    SET_ONERROR (uwp, free_replace_many_context, &ctx);       for(num=e=0;e<from->size;e++)    {    if(ITEM(from)[e].u.string->size_shift > str->size_shift)    continue;   
pike.git/src/builtin_functions.c:4775:    {    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) +  if( (a->type_field & ~BIT_STRING) && +  (array_fix_type_field(a) & ~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(does_match(ITEM(a)[i].u.string,0,glob,0))    {    ref_push_string(ITEM(a)[i].u.string);    matches++;    DO_AGGREGATE_ARRAY (120);
pike.git/src/builtin_functions.c:4828:    struct array *order = NULL;    int max = 0;    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(arr->type_field & ~BIT_MAPPING) { -  array_fix_type_field(arr); -  if(arr->type_field & ~BIT_MAPPING) +  if( (arr->type_field & ~BIT_MAPPING) && +  (array_fix_type_field(arr) & ~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));       /* Initialize the min array */
pike.git/src/builtin_functions.c:6708:    sizein=in->size;       if(!sizein)    {    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 != BIT_ARRAY) +  if( (in->type_field != BIT_ARRAY) && +  (array_fix_type_field(in) != 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);       for(i=0; i<sizein; i++)