Skip to content
Snippets Groups Projects
Commit 99453faa authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: adjusted comments in natstrcmp

parent b8f0823d
Branches
Tags
1 merge request!157Style list methods
...@@ -56,11 +56,6 @@ Changes for OpenFOAM ...@@ -56,11 +56,6 @@ Changes for OpenFOAM
// - normally do not want this (Mark Olesen: Oct-2017) // - normally do not want this (Mark Olesen: Oct-2017)
#undef DIGITS_ALWAYS_FIRST #undef DIGITS_ALWAYS_FIRST
// [IGNORE_LEADING_ZEROS] : as per original code
// This results in "file0005.txt" sorting before "file06.txt"
// -> normally want this (Mark Olesen: Oct-2017)
#define IGNORE_LEADING_ZEROS
// [MANUAL_NUMCOMPARE] : handwritten code instead of strncmp // [MANUAL_NUMCOMPARE] : handwritten code instead of strncmp
// The orignal code has a mix of strncmp for equality but handwritten code // The orignal code has a mix of strncmp for equality but handwritten code
// for greater-than/less-than. // for greater-than/less-than.
...@@ -204,23 +199,27 @@ int Foam::stringOps::natstrcmp(const char* s1, const char* s2) ...@@ -204,23 +199,27 @@ int Foam::stringOps::natstrcmp(const char* s1, const char* s2)
{ {
state = NUMERIC; state = NUMERIC;
#ifdef IGNORE_LEADING_ZEROS // State changed from SCAN to NUMERIC, so skip leading
if (!zeros1) // Start skip of leading zeros // leading zeros so the numeric comparison is
// untainted by them, but capture the first occurrence
// of leading zeroes for a final tie-break if needed.
if (!zeros1)
{ {
// First occurrence of any leading zeroes
while (*p1 == '0') { ++p1; ++zeros1; } while (*p1 == '0') { ++p1; ++zeros1; }
} }
else else
#endif
{ {
while (*p1 == '0') { ++p1; } while (*p1 == '0') { ++p1; }
} }
#ifdef IGNORE_LEADING_ZEROS
if (!zeros2) // Start skip of leading zeros if (!zeros2)
{ {
// First occurrence of any leading zeroes
while (*p2 == '0') { ++p2; ++zeros2; } while (*p2 == '0') { ++p2; ++zeros2; }
} }
else else
#endif
{ {
while (*p2 == '0') { ++p2; } while (*p2 == '0') { ++p2; }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment