pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:993:       start=0;    end = haystack->len;    if(args > 2)    {    if(TYPEOF(Pike_sp[2-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR("search", 3, "int");       start=Pike_sp[2-args].u.integer;    if(start<0) { -  bad_arg_error("search", Pike_sp-args, args, 3, "int(0..)", Pike_sp+2-args, +  bad_arg_error("search", args, 3, "int(0..)", Pike_sp+2-args,    "Start must be greater or equal to zero.\n");    }       if (args > 3) {    if(TYPEOF(Pike_sp[3-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR("search", 4, "int");       if (Pike_sp[3-args].u.integer < end) {    end = Pike_sp[3-args].u.integer;    if(start<0) { -  bad_arg_error("search", Pike_sp-args, args, 4, "int(0..)", +  bad_arg_error("search", args, 4, "int(0..)",    Pike_sp+3-args,    "End must be greater or equal to zero.\n");    }    }    }    }       if(haystack->len < start) -  bad_arg_error("search", Pike_sp-args, args, 3, "int(0..)", Pike_sp-args, +  bad_arg_error("search", args, 3, "int(0..)", Pike_sp-args,    "Start must not be greater than the "    "length of the string.\n");       if (end <= start) {    pop_n_elems(args);    push_int(-1);    return;    }       if ((TYPEOF(Pike_sp[1-args]) == T_INT) ||
pike.git/src/builtin_functions.c:1105:    case T_ARRAY:    start=0;    end = Pike_sp[-args].u.array->size;    if(args > 2)    {    if(TYPEOF(Pike_sp[2-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR("search", 3, "int");       start=Pike_sp[2-args].u.integer;    if(start<0) { -  bad_arg_error("search", Pike_sp-args, args, 3, "int(0..)", Pike_sp+2-args, +  bad_arg_error("search", args, 3, "int(0..)", Pike_sp+2-args,    "Start must be greater or equal to zero.\n");    }       if (args > 3) {    if(TYPEOF(Pike_sp[3-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR("search", 4, "int");       if (Pike_sp[3-args].u.integer < end) {    end = Pike_sp[3-args].u.integer;    if(end<0) { -  bad_arg_error("search", Pike_sp-args, args, 4, "int(0..)", +  bad_arg_error("search", args, 4, "int(0..)",    Pike_sp+3-args,    "End must be greater or equal to zero.\n");    }    }    }    }    start=array_search(Pike_sp[-args].u.array,Pike_sp+1-args,start);    pop_n_elems(args);    if (start >= end) {    start = -1;
pike.git/src/builtin_functions.c:1920:    struct pike_string *in;    struct pike_string *out = NULL;    ptrdiff_t len, i, num_surrogates = 0;    INT_TYPE byteorder = 0;    int swab=0;    p_wchar1 surr1, surr2, surrmask, *str0;       get_all_args("unicode_to_string", args, "%S.%i", &in, &byteorder);       if (in->len & 1) { -  bad_arg_error("unicode_to_string", Pike_sp-args, args, 1, "string", Pike_sp-args, +  bad_arg_error("unicode_to_string", args, 1, "string", Pike_sp-args,    "String length is odd.\n");    }       if (byteorder >= 2) {    if (byteorder == 2) {   #if PIKE_BYTEORDER == 1234    /* Little endian. */    byteorder = 1;   #else    byteorder = 0;
pike.git/src/builtin_functions.c:2190:    if (c & ~0x7f) {    /* 8bit or more. */    len++;    if (c & ~0x7ff) {    /* 12bit or more. */    len++;    if (c & ~0xffff) {    /* 17bit or more. */    len++;    if (!extended && c > 0x10ffff) -  bad_arg_error ("string_to_utf8", Pike_sp - args, args, 1, +  bad_arg_error ("string_to_utf8", args, 1,    NULL, Pike_sp - args,    "Character 0x%08x at index %"PRINTPTRDIFFT"d is "    "outside the allowed range.\n",    c, i);    if (c & ~0x1fffff) {    /* 22bit or more. */    len++;    if (c & ~0x3ffffff) {    /* 27bit or more. */    len++;    if (c & ~0x7fffffff) {    /* 32bit or more. */    len++;    /* FIXME: Needs fixing when we get 64bit chars... */    }    }    }    }    else if (!extended && c >= 0xd800 && c <= 0xdfff) -  bad_arg_error ("string_to_utf8", Pike_sp - args, args, 1, +  bad_arg_error ("string_to_utf8", args, 1,    NULL, Pike_sp - args,    "Character 0x%08x at index %"PRINTPTRDIFFT"d is "    "in the surrogate range and therefore invalid.\n",    c, i);    }    }    }    if (len == in->len) {    /* 7bit string -- already valid utf8. */    pop_n_elems(args - 1);
pike.git/src/builtin_functions.c:2354:    * 000800-000fff e0 a0-bf 80-bf    * 001000-00cfff e1-ec 80-bf 80-bf    * 00d000-00d7ff ed 80-9f 80-bf    * 00e000-00ffff ee-ef 80-bf 80-bf    * 010000-03ffff f0 90-bf 80-bf 80-bf    * 040000-0fffff f1-f3 80-bf 80-bf 80-bf    * 100000-10ffff f4 80-8f 80-bf 80-bf    */       if ((c & 0xc0) == 0x80) { -  bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1, +  bad_arg_error ("utf8_to_string", args, 1,    NULL, Pike_sp - args,    "Invalid continuation character 0x%02x "    "at index %"PRINTPTRDIFFT"d.\n",    c, i);    }      #define GET_CHAR(in, i, c) do { \    i++; \    if (i >= in->len) \ -  bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1, \ +  bad_arg_error ("utf8_to_string", args, 1, \    NULL, Pike_sp - args, \    "Truncated UTF-8 sequence at end of string.\n"); \    c = STR0 (in)[i]; \    } while(0)   #define GET_CONT_CHAR(in, i, c) do { \    GET_CHAR(in, i, c); \    if ((c & 0xc0) != 0x80) \ -  bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1, \ +  bad_arg_error ("utf8_to_string", args, 1, \    NULL, Pike_sp - args, \    "Expected continuation character at index %d, " \    "got 0x%02x.\n", \    i, c); \    } while (0)      #define UTF8_SEQ_ERROR(prefix, c, i, problem) do { \ -  bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1, \ +  bad_arg_error ("utf8_to_string", args, 1, \    NULL, Pike_sp - args, \    "UTF-8 sequence beginning with %s0x%02x " \    "at index %"PRINTPTRDIFFT"d %s.\n", \    prefix, c, i, problem); \    } while (0)       if ((c & 0xe0) == 0xc0) {    /* 11bit */    if (!(c & 0x1e))    UTF8_SEQ_ERROR ("", c, i, "is a non-shortest form");
pike.git/src/builtin_functions.c:2470:    cont = 2;    }    else    cont = 3;    }    else    cont = 3;    }       else if (c == 0xff) -  bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1, +  bad_arg_error ("utf8_to_string", args, 1,    NULL, Pike_sp - args,    "Invalid character 0xff at index %"PRINTPTRDIFFT"d.\n",    i);       else if (!(extended & 1))    UTF8_SEQ_ERROR ("", c, i, "would decode to "    "a character outside the valid UTF-8 range");       else {    if ((c & 0xfc) == 0xf8) {
pike.git/src/builtin_functions.c:5365:    if(TYPEOF(Pike_sp[-args]) != T_ARRAY)    SIMPLE_ARG_TYPE_ERROR("sort", 1, "array");    a = Pike_sp[-args].u.array;       for(e=1;e<args;e++)    {    if(TYPEOF(Pike_sp[e-args]) != T_ARRAY)    SIMPLE_ARG_TYPE_ERROR("sort", e+1, "array");       if(Pike_sp[e-args].u.array->size != a->size) -  bad_arg_error("sort", Pike_sp-args, args, e+1, "array", Pike_sp+e-args, +  bad_arg_error("sort", args, e+1, "array", Pike_sp+e-args,    "Argument %d has wrong size.\n", (e+1));    }       if(args > 1)    {    order = stable_sort_array_destructively(a);    for(e=1;e<args;e++) order_array(Pike_sp[e-args].u.array,order);    pop_n_elems(args-1);    free(order);    }
pike.git/src/builtin_functions.c:7890:   PMOD_EXPORT void f_replace_master(INT32 args)   {    struct object *new_master;       if(!args)    SIMPLE_WRONG_NUM_ARGS_ERROR("replace_master", 1);    if(TYPEOF(Pike_sp[-args]) != T_OBJECT)    SIMPLE_ARG_TYPE_ERROR("replace_master", 1, "object");    new_master = Pike_sp[-args].u.object;    if(!new_master->prog) -  bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args, +  bad_arg_error("replace_master", args, 1, "object", Pike_sp-args,    "Called with destructed object.\n");       if (SUBTYPEOF(Pike_sp[-args])) -  bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args, +  bad_arg_error("replace_master", args, 1, "object", Pike_sp-args,    "Subtyped master objects are not supported yet.\n");       push_static_text ("is_pike_master");    args++;    object_set_index (new_master, 0, Pike_sp - 1, (struct svalue *) &svalue_int_one);       free_object(master_object);    master_object=new_master;    add_ref(master_object);   
pike.git/src/builtin_functions.c:8210:    */   PMOD_EXPORT void f_object_variablep(INT32 args)   {    struct object *o;    struct pike_string *s;    int ret;       get_all_args("variablep",args,"%o%S",&o, &s);       if(!o->prog) -  bad_arg_error("variablep", Pike_sp-args, args, 1, "object", Pike_sp-args, +  bad_arg_error("variablep", args, 1, "object", Pike_sp-args,    "Called on destructed object.\n");       /* FIXME: Ought to be overloadable, since `[]=() is... */       ret=find_shared_string_identifier(s,o->prog);    if(ret!=-1)    {    ret=IDENTIFIER_IS_VARIABLE(ID_FROM_INT(o->prog, ret)->identifier_flags);    }else{    ret=0;
pike.git/src/builtin_functions.c:8353:       check_all_args("everynth", args,    BIT_ARRAY, BIT_INT | BIT_VOID, BIT_INT | BIT_VOID , 0);       switch(args)    {    default:    case 3:    start=Pike_sp[2-args].u.integer;    if(start<0) -  bad_arg_error("everynth", Pike_sp-args, args, 3, "int", Pike_sp+2-args, +  bad_arg_error("everynth", args, 3, "int", Pike_sp+2-args,    "Argument negative.\n");    /* FALLTHRU */    case 2:    n=Pike_sp[1-args].u.integer;    if(n<1) -  bad_arg_error("everynth", Pike_sp-args, args, 2, "int", Pike_sp+1-args, +  bad_arg_error("everynth", args, 2, "int", Pike_sp+1-args,    "Argument negative.\n");    /* FALLTHRU */    case 1:    ina=Pike_sp[-args].u.array;    }       a=allocate_array(((size=ina->size)-start+n-1)/n);    types = 0;    for(k=0; start<size; k++, start+=n) {    assign_svalue_no_free(ITEM(a) + k, ina->item+start);