Branch: Tag:

2010-11-15

2010-11-15 14:49:19 by Henrik Grubbström (Grubba) <grubba@grubba.org>

has_prefix() should not throw errors when the prefix is longer than the object supports.

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.706 2010/09/28 16:06:35 mast Exp $ + || $Id$   */      #include "global.h"
1081:    *! 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()]    */
1101:    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);