| 101 | } |
| 102 | |
| 103 | void GridFormat(BString<32>& buffer, RString format, int i) |
| 104 | { |
| 105 | const char* first = nullptr; |
| 106 | for (const char* p = format; *p != 0; p++) |
| 107 | { |
| 108 | if (isalnum(*p)) |
| 109 | { |
| 110 | first = p; |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | if (!first) |
| 115 | { |
| 116 | return; |
| 117 | } |
| 118 | BString<32> revert; |
| 119 | int cf = 0; |
| 120 | const char* p; |
| 121 | for (p = format + format.GetLength() - 1; p != first; p--) |
| 122 | { |
| 123 | if (*p >= '0' && *p <= '9') |
| 124 | { |
| 125 | int m = Modulo(i, 10) + cf + *p - '0'; |
| 126 | int cf = m; |
| 127 | m = Modulo(cf, 10); |
| 128 | AddChar(revert, '0' + m); |
| 129 | } |
| 130 | else if (*p >= 'A' && *p <= 'J') |
| 131 | { |
| 132 | int m = Modulo(i, 10) + cf + *p - 'A'; |
| 133 | int cf = m; |
| 134 | m = Modulo(cf, 10); |
| 135 | AddChar(revert, 'A' + m); |
| 136 | } |
| 137 | else if (*p >= 'a' && *p <= 'j') |
| 138 | { |
| 139 | int m = Modulo(i, 10) + cf + *p - 'a'; |
| 140 | int cf = m; |
| 141 | m = Modulo(cf, 10); |
| 142 | AddChar(revert, 'a' + m); |
| 143 | } |
| 144 | else |
| 145 | { |
| 146 | AddChar(revert, *p); |
| 147 | } |
| 148 | } |
| 149 | if (*p >= '0' && *p <= '9') |
| 150 | { |
| 151 | int m = Modulo(i, 10) + cf + *p - '0'; |
| 152 | int cf = m; |
| 153 | m = Modulo(cf, 10); |
| 154 | AddChar(revert, '0' + m); |
| 155 | } |
| 156 | else if (*p >= 'A' && *p <= 'Z') |
| 157 | { |
| 158 | int m = Modulo(i, 26) + cf + *p - 'A'; |
| 159 | int cf = m; |
| 160 | m = Modulo(cf, 26); |
no test coverage detected