MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / compare_right

Function compare_right

Engine/source/core/strings/stringFunctions.cpp:100–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99
100static S32
101compare_right(const nat_char* a, const nat_char* b)
102{
103 S32 bias = 0;
104
105 /* The longest run of digits wins. That aside, the greatest
106 value wins, but we can't know that it will until we've scanned
107 both numbers to know that they have the same magnitude, so we
108 remember it in BIAS. */
109 for (;; a++, b++) {
110 if (!nat_isdigit(*a) && !nat_isdigit(*b))
111 break;
112 else if (!nat_isdigit(*a))
113 return -1;
114 else if (!nat_isdigit(*b))
115 return +1;
116 else if (*a < *b) {
117 if (!bias)
118 bias = -1;
119 } else if (*a > *b) {
120 if (!bias)
121 bias = +1;
122 } else if (!*a && !*b)
123 return bias;
124 }
125
126 return bias;
127}
128
129
130static int

Callers 1

strnatcmp0Function · 0.85

Calls 1

nat_isdigitFunction · 0.85

Tested by

no test coverage detected