Remove trailing whitespaces and change tabs to spaces

This commit is contained in:
Łukasz Niemier
2012-11-18 11:23:22 +01:00
parent b79854ad1a
commit 47df1ae40a
140 changed files with 29549 additions and 29549 deletions

128
util.cpp
View File

@@ -1,7 +1,7 @@
/** \file util.c
Generic utilities library.
Generic utilities library.
Contains datastructures such as automatically growing array lists, priority queues, etc.
Contains datastructures such as automatically growing array lists, priority queues, etc.
*/
#include "config.h"
@@ -49,79 +49,79 @@
int wcsfilecmp( const wchar_t *a, const wchar_t *b )
{
CHECK( a, 0 );
CHECK( b, 0 );
if( *a==0 )
{
if( *b==0)
return 0;
return -1;
}
if( *b==0 )
{
return 1;
}
CHECK( a, 0 );
CHECK( b, 0 );
long secondary_diff=0;
if( iswdigit( *a ) && iswdigit( *b ) )
{
wchar_t *aend, *bend;
long al;
long bl;
long diff;
if( *a==0 )
{
if( *b==0)
return 0;
return -1;
}
if( *b==0 )
{
return 1;
}
errno = 0;
al = wcstol( a, &aend, 10 );
bl = wcstol( b, &bend, 10 );
long secondary_diff=0;
if( iswdigit( *a ) && iswdigit( *b ) )
{
wchar_t *aend, *bend;
long al;
long bl;
long diff;
if( errno )
{
/*
Huuuuuuuuge numbers - fall back to regular string comparison
*/
return wcscmp( a, b );
}
diff = al - bl;
if( diff )
return diff > 0 ? 2 : -2;
errno = 0;
al = wcstol( a, &aend, 10 );
bl = wcstol( b, &bend, 10 );
secondary_diff = (aend-a) - (bend-b);
if( errno )
{
/*
Huuuuuuuuge numbers - fall back to regular string comparison
*/
return wcscmp( a, b );
}
a=aend-1;
b=bend-1;
}
else
{
int diff = towlower(*a) - towlower(*b);
if( diff != 0 )
return (diff>0)?2:-2;
diff = al - bl;
if( diff )
return diff > 0 ? 2 : -2;
secondary_diff = *a-*b;
}
secondary_diff = (aend-a) - (bend-b);
int res = wcsfilecmp( a+1, b+1 );
a=aend-1;
b=bend-1;
}
else
{
int diff = towlower(*a) - towlower(*b);
if( diff != 0 )
return (diff>0)?2:-2;
if( abs(res) < 2 )
{
/*
No primary difference in rest of string.
Use secondary difference on this element if found.
*/
if( secondary_diff )
{
return secondary_diff > 0 ? 1 :-1;
}
}
return res;
secondary_diff = *a-*b;
}
int res = wcsfilecmp( a+1, b+1 );
if( abs(res) < 2 )
{
/*
No primary difference in rest of string.
Use secondary difference on this element if found.
*/
if( secondary_diff )
{
return secondary_diff > 0 ? 1 :-1;
}
}
return res;
}
long long get_time()
{
struct timeval time_struct;
gettimeofday( &time_struct, 0 );
return 1000000ll*time_struct.tv_sec+time_struct.tv_usec;
struct timeval time_struct;
gettimeofday( &time_struct, 0 );
return 1000000ll*time_struct.tv_sec+time_struct.tv_usec;
}