| 98 | |
| 99 | |
| 100 | static S32 |
| 101 | compare_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 | |
| 130 | static int |
no test coverage detected