pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:464:   int 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( i ) +     if( state )    aa += ({ a[oi..i-1] });    else    aa += ({ (int)a[oi..i-1] });    oi = i;    }    if( state )    aa += ({ (int)a[oi..] });    else    aa += ({ a[oi..] });          oi = state = 0;       for( int i = 0; i<sizeof(b); i++ )    if( (<'0','1','2','3','4','5','6','7','8','9'>)[b[i]] != state )    {    state = !state; -  if( i ) +     if( state )    bb += ({ b[oi..i-1] });    else    bb += ({ (int)b[oi..i-1] });    oi = i;    }    if( state )    bb += ({ (int)b[oi..] });    else    bb += ({ b[oi..] });       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;    }    -  return 0; +  // Either equal, or bb is longer. +  +  return -(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)   {    string a0=a,b0=b;    a=replace(lower_case(a),"][\\}{|"/1,"åäöåäö"/1);