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.706 2010/09/28 16:06:35 mast Exp $ + || $Id$   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:1074:    default:    SIMPLE_BAD_ARG_ERROR("search", 1, "string|array|mapping|object");    }   }      /*! @decl int has_prefix(string|object s, string prefix)    *!    *! Returns @expr{1@} if the string @[s] starts with @[prefix],    *! returns @expr{0@} (zero) otherwise.    *! +  *! When @[s] is an object, it needs to implement +  *! @[lfun::_sizeof()] and @[lfun::`[]]. +  *!    *! @seealso    *! @[has_suffix()], @[has_value()], @[search()]    */   PMOD_EXPORT void f_has_prefix(INT32 args)   {    struct pike_string *a, *b;       if(args<2)    SIMPLE_TOO_FEW_ARGS_ERROR("has_prefix", 2);    if((Pike_sp[-args].type!=T_STRING) && (Pike_sp[-args].type!=T_OBJECT))    SIMPLE_ARG_TYPE_ERROR("has_prefix", 1, "string|object");    if(Pike_sp[1-args].type!=T_STRING)    SIMPLE_ARG_TYPE_ERROR("has_prefix", 2, "string");       b = Pike_sp[1-args].u.string;       if (Pike_sp[-args].type == T_OBJECT) {    ptrdiff_t i;    struct object *o = Pike_sp[-args].u.object;    int inherit_no = Pike_sp[-args].subtype; -  +  +  apply_lfun(o, LFUN__SIZEOF, 0); +  if ((Pike_sp[-1].type != T_INT) || (Pike_sp[-1].u.integer < b->len)) { +  pop_n_elems(args + 1);    push_int(0); -  +  return; +  }       for (i = 0; i < b->len; i++) {    p_wchar2 ch = index_shared_string(b, i);    Pike_sp[-1].u.integer = i;    /* Note: Integers do not need to be freed. */    object_index_no_free(Pike_sp-1, o, inherit_no, Pike_sp-1);    if (Pike_sp[-1].type != PIKE_T_INT) {    Pike_error("Unexepected value returned from index operator.\n");    }    if (ch != Pike_sp[-1].u.integer) {