pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:459:    rpos+=x;    lpos+=x;    n+=x;    }       return transpose(res);   }      //! Sort without respect to number formatting (most notably leading   //! zeroes). - int dwim_sort_func(string a, string b) + int(-1..1) dwim_sort_func(string a, string b)   {    if (a==b) return 0;    array aa=({}), bb=({});    int state, oi;       for( int i = 0; i<sizeof(a); i++ )    if( (<'0','1','2','3','4','5','6','7','8','9'>)[a[i]] != state )    {    state = !state;    if( state )
pike.git/lib/modules/Array.pmod:508:    for( int i = 0; i<sizeof( aa ); i++ )    {    if( i >= sizeof( bb ) ) return 1; // a is definately bigger.       if( aa[i] < bb[i] ) return -1;    if( aa[i] > bb[i] ) return 1;    }       // Either equal, or bb is longer.    -  return -(sizeof(aa)<sizeof(bb)); +  return [int(-1..1)]-(sizeof(aa)<sizeof(bb));   }      //! Sort comparison function that does not care about case, nor about   //! the contents of any parts of the string enclosed with '()'   //!   //! Example: "Foo (bar)" is given the same weight as "foo (really!)" - int lyskom_sort_func(string a,string b) + int(-1..1) lyskom_sort_func(string a,string b)   {    string a0=a,b0=b;    a=replace(lower_case(a),"][\\}{|"/1,"åäöåäö"/1);    b=replace(lower_case(b),"][\\}{|"/1,"åäöåäö"/1);       while (sscanf(a0=a,"%*[ \t](%*[^)])%*[ \t]%s",a)==4 && a0!=a);    while (sscanf(b0=b,"%*[ \t](%*[^)])%*[ \t]%s",b)==4 && b0!=b);    a0=b0="";    sscanf(a,"%[^ \t]%*[ \t](%*[^)])%*[ \t]%s",a,a0);    sscanf(b,"%[^ \t]%*[ \t](%*[^)])%*[ \t]%s",b,b0);    if (a>b) return 1; -  if (a<b) return 0; +  if (a<b) return -1;    if (a0==b0) return 0;    return lyskom_sort_func(a0,b0);   }      //! Flatten a multi-dimensional array to a one-dimensional array.   //! @note   //! Prior to Pike 7.5.7 it was not safe to call this function   //! with cyclic data-structures.   array flatten(array a, mapping(array:array)|void state)   {    if (state && state[a]) return state[a];    if (!state) state = ([a:({})]);    else state[a] = ({});    array res = allocate(sizeof(a));    foreach(a; int i; mixed b) {    res[i] = arrayp(b)?flatten([array]b, state):({b});    }    return state[a] = (res*({}));   }    - //! Sum the elements of an array using `+ + //! Sum the elements of an array using `+. The empty array + //! results in 0.   mixed sum(array a)   {    if(a==({})) return 0;    // 1000 is a safe stack limit    if (sizeof(a)<1000)    return `+(@a);    else    {    mixed mem=`+(@a[..999]);    int j=1000;