svn path=/trunk/playground/utils/dolphin/; revision=623878
//
// The longest run of digits wins. That aside, the greatest
// value wins, but we can't know that it will until we've scanned
//
// The longest run of digits wins. That aside, the greatest
// value wins, but we can't know that it will until we've scanned
- // both numbers to know that they have the same magnitude, so we
- // remember the values in 'valueA' and 'valueB'.
-
- int valueA = 0;
- int valueB = 0;
+ // both numbers to know that they have the same magnitude.
while (1) {
if (!currA->isDigit() && !currB->isDigit()) {
while (1) {
if (!currA->isDigit() && !currB->isDigit()) {
- if (valueA != valueB) {
- return valueA - valueB;
+ if (weight != 0) {
+ return weight;
else if (!currB->isDigit()) {
return +1;
}
else if (!currB->isDigit()) {
return +1;
}
- else {
- valueA = (valueA * 10) + currA->digitValue();
- valueB = (valueB * 10) + currB->digitValue();
+ else if ((*currA < *currB) && (weight == 0)) {
+ weight = -1;
+ }
+ else if ((*currA > *currB) && (weight == 0)) {
+ weight = +1;