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.556 2004/05/14 18:18:42 nilsson Exp $ + || $Id: builtin_functions.c,v 1.557 2004/05/18 01:06:46 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.556 2004/05/14 18:18:42 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.557 2004/05/18 01:06:46 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:915:      /*! @decl int has_prefix(string s, string prefix)    *!    *! Returns @expr{1@} if the string @[s] starts with @[prefix],    *! returns @expr{0@} (zero) otherwise.    */   PMOD_EXPORT void f_has_prefix(INT32 args)   {    struct pike_string *a, *b;    -  get_all_args("has_prefix", args, "%W%W", &a, &b); +  if(args<2) +  SIMPLE_TOO_FEW_ARGS_ERROR("has_prefix", 2); +  if(Pike_sp[-args].type!=T_STRING) +  SIMPLE_ARG_TYPE_ERROR("has_prefix", 1, "string"); +  if(Pike_sp[1-args].type!=T_STRING) +  SIMPLE_ARG_TYPE_ERROR("has_prefix", 2, "string");    -  +  a = Pike_sp[-args].u.string; +  b = Pike_sp[1-args].u.string; +     /* First handle some common special cases. */    if ((b->len > a->len) || (b->size_shift > a->size_shift)) {    pop_n_elems(args);    push_int(0);    return;    }       /* Trivial cases. */    if ((a == b)||(!b->len)) {    pop_n_elems(args);
pike.git/src/builtin_functions.c:976:      /*! @decl int has_suffix(string s, string suffix)    *!    *! Returns @expr{1@} if the string @[s] ends with @[suffix],    *! returns @expr{0@} (zero) otherwise.    */   PMOD_EXPORT void f_has_suffix(INT32 args)   {    struct pike_string *a, *b;    -  get_all_args("has_suffix", args, "%W%W", &a, &b); +  if(args<2) +  SIMPLE_TOO_FEW_ARGS_ERROR("has_suffix", 2); +  if(Pike_sp[-args].type!=T_STRING) +  SIMPLE_ARG_TYPE_ERROR("has_suffix", 1, "string"); +  if(Pike_sp[1-args].type!=T_STRING) +  SIMPLE_ARG_TYPE_ERROR("has_suffix", 2, "string");    -  +  a = Pike_sp[-args].u.string; +  b = Pike_sp[1-args].u.string; +     /* First handle some common special cases. */    if ((b->len > a->len) || (b->size_shift > a->size_shift)) {    pop_n_elems(args);    push_int(0);    return;    }       /* Trivial cases. */    if ((a == b)||(!b->len)) {    pop_n_elems(args);