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.494 2003/06/03 18:45:51 mast Exp $ + || $Id: builtin_functions.c,v 1.495 2003/06/11 23:01:48 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.494 2003/06/03 18:45:51 mast Exp $"); + RCSID("$Id: builtin_functions.c,v 1.495 2003/06/11 23:01:48 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:1923:    n->parent->node_info |= OPT_TYPE_NOT_FIXED;    }    return NULL;   }      static int generate_this_object(node *n)   {    int level;       if (CDR (n)) { -  struct program_state *state = Pike_compiler; +     if (CDR (n)->token != F_CONSTANT)    /* Not a constant expression. Make a call to f_this_object. */    return 0;    else {   #ifdef PIKE_DEBUG    if (CDR (n)->u.sval.type != T_INT || CDR (n)->u.sval.u.integer < 0)    Pike_fatal ("The type check for this_object() failed.\n");   #endif    level = CDR (n)->u.sval.u.integer;   #ifdef PIKE_DEBUG
pike.git/src/builtin_functions.c:4336:    push_int(retval);   }      #endif      /* Parse a sprintf/sscanf-style format string */   static ptrdiff_t low_parse_format(p_wchar0 *s, ptrdiff_t slen)   {    ptrdiff_t i;    ptrdiff_t offset = 0; -  int num_percent_percent = 0; +     struct svalue *old_sp = Pike_sp;       for (i=offset; i < slen; i++) {    if (s[i] == '%') {    ptrdiff_t j;    if (i != offset) {    push_string(make_shared_binary_string0(s + offset, i));    if ((Pike_sp != old_sp+1) && (Pike_sp[-2].type == T_STRING)) {    /* Concat. */    f_add(2);
pike.git/src/builtin_functions.c:4513:    *! If the second array is an array and array containing the strings in    *! @[arr] that match @[glob] will be returned.    *!    *! @seealso    *! @[sscanf()], @[Regexp]    */   PMOD_EXPORT void f_glob(INT32 args)   {    INT32 i,matches;    struct array *a; -  struct svalue tmp; +     struct pike_string *glob;       if(args < 2)    SIMPLE_TOO_FEW_ARGS_ERROR("glob", 2);       if(args > 2)    pop_n_elems(args-2);    args=2;       if (Pike_sp[-args].type!=T_STRING)
pike.git/src/builtin_functions.c:4769:    h = middle;    }    }    return l;   }      static struct array *longest_ordered_sequence(struct array *a)   {    int *stack;    int *links; -  int i, top=0, l=0, ltop=-1; +  int i, top=0, ltop=-1;    struct array *res;    ONERROR tmp;    ONERROR tmp2;       if(!a->size)    return allocate_array(0);       stack = malloc(sizeof(int)*a->size);    links = malloc(sizeof(int)*a->size);   
pike.git/src/builtin_functions.c:5085:    * For ascii data:    * K ~= C * min(Na, Nb), C constant => O(max(Na, Nb)*lg(max(Na,Nb))),    * Na ~= Nb ~= N => O(N * lg(N))    *    * diff_longest_sequence() takes two arguments:    * cmptbl == diff_compare_table(a, b)    * blen == sizeof(b) >= max(@(cmptbl*({})))    */   static struct array *diff_longest_sequence(struct array *cmptbl, int blen)   { -  int i,j,top=0,lsize=0; +  int i,j,top=0;    struct array *a;    struct diff_magic_link_pool *pools=NULL;    struct diff_magic_link *dml;    struct diff_magic_link **stack;    char *marks;       if(!cmptbl->size)    return allocate_array(0);       stack = malloc(sizeof(struct diff_magic_link*)*cmptbl->size);
pike.git/src/builtin_functions.c:5306:    *    * This makes it faster than the G-M algorithm on binary data,    * but slower on ascii data.    *    * NOT true! The G-M algorithm seems to be faster on most data anyway.    * /grubba 1998-05-19    */   static struct array *diff_dyn_longest_sequence(struct array *cmptbl, int blen)   {    struct array *res = NULL; -  struct diff_magic_link_head *table = NULL; +  struct diff_magic_link_head *table;    struct diff_magic_link_pool *dml_pool = NULL;    struct diff_magic_link *dml;    unsigned int sz = (unsigned int)cmptbl->size;    unsigned int i;    unsigned int off1 = 0;    unsigned int off2 = blen + 1; -  unsigned int l1 = 0; -  unsigned int l2 = 0; +        table = calloc(sizeof(struct diff_magic_link_head)*2, off2);    if (!table) {    int args = 0;    SIMPLE_OUT_OF_MEMORY_ERROR("diff_dyn_longest_sequence",    sizeof(struct diff_magic_link_head) * 2 * off2);    }       /* FIXME: Assumes NULL is represented with all zeroes */    /* NOTE: Scan strings backwards to get the same result as the G-M
pike.git/src/builtin_functions.c:6458:   }      /*! @decl array(array) transpose(array(array) matrix)    */   PMOD_EXPORT void f_transpose(INT32 args)   {    struct array *out;    struct array *in;    struct array *outinner;    INT32 sizeininner=0,sizein=0; -  INT32 inner=0; +     INT32 j,i;    TYPE_FIELD type=0;   #ifdef PIKE_DEBUG    if(args < 0) Pike_fatal("Negative args to f_transpose()\n");   #endif       if (args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("transpose", 1);       if (Pike_sp[-args].type!=T_ARRAY)