Some improvements/simplifications in strnatcmp() function.

This commit is contained in:
LoRd_MuldeR 2013-08-25 15:34:41 +02:00
parent df103af706
commit 6d6f0ee943
3 changed files with 16 additions and 10 deletions

View File

@ -26,11 +26,12 @@ a:visited { color: #0000EE; }
<li>Updated MediaInfo to v0.7.64 (2013-07-05), compiled with ICL 13.1 and MSVC 10.0 <li>Updated MediaInfo to v0.7.64 (2013-07-05), compiled with ICL 13.1 and MSVC 10.0
<li>Updated GnuPG to v1.4.14 (2013-07-25), compiled with GCC 4.8.1 <li>Updated GnuPG to v1.4.14 (2013-07-25), compiled with GCC 4.8.1
<li>Updated GNU Wget binary to v1.13.4 (2011-09-17) <li>Updated GNU Wget binary to v1.13.4 (2011-09-17)
<li>Updated language files (big thank-you to all contributors !!!)
<li>Fixed a potential deadlock during startup when %TMP% points to an invalid folder <li>Fixed a potential deadlock during startup when %TMP% points to an invalid folder
<li>Fixed a superfluous "beep" sound that appeared on application startup <li>Fixed a superfluous "beep" sound that appeared on application startup
<li>Fixed the Ogg Vorbis quality modes "-1" and "-2" (those were clipped to "0" before) <li>Fixed the Ogg Vorbis quality modes "-1" and "-2" (those were clipped to "0" before)
<li>Fixed a bug that could cause the output directory to be reset mistakenly <li>Fixed a bug that could cause the output directory to be reset mistakenly
<li>Implemented "natural ordering" for sorting input files, using strnatcmp() by Martin Pool <li>Implemented "natural order" string comparison/sorting, using strnatcmp() by Martin Pool
</ul><br> </ul><br>
<a name="4.07"></a>Changes between v4.06 and v4.07 [2013-04-28]:<br><ul> <a name="4.07"></a>Changes between v4.06 and v4.07 [2013-04-28]:<br><ul>

View File

@ -59,6 +59,7 @@ static inline nat_char nat_isdecpoint(nat_char a)
{ {
return (a == L'.') || (a == L','); return (a == L'.') || (a == L',');
} }
static inline nat_char nat_toupper(nat_char a) static inline nat_char nat_toupper(nat_char a)
{ {
return towupper(a); return towupper(a);
@ -123,12 +124,12 @@ static int strnatcmp0(nat_char const *a, nat_char const *b, const bool fold_case
int ai, bi; int ai, bi;
nat_char ca, cb; nat_char ca, cb;
int result; int result;
bool fractional, skip_zeros; bool fractional;
int sa, sb; int sa, sb;
assert(a && b); assert(a && b);
ai = bi = 0; ai = bi = 0;
skip_zeros = true; fractional = false;
while (1) while (1)
{ {
@ -146,14 +147,18 @@ static int strnatcmp0(nat_char const *a, nat_char const *b, const bool fold_case
{ {
sa = sb = 0; sa = sb = 0;
if(skip_zeros) if(!fractional)
{ {
while (ca == L'0') { ca = a[++ai]; sa++; } while (ca == L'0')
while (cb == L'0') { cb = b[++bi]; sb++; } {
ca = a[++ai]; sa++;
}
while (cb == L'0')
{
cb = b[++bi]; sb++;
}
} }
fractional = (ca == L'0' || cb == L'0');
if (fractional) if (fractional)
{ {
if ((result = compare_left(a+ai, b+bi)) != 0) if ((result = compare_left(a+ai, b+bi)) != 0)
@ -191,7 +196,7 @@ static int strnatcmp0(nat_char const *a, nat_char const *b, const bool fold_case
return +1; return +1;
/* skipp leading zero's, unless previously seen char was a decimal point */ /* skipp leading zero's, unless previously seen char was a decimal point */
skip_zeros = (!nat_isdecpoint(ca)) || (!nat_isdecpoint(cb)); fractional = nat_isdecpoint(ca) && nat_isdecpoint(cb);
++ai; ++bi; ++ai; ++bi;
} }

View File

@ -34,7 +34,7 @@
#define VER_LAMEXP_MINOR_LO 8 #define VER_LAMEXP_MINOR_LO 8
#define VER_LAMEXP_TYPE RC #define VER_LAMEXP_TYPE RC
#define VER_LAMEXP_PATCH 2 #define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 1333 #define VER_LAMEXP_BUILD 1336
#define VER_LAMEXP_CONFG 1288 #define VER_LAMEXP_CONFG 1288
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////