diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-18 16:30:30 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-18 16:30:30 -0800 |
commit | 9992b8eb0e3366ff8a3948aa0b66a19c3c12c737 (patch) | |
tree | 6dda0fef85812016fbba9ea067c9d586092b506d /util.cpp | |
parent | bab69f26724028d16054a3daf5c78aad7c67bb2d (diff) |
Apply new indentation, brace, and whitespace style
Diffstat (limited to 'util.cpp')
-rw-r--r-- | util.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
@@ -47,81 +47,81 @@ */ #define SB_MAX_SIZE (128*1024*1024) -int wcsfilecmp( const wchar_t *a, const wchar_t *b ) +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; - } - - long secondary_diff=0; - if( iswdigit( *a ) && iswdigit( *b ) ) - { - wchar_t *aend, *bend; - long al; - long bl; - long diff; - - errno = 0; - al = wcstol( a, &aend, 10 ); - bl = wcstol( b, &bend, 10 ); - - if( errno ) + CHECK(a, 0); + CHECK(b, 0); + + if (*a==0) + { + if (*b==0) + return 0; + return -1; + } + if (*b==0) + { + return 1; + } + + long secondary_diff=0; + if (iswdigit(*a) && iswdigit(*b)) { - /* - Huuuuuuuuge numbers - fall back to regular string comparison - */ - return wcscmp( a, b ); + wchar_t *aend, *bend; + long al; + long bl; + long diff; + + errno = 0; + al = wcstol(a, &aend, 10); + bl = wcstol(b, &bend, 10); + + if (errno) + { + /* + Huuuuuuuuge numbers - fall back to regular string comparison + */ + return wcscmp(a, b); + } + + diff = al - bl; + if (diff) + return diff > 0 ? 2 : -2; + + secondary_diff = (aend-a) - (bend-b); + + a=aend-1; + b=bend-1; } + else + { + int diff = towlower(*a) - towlower(*b); + if (diff != 0) + return (diff>0)?2:-2; + + secondary_diff = *a-*b; + } + + int res = wcsfilecmp(a+1, b+1); - diff = al - bl; - if( diff ) - return diff > 0 ? 2 : -2; - - secondary_diff = (aend-a) - (bend-b); - - a=aend-1; - b=bend-1; - } - else - { - int diff = towlower(*a) - towlower(*b); - if( diff != 0 ) - return (diff>0)?2:-2; - - 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 ) + if (abs(res) < 2) { - return secondary_diff > 0 ? 1 :-1; + /* + 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; + 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; } |