diff --git a/src/utils/smallut.cpp b/src/utils/smallut.cpp index f91c6352..469c969f 100644 --- a/src/utils/smallut.cpp +++ b/src/utils/smallut.cpp @@ -57,7 +57,7 @@ int stringicmp(const string & s1, const string& s2) int size1 = s1.length(), size2 = s2.length(); char c1, c2; - if (size1 > size2) { + if (size1 < size2) { while (it1 != s1.end()) { c1 = ::toupper(*it1); c2 = ::toupper(*it2); @@ -66,7 +66,7 @@ int stringicmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : 1; + return size1 == size2 ? 0 : -1; } else { while (it2 != s2.end()) { c1 = ::toupper(*it1); @@ -76,7 +76,7 @@ int stringicmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : -1; + return size1 == size2 ? 0 : 1; } } void stringtolower(string& io) @@ -117,7 +117,7 @@ int stringlowercmp(const string & s1, const string& s2) int size1 = s1.length(), size2 = s2.length(); char c2; - if (size1 > size2) { + if (size1 < size2) { while (it1 != s1.end()) { c2 = ::tolower(*it2); if (*it1 != c2) { @@ -125,7 +125,7 @@ int stringlowercmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : 1; + return size1 == size2 ? 0 : -1; } else { while (it2 != s2.end()) { c2 = ::tolower(*it2); @@ -134,7 +134,7 @@ int stringlowercmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : -1; + return size1 == size2 ? 0 : 1; } } @@ -146,7 +146,7 @@ int stringuppercmp(const string & s1, const string& s2) int size1 = s1.length(), size2 = s2.length(); char c2; - if (size1 > size2) { + if (size1 < size2) { while (it1 != s1.end()) { c2 = ::toupper(*it2); if (*it1 != c2) { @@ -154,7 +154,7 @@ int stringuppercmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : 1; + return size1 == size2 ? 0 : -1; } else { while (it2 != s2.end()) { c2 = ::toupper(*it2); @@ -163,7 +163,7 @@ int stringuppercmp(const string & s1, const string& s2) } ++it1; ++it2; } - return size1 == size2 ? 0 : -1; + return size1 == size2 ? 0 : 1; } } @@ -708,73 +708,73 @@ typedef int clockid_t; #undef USE_CLOCK_GETTIME #endif -#ifdef WIN32 -#include "safewindows.h" -// Note: struct timespec is defined by pthread.h (from pthreads-w32) -#ifndef CLOCK_REALTIME -#define CLOCK_REALTIME 0 -#endif - -LARGE_INTEGER getFILETIMEoffset() -{ - SYSTEMTIME s; - FILETIME f; - LARGE_INTEGER t; - - s.wYear = 1970; - s.wMonth = 1; - s.wDay = 1; - s.wHour = 0; - s.wMinute = 0; - s.wSecond = 0; - s.wMilliseconds = 0; - SystemTimeToFileTime(&s, &f); - t.QuadPart = f.dwHighDateTime; - t.QuadPart <<= 32; - t.QuadPart |= f.dwLowDateTime; - return (t); -} - -int clock_gettime(int X, struct timespec *tv) -{ - LARGE_INTEGER t; - FILETIME f; - double microseconds; - static LARGE_INTEGER offset; - static double frequencyToMicroseconds; - static int initialized = 0; - static BOOL usePerformanceCounter = 0; - - if (!initialized) { - LARGE_INTEGER performanceFrequency; - initialized = 1; - usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency); - if (usePerformanceCounter) { - QueryPerformanceCounter(&offset); - frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.; - } - else { - offset = getFILETIMEoffset(); - frequencyToMicroseconds = 10.; - } - } - if (usePerformanceCounter) QueryPerformanceCounter(&t); - else { - GetSystemTimeAsFileTime(&f); - t.QuadPart = f.dwHighDateTime; - t.QuadPart <<= 32; - t.QuadPart |= f.dwLowDateTime; - } - - t.QuadPart -= offset.QuadPart; - microseconds = (double)t.QuadPart / frequencyToMicroseconds; - t.QuadPart = (long long)microseconds; - tv->tv_sec = t.QuadPart / 1000000; - tv->tv_nsec = (t.QuadPart % 1000000) * 1000; - return (0); -} -#define USE_CLOCK_GETTIME -#else /* -> !_WIN32 */ +#ifdef WIN32 +#include "safewindows.h" +// Note: struct timespec is defined by pthread.h (from pthreads-w32) +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#endif + +LARGE_INTEGER getFILETIMEoffset() +{ + SYSTEMTIME s; + FILETIME f; + LARGE_INTEGER t; + + s.wYear = 1970; + s.wMonth = 1; + s.wDay = 1; + s.wHour = 0; + s.wMinute = 0; + s.wSecond = 0; + s.wMilliseconds = 0; + SystemTimeToFileTime(&s, &f); + t.QuadPart = f.dwHighDateTime; + t.QuadPart <<= 32; + t.QuadPart |= f.dwLowDateTime; + return (t); +} + +int clock_gettime(int X, struct timespec *tv) +{ + LARGE_INTEGER t; + FILETIME f; + double microseconds; + static LARGE_INTEGER offset; + static double frequencyToMicroseconds; + static int initialized = 0; + static BOOL usePerformanceCounter = 0; + + if (!initialized) { + LARGE_INTEGER performanceFrequency; + initialized = 1; + usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency); + if (usePerformanceCounter) { + QueryPerformanceCounter(&offset); + frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.; + } + else { + offset = getFILETIMEoffset(); + frequencyToMicroseconds = 10.; + } + } + if (usePerformanceCounter) QueryPerformanceCounter(&t); + else { + GetSystemTimeAsFileTime(&f); + t.QuadPart = f.dwHighDateTime; + t.QuadPart <<= 32; + t.QuadPart |= f.dwLowDateTime; + } + + t.QuadPart -= offset.QuadPart; + microseconds = (double)t.QuadPart / frequencyToMicroseconds; + t.QuadPart = (long long)microseconds; + tv->tv_sec = t.QuadPart / 1000000; + tv->tv_nsec = (t.QuadPart % 1000000) * 1000; + return (0); +} +#define USE_CLOCK_GETTIME +#else /* -> !_WIN32 */ #ifndef USE_CLOCK_GETTIME #include