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$ +    */      #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:30:   #include "time_stuff.h"   #include "version.h"   #include "encode.h"   #include <math.h>   #include <ctype.h>   #include "module_support.h"   #include "module.h"   #include "opcodes.h"   #include "cyclic.h"   #include "signal_handler.h" - #include "pike_security.h" +    #include "builtin_functions.h"   #include "bignum.h"   #include "peep.h"   #include "docode.h"   #include "lex.h"   #include "pike_float.h" -  + #include "stuff.h"   #include "pike_compiler.h"      #include <errno.h>      #ifdef HAVE_POLL   #ifdef HAVE_POLL_H   #include <poll.h>   #endif /* HAVE_POLL_H */      #ifdef HAVE_SYS_POLL_H
pike.git/src/builtin_functions.c:60: Inside #if defined(HAVE_CRYPT_H)
     #ifdef HAVE_CRYPT_H   #include <crypt.h>   #endif      /* #define DIFF_DEBUG */   /* #define ENABLE_DYN_DIFF */      /*! @decl int equal(mixed a, mixed b)    *! -  *! This function checks if the values @[a] and @[b] are equal. +  *! This function checks if the values @[a] and @[b] are equivalent.    *! -  *! For all types but arrays, multisets and mappings, this operation is -  *! the same as doing @expr{@[a] == @[b]@}. -  *! For arrays, mappings and multisets however, their contents are checked -  *! recursively, and if all their contents are the same and in the same -  *! place, they are considered equal. +  *! @returns +  *! If either of the values is an object the (normalized) result +  *! of calling @[lfun::_equal()] will be returned.    *! -  +  *! Returns @expr{1@} if both values are false (zero, destructed objects, +  *! prototype functions, etc). +  *! +  *! Returns @expr{0@} (zero) if the values have different types. +  *! +  *! Otherwise depending on the type of the values: +  *! @mixed +  *! @type int +  *! @type float +  *! @type string +  *! @type program +  *! Returns the same as @expr{a == b@}. +  *! @type array +  *! @type mapping +  *! @type multiset +  *! @type object +  *! The contents of @[a] and @[b] are checked recursively, and +  *! if all their contents are @[equal] and in the same place, +  *! they are considered equal. +  *! +  *! Note that for objects this case is only reached if neither +  *! @[a] nor @[b] implements @[lfun::_equal()]. +  *! @type type +  *! Returns @expr{(a <= b) && (b <= a)@}. +  *! @endmixed +  *!    *! @seealso -  *! @[copy_value()] +  *! @[copy_value()], @[`==()]    */   PMOD_EXPORT void f_equal(INT32 args)   {    int i;    if(args != 2)    SIMPLE_TOO_FEW_ARGS_ERROR("equal", 2);       i=is_equal(Pike_sp-2,Pike_sp-1);    pop_n_elems(args);    push_int(i);
pike.git/src/builtin_functions.c:194:    if (count) {    add_args = mknode(F_ARG_LIST, add_args,    mkapplynode(copy_node(CAR(n)), new_args));    new_args = NULL;    count = 0;    }    CDR(n)->parent = n;    return mkefuncallnode("`+", add_args);   }    - /*! @decl __deprecated__ int hash_7_4(string s) -  *! @decl __deprecated__ int hash_7_4(string s, int max) -  *! -  *! @deprecated 7.4::hash -  *! -  *! @seealso -  *! @[7.4::hash()] -  */ -  - /*! @decl __deprecated__ int hash_7_0(string s) -  *! @decl __deprecated__ int hash_7_0(string s, int max) -  *! -  *! @deprecated 7.0::hash -  *! -  *! @seealso -  *! @[7.0::hash()] -  */ -  - /*! @namespace 7.4:: -  */ -  +    #define MK_HASHMEM(NAME, TYPE) ATTRIBUTE((const)) \    static INLINE size_t NAME(const TYPE *str, ptrdiff_t len, ptrdiff_t maxn) \    { \    size_t ret,c; \    \    ret = len*92873743; \    \    len = MINIMUM(maxn,len); \    for(; len>=0; len--) \    { \
pike.git/src/builtin_functions.c:236:    ret ^= ( ret << 4 ) + c ; \    ret &= 0x7fffffff; \    } \    return ret; \    }      MK_HASHMEM(simple_hashmem, unsigned char)   MK_HASHMEM(simple_hashmem1, p_wchar1)   MK_HASHMEM(simple_hashmem2, p_wchar2)    - /*! @decl int hash(string s) -  *! @decl int hash(string s, int max) + /*! @decl int hash_7_4(string s) +  *! @decl int hash_7_4(string s, int max)    *!    *! Return an integer derived from the string @[s]. The same string -  *! will always hash to the same value, also between processes. +  *! always hashes to the same value, also between processes.    *!    *! If @[max] is given, the result will be >= 0 and < @[max],    *! otherwise the result will be >= 0 and <= 0x7fffffff.    *!    *! @note -  *! This function is provided for backward compatibility reasons. +  *! This function is provided for backward compatibility with +  *! code written for Pike up and including version 7.4.    *!    *! This function is byte-order dependant for wide strings.    *!    *! @seealso -  *! @[hash()], @[7.0::hash()] +  *! @[hash()], @[hash_7_0]    */   static void f_hash_7_4(INT32 args)   {    size_t i = 0;    struct pike_string *s = Pike_sp[-args].u.string;       if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("7.4::hash",1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)
pike.git/src/builtin_functions.c:281:       if(!Pike_sp[1-args].u.integer)    PIKE_ERROR("7.4::hash", "Modulo by zero.\n", Pike_sp, args);       i%=(unsigned INT32)Pike_sp[1-args].u.integer;    }    pop_n_elems(args);    push_int64(i);   }    - /*! @endnamespace -  */ -  - /*! @namespace 7.0:: -  */ -  +    ATTRIBUTE((const)) static INLINE size_t hashstr(const unsigned char *str, ptrdiff_t maxn)   {    size_t ret,c;       if(!(ret=str++[0]))    return ret;    for(; maxn>=0; maxn--)    {    c=str++[0];    if(!c) break;    ret ^= ( ret << 4 ) + c ;    ret &= 0x7fffffff;    }       return ret;   }    - /*! @decl int hash(string s) -  *! @decl int hash(string s, int max) + /*! @decl int hash_7_0(string s) +  *! @decl int hash_7_0(string s, int max)    *!    *! Return an integer derived from the string @[s]. The same string    *! always hashes to the same value, also between processes.    *!    *! If @[max] is given, the result will be >= 0 and < @[max],    *! otherwise the result will be >= 0 and <= 0x7fffffff.    *!    *! @note -  *! This function is provided for backward compatibility reasons. +  *! This function is provided for backward compatibility with +  *! code written for Pike up and including version 7.0.    *!    *! This function is not NUL-safe, and is byte-order dependant.    *!    *! @seealso -  *! @[hash()], @[7.4::hash()] +  *! @[hash()], @[hash_7_4]    */   static void f_hash_7_0( INT32 args )   {    struct pike_string *s = Pike_sp[-args].u.string;    unsigned int i;    if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("7.0::hash",1);    if(TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("7.0::hash", 1, "string");       if( s->size_shift )    {    f_hash_7_4( args );    return;    }    -  i = DO_NOT_WARN((unsigned int)hashstr( (unsigned char *)s->str, -  MINIMUM(100,s->len))); +  i = (unsigned int)hashstr( (unsigned char *)s->str, +  MINIMUM(100,s->len));    if(args > 1)    {    if(TYPEOF(Pike_sp[1-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("7.0::hash",2,"int");       if(!Pike_sp[1-args].u.integer)    PIKE_ERROR("7.0::hash", "Modulo by zero.\n", Pike_sp, args);       i%=(unsigned INT32)Pike_sp[1-args].u.integer;    }    pop_n_elems(args);    push_int( i );   }    - /*! @endnamespace -  */ -  +    /*! @decl int hash(string s)    *! @decl int hash(string s, int max)    *!    *! Return an integer derived from the string @[s]. The same string    *! always hashes to the same value, also between processes,    *! architectures, and Pike versions (see compatibility notes below,    *! though).    *!    *! If @[max] is given, the result will be >= 0 and < @[max],    *! otherwise the result will be >= 0 and <= 0x7fffffff.    *!    *! @note    *! The hash algorithm was changed in Pike 7.5. If you want a hash -  *! that is compatible with Pike 7.4 and earlier, use @[7.4::hash()]. +  *! that is compatible with Pike 7.4 and earlier, use @[hash_7_4()].    *! The difference only affects wide strings.    *!    *! The hash algorithm was also changed in Pike 7.1. If you want a hash -  *! that is compatible with Pike 7.0 and earlier, use @[7.0::hash()]. +  *! that is compatible with Pike 7.0 and earlier, use @[hash_7_0()].    *!    *! @note    *! This hash function differs from the one provided by @[hash_value()],    *! in that @[hash_value()] returns a process specific value.    *!    *! @seealso -  *! @[7.0::hash()], @[7.4::hash()], @[hash_value] +  *! @[hash_7_0()], @[hash_7_4()], @[hash_value]    */   PMOD_EXPORT void f_hash(INT32 args)   {    size_t i = 0;    struct pike_string *s;       if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("hash",1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)
pike.git/src/builtin_functions.c:403:    switch(s->size_shift) {    case 0:    i = simple_hashmem(STR0(s), s->len, 100);    break;    case 1:    i = simple_hashmem1(STR1(s), s->len, 100);    break;    case 2:    i = simple_hashmem2(STR2(s), s->len, 100);    break; - #ifdef PIKE_DEBUG -  default: -  Pike_fatal("hash(): Unsupported string shift: %d\n", s->size_shift); -  break; - #endif +     }       if(args > 1)    {    if(TYPEOF(Pike_sp[1-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("hash",2,"int");       if(Pike_sp[1-args].u.integer <= 0)    PIKE_ERROR("hash", "Modulo < 1.\n", Pike_sp, args);   
pike.git/src/builtin_functions.c:639:    *!    *! Convert a string or character to lower case.    *!    *! @returns    *! Returns a copy of the string @[s] with all upper case characters    *! converted to lower case, or the character @[c] converted to lower    *! case.    *!    *! @note    *! Assumes the string or character to be coded according to -  *! ISO-10646 (aka Unicode). If they are not, @[Locale.Charset.decoder] -  *! can do the initial conversion for you. +  *! ISO-10646 (aka Unicode). If they are not, @[Charset.decoder] can +  *! do the initial conversion for you.    *!    *! @note    *! Prior to Pike 7.5 this function only accepted strings.    *!    *! @seealso -  *! @[upper_case()], @[Locale.Charset.decoder] +  *! @[upper_case()], @[Charset.decoder]    */   PMOD_EXPORT void f_lower_case(INT32 args)   {    ptrdiff_t i;    struct pike_string *orig;    struct pike_string *ret;       check_all_args("lower_case", args, BIT_STRING|BIT_INT, 0);       if (TYPEOF(Pike_sp[-args]) == T_INT) {    /* NOTE: Performs the case change in place. */    DO_LOWER_CASE(Pike_sp[-args].u.integer);    pop_n_elems(args-1);    return;    }       orig = Pike_sp[-args].u.string; -  +  +  if( orig->flags & STRING_IS_LOWERCASE ) +  return; +     ret = begin_wide_shared_string(orig->len, orig->size_shift);    -  MEMCPY(ret->str, orig->str, orig->len << orig->size_shift); +  memcpy(ret->str, orig->str, orig->len << orig->size_shift);       i = orig->len;       if (!orig->size_shift) {    p_wchar0 *str = STR0(ret);       while(i--) {    DO_LOWER_CASE_SHIFT0(str[i]);    }    } else if (orig->size_shift == 1) {
pike.git/src/builtin_functions.c:694:       while(i--) {    DO_LOWER_CASE(str[i]);    }   #ifdef PIKE_DEBUG    } else {    Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);   #endif    }    +  ret = end_shared_string(ret); +  ret->flags |= STRING_IS_LOWERCASE;    pop_n_elems(args); -  push_string(end_shared_string(ret)); +  push_string(ret);   }      /*! @decl string upper_case(string s)    *! @decl int upper_case(int c)    *!    *! Convert a string or character to upper case.    *!    *! @returns    *! Returns a copy of the string @[s] with all lower case characters    *! converted to upper case, or the character @[c] converted to upper    *! case.    *!    *! @note    *! Assumes the string or character to be coded according to -  *! ISO-10646 (aka Unicode). If they are not, @[Locale.Charset.decoder] -  *! can do the initial conversion for you. +  *! ISO-10646 (aka Unicode). If they are not, @[Charset.decoder] can +  *! do the initial conversion for you.    *!    *! @note    *! Prior to Pike 7.5 this function only accepted strings.    *!    *! @seealso -  *! @[lower_case()], @[Locale.Charset.decoder] +  *! @[lower_case()], @[Charset.decoder]    */   PMOD_EXPORT void f_upper_case(INT32 args)   {    ptrdiff_t i;    struct pike_string *orig;    struct pike_string *ret;    check_all_args("upper_case", args, BIT_STRING|BIT_INT, 0);       if (TYPEOF(Pike_sp[-args]) == T_INT) {    /* NOTE: Performs the case change in place. */    DO_UPPER_CASE(Pike_sp[-args].u.integer);    pop_n_elems(args-1);    return;    }       orig = Pike_sp[-args].u.string; -  +  if( orig->flags & STRING_IS_UPPERCASE ) +  { +  return; +  } +     ret=begin_wide_shared_string(orig->len,orig->size_shift); -  MEMCPY(ret->str, orig->str, orig->len << orig->size_shift); +  memcpy(ret->str, orig->str, orig->len << orig->size_shift);       i = orig->len;       if (!orig->size_shift) {    p_wchar0 *str = STR0(ret);       while(i--) {    if(str[i]!=0xff && str[i]!=0xb5) {    DO_UPPER_CASE_SHIFT0(str[i]);    } else {
pike.git/src/builtin_functions.c:794:    while(i--) {    DO_UPPER_CASE(str[i]);    }   #ifdef PIKE_DEBUG    } else {    Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);   #endif    }       pop_n_elems(args); -  push_string(end_shared_string(ret)); +  ret = end_shared_string(ret); +  ret->flags |= STRING_IS_UPPERCASE; +  push_string(ret);   }      /*! @decl string random_string(int len)    *!    *! Returns a string of random characters 0-255 with the length @[len].    */   PMOD_EXPORT void f_random_string(INT32 args)   {    struct pike_string *ret; -  INT_TYPE len, e; +  INT_TYPE len, e = 0; +  unsigned INT64 *str;    get_all_args("random_string",args,"%+",&len);    ret = begin_shared_string(len); -  for(e=0;e<len;e++) ret->str[e] = DO_NOT_WARN((char)my_rand()); +  +  /* Note: Assumes pike_string->str is aligned on a 4 byte boundary +  * (it is, currently) +  */ +  str = (unsigned INT64 *)ret->str; +  +  while( (e+=sizeof(INT64)) <= len ) +  { +  str[0] = my_rand64(0xffffffffffffffff); +  str++; +  } +  +  for(e-=sizeof(INT64);e<len;e++) +  { +  ret->str[e] = (char)my_rand(0xffffffff); +  } +     pop_n_elems(args);    push_string(end_shared_string(ret));   }      /*! @decl void random_seed(int seed)    *!    *! This function sets the initial value for the random generator.    *!    *! @seealso    *! @[random()]    */   PMOD_EXPORT void f_random_seed(INT32 args)   {    INT_TYPE i; - #ifdef AUTO_BIGNUM +     check_all_args("random_seed",args,BIT_INT | BIT_OBJECT, 0); -  +     if(TYPEOF(Pike_sp[-args]) == T_INT)    {    i=Pike_sp[-args].u.integer;    }else{    i=hash_svalue(Pike_sp-args);    } - #else -  get_all_args("random_seed",args,"%i",&i); - #endif +     my_srand(i);    pop_n_elems(args);   }      /*! @decl int query_num_arg()    *!    *! Returns the number of arguments given when the previous function was    *! called.    *!    *! This is useful for functions that take a variable number of arguments.
pike.git/src/builtin_functions.c:949:    if ((TYPEOF(Pike_sp[1-args]) == T_INT) ||    ((TYPEOF(Pike_sp[1-args]) == T_STRING) &&    (Pike_sp[1-args].u.string->len == 1))) {    INT_TYPE val;    if (TYPEOF(Pike_sp[1-args]) == T_INT) {    val = Pike_sp[1-args].u.integer;    } else {    val = index_shared_string(Pike_sp[1-args].u.string, 0);    }    +  if( !string_range_contains( haystack, val ) ) +  { +  pop_n_elems(args); +  push_int( -1 ); +  return; +  }    switch(Pike_sp[-args].u.string->size_shift) {    case 0:    {    p_wchar0 *str = STR0(haystack);    if (val >= 256) {    start = -1;    break;    }    while (start < haystack->len) {    if (str[start] == val) break;
pike.git/src/builtin_functions.c:985:    break;    case 2:    {    p_wchar2 *str = STR2(haystack);    while (start < haystack->len) {    if (str[start] == (p_wchar2)val) break;    start++;    }    }    break; - #ifdef PIKE_DEBUG -  default: -  Pike_fatal("search(): Unsupported string shift: %d!\n", -  haystack->size_shift); -  break; - #endif +     }    if (start >= haystack->len) {    start = -1;    }    } else if(TYPEOF(Pike_sp[1-args]) == T_STRING) {    /* Handle searching for the empty string. */    if (Pike_sp[1-args].u.string->len) {    start = string_search(haystack,    Pike_sp[1-args].u.string,    start);
pike.git/src/builtin_functions.c:1139:    if(TYPEOF(Pike_sp[1-args]) != T_STRING)    SIMPLE_ARG_TYPE_ERROR("has_prefix", 2, "string");       b = Pike_sp[1-args].u.string;       if (TYPEOF(Pike_sp[-args]) == T_OBJECT) {    ptrdiff_t i;    struct object *o = Pike_sp[-args].u.object;    int inherit_no = SUBTYPEOF(Pike_sp[-args]);    +  if (!o->prog || FIND_LFUN(o->prog, LFUN__SIZEOF) < 0) { +  Pike_error("Object in argument 1 lacks lfun::_sizeof().\n"); +  } +     apply_lfun(o, LFUN__SIZEOF, 0);    if ((TYPEOF(Pike_sp[-1]) != 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;
pike.git/src/builtin_functions.c:1168:    }    }    pop_n_elems(args+1);    push_int(1);    return;    }       a = Pike_sp[-args].u.string;       /* First handle some common special cases. */ -  if ((b->len > a->len) || (b->size_shift > a->size_shift)) { +  if ((b->len > a->len) || (b->size_shift > a->size_shift) +  || !string_range_contains_string(a, b)) {    pop_n_elems(args);    push_int(0);    return;    }       /* Trivial cases. */    if ((a == b)||(!b->len)) {    pop_n_elems(args);    push_int(1);    return;    }       if (a->size_shift == b->size_shift) { -  int res = !MEMCMP(a->str, b->str, b->len << b->size_shift); +  int res = !memcmp(a->str, b->str, b->len << b->size_shift);    pop_n_elems(args);    push_int(res);    return;    }       /* At this point a->size_shift > b->size_shift */   #define TWO_SHIFTS(S1, S2) ((S1)|((S2)<<2))    switch(TWO_SHIFTS(a->size_shift, b->size_shift)) {   #define CASE_SHIFT(S1, S2) \    case TWO_SHIFTS(S1, S2): \
pike.git/src/builtin_functions.c:1208:    ; \    pop_n_elems(args); \    push_int(len == -1); \    return; \    } \    break       CASE_SHIFT(1,0);    CASE_SHIFT(2,0);    CASE_SHIFT(2,1); -  default: -  Pike_error("has_prefix(): Unexpected string shift combination: a:%d, b:%d!\n", -  a->size_shift, b->size_shift); -  break; +     }   #undef CASE_SHIFT   #undef TWO_SHIFTS   }      /*! @decl int has_suffix(string s, string suffix)    *!    *! Returns @expr{1@} if the string @[s] ends with @[suffix],    *! returns @expr{0@} (zero) otherwise.    *!
pike.git/src/builtin_functions.c:1240:    SIMPLE_TOO_FEW_ARGS_ERROR("has_suffix", 2);    if(TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_ARG_TYPE_ERROR("has_suffix", 1, "string");    if(TYPEOF(Pike_sp[1-args]) != 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)) { +  if ((b->len > a->len) || (b->size_shift > a->size_shift) +  || !string_range_contains_string(a, b)) {    pop_n_elems(args);    push_int(0);    return;    }       /* Trivial cases. */    if ((a == b)||(!b->len)) {    pop_n_elems(args);    push_int(1);    return;    }       if (a->size_shift == b->size_shift) { -  int res = !MEMCMP(a->str + ((a->len - b->len)<<b->size_shift), b->str, +  int res = !memcmp(a->str + ((a->len - b->len)<<b->size_shift), b->str,    b->len << b->size_shift);    pop_n_elems(args);    push_int(res);    return;    }       /* At this point a->size_shift > b->size_shift */   #define TWO_SHIFTS(S1, S2) ((S1)|((S2)<<2))    switch(TWO_SHIFTS(a->size_shift, b->size_shift)) {   #define CASE_SHIFT(S1, S2) \
pike.git/src/builtin_functions.c:1281:    ; \    pop_n_elems(args); \    push_int(len == -1); \    return; \    } \    break       CASE_SHIFT(1,0);    CASE_SHIFT(2,0);    CASE_SHIFT(2,1); -  default: -  Pike_error("has_prefix(): Unexpected string shift combination: a:%d, b:%d!\n", -  a->size_shift, b->size_shift); -  break; +     }   #undef CASE_SHIFT   #undef TWO_SHIFTS   }      /*! @decl int has_index(string haystack, int index)    *! @decl int has_index(array haystack, int index)    *! @decl int has_index(mapping|multiset|object|program haystack, mixed index)    *!    *! Search for @[index] in @[haystack].
pike.git/src/builtin_functions.c:1342:    break;       case T_ARRAY:    if(TYPEOF(Pike_sp[-1]) == T_INT)    t = (0 <= Pike_sp[-1].u.integer && Pike_sp[-1].u.integer < Pike_sp[-2].u.array->size);       pop_n_elems(args);    push_int(t);    break;    -  case T_MULTISET: +     case T_MAPPING: -  f_index(2); -  f_zero_type(1); +  t=!!low_mapping_lookup( Pike_sp[-2].u.mapping, Pike_sp-1 ); +  pop_n_elems(2); +  push_int(t); +  break;    - #ifdef PIKE_DEBUG -  if(TYPEOF(Pike_sp[-1]) != T_INT) -  PIKE_ERROR("has_index", -  "Function `zero_type' gave incorrect result.\n", Pike_sp, args); - #endif -  Pike_sp[-1].u.integer = !Pike_sp[-1].u.integer; +  case T_MULTISET: +  t = multiset_member( Pike_sp[-2].u.multiset, Pike_sp-1 ); +  pop_n_elems(2); +  push_int(t);    break;       case T_OBJECT:    case T_PROGRAM:    /* FIXME: If the object behaves like an array, it will throw an    error for non-valid indices. Therefore it's not a good idea    to use the index operator.       Maybe we should use object->_has_index(index) provided that    the object implements it.
pike.git/src/builtin_functions.c:1492:    *!    *! Calling @[add_constant()] without a value will remove that name from    *! the list of constants. As with replacing, this will not affect already    *! compiled programs.    *!    *! @seealso    *! @[all_constants()]    */   PMOD_EXPORT void f_add_constant(INT32 args)   { -  ASSERT_SECURITY_ROOT("add_constant"); -  +     if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("add_constant", 1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("add_constant", 1, "string");       if(args>1)    {    dmalloc_touch_svalue(Pike_sp-args+1);    low_add_efun(Pike_sp[-args].u.string, Pike_sp-args+1);
pike.git/src/builtin_functions.c:1580:    *! In all other cases @[zero_type()] will return @expr{0@} (zero).    *!    *! @seealso    *! @[find_call_out()]    */   PMOD_EXPORT void f_zero_type(INT32 args)   {    if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("zero_type",1);    -  if((TYPEOF(Pike_sp[-args]) == T_OBJECT || -  TYPEOF(Pike_sp[-args]) == T_FUNCTION) -  && !Pike_sp[-args].u.object->prog) +  if(IS_DESTRUCTED(Pike_sp-args))    {    pop_n_elems(args);    push_int(NUMBER_DESTRUCTED);    }    else if(TYPEOF(Pike_sp[-args]) != T_INT)    {    pop_n_elems(args);    push_int(0);    }    else    {    pop_n_elems(args-1);    Pike_sp[-1].u.integer = SUBTYPEOF(Pike_sp[-1]);    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER);    }   }    - static int generate_zero_type(node *n) + static int generate_arg_for(node *n)   { -  struct compilation *c = THIS_COMPILATION; -  CHECK_COMPILER(); +     if(count_args(CDR(n)) != 1) return 0;    if(do_docode(CDR(n),DO_NOT_COPY) != 1)    Pike_fatal("Count args was wrong in generate_zero_type().\n"); -  +  return 1; + } +  + static int generate_zero_type(node *n) + { +  struct compilation *c = THIS_COMPILATION; +  if( generate_arg_for( n ) )    emit0(F_ZERO_TYPE); -  +  else +  return 0;    return 1;   }    -  + static int generate_undefinedp(node *n) + { +  struct compilation *c = THIS_COMPILATION; +  if( generate_arg_for(n) ) +  emit0(F_UNDEFINEDP); +  else +  return 0; +  return 1; + } +  + static int generate_destructedp(node *n) + { +  struct compilation *c = THIS_COMPILATION; +  if( generate_arg_for(n) ) +  emit0(F_DESTRUCTEDP); +  else +  return 0; +  return 1; + } +    /*    * Some wide-strings related functions    */    - /*! @decl string(0..255) string_to_unicode(string s) + /*! @decl string(0..255) string_to_unicode(string s, int(0..2)|void byteorder)    *!    *! Converts a string into an UTF16 compliant byte-stream.    *! -  +  *! @param s +  *! String to convert to UTF16. +  *! +  *! @param byteorder +  *! Byte-order for the output. One of: +  *! @int +  *! @value 0 +  *! Network (aka big-endian) byte-order (default). +  *! @value 1 +  *! Little-endian byte-order. +  *! @value 2 +  *! Native byte-order. +  *! @endint +  *!    *! @note    *! Throws an error if characters not legal in an UTF16 stream are    *! encountered. Valid characters are in the range 0x00000 - 0x10ffff,    *! except for characters 0xfffe and 0xffff.    *!    *! Characters in range 0x010000 - 0x10ffff are encoded using surrogates.    *!    *! @seealso -  *! @[Locale.Charset.decoder()], @[string_to_utf8()], @[unicode_to_string()], +  *! @[Charset.decoder()], @[string_to_utf8()], @[unicode_to_string()],    *! @[utf8_to_string()]    */   PMOD_EXPORT void f_string_to_unicode(INT32 args)   {    struct pike_string *in;    struct pike_string *out = NULL;    ptrdiff_t len;    ptrdiff_t i; -  +  unsigned INT_TYPE byteorder = 0;    -  get_all_args("string_to_unicode", args, "%W", &in); +  get_all_args("string_to_unicode", args, "%W.%i", &in, &byteorder);    -  +  if (byteorder >= 2) { +  if (byteorder == 2) { + #if PIKE_BYTEORDER == 1234 +  /* Little endian. */ +  byteorder = 1; + #else +  byteorder = 0; + #endif +  } else { +  SIMPLE_BAD_ARG_ERROR("string_to_unicode", 2, "int(0..2)|void"); +  } +  } +     switch(in->size_shift) {    case 0:    /* Just 8bit characters */    len = in->len * 2;    out = begin_shared_string(len);    if (len) { -  MEMSET(out->str, 0, len); /* Clear the upper (and lower) byte */ - #ifdef PIKE_DEBUG -  if (d_flag) { -  for(i = len; i--;) { -  if (out->str[i]) { -  Pike_fatal("MEMSET didn't clear byte %ld of %ld\n", -  PTRDIFF_T_TO_LONG(i+1), -  PTRDIFF_T_TO_LONG(len)); -  } -  } -  } - #endif /* PIKE_DEBUG */ +  memset(out->str, 0, len); /* Clear the upper (and lower) byte */    for(i = in->len; i--;) { -  out->str[i * 2 + 1] = in->str[i]; +  out->str[i * 2 + 1 - byteorder] = in->str[i];    }    }    out = end_shared_string(out);    break;    case 1:    /* 16 bit characters */    /* FIXME: Should we check for 0xfffe & 0xffff here too? */    len = in->len * 2;    out = begin_shared_string(len); -  +  if (byteorder ==   #if (PIKE_BYTEORDER == 4321) -  /* Big endian -- We don't need to do much... -  * -  * FIXME: Future optimization: Check if refcount is == 1, -  * and perform sufficient magic to be able to convert in place. -  */ -  MEMCPY(out->str, in->str, len); +  1 /* Little endian. */   #else -  +  0 /* Big endian. */ + #endif +  ) {    /* Other endianness, may need to do byte-order conversion also. */ -  { +     p_wchar1 *str1 = STR1(in);    for(i = in->len; i--;) {    unsigned INT32 c = str1[i]; -  out->str[i * 2 + 1] = c & 0xff; -  out->str[i * 2] = c >> 8; +  out->str[i * 2 + 1 - byteorder] = c & 0xff; +  out->str[i * 2 + byteorder] = c >> 8;    } -  +  } else { +  /* Native byte order -- We don't need to do much... +  * +  * FIXME: Future optimization: Check if refcount is == 1, +  * and perform sufficient magic to be able to convert in place. +  */ +  memcpy(out->str, in->str, len);    } - #endif +     out = end_shared_string(out);    break;    case 2:    /* 32 bit characters -- Is someone writing in Klingon? */    {    p_wchar2 *str2 = STR2(in);    ptrdiff_t j;    len = in->len * 2;    /* Check how many extra wide characters there are. */    for(i = in->len; i--;) {    if (str2[i] > 0xfffd) {    if (str2[i] < 0x10000) {    /* 0xfffe: Byte-order detection illegal character.    * 0xffff: Illegal character.    */ -  Pike_error("string_to_unicode(): Illegal character 0x%04x (index %ld) " +  Pike_error("Illegal character 0x%04x (index %ld) "    "is not a Unicode character.",    str2[i], PTRDIFF_T_TO_LONG(i));    }    if (str2[i] > 0x10ffff) { -  Pike_error("string_to_unicode(): Character 0x%08x (index %ld) " +  Pike_error("Character 0x%08x (index %ld) "    "is out of range (0x00000000..0x0010ffff).",    str2[i], PTRDIFF_T_TO_LONG(i));    } -  /* Extra wide characters take two unicode characters in space. -  * ie One unicode character extra. +  /* Extra wide characters take two UTF16 characters in space. +  * ie One UTF16 character extra.    */    len += 2;    }    }    out = begin_shared_string(len);    j = len;    for(i = in->len; i--;) {    unsigned INT32 c = str2[i];       j -= 2;       if (c > 0xffff) {    /* Use surrogates */    c -= 0x10000;    -  out->str[j + 1] = c & 0xff; -  out->str[j] = 0xdc | ((c >> 8) & 0x03); +  out->str[j + 1 - byteorder] = c & 0xff; +  out->str[j + byteorder] = 0xdc | ((c >> 8) & 0x03);    j -= 2;    c >>= 10;    c |= 0xd800;    } -  out->str[j + 1] = c & 0xff; -  out->str[j] = c >> 8; +  out->str[j + 1 - byteorder] = c & 0xff; +  out->str[j + byteorder] = c >> 8;    }   #ifdef PIKE_DEBUG    if (j) {    Pike_fatal("string_to_unicode(): Indexing error: len:%ld, j:%ld.\n",    PTRDIFF_T_TO_LONG(len), PTRDIFF_T_TO_LONG(j));    }   #endif /* PIKE_DEBUG */    out = end_shared_string(out);    }    break; - #ifdef PIKE_DEBUG -  default: -  Pike_fatal("string_to_unicode(): Bad string shift: %d!\n", in->size_shift); -  break; - #endif +     }    pop_n_elems(args);    push_string(out);   }    - /*! @decl string unicode_to_string(string(0..255) s) + /*! @decl string unicode_to_string(string(0..255) s, int(0..2)|void byteorder)    *!    *! Converts an UTF16 byte-stream into a string.    *! -  *! @note -  *! This function did not decode surrogates in Pike 7.2 and earlier. +  *! @param s +  *! String to convert to UTF16.    *! -  +  *! @param byteorder +  *! Default input byte-order. One of: +  *! @int +  *! @value 0 +  *! Network (aka big-endian) byte-order (default). +  *! @value 1 +  *! Little-endian byte-order. +  *! @value 2 +  *! Native byte-order. +  *! @endint +  *! Note that this argument is disregarded if @[s] starts with a BOM. +  *!    *! @seealso -  *! @[Locale.Charset.decoder()], @[string_to_unicode()], @[string_to_utf8()], +  *! @[Charset.decoder()], @[string_to_unicode()], @[string_to_utf8()],    *! @[utf8_to_string()]    */   PMOD_EXPORT void f_unicode_to_string(INT32 args)   {    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", &in); +  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,    "String length is odd.\n");    }    -  +  if (byteorder >= 2) { +  if (byteorder == 2) { + #if PIKE_BYTEORDER == 1234 +  /* Little endian. */ +  byteorder = 1; + #else +  byteorder = 0; + #endif +  } else { +  SIMPLE_BAD_ARG_ERROR("unicode_to_string", 2, "int(0..2)|void"); +  } +  } +  +  if (byteorder != + #if PIKE_BYTEORDER == 1234 +  1 + #else +  0 + #endif +  ) { +  /* Need to swap as the wanted byte-order differs +  * from the native byte-order. +  */ +  swab = 1; +  } +     /* Check byteorder of UTF data */    str0 = (p_wchar1 *)in->str;    len = in->len;    if (len && (str0[0] == 0xfeff)) {    /* Correct byte order mark. No swap necessary. */    swab = 0;    str0 ++;    len -= 2;    } else if (len && (str0[0] == 0xfffe)) {    /* Reversed byte order mark. Need to swap. */    swab = 1;    str0 ++;    len -= 2;    } else { -  /* No byte order mark. Need to swap unless big endian */ - #if (PIKE_BYTEORDER == 4321) -  swab = 0; - #else -  swab = 1; - #endif /* PIKE_BYTEORDER == 4321 */ +  /* No byte order mark. Use the user-specified byte-order. */    }       /* Indentify surrogates by pre-swapped bitmasks, for efficiency */    if (swab) {    surr1 = 0xd8;    surr2 = 0xdc;    surrmask = 0xfc;    } else {    surr1 = 0xd800;    surr2 = 0xdc00;
pike.git/src/builtin_functions.c:1853:       } else       str2[i] = str0[-1];       } else    /*    * FIXME: Future optimization: Perform sufficient magic    * to do the conversion in place if the ref-count is == 1.    */ -  MEMCPY(out->str, (char *)(str0-len), len*2); +  memcpy(out->str, str0-len, len*2);    } else {    /* Reverse endian */       if (num_surrogates) {    /* Convert surrogates */       p_wchar2 *str2 = STR2(out);       for (i = len; i--; --str0) {   
pike.git/src/builtin_functions.c:1914:    ((unsigned char *)str0)[-1];   #endif /* PIKE_BYTEORDER == 4321 */    }    }    }    out = end_shared_string(out);    pop_n_elems(args);    push_string(out);   }    + /*! @decl string(1..) string_filter_non_unicode(string s) +  *! +  *! Replace the most obviously non-unicode characters from @[s] with +  *! the unicode replacement character. +  *! +  *! @note +  *! This will replace characters outside the ranges +  *! @expr{0x00000000-0x0000d7ff@} and @expr{0x0000e000-0x0010ffff@} +  *! with 0xffea (the replacement character). +  *! +  *! @seealso +  *! @[Charset.encoder()], @[string_to_unicode()], +  *! @[unicode_to_string()], @[utf8_to_string()], @[string_to_utf8()] +  */ + static void f_string_filter_non_unicode( INT32 args ) + { +  struct pike_string *in; +  INT32 min,max; +  int i; +  static const p_wchar1 replace = 0xfffd; +  static const PCHARP repl_char = {(void*)&replace,1}; +  +  get_all_args("filter_non_unicode", args, "%W", &in); +  check_string_range( in, 1, &min, &max ); +  +  if( !in->len || (min >= 0 && max < 0xd800) ) +  return; /* The string is obviously ok. */ +  +  if( (max < 0 || min > 0x10ffff) || (max < 0xe000 && min > 0xd7ff) ) +  { +  /* All invalid. Could probably be optimized. */ +  debug_make_shared_binary_pcharp( repl_char, 1 ); +  push_int( in->len ); +  o_multiply(); +  } +  else +  { +  /* Note: we could optimize this by not doing any string builder +  * at all unless there is at least one character that needs to +  * be replaced. +  */ +  struct string_builder out; +  /* on average shift 1 is more correct than in->size_shift, since +  * there is usually only the one character that is outside the +  * range. +  */ +  init_string_builder_alloc( &out, in->len, 1 ); +  for( i=0; i<in->len; i++ ) +  { +  p_wchar2 c = index_shared_string(in,i); +  if( (c < 0 || c > 0x10ffff) || (c>0xd7ff && c<0xe000) ) +  string_builder_append( &out, repl_char, 1 ); +  else +  string_builder_putchar( &out, c ); +  } +  push_string( finish_string_builder( &out ) ); +  } + } +    /*! @decl string(0..255) string_to_utf8(string s)    *! @decl string(0..255) string_to_utf8(string s, int extended)    *!    *! Converts a string into an UTF-8 compliant byte-stream.    *!    *! @note    *! Throws an error if characters not valid in an UTF-8 stream are    *! encountered. Valid characters are in the ranges    *! @expr{0x00000000-0x0000d7ff@} and @expr{0x0000e000-0x0010ffff@}.    *!    *! If @[extended] is 1 then characters outside the valid ranges are    *! accepted too and encoded using the same algorithm. Such encoded    *! characters are however not UTF-8 compliant.    *!    *! @seealso -  *! @[Locale.Charset.encoder()], @[string_to_unicode()], +  *! @[Charset.encoder()], @[string_to_unicode()],    *! @[unicode_to_string()], @[utf8_to_string()]    */   PMOD_EXPORT void f_string_to_utf8(INT32 args)   {    ptrdiff_t len;    struct pike_string *in;    struct pike_string *out;    ptrdiff_t i,j;    INT_TYPE extended = 0; -  +  PCHARP src; +  INT32 min, max;       get_all_args("string_to_utf8", args, "%W.%i", &in, &extended);       len = in->len;    -  for(i=0; i < in->len; i++) { -  unsigned INT32 c = index_shared_string(in, i); +  check_string_range(in, 1, &min, &max); +  +  if (min >= 0 && max <= 0x7f) { +  /* 7bit string -- already valid utf8. */ +  pop_n_elems(args - 1); +  return; +  } +  +  for(i=0,src=MKPCHARP_STR(in); i < in->len; INC_PCHARP(src,1),i++) { +  unsigned INT32 c = EXTRACT_PCHARP(src);    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)
pike.git/src/builtin_functions.c:1991:    }    }    }    if (len == in->len) {    /* 7bit string -- already valid utf8. */    pop_n_elems(args - 1);    return;    }    out = begin_shared_string(len);    -  for(i=j=0; i < in->len; i++) { -  unsigned INT32 c = index_shared_string(in, i); +  for(i=j=0,src=MKPCHARP_STR(in); i < in->len; INC_PCHARP(src,1),i++) { +  unsigned INT32 c = EXTRACT_PCHARP(src);    if (!(c & ~0x7f)) {    /* 7bit */    out->str[j++] = c;    } else if (!(c & ~0x7ff)) {    /* 11bit */    out->str[j++] = 0xc0 | (c >> 6);    out->str[j++] = 0x80 | (c & 0x3f);    } else if (!(c & ~0xffff)) {    /* 16bit */    out->str[j++] = 0xe0 | (c >> 12);
pike.git/src/builtin_functions.c:2028:    } else if (!(c & ~0x7fffffff)) {    /* 31bit */    out->str[j++] = 0xfc | (c >> 30);    out->str[j++] = 0x80 | ((c >> 24) & 0x3f);    out->str[j++] = 0x80 | ((c >> 18) & 0x3f);    out->str[j++] = 0x80 | ((c >> 12) & 0x3f);    out->str[j++] = 0x80 | ((c >> 6) & 0x3f);    out->str[j++] = 0x80 | (c & 0x3f);    } else {    /* 32 - 36bit */ -  out->str[j++] = DO_NOT_WARN((char)0xfe); +  out->str[j++] = (char)0xfe;    out->str[j++] = 0x80 | ((c >> 30) & 0x3f);    out->str[j++] = 0x80 | ((c >> 24) & 0x3f);    out->str[j++] = 0x80 | ((c >> 18) & 0x3f);    out->str[j++] = 0x80 | ((c >> 12) & 0x3f);    out->str[j++] = 0x80 | ((c >> 6) & 0x3f);    out->str[j++] = 0x80 | (c & 0x3f);    }    }   #ifdef PIKE_DEBUG    if (len != j) {
pike.git/src/builtin_functions.c:2053:    out = end_shared_string(out);    pop_n_elems(args);    push_string(out);   }      /*! @decl string utf8_to_string(string(0..255) s)    *! @decl string utf8_to_string(string(0..255) s, int extended)    *!    *! Converts an UTF-8 byte-stream into a string.    *! +  *! @param s +  *! String of UTF-8 encoded data to decode. +  *! +  *! @param extended +  *! Bitmask with extension options. +  *! @int +  *! @value 1 +  *! Accept and decode the extension used by @[string_to_utf8()]. +  *! @value 2 +  *! Accept and decode UTF-8 encoded UTF-16 (ie accept and +  *! decode valid surrogates). +  *! @endint +  *!    *! @note    *! Throws an error if the stream is not a legal UTF-8 byte-stream.    *! -  *! Accepts and decodes the extension used by @[string_to_utf8()] if -  *! @[extended] is @expr{1@}. -  *! +     *! @note -  *! In conformance with RFC 3629 and Unicode 3.1 and later, +  *! In conformance with @rfc{3629@} and Unicode 3.1 and later,    *! non-shortest forms are not decoded. An error is thrown instead.    *!    *! @seealso -  *! @[Locale.Charset.encoder()], @[string_to_unicode()], @[string_to_utf8()], +  *! @[Charset.encoder()], @[string_to_unicode()], @[string_to_utf8()],    *! @[unicode_to_string()]    */   PMOD_EXPORT void f_utf8_to_string(INT32 args)   {    struct pike_string *in;    struct pike_string *out;    ptrdiff_t len = 0;    int shift = 0;    ptrdiff_t i,j=0;    INT_TYPE extended = 0; -  +  INT32 min, max;       get_all_args("utf8_to_string", args, "%S.%i", &in, &extended);    -  +  check_string_range(in, 1, &min, &max); +  +  if (min >= 0 && max <= 0x7f) { +  /* 7bit string -- already valid utf8. */ +  pop_n_elems(args - 1); +  return; +  } +     for(i=0; i < in->len; i++) {    unsigned int c = STR0(in)[i];    len++;    if (c & 0x80) {    int cont = 0;       /* From table 3-6 in the Unicode standard 4.0: Well-Formed UTF-8    * Byte Sequences    *    * Code Points 1st Byte 2nd Byte 3rd Byte 4th Byte
pike.git/src/builtin_functions.c:2107:    */       if ((c & 0xc0) == 0x80) {    bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1,    NULL, Pike_sp - args,    "Invalid continuation character 0x%02x "    "at index %"PRINTPTRDIFFT"d.\n",    c, i);    }    - #define GET_CONT_CHAR(in, i, c) do { \ + #define GET_CHAR(in, i, c) do { \    i++; \    if (i >= in->len) \    bad_arg_error ("utf8_to_string", Pike_sp - args, 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, \    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, \
pike.git/src/builtin_functions.c:2150:    }       else if ((c & 0xf0) == 0xe0) {    /* 16bit */    if (c == 0xe0) {    GET_CONT_CHAR (in, i, c);    if (!(c & 0x20))    UTF8_SEQ_ERROR ("0xe0 ", c, i - 1, "is a non-shortest form");    cont = 1;    } -  else if (!extended && c == 0xed) { +  else if (!(extended & 1) && c == 0xed) {    GET_CONT_CHAR (in, i, c); -  if (c > 0x9f) +  if (c & 0x20) { +  /* Surrogate. */ +  if (!(extended & 2)) {    UTF8_SEQ_ERROR ("0xed ", c, i - 1, "would decode to " -  "an invalid surrogate character"); +  "a UTF-16 surrogate character"); +  } +  if (c & 0x10) { +  UTF8_SEQ_ERROR ("0xed ", c, i - 1, "would decode to " +  "a UTF-16 low surrogate character"); +  } +  GET_CONT_CHAR(in, i, c); +  +  GET_CHAR (in, i, c); +  if (c != 0xed) { +  UTF8_SEQ_ERROR ("", c, i-1, "UTF-16 low surrogate " +  "character required"); +  } +  GET_CONT_CHAR (in, i, c); +  if ((c & 0xf0) != 0xb0) { +  UTF8_SEQ_ERROR ("0xed ", c, i-1, "UTF-16 low surrogate " +  "character required"); +  } +  shift = 2; +  }    cont = 1;    }    else    cont = 2;    if (shift < 1) {    shift = 1;    }    }       else {    if ((c & 0xf8) == 0xf0) {    /* 21bit */    if (c == 0xf0) {    GET_CONT_CHAR (in, i, c);    if (!(c & 0x30))    UTF8_SEQ_ERROR ("0xf0 ", c, i - 1, "is a non-shortest form");    cont = 2;    } -  else if (!extended) { +  else if (!(extended & 1)) {    if (c > 0xf4)    UTF8_SEQ_ERROR ("", c, i, "would decode to "    "a character outside the valid UTF-8 range");    else if (c == 0xf4) {    GET_CONT_CHAR (in, i, c);    if (c > 0x8f)    UTF8_SEQ_ERROR ("0xf4 ", c, i - 1, "would decode to "    "a character outside the valid UTF-8 range");    cont = 2;    }
pike.git/src/builtin_functions.c:2197:    else    cont = 3;    }       else if (c == 0xff)    bad_arg_error ("utf8_to_string", Pike_sp - args, args, 1,    NULL, Pike_sp - args,    "Invalid character 0xff at index %"PRINTPTRDIFFT"d.\n",    i);    -  else if (!extended) +  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) {    /* 26bit */    if (c == 0xf8) {    GET_CONT_CHAR (in, i, c);    if (!(c & 0x38))    UTF8_SEQ_ERROR ("0xf8 ", c, i - 1, "is a non-shortest form");
pike.git/src/builtin_functions.c:2241:    }    }       if (shift < 2)    shift = 2;    }       while(cont--)    GET_CONT_CHAR (in, i, c);    + #undef GET_CHAR   #undef GET_CONT_CHAR   #undef UTF8_SEQ_ERROR    }    }    if (len == in->len) {    /* 7bit in == 7bit out */    pop_n_elems(args-1);    return;    }   
pike.git/src/builtin_functions.c:2330:    c &= 0x01;    } else {    /* 36bit */    cont = 6;    c = 0;    }    while(cont--) {    unsigned int c2 = STR0(in)[i++] & 0x3f;    c = (c << 6) | c2;    } +  if ((extended & 2) && (c & 0xfc00) == 0xdc00) { +  /* Low surrogate */ +  c &= 0x3ff; +  c |= ((out_str[--j] & 0x3ff)<<10) + 0x10000;    } -  +  }    out_str[j++] = c;    }    break;    }    }      #ifdef PIKE_DEBUG    if (j != len) { -  Pike_fatal("utf8_to_string(): Calculated and actual lengths differ: " +  Pike_fatal("Calculated and actual lengths differ: "    "%"PRINTPTRDIFFT"d != %"PRINTPTRDIFFT"d\n",    len, j);    }   #endif /* PIKE_DEBUG */    out = low_end_shared_string(out);   #ifdef PIKE_DEBUG    check_string (out);   #endif    pop_n_elems(args);    push_string(out);
pike.git/src/builtin_functions.c:2368:    if( !args || TYPEOF(Pike_sp[-1]) != T_STRING ||    Pike_sp[-1].u.string->size_shift )    Pike_error( "__parse_pike_type requires a 8bit string as its first argument\n" );    t = parse_type( (char *)STR0(Pike_sp[-1].u.string) );    pop_stack();       push_string(type_to_string(t));    free_type(t);   }    - /*! @decl type __soft_cast(type to, type from) + /*! @module Pike +  */ +  + /*! @decl type soft_cast(type to, type from)    *!    *! Return the resulting type from a soft cast of @[from] to @[to].    */   static void f___soft_cast(INT32 args)   {    struct pike_type *res;    if (args < 2) Pike_error("Bad number of arguments to __soft_cast().\n");    if (TYPEOF(Pike_sp[-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __soft_cast() expected type.\n");    }
pike.git/src/builtin_functions.c:2392:    if (!(res = soft_cast(Pike_sp[-args].u.type,    Pike_sp[1-args].u.type, 0))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }    - /*! @decl type __low_check_call(type fun_type, type arg_type) -  *! @decl type __low_check_call(type fun_type, type arg_type, int flags) + /*! @decl type low_check_call(type fun_type, type arg_type) +  *! @decl type low_check_call(type fun_type, type arg_type, int flags)    *!    *! Check whether a function of type @[fun_type] may be called    *! with a first argument of type @[arg_type].    *!    *! @param flags    *! The following flags are currently defined:    *! @int    *! @value 1    *! Strict types. Fail if not all possible values in @[arg_type]    *! are valid as the first argument to @[fun_type].
pike.git/src/builtin_functions.c:2418:    *! @endint    *!    *! @returns    *! Returns a continuation type on success.    *!    *! Returns @tt{0@} (zero) on failure.    */   static void f___low_check_call(INT32 args)   {    struct pike_type *res; -  INT32 flags = 0; +  INT32 flags = CALL_NOT_LAST_ARG;    struct svalue *sval = NULL;    if (args < 2) Pike_error("Bad number of arguments to __low_check_call().\n");    if (TYPEOF(Pike_sp[-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __low_check_call() expected type.\n");    }    if (TYPEOF(Pike_sp[1-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 2 to __low_check_call() expected type.\n");    }    if (args > 2) {    if (TYPEOF(Pike_sp[2-args]) != PIKE_T_INT) {    Pike_error("Bad argument 3 to __low_check_call() expected int.\n");    } -  flags = Pike_sp[2-args].u.integer; +  flags = Pike_sp[2-args].u.integer ^ CALL_NOT_LAST_ARG;    }    if (args > 3) sval = Pike_sp + 3 - args;    if (!(res = low_new_check_call(Pike_sp[-args].u.type,    Pike_sp[1-args].u.type, flags, sval))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }    - /*! @decl type __get_return_type(type fun_type) + /*! @decl type get_return_type(type fun_type)    *!    *! Check what a function of the type @[fun_type] will    *! return if called with no arguments.    *!    *! @returns    *! Returns the type of the returned value on success    *!    *! Returns @tt{0@} (zero) on failure.    */   static void f___get_return_type(INT32 args)
pike.git/src/builtin_functions.c:2472:    }    if (!(res = new_get_return_type(Pike_sp[-1].u.type, 0))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }    - /*! @decl type __get_first_arg_type(type fun_type) + /*! @decl type get_first_arg_type(type fun_type)    *!    *! Check if a function of the type @[fun_type] may be called    *! with an argument, and return the type of that argument.    *!    *! @returns    *! Returns the expected type of the first argument to the function.    *!    *! Returns @tt{0@} (zero) if a function of the type @[fun_type]    *! may not be called with any argument, or if it is not callable.    */ - static void f___get_first_arg_type(INT32 args) + void f___get_first_arg_type(INT32 args)   {    struct pike_type *res;    if (args != 1) {    Pike_error("Bad number of arguments to __get_first_arg_type().\n");    }    if (TYPEOF(Pike_sp[-1]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __get_first_arg_type() expected type.\n");    } -  if (!(res = get_first_arg_type(Pike_sp[-1].u.type, 0))) { +  if (!(res = get_first_arg_type(Pike_sp[-1].u.type, CALL_NOT_LAST_ARG)) && +  !(res = get_first_arg_type(Pike_sp[-1].u.type, 0))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }    - /*! @decl array(string) __get_type_attributes(type t) + /*! @decl array(string) get_type_attributes(type t)    *!    *! Get the attribute markers for a type.    *!    *! @returns    *! Returns an array with the attributes for the type @[t].    *!    *! @seealso -  *! @[__get_return_type()], @[__get_first_arg_type()] +  *! @[get_return_type()], @[get_first_arg_type()]    */   static void f___get_type_attributes(INT32 args)   {    struct pike_type *t;    int count = 0;    if (args != 1) {    Pike_error("Bad number of arguments to __get_type_attributes().\n");    }    if (TYPEOF(Pike_sp[-1]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __get_type_attributes() expected type.\n");
pike.git/src/builtin_functions.c:2535:    if (t->type == PIKE_T_ATTRIBUTE) {    ref_push_string((struct pike_string *)t->car);    count++;    }    t = t->cdr;    }    f_aggregate(count);    stack_pop_n_elems_keep_top(args);   }    + /*! @endmodule Pike +  */ +    /*! @decl mapping (string:mixed) all_constants()    *!    *! Returns a mapping containing all global constants, indexed on the name    *! of the constant, and with the value of the constant as value.    *!    *! @seealso    *! @[add_constant()]    */   PMOD_EXPORT void f_all_constants(INT32 args)   {
pike.git/src/builtin_functions.c:2674:    a->type_field = BIT_INT;    pop_n_elems(args);    push_array(a);    }   }      /*! @decl object this_object(void|int level);    *!    *! Returns the object we are currently evaluating in.    *! -  *! @[level] might be used to access the object of a surrounding +  *! @param level +  *! @[level] may be used to access the object of a surrounding    *! class: The object at level 0 is the current object, the object    *! at level 1 is the one belonging to the class that surrounds    *! the class that the object comes from, and so on.    *!    *! @note    *! As opposed to a qualified @expr{this@} reference such as    *! @expr{global::this@}, this function doesn't always access the    *! objects belonging to the lexically surrounding classes. If the    *! class containing the call has been inherited then the objects    *! surrounding the inheriting class are accessed.
pike.git/src/builtin_functions.c:2837:    *!    *! The arguments after the @[returncode] will be used for a call to    *! @[werror] to output a message on stderr.    *!    *! @seealso    *! @[_exit()]    */   PMOD_EXPORT void f_exit(INT32 args)   {    static int in_exit=0; -  ASSERT_SECURITY_ROOT("exit"); +        if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("exit", 1);       if(TYPEOF(Pike_sp[-args]) != T_INT)    SIMPLE_BAD_ARG_ERROR("exit", 1, "int");       if(in_exit) Pike_error("exit already called!\n");    in_exit=1;   
pike.git/src/builtin_functions.c:2886:    *! released, and databases might not be closed properly.    *!    *! Use with extreme caution.    *!    *! @seealso    *! @[exit()]    */   void f__exit(INT32 args)   {    int code; -  ASSERT_SECURITY_ROOT("_exit"); +        get_all_args("_exit", args, "%d", &code);      #ifdef PIKE_DEBUG    {    /* This will allow -p to work with _exit -Hubbe */    exit_opcodes();    }   #endif   
pike.git/src/builtin_functions.c:2924:    *! The third syntax can be used to measure time more preciely than one    *! second. It return how many seconds has passed since @[t]. The precision    *! of this function varies from system to system.    *!    *! @seealso    *! @[ctime()], @[localtime()], @[mktime()], @[gmtime()],    *! @[System.gettimeofday], @[gethrtime]    */   PMOD_EXPORT void f_time(INT32 args)   { +  struct timeval ret;    if(!args ||    (TYPEOF(Pike_sp[-args]) == T_INT && Pike_sp[-args].u.integer == 0))    { -  GETTIMEOFDAY(&current_time); +  ACCURATE_GETTIMEOFDAY(&ret); +  pop_n_elems(args); +  push_int(ret.tv_sec); +  +  return;    }else{    if(TYPEOF(Pike_sp[-args]) == T_INT && Pike_sp[-args].u.integer > 1)    {    struct timeval tmp; -  GETTIMEOFDAY(&current_time); +  ACCURATE_GETTIMEOFDAY(&ret);    tmp.tv_sec=Pike_sp[-args].u.integer;    tmp.tv_usec=0; -  my_subtract_timeval(&tmp,&current_time); +  my_subtract_timeval(&tmp,&ret);    pop_n_elems(args);    push_float( - (FLOAT_TYPE)tmp.tv_sec-((FLOAT_TYPE)tmp.tv_usec)/1000000 );    return;    }    }    pop_n_elems(args); -  push_int(current_time.tv_sec); +  INACCURATE_GETTIMEOFDAY(&ret); +  push_int(ret.tv_sec);   }    - /*! @decl string crypt(string password) + /*! @decl string(0..127) crypt(string password)    *! @decl int(0..1) crypt(string typed_password, string crypted_password)    *!    *! This function crypts and verifies a short string (only the first    *! 8 characters are significant).    *!    *! The first syntax crypts the string @[password] into something that    *! is hopefully hard to decrypt.    *!    *! The second syntax is used to verify @[typed_password] against    *! @[crypted_password], and returns @expr{1@} if they match, and
pike.git/src/builtin_functions.c:2980:       if(saltp)    {    if( Pike_sp[1-args].u.string->len < 2 )    {    pop_n_elems(args);    push_int(0);    return;    }    } else { -  unsigned int foo; /* Sun CC wants this :( */ -  foo=my_rand(); -  salt[0] = choise[foo % (size_t) strlen(choise)]; -  foo=my_rand(); -  salt[1] = choise[foo % (size_t) strlen(choise)]; +  salt[0] = choise[my_rand(strlen(choise))]; +  salt[1] = choise[my_rand(strlen(choise))];    saltp=salt; -  +  if (args > 1) { +  pop_n_elems(args-1); +  args = 1;    } -  +  }   #ifdef HAVE_CRYPT    ret = (char *)crypt(pwd, saltp);   #else   #ifdef HAVE__CRYPT    ret = (char *)_crypt(pwd, saltp);   #else   #error No crypt function found and fallback failed.   #endif   #endif    if (!ret) {
pike.git/src/builtin_functions.c:3061:    if(!Pike_fp) {    PIKE_ERROR("destruct",    "Destruct called without argument from callback function.\n",    Pike_sp, args);    }    o=Pike_fp->current_object;    }    if (o->prog && o->prog->flags & PROGRAM_NO_EXPLICIT_DESTRUCT)    PIKE_ERROR("destruct", "Object can't be destructed explicitly.\n",    Pike_sp, args); - #ifdef PIKE_SECURITY -  if(!CHECK_DATA_SECURITY(o, SECURITY_BIT_DESTRUCT)) -  Pike_error("Destruct permission denied.\n"); - #endif +     debug_malloc_touch(o);    destruct_object (o, DESTRUCT_EXPLICIT);    pop_n_elems(args);    destruct_objects_to_destruct();   }      /*! @decl array indices(string|array|mapping|multiset|object x)    *!    *! Return an array of all valid indices for the value @[x].    *! -  *! For strings and arrays this is simply an array of ascending -  *! numbers. +  *! @param x +  *! @mixed +  *! @type string +  *! @type array +  *! For strings and arrays this is simply an array of ascending +  *! numbers.    *! -  *! For mappings and multisets, the array might contain any value. +  *! @type mapping +  *! @type multiset +  *! For mappings and multisets, the array might contain any value.    *! -  *! For objects which define @[lfun::_indices()] that return value -  *! is used. +  *! @type object +  *! For objects which define @[lfun::_indices()] that return value +  *! is used.    *! -  *! For other objects an array with all non-protected symbols is -  *! returned. +  *! For other objects an array with the names of all non-protected +  *! symbols is returned. +  *! @endmixed    *!    *! @seealso    *! @[values()], @[types()], @[lfun::_indices()]    */   PMOD_EXPORT void f_indices(INT32 args)   {    ptrdiff_t size;    struct array *a = NULL;       if(args < 1)
pike.git/src/builtin_functions.c:3111:    goto qjump;       case T_ARRAY:    size=Pike_sp[-args].u.array->size;       qjump:    a=allocate_array_no_init(size,0);    while(--size>=0)    {    /* Elements are already integers. */ -  ITEM(a)[size].u.integer = DO_NOT_WARN((INT_TYPE)size); +  ITEM(a)[size].u.integer = (INT_TYPE)size;    }    a->type_field = BIT_INT;    break;       case T_MAPPING:    a=mapping_indices(Pike_sp[-args].u.mapping);    break;       case T_MULTISET:    a = multiset_indices (Pike_sp[-args].u.multiset);
pike.git/src/builtin_functions.c:3146:    a = program_indices(p);    break;    }    }    /* FALL THROUGH */       default:    SIMPLE_BAD_ARG_ERROR("indices", 1,    "string|array|mapping|"    "multiset|object|program|function"); -  return; /* make apcc happy */ +     }    pop_n_elems(args);    push_array(a);   }      /* this should probably be moved to pike_types.c or something */   #define FIX_OVERLOADED_TYPE(n, lf, X) fix_overloaded_type(n,lf,X,CONSTANT_STRLEN(X))   /* FIXME: This function messes around with the implementation of pike_type,    * and should probably be in pike_types.h instead.    */ - static node *fix_overloaded_type(node *n, int lfun, const char *deftype, int deftypelen) + static node *fix_overloaded_type(node *n, int lfun, const char *deftype, int UNUSED(deftypelen))   {    node **first_arg;    struct pike_type *t, *t2;    first_arg=my_get_arg(&_CDR(n), 0);    if(!first_arg) return 0;    t=first_arg[0]->type;    if(!t || match_types(t, object_type_string))    {    /* Skip any name-nodes. */    while(t && t->type == PIKE_T_NAME) {
pike.git/src/builtin_functions.c:3371:    free_type(types[0]);    }    return NULL;   }      /*! @decl array values(string|array|mapping|multiset|object x)    *!    *! Return an array of all possible values from indexing the value    *! @[x].    *! -  *! For strings an array of int with the ISO10646 codes of the -  *! characters in the string is returned. +  *! @param x +  *! @mixed +  *! @type string +  *! For strings an array of int with the ISO10646 codes of the +  *! characters in the string is returned.    *! -  *! For a multiset an array filled with ones (@expr{1@}) is -  *! returned. +  *! @type multiset +  *! For a multiset an array filled with ones (@expr{1@}) is +  *! returned.    *! -  *! For arrays a single-level copy of @[x] is returned. +  *! @type array +  *! For arrays a single-level copy of @[x] is returned.    *! -  *! For mappings the array may contain any value. +  *! @type mapping +  *! For mappings the array may contain any value.    *! -  *! For objects which define @[lfun::_values()] that return value -  *! is used. +  *! @type object +  *! For objects which define @[lfun::_values()] that return value +  *! is used.    *! -  *! For other objects an array with the values of all non-protected -  *! symbols is returned. +  *! For other objects an array with the values of all non-protected +  *! symbols is returned. +  *! @endmixed    *!    *! @seealso    *! @[indices()], @[types()], @[lfun::_values()]    */   PMOD_EXPORT void f_values(INT32 args)   {    ptrdiff_t size;    struct array *a = NULL;    if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("values", 1);
pike.git/src/builtin_functions.c:3444:    a = program_values(p);    break;    }    }    /* FALL THROUGH */       default:    SIMPLE_BAD_ARG_ERROR("values", 1,    "string|array|mapping|multiset|"    "object|program|function"); -  return; /* make apcc happy */ +     }    pop_n_elems(args);    push_array(a);   }      /*! @decl array(type(mixed)) types(string|array|mapping|multiset|object x)    *! -  *! Return an array of all valid indices for the value @[x]. +  *! Return an array with the types of all valid indices for the value @[x].    *! -  *! For strings this is simply an array with @tt{int@} +  *! @param x +  *! @mixed +  *! @type string +  *! For strings this is simply an array with @tt{int@}    *! -  *! For arrays, mappings and multisets this is simply -  *! an array with @tt{mixed@}. +  *! @type array +  *! @type mapping +  *! @type multiset +  *! For arrays, mappings and multisets this is simply +  *! an array with @tt{mixed@}.    *! -  *! For objects which define @[lfun::_types()] that return value -  *! is used. +  *! @type object +  *! For objects which define @[lfun::_types()] that return value +  *! is used.    *! -  *! For other objects an array with type types for all non-protected -  *! symbols is returned. +  *! For other objects an array with type types for all non-protected +  *! symbols is returned. +  *! @endmixed    *!    *! @note    *! This function was added in Pike 7.9.    *!    *! @seealso    *! @[indices()], @[values()], @[lfun::_types()]    */   PMOD_EXPORT void f_types(INT32 args)   {    ptrdiff_t size;
pike.git/src/builtin_functions.c:3533:    a = program_types(p);    break;    }    }    /* FALL THROUGH */       default:    SIMPLE_BAD_ARG_ERROR("types", 1,    "string|array|mapping|"    "multiset|object|program|function"); -  return; /* make apcc happy */ +     }    pop_n_elems(args);    push_array(a);   }    - /*! @decl object next_object(object o) -  *! @decl object next_object() -  *! -  *! Returns the next object from the list of all objects. -  *! -  *! All objects are stored in a linked list. -  *! -  *! @returns -  *! If no arguments have been given @[next_object()] will return the first -  *! object from the list. -  *! -  *! If @[o] has been specified the object after @[o] on the list will be -  *! returned. -  *! -  *! @note -  *! This function is not recomended to use. -  *! -  *! @seealso -  *! @[destruct()] -  */ - PMOD_EXPORT void f_next_object(INT32 args) - { -  struct object *o; -  -  ASSERT_SECURITY_ROOT("next_object"); -  -  if(args < 1) -  { -  o = first_object; -  }else{ -  if(TYPEOF(Pike_sp[-args]) != T_OBJECT) -  SIMPLE_BAD_ARG_ERROR("next_object", 1, "object"); -  o = Pike_sp[-args].u.object->next; -  } -  while(o && !o->prog) o=o->next; -  pop_n_elems(args); -  if(!o) -  { -  push_int(0); -  }else{ -  ref_push_object(o); -  } - } -  +    /*! @decl program|function object_program(mixed o)    *!    *! Return the program from which @[o] was instantiated. If the    *! object was instantiated from a class using parent references    *! the generating function will be returned.    *!    *! If @[o] is not an object or has been destructed @expr{0@} (zero)    *! will be returned.    */   PMOD_EXPORT void f_object_program(INT32 args)   {    if(args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR("object_program", 1);       if(TYPEOF(Pike_sp[-args]) == T_OBJECT)    {    struct object *o=Pike_sp[-args].u.object;    struct program *p = o->prog;    - #if 0 -  /* This'd be nice, but it doesn't work well since the returned -  * function can't double as a program (program_from_svalue returns -  * NULL for it). */ -  if (p == pike_trampoline_program) { -  struct pike_trampoline *t = (struct pike_trampoline *) o->storage; -  if (t->frame && t->frame->current_object) { -  add_ref (o = t->frame->current_object); -  pop_n_elems (args); -  push_function (o, t->func); -  return; -  } -  } - #endif -  +     if(p)    {    if (SUBTYPEOF(Pike_sp[-args])) {    /* FIXME: This probably works for the subtype-less case as well.    */    struct external_variable_context loc;    loc.o = o;    p = (loc.inherit = p->inherits + SUBTYPEOF(Pike_sp[-args]))->prog;    if (p->flags & PROGRAM_USES_PARENT) {    loc.parent_identifier = loc.inherit->parent_identifier;
pike.git/src/builtin_functions.c:3933:    match_len = v[c].ind->len;    }    }    return match;   }         static int replace_sortfun(struct replace_many_tupel *a,    struct replace_many_tupel *b)   { -  return DO_NOT_WARN((int)my_quick_strcmp(a->ind, b->ind)); +  return (int)my_quick_strcmp(a->ind, b->ind);   }      void free_replace_many_context(struct replace_many_context *ctx)   {    if (ctx->v) {    if (ctx->flags) {    /* Used for the precompiled case. */    int e = ctx->num;    while (e--) {    free_string(ctx->v[e].ind);    free_string(ctx->v[e].val);    }    if (ctx->empty_repl) {    free_string(ctx->empty_repl);    }    } -  free ((char *) ctx->v); +  free (ctx->v);    ctx->v = NULL;    }   }      void compile_replace_many(struct replace_many_context *ctx,    struct array *from,    struct array *to,    int reference_strings)   {    INT32 e, num;
pike.git/src/builtin_functions.c:4007:    if (ctx->empty_repl) add_ref(ctx->empty_repl);    for (e = 0; e < num; e++) {    add_ref(ctx->v[e].ind);    add_ref(ctx->v[e].val);    }    }       fsort((char *)ctx->v, num, sizeof(struct replace_many_tupel),    (fsortfun)replace_sortfun);    -  MEMSET(ctx->set_start, 0, sizeof(ctx->set_start)); -  MEMSET(ctx->set_end, 0, sizeof(ctx->set_end)); +  memset(ctx->set_start, 0, sizeof(ctx->set_start)); +  memset(ctx->set_end, 0, sizeof(ctx->set_end));    ctx->other_start = num;       for(e=0;e<num;e++)    {    {    p_wchar2 x;       if (ctx->v[num-1-e].ind->len) {    x=index_shared_string(ctx->v[num-1-e].ind,0);    if ((size_t) x < NELEM(ctx->set_start))
pike.git/src/builtin_functions.c:4345:    */    n->node_info |= OPT_SIDE_EFFECT;    n->tree_info |= OPT_SIDE_EFFECT;    } else {    /* First argument is not an array or mapping,    *    * It must thus be a string.    */    node **arg1 = my_get_arg(&_CDR(n), 1);    node **arg2 = my_get_arg(&_CDR(n), 2); -  struct program *replace_compiler = NULL; +     -  +  /* This variable is modified in between setjmp and longjmp, +  * so it needs to be volatile to prevent it from being globbered. +  */ +  struct program * volatile replace_compiler = NULL; +     if (arg1 && ((pike_types_le((*arg1)->type, array_type_string) &&    arg2 &&    (pike_types_le((*arg2)->type, array_type_string) ||    pike_types_le((*arg2)->type, string_type_string))) ||    (pike_types_le((*arg1)->type, mapping_type_string)))) {    /* Handle the cases:    *    * replace(string, array, array)    * replace(string, array, string)    * replace(string, mapping(string:string))
pike.git/src/builtin_functions.c:4536:    *!    *! @seealso    *! @[mappingp()], @[programp()], @[arrayp()], @[stringp()], @[functionp()],    *! @[multisetp()], @[floatp()], @[intp()]    */   PMOD_EXPORT void f_objectp(INT32 args)   {    if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("objectp", 1);    if(TYPEOF(Pike_sp[-args]) != T_OBJECT || !Pike_sp[-args].u.object->prog - #ifdef AUTO_BIGNUM -  || is_bignum_object(Pike_sp[-args].u.object) - #endif -  ) +  || is_bignum_object(Pike_sp[-args].u.object))    {    pop_n_elems(args);    push_int(0);    }else{    pop_n_elems(args);    push_int(1);    }   }      /*! @decl int functionp(mixed arg)
pike.git/src/builtin_functions.c:4570:    if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("functionp", 1);    if( TYPEOF(Pike_sp[-args]) == T_FUNCTION &&    (SUBTYPEOF(Pike_sp[-args]) == FUNCTION_BUILTIN ||    Pike_sp[-args].u.object->prog))    res=1;    pop_n_elems(args);    push_int(res);   }    - /*! @decl int callablep(mixed arg) -  *! -  *! Returns @expr{1@} if @[arg] is a callable, @expr{0@} (zero) otherwise. -  *! -  *! @seealso -  *! @[mappingp()], @[programp()], @[arrayp()], @[stringp()], @[objectp()], -  *! @[multisetp()], @[floatp()], @[intp()] -  */ - PMOD_EXPORT void f_callablep(INT32 args) + PMOD_EXPORT int callablep(struct svalue *s)   { -  int res = 0; -  if(args<1) -  SIMPLE_TOO_FEW_ARGS_ERROR("callablep", 1); +  int ret = 0; +  DECLARE_CYCLIC();    -  switch( TYPEOF(Pike_sp[-args]) ) +  if (BEGIN_CYCLIC(s, NULL)) { +  END_CYCLIC(); +  return 1; +  } +  +  SET_CYCLIC_RET((ptrdiff_t)1); +  +  switch( TYPEOF(*s) )    {    case T_FUNCTION: -  if( SUBTYPEOF(Pike_sp[-args]) != FUNCTION_BUILTIN -  && !Pike_sp[-args].u.object->prog) +  if( SUBTYPEOF(*s) == FUNCTION_BUILTIN +  || s->u.object->prog) +  ret = 1;    break; -  res = 1; -  break; +     case T_PROGRAM: -  res = 1; +  ret = 1;    break;    case T_OBJECT:    {    struct program *p; -  if((p = Pike_sp[-args].u.object->prog) && -  FIND_LFUN(p->inherits[SUBTYPEOF(Pike_sp[-args])].prog, +  if((p = s->u.object->prog) && +  FIND_LFUN(p->inherits[SUBTYPEOF(*s)].prog,    LFUN_CALL ) != -1) -  res = 1; +  ret = 1;    }    break;    case T_ARRAY: -  /* FIXME: What about the recursive case? */ -  array_fix_type_field(Pike_sp[-args].u.array); -  if( (Pike_sp[-args].u.array->type_field==BIT_CALLABLE) || -  !Pike_sp[-args].u.array->type_field) { -  res = 1; +  array_fix_type_field(s->u.array); +  if( !s->u.array->type_field) { +  ret = 1; +  break;    } -  else if( !(Pike_sp[-args].u.array->type_field & -  ~(BIT_CALLABLE|BIT_INT)) ) { -  struct array *a = Pike_sp[-args].u.array; +  if( !(s->u.array->type_field & ~(BIT_CALLABLE|BIT_INT)) ) { +  struct array *a = s->u.array;    int i; -  res = 1; +  ret = 1;    for(i=0; i<a->size; i++) -  if( TYPEOF(ITEM(a)[i]) == T_INT && ITEM(a)[i].u.integer ) { -  res = 0; -  break; +  if( TYPEOF(ITEM(a)[i])!=T_INT && !callablep(&ITEM(a)[i]) ) +  ret = 0;    } -  } +     break;    } -  +  +  END_CYCLIC(); +  return ret; + } +  + /*! @decl int callablep(mixed arg) +  *! +  *! Returns @expr{1@} if @[arg] is a callable, @expr{0@} (zero) otherwise. +  *! +  *! @seealso +  *! @[mappingp()], @[programp()], @[arrayp()], @[stringp()], @[objectp()], +  *! @[multisetp()], @[floatp()], @[intp()] +  */ + PMOD_EXPORT void f_callablep(INT32 args) + { +  int res = 0; +  if(args<1) +  SIMPLE_TOO_FEW_ARGS_ERROR("callablep", 1); +  +  res = callablep(&Pike_sp[-args]);    pop_n_elems(args);    push_int(res);   }   #ifndef HAVE_AND_USE_POLL   #undef HAVE_POLL   #endif      static void delaysleep(double delay, unsigned do_abort_on_signal,    unsigned do_microsleep)   {   #define POLL_SLEEP_LIMIT 0.02    -  struct timeval gtod_t0, gtod_tv; +  struct timeval gtod_t0 = {0,0}, gtod_tv = {0,0};    cpu_time_t t0, tv;       /* Special case, sleep(0) means 'yield' */    if(delay == 0.0)    {    check_threads_etc();    /* Since check_threads doesn't yield on every call, we need this    * to ensure th_yield gets called. */    pike_thread_yield();    return;    }       if(sizeof(FLOAT_TYPE)<sizeof(double))    delay += FLT_EPSILON*5; /* round up */       t0 = tv = get_real_time();    if (t0 == -1) {    /* Paranoia in case get_real_time fails. */    /* fprintf (stderr, "get_real_time failed in sleep()\n"); */ -  GETTIMEOFDAY (&gtod_t0); +  ACCURATE_GETTIMEOFDAY (&gtod_t0);    gtod_tv = gtod_t0;    }      #define FIX_LEFT() \    if (t0 == -1) { \ -  GETTIMEOFDAY (&gtod_tv); \ +  ACCURATE_GETTIMEOFDAY (&gtod_tv); \    left = delay - ((gtod_tv.tv_sec-gtod_t0.tv_sec) + \    (gtod_tv.tv_usec-gtod_t0.tv_usec)*1e-6); \    } \    else { \    tv = get_real_time(); \    left = delay - (tv - t0) * (1.0 / CPU_TIME_TICKS); \    } \    if (do_microsleep) left-=POLL_SLEEP_LIMIT;       if (!do_microsleep || delay>POLL_SLEEP_LIMIT)
pike.git/src/builtin_functions.c:4684:    for(;;)    {    double left;    /* THREADS_ALLOW may take longer time then POLL_SLEEP_LIMIT */    THREADS_ALLOW();    FIX_LEFT();    if(left>0.0)    sysleep(left);    THREADS_DISALLOW();    if(do_abort_on_signal) { -  GETTIMEOFDAY (&current_time); +  INVALIDATE_CURRENT_TIME();    return;    }    FIX_LEFT();    if(left<=0.0)    break;    check_threads_etc();    } -  GETTIMEOFDAY (&current_time); +  INVALIDATE_CURRENT_TIME();    }       if (do_microsleep) {    if (t0 == -1) {    while (delay> ((gtod_tv.tv_sec-gtod_t0.tv_sec) +    (gtod_tv.tv_usec-gtod_t0.tv_usec)*1e-6)) -  GETTIMEOFDAY (&gtod_tv); +  ACCURATE_GETTIMEOFDAY (&gtod_tv);    }    else {    while (delay> (tv - t0) * (1.0 / CPU_TIME_TICKS))    tv = get_real_time();    }    }       /* fprintf (stderr, "slept %g\n", (tv - t0) * (1.0 / CPU_TIME_TICKS)); */   }   
pike.git/src/builtin_functions.c:4750:    }       do_abort_on_signal = delay!=0.0 && args > 1    && !UNSAFE_IS_ZERO(Pike_sp + 1-args);    pop_n_elems(args);       delaysleep(delay, do_abort_on_signal, 0);   }      #undef FIX_LEFT - #undef GET_TIME_ELAPSED +    #undef TIME_ELAPSED      /*! @decl void delay(int|float s)    *!    *! This function makes the program stop for @[s] seconds.    *!    *! Only signal handlers can interrupt the sleep. Other callbacks are    *! not called during delay. Beware that this function uses busy-waiting    *! to achieve the highest possible accuracy.    *!
pike.git/src/builtin_functions.c:4839:    SIMPLE_TOO_FEW_ARGS_ERROR(NAME, 1); \    if (TYPEOF(Pike_sp[-args]) == T_OBJECT && \    (p = Pike_sp[-args].u.object->prog)) \    { \    int fun = FIND_LFUN(p->inherits[SUBTYPEOF(Pike_sp[-args])].prog, \    LFUN__IS_TYPE); \    if (fun != -1) \    { \    int id_level = \    p->inherits[SUBTYPEOF(Pike_sp[-args])].identifier_level; \ -  push_constant_text(TYPE_NAME); \ +  ref_push_string(literal_##TYPE_NAME##_string); \    apply_low(Pike_sp[-args-1].u.object, fun + id_level, 1); \    stack_unlink(args); \    return; \    } \    } \    t = TYPEOF(Pike_sp[-args]) == TYPE; \    pop_n_elems(args); \    push_int(t); \    }   
pike.git/src/builtin_functions.c:4907:    push_int(1);    return;       case T_FUNCTION:    if(program_from_function(Pike_sp-args))    {    pop_n_elems(args);    push_int(1);    return;    } +  /* FALL_THROUGH */       default:    pop_n_elems(args);    push_int(0);    }   }      /*! @decl int intp(mixed arg)    *!    *! Returns @expr{1@} if @[arg] is an int, @expr{0@} (zero) otherwise.
pike.git/src/builtin_functions.c:4969:   /*! @decl int floatp(mixed arg)    *!    *! Returns @expr{1@} if @[arg] is a float, @expr{0@} (zero) otherwise.    *!    *! @seealso    *! @[intp()], @[programp()], @[arrayp()], @[multisetp()], @[objectp()],    *! @[mappingp()], @[stringp()], @[functionp()]    */       - TYPEP(f_intp, "intp", T_INT, "int") - TYPEP(f_mappingp, "mappingp", T_MAPPING, "mapping") - TYPEP(f_arrayp, "arrayp", T_ARRAY, "array") - TYPEP(f_multisetp, "multisetp", T_MULTISET, "multiset") - TYPEP(f_stringp, "stringp", T_STRING, "string") - TYPEP(f_floatp, "floatp", T_FLOAT, "float") + TYPEP(f_intp, "intp", T_INT, int) + TYPEP(f_mappingp, "mappingp", T_MAPPING, mapping) + TYPEP(f_arrayp, "arrayp", T_ARRAY, array) + TYPEP(f_multisetp, "multisetp", T_MULTISET, multiset) + TYPEP(f_stringp, "stringp", T_STRING, string) + TYPEP(f_floatp, "floatp", T_FLOAT, float)      /*! @decl array sort(array(mixed) index, array(mixed) ... data)    *!    *! Sort arrays destructively.    *!    *! This function sorts the array @[index] destructively. That means    *! that the array itself is changed and returned, no copy is created.    *!    *! If extra arguments are given, they are supposed to be arrays of the    *! same size as @[index]. Each of these arrays will be modified in the
pike.git/src/builtin_functions.c:5054:    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,    "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((char *)order); +  free(order);    }    else {    /* If there are only simple types in the array we can use unstable    * sorting. */    array_fix_unfinished_type_field (a);    if (a->type_field & BIT_COMPLEX)    free (stable_sort_array_destructively (a));    else    sort_array_destructively (a);    }
pike.git/src/builtin_functions.c:5141:    *! generates a fatal error if one of them is found to be out of order.    *! It is only used for debugging.    *!    *! @note    *! This function does a more thorough check if the Pike runtime has    *! been compiled with RTL debug.    */   PMOD_EXPORT void f__verify_internals(INT32 args)   {    INT32 tmp=d_flag; -  ASSERT_SECURITY_ROOT("_verify_internals"); +        /* Keep below calls to low_thorough_check_short_svalue, or else we    * get O(n!) or so, where n is the number of allocated things. */    d_flag = 49;      #ifdef PIKE_DEBUG    do_debug(); /* Calls do_gc() since d_flag > 3. */   #else    do_gc(NULL, 1);   #endif    d_flag=tmp;    pop_n_elems(args);   }    - #ifdef PIKE_DEBUG -  - /*! @decl int debug(int(0..) level) -  *! @belongs Debug -  *! -  *! Set the run-time debug level. -  *! -  *! @returns -  *! The old debug level will be returned. -  *! -  *! @note -  *! This function is only available if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__debug(INT32 args) - { -  INT_TYPE d; -  -  ASSERT_SECURITY_ROOT("_debug"); -  -  get_all_args("_debug", args, "%i", &d); -  pop_n_elems(args); -  push_int(d_flag); -  d_flag = d; - } -  - /*! @decl int optimizer_debug(int(0..) level) -  *! @belongs Debug -  *! -  *! Set the optimizer debug level. -  *! -  *! @returns -  *! The old optimizer debug level will be returned. -  *! -  *! @note -  *! This function is only available if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__optimizer_debug(INT32 args) - { -  INT_TYPE l; -  -  ASSERT_SECURITY_ROOT("_optimizer_debug"); -  -  get_all_args("_optimizer_debug", args, "%i", &l); -  pop_n_elems(args); -  push_int(l_flag); -  l_flag = l; - } -  -  - /*! @decl int assembler_debug(int(0..) level) -  *! @belongs Debug -  *! -  *! Set the assembler debug level. -  *! -  *! @returns -  *! The old assembler debug level will be returned. -  *! -  *! @note -  *! This function is only available if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__assembler_debug(INT32 args) - { -  INT_TYPE l; -  -  ASSERT_SECURITY_ROOT("_assembler_debug"); -  -  get_all_args("_assembler_debug", args, "%i", &l); -  pop_n_elems(args); -  push_int(a_flag); -  a_flag = l; - } -  - /*! @decl void dump_program_tables(program p, int|void indent) -  *! @belongs Debug -  *! -  *! Dumps the internal tables for the program @[p] on stderr. -  *! -  *! @param p -  *! Program to dump. -  *! -  *! @param indent -  *! Number of spaces to indent the output. -  *! -  *! @note -  *! In Pike 7.8.308 and earlier @[indent] wasn't supported. -  */ - void f__dump_program_tables(INT32 args) - { -  struct program *p; -  int indent = 0; -  -  ASSERT_SECURITY_ROOT("_dump_program_tables"); /* FIXME: Might want lower. */ -  get_all_args("_dump_program_tables", args, "%p.%d", &p, &indent); -  -  dump_program_tables(p, indent); -  pop_n_elems(args); - } -  - #ifdef YYDEBUG -  - /*! @decl int compiler_trace(int(0..) level) -  *! @belongs Debug -  *! -  *! Set the compiler trace level. -  *! -  *! @returns -  *! The old compiler trace level will be returned. -  *! -  *! @note -  *! This function is only available if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__compiler_trace(INT32 args) - { -  extern int yydebug; -  INT_TYPE yyd; -  ASSERT_SECURITY_ROOT("_compiler_trace"); -  -  get_all_args("_compiler_trace", args, "%i", &yyd); -  pop_n_elems(args); -  push_int(yydebug); -  yydebug = yyd; - } -  - #endif /* YYDEBUG */ - #endif -  - #if defined(HAVE_LOCALTIME) || defined(HAVE_GMTIME) +    static void encode_struct_tm(struct tm *tm)   { -  push_text("sec"); +  push_static_text("sec");    push_int(tm->tm_sec); -  push_text("min"); +  push_static_text("min");    push_int(tm->tm_min); -  push_text("hour"); +  push_static_text("hour");    push_int(tm->tm_hour);    -  push_text("mday"); +  push_static_text("mday");    push_int(tm->tm_mday); -  push_text("mon"); +  push_static_text("mon");    push_int(tm->tm_mon); -  push_text("year"); +  push_static_text("year");    push_int(tm->tm_year);    -  push_text("wday"); +  push_static_text("wday");    push_int(tm->tm_wday); -  push_text("yday"); +  push_static_text("yday");    push_int(tm->tm_yday); -  push_text("isdst"); +  push_static_text("isdst");    push_int(tm->tm_isdst);   } - #endif +     - #if defined (HAVE_GMTIME) || defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S) +    /*! @decl mapping(string:int) gmtime(int timestamp)    *!    *! Convert seconds since 00:00:00 UTC, Jan 1, 1970 into components.    *!    *! This function works like @[localtime()] but the result is    *! not adjusted for the local time zone.    *!    *! @seealso    *! @[localtime()], @[time()], @[ctime()], @[mktime()]    */
pike.git/src/builtin_functions.c:5352: Inside #if defined (HAVE_GMTIME) || defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S)
  #elif defined (HAVE_GMTIME_S)    if (!gmtime_s (&tm_s, &t)) tm = &tm_s; else tm = NULL;   #else    tm = gmtime(&t);   #endif    if (!tm) Pike_error ("gmtime() on this system cannot handle "    "the timestamp %"PRINTLONGEST"d.\n", (LONGEST) t);    pop_n_elems(args);    encode_struct_tm(tm);    -  push_text("timezone"); +  push_static_text("timezone");    push_int(0);    f_aggregate_mapping(20);   } - #endif +     - #ifdef HAVE_LOCALTIME +    /*! @decl mapping(string:int) localtime(int timestamp)    *!    *! Convert seconds since 00:00:00 UTC, 1 Jan 1970 into components.    *!    *! @returns    *! This function returns a mapping with the following components:    *! @mapping    *! @member int(0..60) "sec"    *! Seconds over the minute.    *! @member int(0..59) "min"
pike.git/src/builtin_functions.c:5419: Inside #if defined(HAVE_LOCALTIME)
   SIMPLE_ARG_ERROR ("localtime", 1, "Timestamp outside valid range.");   #endif    t = (time_t) tt;       tm = localtime(&t);    if (!tm) Pike_error ("localtime() on this system cannot handle "    "the timestamp %ld.\n", (long) t);    pop_n_elems(args);    encode_struct_tm(tm);    -  push_text("timezone"); +  push_static_text("timezone");   #ifdef STRUCT_TM_HAS_GMTOFF    push_int(-tm->tm_gmtoff);   #elif defined(STRUCT_TM_HAS___TM_GMTOFF)    push_int(-tm->__tm_gmtoff);   #elif defined(HAVE_EXTERNAL_TIMEZONE)    /* Assume dst is one hour. */    push_int(timezone - 3600*tm->tm_isdst);   #else    /* Assume dst is one hour. */    push_int(-3600*tm->tm_isdst);   #endif    f_aggregate_mapping(20);   } - #endif +     - #if defined (HAVE_GMTIME) || defined (HAVE_LOCALTIME) -  +    #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)      static const int mon_lengths[2][12] = {    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}   };      static void normalize_date (struct tm *t)   /* Normalizes t->tm_mday and t->tm_mon. */   {
pike.git/src/builtin_functions.c:5656:    else    return 0;    });    }       CHECKED_ADD (current_ts, displacement, return 0);       *result = current_ts;    return 1;   } - #endif /* HAVE_GMTIME || HAVE_LOCALTIME */ +     - #if defined (HAVE_MKTIME) || defined (HAVE_LOCALTIME) +    /*! @decl int mktime(mapping(string:int) tm)    *! @decl int mktime(int sec, int min, int hour, int mday, int mon, int year, @    *! int|void isdst, int|void tz)    *!    *! This function converts information about date and time into an integer    *! which contains the number of seconds since 00:00:00 UTC, Jan 1, 1970.    *!    *! You can either call this function with a mapping containing the    *! following elements:    *! @mapping
pike.git/src/builtin_functions.c:5712: Inside #if defined (HAVE_MKTIME) || defined (HAVE_LOCALTIME)
   INT_TYPE sec, min, hour, mday, mon, year;    INT_TYPE isdst = -1, tz = 0;    struct tm date;    time_t retval;       if (args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("mktime", 1);       if(args == 1)    { -  MEMSET(&date, 0, sizeof(date)); +  memset(&date, 0, sizeof(date));    -  push_text("sec"); -  push_text("min"); -  push_text("hour"); -  push_text("mday"); -  push_text("mon"); -  push_text("year"); -  push_text("isdst"); -  push_text("timezone"); +  push_static_text("sec"); +  push_static_text("min"); +  push_static_text("hour"); +  push_static_text("mday"); +  push_static_text("mon"); +  push_static_text("year"); +  push_static_text("isdst"); +  push_static_text("timezone");    f_aggregate(8);    f_rows(2);    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    push_array_items(Pike_sp->u.array);       args=8;    }       get_all_args("mktime",args, "%i%i%i%i%i%i.%i%i",    &sec, &min, &hour, &mday, &mon, &year, &isdst, &tz);    -  MEMSET(&date, 0, sizeof(date)); +  memset(&date, 0, sizeof(date));    date.tm_sec=sec;    date.tm_min=min;    date.tm_hour=hour;    date.tm_mday=mday;    date.tm_mon=mon;    date.tm_year=year;    date.tm_isdst=isdst;       /* date.tm_zone = NULL; */    - #ifdef HAVE_GMTIME +     if((args > 7) && (SUBTYPEOF(Pike_sp[7-args]) == NUMBER_NUMBER))    {    /* UTC-relative time. Use gmtime. */    if (!my_time_inverse (&date, &retval, gmtime))    PIKE_ERROR("mktime", "Time conversion failed.\n", Pike_sp, args);    retval += tz;    } else - #endif /* HAVE_GMTIME */ +        { - #ifndef HAVE_GMTIME - #ifdef STRUCT_TM_HAS_GMTOFF -  /* BSD-style */ -  date.tm_gmtoff = 0; - #else - #ifdef STRUCT_TM_HAS___TM_GMTOFF -  /* (Old) Linux-style */ -  date.__tm_gmtoff = 0; - #else -  if((args > 7) && (SUBTYPEOF(Pike_sp[7-args]) == NUMBER_NUMBER)) -  { -  /* Pre-adjust for the timezone. -  * -  * Note that pre-adjustment must be done on AIX for dates -  * near Jan 1, 1970, since AIX mktime(3) doesn't support -  * negative time. -  */ -  date.tm_sec += tz - #ifdef HAVE_EXTERNAL_TIMEZONE -  - timezone - #endif /* HAVE_EXTERNAL_TIMEZONE */ -  ; -  } - #endif /* STRUCT_TM_HAS___TM_GMTOFF */ - #endif /* STRUCT_TM_HAS_GMTOFF */ - #endif /* !HAVE_GMTIME */ -  - #ifdef HAVE_MKTIME +     retval = mktime(&date);    if (retval == -1) - #endif +     { - #ifdef HAVE_LOCALTIME +     /* mktime might fail on dates before 1970 (e.g. GNU libc 2.3.2),    * so try our own inverse function with localtime.    *    * Note that localtime on Win32 will also fail for dates before 1970.    */    if (!my_time_inverse (&date, &retval, localtime)) - #endif +     PIKE_ERROR("mktime", "Time conversion unsuccessful.\n", Pike_sp, args);    } -  - #if !defined (HAVE_GMTIME) && (defined(STRUCT_TM_HAS_GMTOFF) || defined(STRUCT_TM_HAS___TM_GMTOFF)) -  if((args > 7) && (SUBTYPEOF(Pike_sp[7-args]) == NUMBER_NUMBER)) -  { -  /* Post-adjust for the timezone. -  * -  * Note that tm_gmtoff has the opposite sign of timezone. -  * -  * Note also that it must be post-adjusted, since the gmtoff -  * field is set by mktime(3). -  */ - #ifdef STRUCT_TM_HAS_GMTOFF -  retval += tz + date.tm_gmtoff; - #else -  retval += tz + date.__tm_gmtoff; - #endif /* STRUCT_TM_HAS_GMTOFF */ +     } - #endif /* !HAVE_GMTIME && (STRUCT_TM_HAS_GMTOFF || STRUCT_TM_HAS___TM_GMTOFF) */ +     - #if 0 -  /* Disabled since the adjustment done here with a hardcoded one -  * hour is bogus in many time zones. mktime(3) in GNU libc is -  * documented to normalize the date spec, which means that e.g. -  * asking for DST time in a non-DST zone will override tm_isdst. -  * /mast */ -  if ((isdst != -1) && (isdst != date.tm_isdst)) { -  /* Some stupid libc's (Hi Linux!) don't accept that we've set isdst... */ -  retval += 3600 * (isdst - date.tm_isdst); -  } - #endif /* 0 */ -  } -  +     pop_n_elems(args);   #if SIZEOF_TIME_T > SIZEOF_INT_TYPE    push_int64 (retval);   #else    push_int(retval);   #endif   } - #define GOT_F_MKTIME - #endif /* HAVE_MKTIME || HAVE_LOCALTIME */ +     - /* 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; -  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) && (TYPEOF(Pike_sp[-2]) == T_STRING)) { -  /* Concat. */ -  f_add(2); -  } -  } -  -  for (j = i+1;j<slen;j++) { -  int c = s[j]; -  -  switch(c) { -  /* Flags */ -  case '!': -  case '#': -  case '$': -  case '-': -  case '/': -  case '0': -  case '=': -  case '>': -  case '@': -  case '^': -  case '_': -  case '|': -  continue; -  /* Padding */ -  case ' ': -  case '\'': -  case '+': -  case '~': -  continue; -  /* Attributes */ -  case '.': -  case ':': -  case ';': -  continue; -  /* Attribute value */ -  case '1': case '2': case '3': case '4': case '5': -  case '6': case '7': case '8': case '9': -  continue; -  /* Specials */ -  case '%': -  push_constant_text("%"); -  if ((Pike_sp != old_sp+1) && (TYPEOF(Pike_sp[-2]) == T_STRING)) { -  /* Concat. */ -  f_add(2); -  } -  break; -  case '{': -  i = j + 1 + low_parse_format(s + j + 1, slen - (j+1)); -  f_aggregate(1); -  if ((i + 2 >= slen) || (s[i] != '%') || (s[i+1] != '}')) { -  Pike_error("parse_format(): Expected %%}.\n"); -  } -  i += 2; -  break; -  case '}': -  f_aggregate(DO_NOT_WARN(Pike_sp - old_sp)); -  return i; -  /* Set */ -  case '[': -  -  break; -  /* Argument */ -  default: -  break; -  } -  break; -  } -  if (j == slen) { -  Pike_error("parse_format(): Unterminated %%-expression.\n"); -  } -  offset = i = j; -  } -  } -  -  if (i != offset) { -  push_string(make_shared_binary_string0(s + offset, i)); -  if ((Pike_sp != old_sp+1) && (TYPEOF(Pike_sp[-2]) == T_STRING)) { -  /* Concat. */ -  f_add(2); -  } -  } -  -  f_aggregate(DO_NOT_WARN(Pike_sp - old_sp)); -  return i; - } -  - /** @decl array parse_format(string fmt) -  ** -  ** Parses a sprintf/sscanf-style format string -  */ - static void f_parse_format(INT32 args) - { -  struct pike_string *s = NULL; -  struct array *a; -  ptrdiff_t len; -  -  get_all_args("parse_format", args, "%W", &s); -  -  len = low_parse_format(STR0(s), s->len); -  if (len != s->len) { -  Pike_error("parse_format(): Unexpected %%} in format string at offset %ld\n", -  PTRDIFF_T_TO_LONG(len)); -  } - #ifdef PIKE_DEBUG -  if (TYPEOF(Pike_sp[-1]) != T_ARRAY) { -  Pike_fatal("parse_format(): Unexpected result from low_parse_format()\n"); -  } - #endif /* PIKE_DEBUG */ -  a = (--Pike_sp)->u.array; -  debug_malloc_touch(a); -  -  pop_n_elems(args); -  push_array(a); - } -  +    /* Common case: both strings are 8bit. */   static int does_match_8_8( const unsigned char *s, int j, int sl,    const unsigned char *m, int i, int ml)   {    for (; i<ml; i++)    {    switch (m[i])    {    case '?':    if(j++>=sl) return 0;
pike.git/src/builtin_functions.c:6261:       /* Initialize the min array */    for (i = 0; i < arr->size; i++) {    struct mapping_data *md;    /* e and k are used by NEW_MAPPING_LOOP() */    INT32 e;    struct keypair *k;    INT_TYPE low = MAX_INT_TYPE;   #ifdef PIKE_DEBUG    if (TYPEOF(ITEM(arr)[i]) != T_MAPPING) { -  Pike_error("interleave_array(): Element %d is not a mapping!\n", i); +  Pike_error("Element %d is not a mapping!\n", i);    }   #endif /* PIKE_DEBUG */    md = ITEM(arr)[i].u.mapping->data;    NEW_MAPPING_LOOP(md) {    if (TYPEOF(k->ind) != T_INT) { -  Pike_error("interleave_array(): Index not an integer in mapping %d!\n", i); +  Pike_error("Index not an integer in mapping %d!\n", i);    }    if (low > k->ind.u.integer) {    low = k->ind.u.integer;    if (low < 0) { -  Pike_error("interleave_array(): Index %"PRINTPIKEINT"d in mapping %d is negative!\n", +  Pike_error("Index %"PRINTPIKEINT"d in mapping %d is negative!\n",    low, i);    }    }    if (max < k->ind.u.integer) {    max = k->ind.u.integer;    }    nelems++;    }    ITEM(min)[i].u.integer = low;    }
pike.git/src/builtin_functions.c:6306:    {    char *tab;    int size;    int minfree = 0;       /* Initialize the lookup table */    max += 1;    max *= 2;    /* max will be the padding at the end. */    size = (nelems + max) * 8; /* Initial size */ -  if (!(tab = malloc(size + max))) { -  SIMPLE_OUT_OF_MEMORY_ERROR("interleave_array", size+max); -  } -  MEMSET(tab, 0, size + max); +  tab = xcalloc(size + max, 1);       for (i = 0; i < order->size; i++) {    int low = ITEM(min)[i].u.integer;    int j = ITEM(order)[i].u.integer;    int offset = 0;    int ok = 0;    struct mapping *m;    struct mapping_data *md;    INT32 e;    struct keypair *k;
pike.git/src/builtin_functions.c:6358:    while(tab[minfree]) {    minfree++;    }    ITEM(min)[i].u.integer = offset;       /* Check need for realloc */    if (offset >= size) {    char *newtab = realloc(tab, size*2 + max);    if (!newtab) {    free(tab); -  Pike_error("interleave_array(): Couldn't extend table!\n"); +  Pike_error("Couldn't extend table!\n");    }    tab = newtab; -  MEMSET(tab + size + max, 0, size); +  memset(tab + size + max, 0, size);    size = size * 2;    }    }    free(tab);    }       /* We want these two to survive the stackpopping. */    add_ref(min);    add_ref(order);   
pike.git/src/builtin_functions.c:6417:      static struct array *longest_ordered_sequence(struct array *a)   {    int *stack;    int *links;    int i, top=0, ltop=-1;    struct array *res;    ONERROR tmp;    ONERROR tmp2;    -  if(!a->size) -  return allocate_array(0); +  if(!a->size) { +  add_ref(&empty_array); +  return &empty_array; +  }    -  stack = malloc(sizeof(int)*a->size); -  links = malloc(sizeof(int)*a->size); +  stack = calloc(sizeof(int), a->size); +  links = calloc(sizeof(int), a->size);       if (!stack || !links)    {    if (stack) free(stack);    if (links) free(links); -  return 0; +  return NULL;    }       /* is_gt(), is_lt() and low_allocate_array() can generate errors. */       SET_ONERROR(tmp, free, stack);    SET_ONERROR(tmp2, free, links);       for (i=0; i<a->size; i++) {    int pos;   
pike.git/src/builtin_functions.c:6451:    top++;    ltop = i;    }    if (pos != 0)    links[i] = stack[pos-1];    else    links[i] = -1;    stack[pos] = i;    }    -  /* FIXME(?) memory unfreed upon error here */ +     res = low_allocate_array(top, 0);    while (ltop != -1)    {    ITEM(res)[--top].u.integer = ltop;    ltop = links[ltop];    }    res->type_field = BIT_INT;       UNSET_ONERROR(tmp2);    UNSET_ONERROR(tmp);
pike.git/src/builtin_functions.c:6483:    *! ordered sequence of elements in the array.    *!    *! @seealso    *! @[diff()]    */   static void f_longest_ordered_sequence(INT32 args)   {    struct array *a = NULL;    struct array *aa = NULL;    -  get_all_args("Array.longest_ordered_sequence", args, "%a", &a); +  get_all_args("longest_ordered_sequence", args, "%a", &a);       /* THREADS_ALLOW(); */       aa = longest_ordered_sequence(a);       /* THREADS_DISALLOW(); */       if (!aa) { -  SIMPLE_OUT_OF_MEMORY_ERROR("Array.longest_ordered_sequence", +  SIMPLE_OUT_OF_MEMORY_ERROR("longest_ordered_sequence",    (int)sizeof(int *)*a->size*2);    }    -  pop_n_elems(args); +     push_array(aa);   }      /**** diff ************************************************************/      static struct array* diff_compare_table(struct array *a,struct array *b,int *u)   {    struct array *res;    struct mapping *map;    struct svalue *pval;
pike.git/src/builtin_functions.c:6738:    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); +  stack = xcalloc(sizeof(struct diff_magic_link*), cmptbl->size);    -  if (!stack) { -  int args = 0; -  SIMPLE_OUT_OF_MEMORY_ERROR("diff_longest_sequence", -  (int)sizeof(struct diff_magic_link*) * -  cmptbl->size); -  } -  +     /* NB: marks is used for optimization purposes only */    marks = calloc(blen, 1);       if (!marks && blen) {    int args = 0;    free(stack);    SIMPLE_OUT_OF_MEMORY_ERROR("diff_longest_sequence", blen);    }      #ifdef DIFF_DEBUG
pike.git/src/builtin_functions.c:6958:    struct array *res = 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;    ONERROR err;    -  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); -  } +  table = xcalloc(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    * algorithm.    */    for (i = sz; i--;) {    struct array *boff = cmptbl->item[i].u.array;      #ifdef DIFF_DEBUG    fprintf(stderr, " i:%d\n", i);
pike.git/src/builtin_functions.c:7171:    push_array(friendly_slice_array(a,ai+1,a->size));    ad=append_array(ad,Pike_sp-1);    pop_stack();    }       push_array(ad);    push_array(bd);    return aggregate_array(2);   }    - /*! @decl array permute(array in, int number) + /*! @decl array permute(array in, int(0..) number)    *!    *! Give a specified permutation of an array.    *!    *! The number of permutations is equal to @expr{sizeof(@[in])!@}    *! (the factorial of the size of the given array).    *!    *! @seealso    *! @[shuffle()]    */   PMOD_EXPORT void f_permute( INT32 args )   {    INT_TYPE q, i=0, n;    struct array *a;    struct svalue *it;    -  if( args != 2 ) -  SIMPLE_TOO_FEW_ARGS_ERROR("permute", 2); -  if( TYPEOF(Pike_sp[ -2 ]) != T_ARRAY ) -  SIMPLE_BAD_ARG_ERROR("permute", 1, "array"); -  if (TYPEOF(Pike_sp[ -1 ]) != T_INT) -  SIMPLE_BAD_ARG_ERROR("permute", 2, "int"); +  get_all_args("permute", args, "%a%+", &a, &n);    -  n = Pike_sp[ -1 ].u.integer; -  a = copy_array( Pike_sp[ -2 ].u.array ); -  pop_n_elems( args ); +  if( a->refs>1 ) +  { +  a = copy_array( a ); +  push_array( a ); +  } +  else +  pop_n_elems(args-1); +     q = a->size;    it = a->item;    while( n && q )    {    int x = n % q;    n /= q;    q--;    if( x )    {    struct svalue tmp;    tmp = it[i];    it[i] = it[i+x];    it[i+x] = tmp;    }    i++;    } -  push_array( a ); +    }      /*! @decl array(array(array)) diff(array a, array b)    *!    *! Calculates which parts of the arrays that are common to both, and    *! which parts that are not.    *!    *! @returns    *! Returns an array with two elements, the first is an array of parts in    *! array @[a], and the second is an array of parts in array @[b].
pike.git/src/builtin_functions.c:7253:    ref_push_array(b);    f_aggregate(2);    } else {    /* The arrays are equal or one of them is empty. */    ref_push_array(a);    f_aggregate(1);    ref_push_array(b);    f_aggregate(1);    f_aggregate(2);    } -  stack_pop_n_elems_keep_top(args); +     return;    }       cmptbl = diff_compare_table(a, b, &uniq); -  +     push_array(cmptbl); -  +    #ifdef ENABLE_DYN_DIFF    if (uniq * 100 > cmptbl->size) {   #endif /* ENABLE_DYN_DIFF */   #ifdef DIFF_DEBUG    fprintf(stderr, "diff: Using G-M algorithm, u:%d, s:%d\n",    uniq, cmptbl->size);   #endif /* DIFF_DEBUG */    seq = diff_longest_sequence(cmptbl, b->size);   #ifdef ENABLE_DYN_DIFF    } else {   #ifdef DIFF_DEBUG    fprintf(stderr, "diff: Using dyn algorithm, u:%d, s:%d\n",    uniq, cmptbl->size);   #endif /* DIFF_DEBUG */    seq = diff_dyn_longest_sequence(cmptbl, b->size);    }   #endif /* ENABLE_DYN_DIFF */ -  push_array(seq); +     -  diff=diff_build(a,b,seq); -  -  pop_n_elems(2+args); -  push_array(diff); +  push_array(seq); +  push_array(diff_build(a,b,seq));   }      /*! @decl array(array(int)) diff_compare_table(array a, array b)    *!    *! Returns an array which maps from index in @[a] to corresponding    *! indices in @[b].    *!    *! @pre{    *! > Array.diff_compare_table( ({ "a","b","c" }), ({ "b", "b", "c", "d", "b" }));    *! Result: ({
pike.git/src/builtin_functions.c:7312:    *! })    *! @}    *!    *! @seealso    *! @[diff()], @[diff_longest_sequence()], @[String.fuzzymatch()]    */   PMOD_EXPORT void f_diff_compare_table(INT32 args)   {    struct array *a;    struct array *b; -  struct array *cmptbl; +        get_all_args("diff_compare_table", args, "%a%a", &a, &b);    -  cmptbl = diff_compare_table(a, b, NULL); -  -  pop_n_elems(args); -  push_array(cmptbl); +  push_array(diff_compare_table(a, b, NULL));   }      /*! @decl array(int) diff_longest_sequence(array a, array b)    *!    *! Gives the longest sequence of indices in @[b] that have corresponding    *! values in the same order in @[a].    *!    *! @seealso    *! @[diff()], @[diff_compare_table()], @[String.fuzzymatch()]    */   PMOD_EXPORT void f_diff_longest_sequence(INT32 args)   {    struct array *a;    struct array *b; -  struct array *seq; +     struct array *cmptbl;       get_all_args("diff_longest_sequence", args, "%a%a", &a, &b);       cmptbl = diff_compare_table(a, b, NULL); -  +     push_array(cmptbl);    -  seq = diff_longest_sequence(cmptbl, b->size); -  -  pop_n_elems(args+1); -  push_array(seq); +  push_array(diff_longest_sequence(cmptbl, b->size));   }      /*! @decl array(int) diff_dyn_longest_sequence(array a, array b)    *!    *! Gives the longest sequence of indices in @[b] that have corresponding    *! values in the same order in @[a].    *!    *! This function performs the same operation as @[diff_longest_sequence()],    *! but uses a different algorithm, which in some rare cases might be faster    *! (usually it's slower though).    *!    *! @seealso    *! @[diff_longest_sequence()], @[diff()], @[diff_compare_table()],    *! @[String.fuzzymatch()]    */   PMOD_EXPORT void f_diff_dyn_longest_sequence(INT32 args)   {    struct array *a;    struct array *b; -  struct array *seq; +     struct array *cmptbl;       get_all_args("diff_dyn_longest_sequence", args, "%a%a", &a, &b);       cmptbl=diff_compare_table(a, b, NULL); -  +     push_array(cmptbl);    -  seq = diff_dyn_longest_sequence(cmptbl, b->size); -  -  pop_n_elems(args+1); -  push_array(seq); +  push_array(diff_dyn_longest_sequence(cmptbl, b->size));   }      /*! @endmodule    */      /**********************************************************************/      static struct callback_list memory_usage_callback;      struct callback *add_memory_usage_callback(callback_func call,
pike.git/src/builtin_functions.c:7404:      /*! @decl mapping(string:int) memory_usage()    *! @belongs Debug    *!    *! Check memory usage.    *!    *! This function is mostly intended for debugging. It delivers a mapping    *! with information about how many arrays/mappings/strings etc. there    *! are currently allocated and how much memory they use.    *! +  *! The entries in the mapping are typically paired, with one +  *! named @expr{"num_" + SYMBOL + "s"@} containing a count, +  *! and the other named @expr{SYMBOL + "_bytes"@} containing +  *! a best effort approximation of the size in bytes. +  *!    *! @note -  *! Exactly what this function returns is version dependant. +  *! Exactly what fields this function returns is version dependant.    *!    *! @seealso    *! @[_verify_internals()]    */   PMOD_EXPORT void f__memory_usage(INT32 args)   {    size_t num,size;    struct svalue *ss; -  + #ifdef USE_DL_MALLOC +  struct mallinfo mi = dlmallinfo(); + #elif HAVE_MALLINFO +  struct mallinfo mi = mallinfo(); + #endif +     pop_n_elems(args);    ss=Pike_sp;    -  count_memory_in_mappings(&num, &size); -  push_text("num_mappings"); -  push_ulongest(num); -  push_text("mapping_bytes"); -  push_ulongest(size); +  /* TODO: If USE_DL_MALLOC is defined then this will report the +  * statistics from our bundled Doug Lea malloc, and not the +  * underlying system malloc. Ideally we should include both. */    -  count_memory_in_strings(&num, &size); -  push_text("num_strings"); -  push_ulongest(num); -  push_text("string_bytes"); -  push_ulongest(size); + #if defined(HAVE_MALLINFO) || defined(USE_DL_MALLOC)    -  count_memory_in_arrays(&num, &size); -  push_text("num_arrays"); -  push_ulongest(num); -  push_text("array_bytes"); +  push_static_text("num_malloc_blocks"); +  push_ulongest(1 + mi.hblks); /* 1 for the arena. */ +  push_static_text("malloc_block_bytes"); +  if (mi.arena < 0) { +  /* Kludge for broken Linux libc, where the fields are ints. +  * +  * 31-bit overflow, so perform an unsigned read. +  */ +  size = (unsigned int)mi.arena; +  } else { +  /* On Solaris the fields are unsigned long (and may thus be 64-bit). */ +  size = mi.arena; +  } +  /* NB: Kludge for glibc: hblkhd is intended for malloc overhead +  * according to the Solaris manpages, but glibc keeps the +  * amount of mmapped memory there, and uses the arena only +  * for the amount from sbrk. +  * +  * The hblkhd value on proper implementations should be +  * small enough not to affect the total much, so no need +  * for a special case. +  */ +  if (mi.hblkhd < 0) { +  size += (unsigned int)mi.hblkhd; +  } else { +  size += mi.hblkhd; +  }    push_ulongest(size);    -  count_memory_in_programs(&num,&size); -  push_text("num_programs"); -  push_ulongest(num); -  push_text("program_bytes"); +  push_static_text("num_malloc"); +  push_ulongest(mi.ordblks + mi.smblks); +  push_static_text("malloc_bytes"); +  if (mi.uordblks < 0) { +  size = (unsigned int)mi.uordblks; +  } else { +  size = mi.uordblks; +  } +  if (mi.smblks) { +  /* NB: Not dlmalloc where usmblks contains the max uordblks value. */ +  if (mi.usmblks < 0) { +  size += (unsigned int)mi.usmblks; +  } else { +  size += mi.usmblks; +  } +  }    push_ulongest(size);    -  count_memory_in_multisets(&num, &size); -  push_text("num_multisets"); -  push_ulongest(num); -  push_text("multiset_bytes"); +  push_static_text("num_free_blocks"); +  push_int(1); +  push_static_text("free_block_bytes"); +  if (mi.fsmblks < 0) { +  size = (unsigned int)mi.fsmblks; +  } else { +  size = mi.fsmblks; +  } +  if (mi.fordblks < 0) { +  size += (unsigned int)mi.fordblks; +  } else { +  size += mi.fordblks; +  }    push_ulongest(size);    -  count_memory_in_objects(&num, &size); -  push_text("num_objects"); -  push_ulongest(num); -  push_text("object_bytes"); -  push_ulongest(size); +  count_string_types();    -  count_memory_in_callbacks(&num, &size); -  push_text("num_callbacks"); -  push_ulongest(num); -  push_text("callback_bytes"); -  push_ulongest(size); + #endif    -  count_memory_in_callables(&num, &size); -  push_text("num_callables"); -  push_ulongest(num); -  push_text("callable_bytes"); -  push_ulongest(size); + #define COUNT(TYPE) do { \ +  PIKE_CONCAT3(count_memory_in_, TYPE, s)(&num, &size); \ +  push_static_text("num_" #TYPE "s"); \ +  push_ulongest(num); \ +  push_static_text(#TYPE "_bytes"); \ +  push_ulongest(size); \ +  } while(0)    -  count_memory_in_pike_frames(&num, &size); -  push_text("num_frames"); -  push_ulongest(num); -  push_text("frame_bytes"); -  push_ulongest(size); +  COUNT(array); +  COUNT(ba_mixed_frame); +  COUNT(callable); +  COUNT(callback); +  COUNT(catch_context); +  COUNT(compat_cb_box); +  COUNT(destroy_called_mark); +  COUNT(gc_rec_frame); +  COUNT(mapping); +  COUNT(marker); +  COUNT(mc_marker); +  COUNT(multiset); +  COUNT(node_s); +  COUNT(object); +  COUNT(pike_frame); +  COUNT(pike_list_node); +  COUNT(pike_type); +  COUNT(program); +  COUNT(string); + #ifdef PIKE_DEBUG +  COUNT(supporter_marker); + #endif      #ifdef DEBUG_MALLOC    {    extern void count_memory_in_memory_maps(size_t*, size_t*);    extern void count_memory_in_memory_map_entrys(size_t*, size_t*);    extern void count_memory_in_memlocs(size_t*, size_t*);    extern void count_memory_in_memhdrs(size_t*, size_t*);    -  count_memory_in_memory_maps(&num, &size); -  push_text("num_memory_maps"); -  push_ulongest(num); -  push_text("memory_map_bytes"); -  push_ulongest(size); -  -  count_memory_in_memory_map_entrys(&num, &size); -  push_text("num_memory_map_entries"); -  push_ulongest(num); -  push_text("memory_map_entrie_bytes"); -  push_ulongest(size); -  -  count_memory_in_memlocs(&num, &size); -  push_text("num_memlocs"); -  push_ulongest(num); -  push_text("memloc_bytes"); -  push_ulongest(size); -  -  count_memory_in_memhdrs(&num, &size); -  push_text("num_memhdrs"); -  push_ulongest(num); -  push_text("memhdr_bytes"); -  push_ulongest(size); +  COUNT(memory_map); +  COUNT(memory_map_entry); +  COUNT(memloc); +  COUNT(memhdr);    }   #endif       call_callback(&memory_usage_callback, NULL);    -  f_aggregate_mapping(DO_NOT_WARN(Pike_sp - ss)); +  f_aggregate_mapping(Pike_sp - ss);   }    - /*! @decl mixed _next(mixed x) -  *! -  *! Find the next object/array/mapping/multiset/program or string. -  *! -  *! All objects, arrays, mappings, multisets, programs and strings are -  *! stored in linked lists inside Pike. This function returns the next -  *! item on the corresponding list. It is mainly meant for debugging -  *! the Pike runtime, but can also be used to control memory usage. -  *! -  *! @seealso -  *! @[next_object()], @[_prev()] -  */ - PMOD_EXPORT void f__next(INT32 args) - { -  struct svalue tmp; + /* Estimate the size of an svalue, not including objects. +  this is used from size_object.    -  ASSERT_SECURITY_ROOT("_next"); +  It should not include the size of the svalue itself, so the basic +  types count as 0 bytes.    -  if(!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("_next", 1); +  This is an estimate mainly because it is very hard to know to whom +  a certain array/mapping/multiset or string "belongs".    -  pop_n_elems(args-1); -  args = 1; -  tmp=Pike_sp[-1]; -  switch(TYPEOF(tmp)) +  The returned size will be the memory usage of the svalue divided by +  the number of references to it. + */ +  + unsigned int rec_size_svalue( struct svalue *s, struct mapping **m )   { -  case T_OBJECT: tmp.u.object=tmp.u.object->next; break; -  case T_ARRAY: tmp.u.array=tmp.u.array->next; break; -  case T_MAPPING: tmp.u.mapping=tmp.u.mapping->next; break; -  case T_MULTISET:tmp.u.multiset=tmp.u.multiset->next; break; -  case T_PROGRAM: tmp.u.program=tmp.u.program->next; break; -  case T_STRING: tmp.u.string=next_pike_string(tmp.u.string); break; -  default: -  SIMPLE_BAD_ARG_ERROR("_next", 1, -  "object|array|mapping|multiset|program|string"); +  unsigned int res = 0; +  int i; +  ptrdiff_t node_ref; +  INT32 e; +  struct svalue *x; +  struct keypair *k; +  +  switch( TYPEOF(*s) ) +  { +  case PIKE_T_STRING: +  return count_memory_in_string(s->u.string) / s->u.string->refs; +  case PIKE_T_INT: +  case PIKE_T_OBJECT: +  case PIKE_T_FLOAT: +  case PIKE_T_FUNCTION: +  case PIKE_T_TYPE: +  return 0;    } -  if(tmp.u.refs) +  if( !m ) return 0; +  +  if( !*m ) +  *m = allocate_mapping( 10 ); +  else if( (x = low_mapping_lookup( *m, s )) )    { -  assign_svalue(Pike_sp-1,&tmp); -  }else{ -  pop_stack(); -  push_int(0); +  /* Already counted. Use the old size. */ +  return x->u.integer;    } - } +     - /*! @decl mixed _prev(mixed x) -  *! -  *! Find the previous object/array/mapping/multiset or program. -  *! -  *! All objects, arrays, mappings, multisets and programs are -  *! stored in linked lists inside Pike. This function returns the previous -  *! item on the corresponding list. It is mainly meant for debugging -  *! the Pike runtime, but can also be used to control memory usage. -  *! -  *! @note -  *! Unlike @[_next()] this function does not work on strings. -  *! -  *! @seealso -  *! @[next_object()], @[_next()] -  */ - PMOD_EXPORT void f__prev(INT32 args) +  low_mapping_insert( *m, s, &svalue_int_one, 0 ); +  switch( TYPEOF(*s) )    { -  struct svalue tmp; +  case PIKE_T_ARRAY: +  res = sizeof( struct array ); +  for( i=0; i<s->u.array->size; i++ ) +  res += sizeof(struct svalue) + rec_size_svalue( s->u.array->item+i, m ); +  break;    -  ASSERT_SECURITY_ROOT("_prev"); +  case PIKE_T_MULTISET: +  res = sizeof(struct multiset) + sizeof(struct multiset_data); +  node_ref = multiset_last( s->u.multiset ); +  while( node_ref != -1 ) +  { +  res += rec_size_svalue( get_multiset_value (s->u.multiset, node_ref), m ) +  /* each node has the index and left/right node pointers. */ +  + sizeof(struct svalue) + (sizeof(void*)*2); +  node_ref = multiset_prev( s->u.multiset, node_ref ); +  } +  break;    -  if(!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("_prev", 1); -  -  pop_n_elems(args-1); -  args = 1; -  tmp=Pike_sp[-1]; -  switch(TYPEOF(tmp)) +  case PIKE_T_MAPPING: +  res = sizeof(struct mapping);    { -  case T_OBJECT: tmp.u.object=tmp.u.object->prev; break; -  case T_ARRAY: tmp.u.array=tmp.u.array->prev; break; -  case T_MAPPING: tmp.u.mapping=tmp.u.mapping->prev; break; -  case T_MULTISET:tmp.u.multiset=tmp.u.multiset->prev; break; -  case T_PROGRAM: tmp.u.program=tmp.u.program->prev; break; -  default: -  SIMPLE_BAD_ARG_ERROR("_prev", 1, "object|array|mapping|multiset|program"); +  struct mapping_data *d = s->u.mapping->data; +  struct keypair *f = d->free_list; +  int data_size = sizeof( struct mapping_data ); +  data_size += d->hashsize * sizeof(struct keypair *) - sizeof(struct keypair *); +  while( f ) +  { +  data_size += sizeof(struct keypair); +  f = f->next;    } -  if(tmp.u.refs) +  NEW_MAPPING_LOOP( s->u.mapping->data )    { -  assign_svalue(Pike_sp-1,&tmp); -  }else{ -  pop_stack(); -  push_int(0); +  data_size += rec_size_svalue( &k->ind, m ); +  data_size += rec_size_svalue( &k->val, m ); +  data_size += sizeof( struct keypair );    } -  +  res += data_size / (d->hardlinks+1);    } -  +  break; +  } +  res /= *s->u.refs; +  low_mapping_lookup(*m,s)->u.integer = res; +  return res; + }    - /*! @decl int _refs(string|array|mapping|multiset|function|object|program o) + /*! @decl int size_object(object o) +  *! @belongs Debug    *! -  *! Return the number of references @[o] has. +  *! Return the aproximate size of the object, in bytes. +  *! This might not work very well for native objects    *! -  *! It is mainly meant for debugging the Pike runtime, but can also be -  *! used to control memory usage. +     *! -  *! @note -  *! Note that the number of references will always be at least one since -  *! the value is located on the stack when this function is executed. +  *! The function tries to estimate the memory usage of variables +  *! belonging to the object.    *! -  +  *! It will not, however, include the size of objects assigned to +  *! variables in the object. +  *! +  *! +  *! If the object has a @[lfun::_size_object()] it will be called +  *! without arguments, and the return value will be added to the final +  *! size. It is primarily intended to be used by C-objects that +  *! allocate memory that is not normally visible to pike. +  *!    *! @seealso -  *! @[_next()], @[_prev()] +  *! @[lfun::_size_object()], @[sizeof()]    */ - PMOD_EXPORT void f__refs(INT32 args) + static void f__size_object( INT32 UNUSED(args) )   { -  INT32 i; +  size_t sum; +  unsigned int i; +  ptrdiff_t fun; +  struct object *o; +  struct program *p; +  struct mapping *map = NULL; +  if( TYPEOF(Pike_sp[-1]) != PIKE_T_OBJECT ) +  Pike_error("Expected an object as argument\n"); +  o = Pike_sp[-1].u.object;    -  if(!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("_refs", 1); +  if( !(p=o->prog) ) +  { +  pop_stack(); +  push_int(0); +  return; +  } +  sum = sizeof(struct object); +  sum += p->storage_needed;    -  if(TYPEOF(Pike_sp[-args]) > MAX_REF_TYPE) -  SIMPLE_BAD_ARG_ERROR("refs", 1, -  "array|mapping|multiset|object|" -  "function|program|string"); +  if( (fun = low_find_lfun( p, LFUN__SIZE_OBJECT)) != -1 ) +  { +  apply_low( o, fun, 0 ); +  if( TYPEOF(Pike_sp[-1]) == PIKE_T_INT ) +  sum += Pike_sp[-1].u.integer; +  pop_stack(); +  }    -  i=Pike_sp[-args].u.refs[0]; -  pop_n_elems(args); -  push_int(i); +  Pike_sp++; +  for (i = 0; i < p->num_identifier_references; i++) +  { +  struct reference *ref = PTR_FROM_INT(p, i); +  struct identifier *id = ID_FROM_PTR(p, ref); +  struct inherit *inh = p->inherits; +  if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags) || +  id->run_time_type == PIKE_T_GET_SET) +  { +  continue;    }    - #ifdef PIKE_DEBUG - /* This function is for debugging *ONLY* -  * do not document please. /Hubbe +  /* NOTE: makes the assumption that a variable saved in an +  * object has at least one reference.    */ - PMOD_EXPORT void f__leak(INT32 args) - { -  INT32 i; +  low_object_index_no_free(Pike_sp-1, o, i + inh->identifier_level); +  if (REFCOUNTED_TYPE(TYPEOF(Pike_sp[-1]))) +  sub_ref( Pike_sp[-1].u.dummy ); +  sum += rec_size_svalue(Pike_sp-1, &map); +  } +  Pike_sp--; +  if( map ) free_mapping(map);    -  if(!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("_leak", 1); -  -  if(TYPEOF(Pike_sp[-args]) > MAX_REF_TYPE) -  SIMPLE_BAD_ARG_ERROR("_leak", 1, -  "array|mapping|multiset|object|" -  "function|program|string"); -  -  add_ref(Pike_sp[-args].u.dummy); -  i=Pike_sp[-args].u.refs[0]; -  pop_n_elems(args); -  push_int(i); +  pop_stack(); +  push_int(sum);   } - #endif +       /*! @decl type _typeof(mixed x)    *!    *! Return the runtime type of @[x].    *!    *! @seealso    *! @[typeof()]    */   PMOD_EXPORT void f__typeof(INT32 args)   {
pike.git/src/builtin_functions.c:7691:    *! only re-define certain functions.    *!    *! FIXME: Tell how to inherit the master.    *!    *! @seealso    *! @[master()]    */   PMOD_EXPORT void f_replace_master(INT32 args)   {    struct object *new_master; -  ASSERT_SECURITY_ROOT("replace_master"); +        if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("replace_master", 1);    if(TYPEOF(Pike_sp[-args]) != T_OBJECT)    SIMPLE_BAD_ARG_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,    "Called with destructed object.\n");       if (SUBTYPEOF(Pike_sp[-args]))    bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args,    "Subtyped master objects are not supported yet.\n");    -  push_constant_text ("is_pike_master"); +  push_static_text ("is_pike_master");    args++; -  object_set_index (new_master, 0, Pike_sp - 1, &svalue_int_one); +  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);       free_program(master_program);    master_program=master_object->prog;    add_ref(master_program);       pop_n_elems(args);
pike.git/src/builtin_functions.c:7875: Inside #if CPU_TIME_TICKS_LOW > 1000000
  #if CPU_TIME_TICKS_LOW > 1000000    push_int64(time / (CPU_TIME_TICKS / 1000000));   #else    push_int64 (time);    push_int (1000000 / CPU_TIME_TICKS);    o_multiply();   #endif    }   }    + /*! @decl int gethrdtime(void|int nsec) +  *! +  *! Return the high resolution real time spent with threads disabled +  *! since the Pike interpreter was started. The time is normally +  *! returned in microseconds, but if the optional argument @[nsec] +  *! is nonzero it's returned in nanoseconds. +  *! +  *! @note +  *! The actual accuracy on many systems is significantly less than +  *! microseconds or nanoseconds. See @[System.REAL_TIME_RESOLUTION]. +  *! +  *! @seealso +  *! @[_disable_threads()], @[gethrtime()] +  */ + static void f_gethrdtime(INT32 args) + { +  int nsec = args && !UNSAFE_IS_ZERO(Pike_sp-args); +  cpu_time_t time = threads_disabled_acc_time; +  pop_n_elems(args); +  +  if (threads_disabled) { +  time += get_real_time() - threads_disabled_start; +  } +  if (nsec) { +  push_int64(time); + #ifndef LONG_CPU_TIME +  push_int(1000000000 / CPU_TIME_TICKS); +  o_multiply(); + #endif +  } else { + #if CPU_TIME_TICKS_LOW > 1000000 +  push_int64(time / (CPU_TIME_TICKS / 1000000)); + #else +  push_int64 (time); +  push_int (1000000 / CPU_TIME_TICKS); +  o_multiply(); + #endif +  } + } +    #ifdef PROFILING   /*! @decl array(int|mapping(string:array(int))) @    *! get_profiling_info(program prog)    *!    *! Get profiling information.    *!    *! @returns    *! Returns an array with two elements.    *! @array    *! @elem int num_clones
pike.git/src/builtin_functions.c:8015:    *! @[lfun::__hash] for further details if the array contains    *! objects).    */   PMOD_EXPORT void f_uniq_array(INT32 args)   {    struct array *a, *b;    struct mapping *m;    int i, j=0,size=0;       get_all_args("uniq", args, "%a", &a); +  if( !a->size ) +  { +  push_empty_array(); +  return; +  } +     push_mapping(m = allocate_mapping(a->size)); -  push_array(b = allocate_array(a->size)); +  b = allocate_array(a->size);       for(i =0; i< a->size; i++)    {    mapping_insert(m, ITEM(a)+i, &svalue_int_one);    if(m_sizeof(m) != size)    {    size=m_sizeof(m);    assign_svalue_no_free(ITEM(b)+ j++, ITEM(a)+i);    }    } -  dmalloc_touch_svalue(Pike_sp-1); -  Pike_sp--; /* keep the ref to 'b' */ -  ACCEPT_UNFINISHED_TYPE_FIELDS { -  b=resize_array(b, j); -  } END_ACCEPT_UNFINISHED_TYPE_FIELDS; +     b->type_field = a->type_field; -  pop_n_elems(args-1); /* pop args and the mapping */ +  if (j != a->size) { +  /* There are zeros in the unused fields... */ +  b->type_field |= BIT_INT; +  b = array_shrink(b, j); +  b->type_field = a->type_field; +  }    push_array(b);   }      /*! @decl array(mixed) splice(array(mixed) arr1, array(mixed) arr2, @    *! array(mixed) ... more_arrays)    *!    *! Splice two or more arrays.    *!    *! This means that the returned array has the first element in the    *! first given array, then the first argument in next array and so
pike.git/src/builtin_functions.c:8062:    INT32 size=0x7fffffff;    INT32 i,j,k;       for(i=0;i<args;i++)    if (TYPEOF(Pike_sp[i-args]) != T_ARRAY)    SIMPLE_BAD_ARG_ERROR("splice", i+1, "array");    else    if (Pike_sp[i-args].u.array->size < size)    size=Pike_sp[i-args].u.array->size;    -  out=allocate_array(args * size); -  if (!args) +  if(!args || !size)    { -  push_array(out); +  push_empty_array();    return;    }    -  +  out=allocate_array(args * size);    out->type_field=0; -  for(i=-args; i<0; i++) out->type_field|=Pike_sp[i].u.array->type_field; +        for(k=j=0; j<size; j++)    for(i=-args; i<0; i++) -  assign_svalue_no_free(out->item+(k++), Pike_sp[i].u.array->item+j); +  { +  assign_svalue_no_free(out->item+k, Pike_sp[i].u.array->item+j); +  out->type_field |= (1<<TYPEOF(*(out->item+(k++)))); +  }    -  pop_n_elems(args); +     push_array(out);    return;   }      /*! @decl array(mixed) everynth(array(mixed) a, void|int n, @    *! void|int start)    *!    *! Return an array with every @[n]:th element of the array @[a].    *!    *! If @[n] is zero every other element will be returned.
pike.git/src/builtin_functions.c:8128:    }       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);    types |= 1 << TYPEOF(ITEM(a)[k]);    }    a->type_field=types;    -  pop_n_elems(args); +     push_array(a);    return;   }      /*! @decl array(array) transpose(array(array) matrix)    *! Takes an array of equally sized arrays (essentially a matrix of size M*N)    *! and returns the transposed (N*M) version of it, where rows and columns    *! are exchanged for one another.    */   PMOD_EXPORT void f_transpose(INT32 args)
pike.git/src/builtin_functions.c:8158:    SIMPLE_TOO_FEW_ARGS_ERROR("transpose", 1);       if (TYPEOF(Pike_sp[-args]) != T_ARRAY)    SIMPLE_BAD_ARG_ERROR("transpose", 1, "array(array)");       in=Pike_sp[-args].u.array;    sizein=in->size;       if(!sizein)    { -  pop_n_elems(args); -  out=allocate_array(0); -  push_array(out); +  push_empty_array();    return;    }       if( (in->type_field != BIT_ARRAY) &&    (array_fix_type_field(in) != BIT_ARRAY) )    SIMPLE_BAD_ARG_ERROR("transpose", 1, "array(array)");       sizeininner=in->item->u.array->size;       for(i=1 ; i<sizein; i++)
pike.git/src/builtin_functions.c:8195:    ett=outinner->item;    tva=in->item;    for(i=0; i<sizein; i++)    assign_svalue_no_free(ett+i, tva[i].u.array->item+j);       outinner->type_field=type;    SET_SVAL(out->item[j], T_ARRAY, 0, array, outinner);    }       out->type_field=BIT_ARRAY; -  pop_n_elems(args); +     push_array(out);    return;   }      /*! @endmodule    */    - #ifdef DEBUG_MALLOC - /*! @decl void reset_dmalloc() -  *! @belongs Debug -  *! -  *! @note -  *! Only available when compiled with dmalloc. -  */ - PMOD_EXPORT void f__reset_dmalloc(INT32 args) - { -  ASSERT_SECURITY_ROOT("_reset_dmalloc"); -  pop_n_elems(args); -  reset_debug_malloc(); - } -  - /*! @decl void dmalloc_set_name(string filename, int linenumber) -  *! @belongs Debug -  *! -  *! @note -  *! Only available when compiled with dmalloc. -  */ - PMOD_EXPORT void f__dmalloc_set_name(INT32 args) - { -  char *s; -  INT_TYPE i; -  extern char * dynamic_location(const char *file, int line); -  extern char * dmalloc_default_location; -  -  if(args) -  { -  get_all_args("_dmalloc_set_name", args, "%s%i", &s, &i); -  dmalloc_default_location = dynamic_location(s, i); -  }else{ -  dmalloc_default_location=0; -  } -  pop_n_elems(args); - } -  - /*! @decl void list_open_fds() -  *! @belongs Debug -  *! -  *! @note -  *! Only available when compiled with dmalloc. -  */ - PMOD_EXPORT void f__list_open_fds(INT32 args) - { -  extern void list_open_fds(void); -  list_open_fds(); - } -  - /*! @decl void dump_dmalloc_locations(string|array|mapping| @ -  *! multiset|function|object| @ -  *! program|type o) -  *! @belongs Debug -  *! -  *! @note -  *! Only available when compiled with dmalloc. -  */ - PMOD_EXPORT void f__dump_dmalloc_locations(INT32 args) - { -  ASSERT_SECURITY_ROOT("_dump_dmalloc_locations"); -  if(args) -  debug_malloc_dump_references (Pike_sp[-args].u.refs, 2, 1, 0); -  pop_n_elems(args-1); - } - #endif -  - #ifdef PIKE_DEBUG - /*! @decl void locate_references(string|array|mapping| @ -  *! multiset|function|object| @ -  *! program|type o) -  *! @belongs Debug -  *! -  *! This function is mostly intended for debugging. It will search through -  *! all data structures in Pike looking for @[o] and print the -  *! locations on stderr. @[o] can be anything but @expr{int@} or -  *! @expr{float@}. -  *! -  *! @note -  *! This function only exists if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__locate_references(INT32 args) - { -  ASSERT_SECURITY_ROOT("_locate_references"); -  if(args) -  locate_references(Pike_sp[-args].u.refs); -  pop_n_elems(args-1); - } -  - /*! @decl mixed describe(mixed x) -  *! @belongs Debug -  *! -  *! Prints out a description of the thing @[x] to standard error. -  *! The description contains various internal info associated with -  *! @[x]. -  *! -  *! @note -  *! This function only exists if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__describe(INT32 args) - { -  struct svalue *s; -  ASSERT_SECURITY_ROOT("_describe"); -  get_all_args("_describe", args, "%*", &s); -  debug_describe_svalue(debug_malloc_pass(s)); -  pop_n_elems(args-1); - } -  - /*! @decl void gc_set_watch(array|multiset|mapping|object|function|program|string x) -  *! @belongs Debug -  *! -  *! Sets a watch on the given thing, so that the gc will print a -  *! message whenever it's encountered. Intended to be used together -  *! with breakpoints to debug the garbage collector. -  *! -  *! @note -  *! This function only exists if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__gc_set_watch(INT32 args) - { -  ASSERT_SECURITY_ROOT("_gc_set_watch"); -  -  if (args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR("_gc_set_watch", 1); -  if (TYPEOF(Pike_sp[-args]) > MAX_REF_TYPE) -  SIMPLE_BAD_ARG_ERROR("_gc_set_watch", 1, "reference type"); -  gc_watch(Pike_sp[-args].u.refs); -  pop_n_elems(args); - } -  - /*! @decl void dump_backlog() -  *! @belongs Debug -  *! -  *! Dumps the 1024 latest executed opcodes, along with the source -  *! code lines, to standard error. The backlog is only collected on -  *! debug level 1 or higher, set with @[_debug] or with the @tt{-d@} -  *! argument on the command line. -  *! -  *! @note -  *! This function only exists if the Pike runtime has been compiled -  *! with RTL debug. -  */ - PMOD_EXPORT void f__dump_backlog(INT32 args) - { -  ASSERT_SECURITY_ROOT("_dump_backlog"); -  pop_n_elems(args); -  dump_backlog(); - } -  - #endif -  +    /*! @decl mixed map(mixed arr, void|mixed fun, mixed ... extra)    *!    *! Applies @[fun] to the elements in @[arr] and collects the results.    *!    *! @[arr] is treated as a set of elements, as follows:    *!    *! @dl    *! @item array    *! @item multiset    *! @item string
pike.git/src/builtin_functions.c:8380:    *! @item mapping    *! @[fun] is applied to the values, and each result is assigned    *! to the same index in a new mapping, which is returned.    *!    *! @item program    *! The program is treated as a mapping containing the    *! identifiers that are indexable from it and their values.    *!    *! @item object    *! If there is a @[lfun::cast] method in the object, it's -  *! called -  *! to try to cast the object to an array, a mapping, or a -  *! multiset, in that order, which is then handled as described -  *! above. +  *! called to try to cast the object to an array, a mapping, or +  *! a multiset, in that order, which is then handled as +  *! described above.    *! @enddl    *!    *! @[fun] is applied in different ways depending on its type:    *!    *! @dl    *! @item function    *! @[fun] is called for each element. It gets the current    *! element as the first argument and @[extra] as the rest. The    *! result of the call is collected.    *!
pike.git/src/builtin_functions.c:8478:    (multiset)(map(indices(arr),fun,@extra)); */    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */    mark_free_svalue (Pike_sp-args-1);    f_indices(1); /* call f_indices */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    Pike_sp[-args]=Pike_sp[0]; /* move it back */    f_map(args);    -  /* FIXME: Handle multisets with values like mappings. */ -  push_multiset (mkmultiset_2 (Pike_sp[-1].u.array, NULL, NULL)); +  push_multiset (mkmultiset (Pike_sp[-1].u.array));    free_array (Pike_sp[-2].u.array);    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp[-2] = Pike_sp[-1];    Pike_sp--;    return;       case T_STRING:    /* multiset ret =    (string)(map((array)arr,fun,@extra)); */    push_svalue(Pike_sp-args); /* take indices from arr */
pike.git/src/builtin_functions.c:8508:    return;       case T_OBJECT:    /* if arr->cast :    try map((array)arr,fun,@extra);    try map((mapping)arr,fun,@extra);    try map((multiset)arr,fun,@extra); */       mysp=Pike_sp+3-args;    -  push_svalue(mysp-3); -  push_constant_text("cast"); -  f_arrow(2); -  if (!UNSAFE_IS_ZERO(Pike_sp-1)) +     { -  pop_stack(); +  struct object *o = mysp[-3].u.object; +  INT16 osub = SUBTYPEOF(mysp[-3]); +  int f = FIND_LFUN(o->prog->inherits[osub].prog, +  LFUN_CAST);    -  push_constant_text("array"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  if( f!=-1 ) +  { +  +  ref_push_string(literal_array_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_ARRAY)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_map(args);    return;    }    pop_stack();    -  push_constant_text("mapping"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  ref_push_string(literal_mapping_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_MAPPING)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_map(args);    return;    }    pop_stack();    -  push_constant_text("multiset"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  ref_push_string(literal_multiset_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_MULTISET)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_map(args);    return;    }    pop_stack();    } -  pop_stack(); -  -  /* if arr->_sizeof && arr->`[] -  array ret; ret[i]=arr[i]; -  ret=map(ret,fun,@extra); */ -  -  /* class myarray { int a0=1,a1=2; int `[](int what) { return ::`[]("a"+what); } int _sizeof() { return 2; } } -  map(myarray(),lambda(int in){ werror("in=%d\n",in); }); */ -  -  push_svalue(mysp-3); -  push_constant_text("`[]"); -  f_arrow(2); -  push_svalue(mysp-3); -  push_constant_text("_sizeof"); -  f_arrow(2); -  if (!UNSAFE_IS_ZERO(Pike_sp-2)&&!UNSAFE_IS_ZERO(Pike_sp-1)) -  { -  f_call_function(1); -  if (TYPEOF(Pike_sp[-1]) != T_INT) -  SIMPLE_BAD_ARG_ERROR("map", 1, -  "object sizeof() returning integer"); -  n=Pike_sp[-1].u.integer; -  pop_stack(); -  push_array(d=allocate_array(n)); -  types = 0; -  stack_swap(); -  for (i=0; i<n; i++) -  { -  stack_dup(); /* `[] */ -  push_int(i); -  f_call_function(2); -  stack_pop_to_no_free (ITEM(d) + i); -  types |= 1 << TYPEOF(*ITEM(d)); +     } -  d->type_field = types; -  pop_stack(); -  free_svalue(mysp-3); -  mysp[-3]=*(--Pike_sp); -  dmalloc_touch_svalue(Pike_sp); -  f_map(args); -  return; -  } -  pop_stack(); -  pop_stack(); +        SIMPLE_BAD_ARG_ERROR("map",1,    "object that works in map");       default:    SIMPLE_BAD_ARG_ERROR("map",1,    "array|mapping|program|function|"    "multiset|string|object");    }   
pike.git/src/builtin_functions.c:8832:       switch (TYPEOF(Pike_sp[-args]))    {    case T_ARRAY:    if (args >= 2 && TYPEOF(Pike_sp[1-args]) == T_ARRAY) {    if (Pike_sp[1-args].u.array->size != Pike_sp[-args].u.array->size)    SIMPLE_BAD_ARG_ERROR("filter", 2, "array of same size as the first");    pop_n_elems(args-2);    }    else { -  MEMMOVE(Pike_sp-args+1,Pike_sp-args,args*sizeof(*Pike_sp)); +  memmove(Pike_sp-args+1,Pike_sp-args,args*sizeof(*Pike_sp));    dmalloc_touch_svalue(Pike_sp);    Pike_sp++;    add_ref_svalue(Pike_sp-args);    f_map(args);    }       f=Pike_sp[-1].u.array;    a=Pike_sp[-2].u.array;    n=a->size;    for (k=m=i=0; i<n; i++)
pike.git/src/builtin_functions.c:8870:    if (k > 1) f_add(k);    stack_pop_2_elems_keep_top();    return;       case T_MAPPING:    case T_PROGRAM:    case T_FUNCTION:    /* mapping ret =    mkmapping(indices(arr),    map(values(arr),fun,@extra)); */ -  MEMMOVE(Pike_sp-args+2,Pike_sp-args,args*sizeof(*Pike_sp)); +  memmove(Pike_sp-args+2,Pike_sp-args,args*sizeof(*Pike_sp));    Pike_sp+=2;    mark_free_svalue (Pike_sp-args-2);    mark_free_svalue (Pike_sp-args-1);       push_svalue(Pike_sp-args);    f_indices(1);    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    Pike_sp[-args-2]=*Pike_sp;    dmalloc_touch_svalue(Pike_sp);
pike.git/src/builtin_functions.c:8917:    case T_MULTISET:    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */    mark_free_svalue (Pike_sp-args-1);    f_indices(1); /* call f_indices */    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    Pike_sp[-args]=Pike_sp[0]; /* move it back */    f_filter(args);    -  /* FIXME: Handle multisets with values like mappings. */ -  push_multiset (mkmultiset_2 (Pike_sp[-1].u.array, NULL, NULL)); +  push_multiset (mkmultiset (Pike_sp[-1].u.array));    free_array (Pike_sp[-2].u.array);    Pike_sp[-2] = Pike_sp[-1];    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    return;       case T_STRING:    push_svalue(Pike_sp-args); /* take indices from arr */    free_svalue(Pike_sp-args-1); /* move it to top of stack */    mark_free_svalue (Pike_sp-args-1);
pike.git/src/builtin_functions.c:8940:    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);    Pike_sp[-args]=Pike_sp[0]; /* move it back */    f_filter(args);    o_cast(NULL,T_STRING); /* cast the array to a string */    return;       case T_OBJECT:    mysp=Pike_sp+3-args;    -  push_svalue(mysp-3); -  push_constant_text("cast"); -  f_arrow(2); -  if (!UNSAFE_IS_ZERO(Pike_sp-1)) +     { -  pop_stack(); +  struct object *o = mysp[-3].u.object; +  int f = FIND_LFUN(o->prog->inherits[SUBTYPEOF(mysp[-3])].prog, +  LFUN_CAST);    -  push_constant_text("array"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  if( f!=-1 ) +  { +  ref_push_string(literal_array_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_ARRAY)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_filter(args);    return;    }    pop_stack();    -  push_constant_text("mapping"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  ref_push_string(literal_mapping_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_MAPPING)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_filter(args);    return;    }    pop_stack();    -  push_constant_text("multiset"); -  /* FIXME: Object subtype! */ -  safe_apply(mysp[-3].u.object,"cast",1); +  ref_push_string(literal_multiset_string); +  apply_low(o, f, 1);    if (TYPEOF(Pike_sp[-1]) == T_MULTISET)    {    free_svalue(mysp-3);    mysp[-3]=*(--Pike_sp);    dmalloc_touch_svalue(Pike_sp);    f_filter(args);    return;    }    pop_stack();    } -  pop_stack(); +  }       SIMPLE_BAD_ARG_ERROR("filter",1,    "...|object that can be cast to array, multiset or mapping");       default:    SIMPLE_BAD_ARG_ERROR("filter",1,    "array|mapping|program|function|"    "multiset|string|object");    }   }
pike.git/src/builtin_functions.c:9088:    push_int(0);    args++;    }       if (args<=3 &&    (TYPEOF(Pike_sp[1-args]) == T_INT &&    TYPEOF(Pike_sp[2-args]) == T_INT))    {    INT_TYPE step,start;    -  get_all_args("enumerate", args, "%i%i%i", &n, &step, &start); -  if (n<0) -  SIMPLE_BAD_ARG_ERROR("enumerate",1,"int(0..)"); +  get_all_args("enumerate", args, "%+%i%i", &n, &step, &start);    -  +  { +  INT_TYPE tmp; +  +  /* this checks if +  * (n - 1) * step + start +  * will overflow. if it does, we continue with the slow path. If it does not, +  * adding step to start repeatedly will not overflow below. This check has +  * false positives, but is much simpler to check than e.g. doing one check +  * for every iteration +  */ +  if (DO_INT_TYPE_MUL_OVERFLOW(n-1, step, &tmp) || INT_TYPE_ADD_OVERFLOW(tmp, start)) +  goto slow_path; +  } +     pop_n_elems(args);    push_array(d=allocate_array(n));    for (i=0; i<n; i++)    {    ITEM(d)[i].u.integer=start; - #ifdef AUTO_BIGNUM -  if ((step>0 && start+step<start) || -  (step<0 && start+step>start)) /* overflow */ -  { -  pop_stack(); -  push_int(n); -  push_int(step); -  convert_stack_top_to_bignum(); -  push_int(start); -  convert_stack_top_to_bignum(); -  f_enumerate(3); -  return; -  } - #endif +     start+=step;    }    d->type_field = BIT_INT;    }    else if (args<=3 &&    ((TYPEOF(Pike_sp[1-args]) == T_INT ||    TYPEOF(Pike_sp[1-args]) == T_FLOAT) &&    (TYPEOF(Pike_sp[2-args]) == T_INT ||    TYPEOF(Pike_sp[2-args]) == T_FLOAT) ) )    {    FLOAT_TYPE step, start;    -  get_all_args("enumerate", args, "%i%F%F", &n, &step, &start); -  if (n<0) -  SIMPLE_BAD_ARG_ERROR("enumerate",1,"int(0..)"); -  +  get_all_args("enumerate", args, "%+%F%F", &n, &step, &start);    pop_n_elems(args); -  +     push_array(d=allocate_array(n));    for (i=0; i<n; i++)    {    SET_SVAL(d->item[i], T_FLOAT, 0, float_number, start);    start+=step;    }    d->type_field = BIT_FLOAT;    }    else    { -  TYPE_FIELD types = 0; -  get_all_args("enumerate", args, "%i", &n); -  if (n<0) SIMPLE_BAD_ARG_ERROR("enumerate",1,"int(0..)"); +  TYPE_FIELD types; + slow_path: +  types = 0; +  get_all_args("enumerate", args, "%+", &n);    if (args>4) pop_n_elems(args-4);    push_array(d=allocate_array(n));    if (args<4)    {    push_svalue(Pike_sp-2); /* start */    for (i=0; i<n; i++)    {    assign_svalue_no_free(ITEM(d)+i,Pike_sp-1);    types |= 1 << TYPEOF(ITEM(d)[i]);    if (i<n-1)
pike.git/src/builtin_functions.c:9183:    }    d->type_field = types;    pop_stack();    stack_pop_n_elems_keep_top(args);    }   }      /*! @module Program    */    +  + /*! @decl string defined(program x, string identifier) +  *! +  *! Returns a string with filename and linenumber where @[idenfifier] +  *! in @[x] was defined. +  *! +  *! Returns @expr{0@} (zero) when no line can be found, e.g. for +  *! builtin functions. +  *! +  *! If @[idenfier] can not be found in @[x] this function returns +  *! where the program is defined. +  */ + PMOD_EXPORT void f_program_identifier_defined(INT32 args) + { +  struct program *p; +  struct pike_string *ident; +  struct program *id_prog, *p2; +  struct identifier *id; +  INT_TYPE line; +  INT_TYPE offset; +  struct pike_string *file = NULL; +  +  if( !(p = program_from_svalue(Pike_sp-args)) ) +  Pike_error("Illegal argument 1 to defined(program,string)\n"); +  +  if( TYPEOF(Pike_sp[1-args]) != PIKE_T_STRING ) +  Pike_error("Illegal argument 2 to defined(program,string)\n"); +  else +  ident = Pike_sp[-args+1].u.string; +  +  if( (offset = find_shared_string_identifier( ident, p )) == -1 ) +  { +  INT_TYPE line; +  struct pike_string *tmp = low_get_program_line(p, &line); +  +  if (tmp) +  { +  push_string(tmp); +  if(line >= 1) +  { +  push_static_text(":"); +  push_int(line); +  f_add(3); +  } +  } +  else +  push_int(0); +  return; +  } +  +  id = ID_FROM_INT(p, offset); +  id_prog = PROG_FROM_INT (p, offset); +  +  if(IDENTIFIER_IS_PIKE_FUNCTION( id->identifier_flags ) && +  id->func.offset != -1) +  file = low_get_line(id_prog->program + id->func.offset, id_prog, &line); +  else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags) && +  id->func.const_info.offset >= 0 && +  (p2 = program_from_svalue (&id_prog->constants[id->func.const_info.offset].sval))) +  file = low_get_program_line (p2, &line); +  else +  /* The program line is better than nothing for C functions. */ +  file = low_get_program_line (p, &line); +  +  if (file) +  { +  if (line) { +  push_string(file); +  push_static_text(":"); +  push_int(line); +  f_add(3); +  } +  else +  push_string (file); +  return; +  } +  +  push_int(0); + } +    /*! @decl array(program) inherit_list(program p)    *!    *! Returns an array with the programs that @[p] has inherited.    */   PMOD_EXPORT void f_inherit_list(INT32 args)   {    struct program *p;    struct svalue *arg;    struct object *par;    int parid,e,q=0;
pike.git/src/builtin_functions.c:9288:   {    check_all_args("Function.defined",args,BIT_FUNCTION, 0);       if(SUBTYPEOF(Pike_sp[-args]) != FUNCTION_BUILTIN &&    Pike_sp[-args].u.object->prog)    {    struct program *p = Pike_sp[-args].u.object->prog;    struct program *id_prog, *p2;    int func = SUBTYPEOF(Pike_sp[-args]);    struct identifier *id; -  INT32 line; +  INT_TYPE line;    struct pike_string *file = NULL;       if (p == pike_trampoline_program) {    struct pike_trampoline *t =    (struct pike_trampoline *) Pike_sp[-args].u.object->storage;    if (t->frame->current_object->prog) {    p = t->frame->current_object->prog;    func = t->func;    }    }
pike.git/src/builtin_functions.c:9316:    else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags) &&    id->func.const_info.offset >= 0 &&    (p2 = program_from_svalue (&id_prog->constants[id->func.const_info.offset].sval)))    file = low_get_program_line (p2, &line);    else    /* The program line is better than nothing for C functions. */    file = low_get_program_line (p, &line);       if (file)    { -  pop_n_elems(args); +     if (line) {    push_string(file); -  push_constant_text(":"); +  push_static_text(":");    push_int(line);    f_add(3);    }    else    push_string (file);    return;    }    }    -  pop_n_elems(args); +     push_int(0); -  +    }      /*! @endmodule Function    */      /* FIXME: Document catch and gauge. */      void init_builtin_efuns(void)   {    struct program *pike___master_program;       ADD_EFUN("gethrvtime",f_gethrvtime,    tFunc(tOr(tInt,tVoid),tInt), OPT_EXTERNAL_DEPEND);    ADD_EFUN("gethrtime", f_gethrtime,    tFunc(tOr(tInt,tVoid),tInt), OPT_EXTERNAL_DEPEND); -  +  ADD_EFUN("gethrdtime", f_gethrdtime, +  tFunc(tOr(tInt,tVoid),tInt), OPT_EXTERNAL_DEPEND);      #ifdef PROFILING    ADD_EFUN("get_profiling_info", f_get_prof_info,    tFunc(tPrg(tObj),tArray), OPT_EXTERNAL_DEPEND);   #endif /* PROFILING */    -  ADD_EFUN("_refs",f__refs,tFunc(tRef,tInt),OPT_EXTERNAL_DEPEND); - #ifdef PIKE_DEBUG -  ADD_EFUN("_leak",f__leak,tFunc(tRef,tInt),OPT_EXTERNAL_DEPEND); - #endif +     ADD_EFUN("_typeof", f__typeof, tFunc(tSetvar(0, tMix), tType(tVar(0))), 0);       /* class __master    * Used to prototype the master object.    */    start_new_program();    ADD_PROTOTYPE("_main", tFunc(tArr(tStr) tArr(tStr),tVoid), 0);       ADD_PROTOTYPE("cast_to_object", tFunc(tStr tStr tOr(tVoid, tObj), tObj), 0);    ADD_PROTOTYPE("cast_to_program", tFunc(tStr tStr tOr(tVoid, tObj), tPrg(tObj)), 0);
pike.git/src/builtin_functions.c:9379:    ADD_PROTOTYPE("decode_charset", tFunc(tStr tStr, tStr), 0);    ADD_PROTOTYPE("describe_backtrace", tFunc(tOr(tObj, tArr(tMix)) tOr(tVoid, tInt), tStr), 0);    ADD_PROTOTYPE("handle_error", tFunc(tOr(tArr(tMix),tObj), tVoid), 0);    ADD_PROTOTYPE("handle_import",    tFunc(tStr tOr(tStr, tVoid) tOr(tObj, tVoid), tMix), 0);    ADD_PROTOTYPE("handle_include", tFunc(tStr tStr tInt, tStr), 0);    ADD_PROTOTYPE("handle_inherit", tFunc(tStr tStr tOr(tObj, tVoid), tPrg(tObj)), 0);    ADD_PROTOTYPE("write", tFunc(tStr tOr(tVoid,tMix), tVoid), OPT_SIDE_EFFECT);    ADD_PROTOTYPE("werror", tFunc(tStr tOr(tVoid,tMix), tVoid), OPT_SIDE_EFFECT);    -  /* FIXME: Are these three actually supposed to be used? -  * They are called by encode.c:rec_restore_value -  * /grubba 2000-03-13 -  */ -  - #if 0 /* they are not required - Hubbe */ -  ADD_PROTOTYPE("functionof", tFunc(tStr, tFunction), ID_OPTIONAL); -  ADD_PROTOTYPE("objectof", tFunc(tStr, tObj), ID_OPTIONAL); -  ADD_PROTOTYPE("programof", tFunc(tStr, tPrg(tObj)), ID_OPTIONAL); - #endif -  +     ADD_PROTOTYPE("read_include", tFunc(tStr, tStr), 0);    ADD_PROTOTYPE("resolv",    tFunc(tStr tOr(tStr,tVoid) tOr(tObj,tVoid), tMix), 0);    - #if 0 -  /* Getenv and putenv are efuns, they do not HAVE to be defined in the -  * master object. -Hubbe -  */ -  -  /* These two aren't called from C-code, but are popular from other code. */ -  ADD_PROTOTYPE("getenv", -  tOr(tFunc(tStr,tStr), tFunc(tNone, tMap(tStr, tStr))), -  ID_OPTIONAL); -  ADD_PROTOTYPE("putenv", tFunc(tStr tStr, tVoid), ID_OPTIONAL); -  - #endif -  -  +     pike___master_program = end_program();    add_program_constant("__master", pike___master_program, 0);       /* FIXME: */    ADD_EFUN("replace_master", f_replace_master,    tFunc(tObj, tVoid), OPT_SIDE_EFFECT);    ADD_EFUN("master", f_master,    tFunc(tNone, tObj), OPT_EXTERNAL_DEPEND); - #if 0 /* FIXME: dtFunc isn't USE_PIKE_TYPE compatible */ -  ADD_EFUN_DTYPE("replace_master", f_replace_master, -  dtFunc(dtObjImpl(pike___master_program), dtVoid), -  OPT_SIDE_EFFECT); +     -  /* function(:object) */ -  /* FIXME: */ -  ADD_EFUN_DTYPE("master", f_master, -  dtFunc(dtNone, dtObjImpl(pike___master_program)), -  OPT_EXTERNAL_DEPEND); - #endif /* 0 */ -  +     /* __master still contains a reference */    free_program(pike___master_program);      /* function(string,void|mixed:void) */    ADD_EFUN("add_constant", f_add_constant,    tFunc(tStr tOr(tVoid,tMix),tVoid),OPT_SIDE_EFFECT);      /* function(0=mixed ...:array(0)) */    ADD_EFUN2("aggregate",debug_f_aggregate,    tFuncV(tNone,tSetvar(0,tMix),tArr(tVar(0))),
pike.git/src/builtin_functions.c:9474:    ADD_EFUN("allocate", f_allocate,    tFunc(tInt tOr(tVoid,tSetvar(0,tMix)),tArr(tVar(0))), 0);      /* function(mixed:int) */    ADD_EFUN("arrayp", f_arrayp,tFunc(tMix,tInt01),0);      /* function(string...:string) */    ADD_EFUN("combine_path_nt",f_combine_path_nt,tFuncV(tNone,tStr,tStr),0);    ADD_EFUN("combine_path_unix",f_combine_path_unix,tFuncV(tNone,tStr,tStr),0);    ADD_EFUN("combine_path_amigaos",f_combine_path_amigaos,tFuncV(tNone,tStr,tStr),0); - #ifdef __NT__ + #if defined(__NT__) || defined(__OS2__)    ADD_EFUN("combine_path",f_combine_path_nt,tFuncV(tNone,tStr,tStr),0);   #else   #ifdef __amigaos__    ADD_EFUN("combine_path",f_combine_path_amigaos,tFuncV(tNone,tStr,tStr),0);   #else    ADD_EFUN("combine_path",f_combine_path_unix,tFuncV(tNone,tStr,tStr),0);   #endif   #endif       ADD_EFUN("compile", f_compile,    tFunc(tStr tOr(tObj, tVoid) tOr(tInt, tVoid) tOr(tInt, tVoid) tOr(tPrg(tObj), tVoid) tOr(tObj, tVoid) ,tPrg(tObj)),    OPT_EXTERNAL_DEPEND);       /* function(1=mixed:1) */    ADD_EFUN("copy_value",f_copy_value,tFunc(tSetvar(1,tMix),tVar(1)),0);       /* function(string:string)|function(string,string:int) */    ADD_EFUN("crypt",f_crypt, -  tOr(tFunc(tStr,tStr),tFunc(tStr tStr,tInt01)),OPT_EXTERNAL_DEPEND); +  tOr(tFunc(tStr,tStr7),tFunc(tStr tStr,tInt01)),OPT_EXTERNAL_DEPEND);      /* function(object|void:void) */    ADD_EFUN("destruct",f_destruct,tFunc(tOr(tObj,tVoid),tVoid),OPT_SIDE_EFFECT);      /* function(mixed,mixed:int) */    ADD_EFUN("equal",f_equal,tFunc(tMix tMix,tInt01),OPT_TRY_OPTIMIZE);       /* function(array(0=mixed),int|void,int|void:array(0)) */    ADD_FUNCTION2("everynth",f_everynth,    tFunc(tArr(tSetvar(0,tMix)) tOr(tInt,tVoid) tOr(tInt,tVoid),
pike.git/src/builtin_functions.c:9522:      /* function(mixed:int) */    ADD_EFUN("floatp", f_floatp,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);      /* function(mixed:int) */    ADD_EFUN("functionp", f_functionp,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);      /* function(mixed:int) */    ADD_EFUN("callablep", f_callablep,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);    - /* function(string,string:int)|function(string,string*:array(string)) */ +  /* function(string,string:int(0..1))|function(string,string*:array(string)) */    ADD_EFUN("glob",f_glob, -  tOr(tFunc(tOr(tStr,tArr(tStr)) tStr,tInt),tFunc(tOr(tStr,tArr(tStr)) tArr(tStr),tArr(tStr))), +  tOr(tFunc(tOr(tStr,tArr(tStr)) tStr,tInt01), +  tFunc(tOr(tStr,tArr(tStr)) tSetvar(1,tArr(tStr)),tVar(1))),    OPT_TRY_OPTIMIZE);       /* function(string,int|void:int) */    ADD_EFUN("hash",f_hash,tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_7_0",f_hash_7_0, -  tDeprecated(tFunc(tStr tOr(tInt,tVoid),tInt)),OPT_TRY_OPTIMIZE); +  tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_7_4",f_hash_7_4, -  tDeprecated(tFunc(tStr tOr(tInt,tVoid),tInt)),OPT_TRY_OPTIMIZE); +  tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_value",f_hash_value,tFunc(tMix,tInt),OPT_TRY_OPTIMIZE);    - #if 1 +     ADD_EFUN2("indices",f_indices, -  tIfnot(tFuncV(tNone,tNot(tOr6(tArray, tMap(tMix, tMix), tSet(tMix), -  tStr, tObj, tPrg(tObj))), -  tNot(tArr(tMix))), +     tOr3(tFunc(tArray,tArr(tIntPos)),    tFunc(tOr3(tMap(tSetvar(1,tMix),tMix),    tSet(tSetvar(1,tMix)),    tNStr(tSetvar(1,tInt))),    tArr(tVar(1))), -  tFunc(tOr(tObj,tPrg(tObj)),tArr(tStr))) -  ), -  OPT_TRY_OPTIMIZE,fix_indices_type,0); - #else -  ADD_EFUN2("indices",f_indices, -  tOr3(tFunc(tArray,tArr(tIntPos)), -  tFunc(tOr3(tMap(tSetvar(1,tMix),tMix), -  tSet(tSetvar(1,tMix)), -  tNStr(tSetvar(1,tInt))), -  tArr(tVar(1))), +     tFunc(tOr(tObj,tPrg(tObj)),tArr(tStr))),    OPT_TRY_OPTIMIZE,fix_indices_type,0); - #endif +     -  ADD_EFUN("undefinedp", f_undefinedp, tFunc(tMix,tInt01), OPT_TRY_OPTIMIZE); -  ADD_EFUN("destructedp", f_destructedp, tFunc(tMix,tInt01), OPT_TRY_OPTIMIZE); +  ADD_EFUN2("undefinedp", f_undefinedp, tFunc(tMix,tInt01), OPT_TRY_OPTIMIZE, +  0, generate_undefinedp); +  ADD_EFUN2("destructedp", f_destructedp, tFunc(tMix,tInt01), OPT_TRY_OPTIMIZE, +  0, generate_destructedp);      /* function(mixed:int) */    ADD_EFUN("intp", f_intp,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);      /* function(mixed:int) */    ADD_EFUN("multisetp", f_multisetp,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);      /* function(string:string)|function(int:int) */    ADD_EFUN("lower_case",f_lower_case,    tOr(tFunc(tStr,tStr), tFunc(tInt,tInt)),OPT_TRY_OPTIMIZE);
pike.git/src/builtin_functions.c:9585:   /* function(mixed:int) */    ADD_EFUN("mappingp",f_mappingp,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);      /* function(1=mixed,int:1) */    ADD_EFUN("set_weak_flag",f_set_weak_flag,    tFunc(tSetvar(1,tMix) tInt,tVar(1)),OPT_SIDE_EFFECT);       ADD_INT_CONSTANT("PIKE_WEAK_INDICES", PIKE_WEAK_INDICES, 0);    ADD_INT_CONSTANT("PIKE_WEAK_VALUES", PIKE_WEAK_VALUES, 0);    - /* function(void|object:object) */ -  ADD_EFUN("next_object",f_next_object, -  tFunc(tOr(tVoid,tObj),tObj),OPT_EXTERNAL_DEPEND); -  - /* function(string:string)|function(object:object)|function(mapping:mapping)|function(multiset:multiset)|function(program:program)|function(array:array) */ -  ADD_EFUN("_next",f__next, -  tOr6(tFunc(tStr,tStr), -  tFunc(tObj,tObj), -  tFunc(tMapping,tMapping), -  tFunc(tMultiset,tMultiset), -  tFunc(tPrg(tObj),tPrg(tObj)), -  tFunc(tArray,tArray)),OPT_EXTERNAL_DEPEND); -  - /* function(object:object)|function(mapping:mapping)|function(multiset:multiset)|function(program:program)|function(array:array) */ -  ADD_EFUN("_prev",f__prev, -  tOr5(tFunc(tObj,tObj), -  tFunc(tMapping,tMapping), -  tFunc(tMultiset,tMultiset), -  tFunc(tPrg(tObj),tPrg(tObj)), -  tFunc(tArray,tArray)),OPT_EXTERNAL_DEPEND); -  +     /* function(mixed:program|function) */    ADD_EFUN2("object_program", f_object_program,    tFunc(tMix, tOr(tPrg(tObj),tFunction)),    OPT_TRY_OPTIMIZE, fix_object_program_type, 0);       /* function(mixed:int) */    ADD_EFUN("objectp", f_objectp,tFunc(tMix,tInt01),0);       /* function(mixed:int) */    ADD_EFUN("programp",f_programp,tFunc(tMix,tInt01),0);       /* function(:int) */    ADD_EFUN("query_num_arg",f_query_num_arg,    tFunc(tNone,tInt),OPT_EXTERNAL_DEPEND);       /* function(int:void) */    ADD_EFUN("random_seed",f_random_seed,    tFunc(tInt,tVoid),OPT_SIDE_EFFECT);       ADD_EFUN("random_string",f_random_string, -  tFunc(tInt,tString), OPT_EXTERNAL_DEPEND); +  tFunc(tInt,tStr8), OPT_EXTERNAL_DEPEND);       ADD_EFUN2("replace", f_replace,    tOr5(tFunc(tStr tStr tStr,tStr),    tFunc(tStr tArr(tStr) tOr(tArr(tStr), tStr), tStr),    tFunc(tStr tMap(tStr,tStr),tStr),    tFunc(tSetvar(0,tArray) tMix tMix,tVar(0)),    tFunc(tSetvar(1,tMapping) tMix tMix,tVar(1))),    OPT_TRY_OPTIMIZE, optimize_replace, 0);       ADD_EFUN("reverse",f_reverse,
pike.git/src/builtin_functions.c:9658:    tFunc(tArr(tSetvar(0,tMix)) tArr(tInt), tArr(tVar(1))),    tFunc(tArray tArr(tNot(tInt)), tArray),    tFunc(tOr4(tObj,tFunction,tPrg(tObj),tInt) tArray, tArray)), 0);       /* FIXME: Is the third arg a good idea when the first is a mapping? */    ADD_EFUN("search",f_search,    tOr4(tFunc(tStr tOr(tStr,tInt) tOr(tVoid,tInt),    tInt),    tFunc(tArr(tSetvar(0,tMix)) tVar(0) tOr(tVoid,tInt),    tInt), -  tFunc(tMap(tSetvar(1,tMix),tSetvar(2,tMix)) tVar(2) tOr(tVoid,tVar(1)), -  tVar(1)), +  tFunc(tMap(tSetvar(1,tMix),tSetvar(2,tMix)) tVar(2) +  tOr(tVoid,tVar(1)), tVar(1)),    tFunc(tObj tMix tOr(tVoid, tSetvar(3, tMix)), tVar(3))),    0);       ADD_EFUN2("has_prefix", f_has_prefix, tFunc(tOr(tStr,tObj) tStr,tInt01),    OPT_TRY_OPTIMIZE, 0, 0);       ADD_EFUN2("has_suffix", f_has_suffix, tFunc(tStr tStr,tInt01),    OPT_TRY_OPTIMIZE, 0, 0);       ADD_EFUN("has_index",f_has_index,
pike.git/src/builtin_functions.c:9755:    tFunc(tOr(tObj,tPrg(tObj)), tArr(tType(tMix)))),0,NULL,0);      /* function(mixed:int) */    ADD_EFUN2("zero_type",f_zero_type,tFunc(tMix,tInt01),0,0,generate_zero_type);      /* function(string,string:array) */    ADD_EFUN("array_sscanf", f_sscanf,    tFunc(tStr tAttr("sscanf_format", tStr),    tArr(tAttr("sscanf_args", tMix))), OPT_TRY_OPTIMIZE);    - /* function(string,string:array) */ -  ADD_EFUN("array_sscanf_76", f_sscanf_76, -  tFunc(tStr tAttr("sscanf_76_format", tStr), -  tArr(tAttr("sscanf_args", tMix))), OPT_TRY_OPTIMIZE); -  +     ADD_EFUN("__handle_sscanf_format", f___handle_sscanf_format,    tFunc(tStr tStr tType(tMix) tType(tMix), tType(tMix)),    0);       /* Some Wide-string stuff */    - /* function(string:string(0..255)) */ +  /* function(string,int(0..2)|void:string(0..255)) */    ADD_EFUN("string_to_unicode", f_string_to_unicode, -  tFunc(tStr,tStr8), OPT_TRY_OPTIMIZE); +  tFunc(tStr tOr(tInt02,tVoid),tStr8), OPT_TRY_OPTIMIZE);    - /* function(string(0..255):string) */ +  /* function(string(0..255),int(0..2)|void:string) */    ADD_EFUN("unicode_to_string", f_unicode_to_string, -  tFunc(tStr8,tStr), OPT_TRY_OPTIMIZE); +  tFunc(tStr8 tOr(tInt02,tVoid),tStr), OPT_TRY_OPTIMIZE);       /* function(string,int|void:string(0..255)) */    ADD_EFUN("string_to_utf8", f_string_to_utf8,    tFunc(tStr tOr(tInt,tVoid),tStr8), OPT_TRY_OPTIMIZE);    -  +  ADD_EFUN("string_filter_non_unicode", f_string_filter_non_unicode, +  tFunc(tStr tOr(tInt,tVoid),tStr8), OPT_TRY_OPTIMIZE); +    /* function(string(0..255),int|void:string) */    ADD_EFUN("utf8_to_string", f_utf8_to_string,    tFunc(tStr8 tOr(tInt,tVoid),tStr), OPT_TRY_OPTIMIZE);          ADD_EFUN("__parse_pike_type", f_parse_pike_type,    tFunc(tStr8,tStr8),OPT_TRY_OPTIMIZE);       ADD_EFUN("__soft_cast", f___soft_cast,    tFunc(tSetvar(0, tType(tMix)) tSetvar(1, tType(tMix)),
pike.git/src/builtin_functions.c:9810:       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_first_arg_type", f___get_first_arg_type,    tFunc(tType(tCallable), tType(tMix)),    OPT_TRY_OPTIMIZE);       ADD_EFUN("__get_type_attributes", f___get_type_attributes,    tFunc(tType(tMix), tArr(tString)),    OPT_TRY_OPTIMIZE);    - #ifdef HAVE_LOCALTIME -  +     /* function(int:mapping(string:int)) */    ADD_EFUN("localtime",f_localtime,    tFunc(tInt,tMap(tStr,tInt)),OPT_EXTERNAL_DEPEND); - #endif - #ifdef HAVE_GMTIME +        /* function(int:mapping(string:int)) */    ADD_EFUN("gmtime",f_gmtime,tFunc(tInt,tMap(tStr,tInt)),OPT_TRY_OPTIMIZE); - #endif +     - #ifdef GOT_F_MKTIME -  +     /* function(int,int,int,int,int,int,int,void|int:int)|function(object|mapping:int) */    ADD_EFUN("mktime",f_mktime,    tOr(tFunc(tInt tInt tInt tInt tInt tInt    tOr(tVoid,tInt) tOr(tVoid,tInt),tInt),    tFunc(tOr(tObj,tMapping),tInt)),OPT_TRY_OPTIMIZE); - #endif +        /* function(:void) */    ADD_EFUN("_verify_internals",f__verify_internals,    tFunc(tNone,tVoid),OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    - #ifdef PIKE_DEBUG -  - /* function(int:int) */ -  ADD_EFUN("_debug",f__debug, -  tFunc(tInt,tInt),OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); -  - /* function(int:int) */ -  ADD_EFUN("_optimizer_debug",f__optimizer_debug, -  tFunc(tInt,tInt),OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); -  - /* function(int:int) */ -  ADD_EFUN("_assembler_debug",f__assembler_debug, -  tFunc(tInt,tInt), OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); -  -  ADD_EFUN("_dump_program_tables", f__dump_program_tables, -  tFunc(tPrg(tObj),tVoid), OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); -  - #ifdef YYDEBUG -  - /* function(int:int) */ -  ADD_EFUN("_compiler_trace",f__compiler_trace, -  tFunc(tInt,tInt),OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); - #endif /* YYDEBUG */ - #endif -  +     /* function(:mapping(string:int)) */    ADD_EFUN("_memory_usage",f__memory_usage,    tFunc(tNone,tMap(tStr,tInt)),OPT_EXTERNAL_DEPEND);    -  +  ADD_EFUN("_size_object",f__size_object, +  tFunc(tObj,tInt),OPT_EXTERNAL_DEPEND);    -  +     /* function(:int) */    ADD_EFUN("gc",f_gc,tFunc(tNone,tInt),OPT_SIDE_EFFECT);       /* function(:string) */    ADD_EFUN("version", f_version,tFunc(tNone,tStr), OPT_TRY_OPTIMIZE);       /* Note: The last argument to the encode and decode functions is    * intentionally not part of the prototype, to keep it free for    * other uses in the future. */       /* function(mixed,void|object:string) */    ADD_EFUN("encode_value", f_encode_value, -  tFunc(tMix tOr(tVoid,tObj),tStr), OPT_TRY_OPTIMIZE); +  tFunc(tMix tOr(tVoid,tObj),tStr8), OPT_TRY_OPTIMIZE);       /* function(mixed,void|object:string) */    ADD_EFUN("encode_value_canonic", f_encode_value_canonic, -  tFunc(tMix tOr(tVoid,tObj),tStr), OPT_TRY_OPTIMIZE); +  tFunc(tMix tOr(tVoid,tObj),tStr8), OPT_TRY_OPTIMIZE);       /* function(string,void|object:mixed) */    ADD_EFUN("decode_value", f_decode_value,    tFunc(tStr tOr(tVoid,tObj),tMix), OPT_TRY_OPTIMIZE);       /* function(object,string:int) */    ADD_EFUN("object_variablep", f_object_variablep,    tFunc(tObj tStr,tInt), OPT_EXTERNAL_DEPEND);       /* function(array(mapping(int:mixed)):array(int)) */    ADD_FUNCTION2("interleave_array", f_interleave_array,    tFunc(tArr(tMap(tInt, tMix)), tArr(tInt)), 0,    OPT_TRY_OPTIMIZE); -  +     /* function(array(0=mixed),array(1=mixed):array(array(array(0)|array(1))) */    ADD_FUNCTION2("diff", f_diff,    tFunc(tArr(tSetvar(0,tMix)) tArr(tSetvar(1,tMix)),    tArr(tArr(tOr(tArr(tVar(0)),tArr(tVar(1)))))), 0,    OPT_TRY_OPTIMIZE);    -  /* Generate the n:th permutation of the array given as the first argument */ -  ADD_FUNCTION2("permute", f_permute, tFunc(tArray tInt,tArray), 0, +  ADD_FUNCTION2("permute", f_permute, tFunc(tArray tIntPos,tArray), 0,    OPT_TRY_OPTIMIZE);       /* function(array,array:array(int)) */    ADD_FUNCTION2("diff_longest_sequence", f_diff_longest_sequence,    tFunc(tArray tArray,tArr(tInt)), 0, OPT_TRY_OPTIMIZE); -  +     /* function(array,array:array(int)) */    ADD_FUNCTION2("diff_dyn_longest_sequence", f_diff_dyn_longest_sequence,    tFunc(tArray tArray,tArr(tInt)), 0, OPT_TRY_OPTIMIZE); -  +     /* function(array,array:array(array)) */    ADD_FUNCTION2("diff_compare_table", f_diff_compare_table,    tFunc(tArray tArray, tArr(tArr(tInt))), 0, OPT_TRY_OPTIMIZE); -  +     /* function(array:array(int)) */    ADD_FUNCTION2("longest_ordered_sequence", f_longest_ordered_sequence,    tFunc(tArray,tArr(tInt)), 0, OPT_TRY_OPTIMIZE);      #define tMapStuff(IN,SUB,OUTFUN,OUTSET,OUTPROG,OUTMIX,OUTARR,OUTMAP) \    tOr6( tFuncV(IN tFuncV(SUB,tSetvar(0,tAnd(tMix,tZero)), \    tSetvar(2,tAny)),tVar(0), \    OUTFUN), \    tFuncV(IN tSet(tMix),tMix,OUTSET), \    tFuncV(IN tMap(tMix, tSetvar(2,tMix)), tMix, OUTMAP), \
pike.git/src/builtin_functions.c:9954:    tMap(tVar(3),tOr(tInt0,tVar(2)))),       tMapStuff(tSet(tSetvar(1,tMix)),tVar(1),    tSet(tVar(2)),    tSet(tInt01),    tSet(tObj),    tSet(tMix),    tSet(tArr(tMix)),    tSet(tOr(tInt0,tVar(2)))),    -  tMapStuff(tOr(tPrg(tObj),tFunction),tMix, +  tMapStuff(tAnd(tNot(tArray),tOr(tPrg(tObj),tFunction)),tMix,    tMap(tStr,tVar(2)),    tMap(tStr,tInt01),    tMap(tStr,tObj),    tMap(tStr,tMix),    tMap(tStr,tArr(tMix)),    tMap(tStr,tOr(tInt0,tVar(2)))),       tOr4( tFuncV(tString tFuncV(tInt,tMix,tInt),tMix,tString),    tFuncV(tString tFuncV(tInt,tMix,tInt),tMix,tString),    tFuncV(tString tSet(tMix),tMix,tString),
pike.git/src/builtin_functions.c:10008:    tFunc(tIntPos tInt tOr(tVoid,tInt),tArr(tInt)),    tFunc(tIntPos tFloat tOr3(tVoid,tInt,tFloat),tArr(tFloat)),    tFunc(tIntPos tOr(tInt,tFloat) tFloat,tArr(tFloat)),    tFunc(tIntPos tMix tObj,tArr(tVar(1))),    tFunc(tIntPos tObj tOr(tVoid,tMix),tArr(tVar(1))),    tFunc(tIntPos tMix tMix    tFuncV(tNone,tMix,tSetvar(1,tMix)),tArr(tVar(1)))),    OPT_TRY_OPTIMIZE);       ADD_FUNCTION2("inherit_list", f_inherit_list, -  tFunc(tOr(tObj,tPrg(tObj)),tArr(tPrg(tObj))), 0, OPT_TRY_OPTIMIZE); +  tFunc(tOr(tObj,tPrg(tObj)),tArr(tPrg(tObj))), 0, +  OPT_TRY_OPTIMIZE); +  +  ADD_FUNCTION2("program_identifier_defined", f_program_identifier_defined, +  tFunc(tOr(tObj,tPrg(tObj)) tString,tString), 0, +  OPT_TRY_OPTIMIZE); +     ADD_FUNCTION2("function_defined", f_function_defined,    tFunc(tFunction,tString), 0, OPT_TRY_OPTIMIZE);    - #ifdef DEBUG_MALLOC -  - /* function(void:void) */ -  ADD_EFUN("_reset_dmalloc",f__reset_dmalloc, -  tFunc(tVoid,tVoid),OPT_SIDE_EFFECT); -  ADD_EFUN("_dmalloc_set_name",f__dmalloc_set_name, -  tOr(tFunc(tStr tInt,tVoid), tFunc(tVoid,tVoid)),OPT_SIDE_EFFECT); -  ADD_EFUN("_list_open_fds",f__list_open_fds, -  tFunc(tVoid,tVoid),OPT_SIDE_EFFECT); -  ADD_EFUN("_dump_dmalloc_locations",f__dump_dmalloc_locations, -  tFunc(tSetvar(1,tMix),tVar(1)),OPT_SIDE_EFFECT); - #endif - #ifdef PIKE_DEBUG -  - /* function(1=mixed:1) */ -  ADD_EFUN("_locate_references",f__locate_references, -  tFunc(tSetvar(1,tMix),tVar(1)),OPT_SIDE_EFFECT); -  ADD_EFUN("_describe",f__describe, -  tFunc(tSetvar(1,tMix),tVar(1)),OPT_SIDE_EFFECT); -  ADD_EFUN("_gc_set_watch", f__gc_set_watch, -  tFunc(tComplex,tVoid), OPT_SIDE_EFFECT); -  ADD_EFUN("_dump_backlog", f__dump_backlog, -  tFunc(tNone,tVoid), OPT_SIDE_EFFECT); +     ADD_EFUN("_gdb_breakpoint", pike_gdb_breakpoint, -  tFuncV(tNone,tMix,tVoid), OPT_SIDE_EFFECT); - #endif +  tFunc(tNone,tVoid), OPT_SIDE_EFFECT);       ADD_EFUN("_gc_status",f__gc_status,    tFunc(tNone,tMap(tString,tOr(tInt,tFloat))),    OPT_EXTERNAL_DEPEND); -  +     ADD_FUNCTION ("implicit_gc_real_time", f_implicit_gc_real_time,    tFunc(tOr(tInt,tVoid),tInt), OPT_EXTERNAL_DEPEND); -  +     ADD_FUNCTION ("count_memory", f_count_memory,    tFuncV(tOr(tInt,tMap(tString,tInt)),    tOr8(tArray,tMultiset,tMapping,tObj,tPrg(tObj),    tString,tType(tMix),tInt),    tInt), 0);    -  +  ADD_FUNCTION("identify_cycle", f_identify_cycle, +  tFunc(tOr7(tArray,tMultiset,tMapping,tObj,tPrg(tObj), +  tString,tType(tMix)), +  tArr(tOr7(tArray,tMultiset,tMapping,tObj,tPrg(tObj), +  tString,tType(tMix)))), 0); +     ADD_INT_CONSTANT ("NATIVE_INT_MAX", MAX_INT_TYPE, 0);    ADD_INT_CONSTANT ("NATIVE_INT_MIN", MIN_INT_TYPE, 0);       /* Maybe make PIKEFLOAT_MANT_DIG, PIKEFLOAT_MIN_EXP and    * PIKEFLOAT_MAX_EXP available, but do we have to export FLT_RADIX    * too? It'd be nice to always assume it's 2 to save the pike    * programmer from that headache. */    ADD_INT_CONSTANT ("FLOAT_DIGITS_10", PIKEFLOAT_DIG, 0);    ADD_INT_CONSTANT ("FLOAT_MIN_10_EXP", PIKEFLOAT_MIN_10_EXP, 0);    ADD_INT_CONSTANT ("FLOAT_MAX_10_EXP", PIKEFLOAT_MAX_10_EXP, 0);
pike.git/src/builtin_functions.c:10078:    ADD_INT_CONSTANT("__LONG_DOUBLE_PRECISION_FLOAT__",1,0);   #else    ADD_INT_CONSTANT("__FLOAT_PRECISION_FLOAT__",1,0);   #endif   #endif       ADD_INT_CONSTANT ("DESTRUCT_EXPLICIT", DESTRUCT_EXPLICIT, 0);    ADD_INT_CONSTANT ("DESTRUCT_NO_REFS", DESTRUCT_NO_REFS, 0);    ADD_INT_CONSTANT ("DESTRUCT_GC", DESTRUCT_GC, 0);    ADD_INT_CONSTANT ("DESTRUCT_CLEANUP", DESTRUCT_CLEANUP, 0); +  +  ADD_INT_CONSTANT("LOWEST_COMPAT_MAJOR", LOWEST_COMPAT_MAJOR, 0); +  ADD_INT_CONSTANT("LOWEST_COMPAT_MINOR", LOWEST_COMPAT_MINOR, 0);   }      void exit_builtin_efuns(void)   {    free_callback_list(&memory_usage_callback);   }