| 183 | }; |
| 184 | |
| 185 | void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding) |
| 186 | { |
| 187 | assert(now); |
| 188 | |
| 189 | // Do nothing if the tabsize is 0. |
| 190 | if (tabsize < 1) |
| 191 | { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | // Get the current row, column. |
| 196 | int row = cursor.row; |
| 197 | int col = cursor.col; |
| 198 | const char* p = stamp; |
| 199 | assert(p); |
| 200 | |
| 201 | while (p < now) |
| 202 | { |
| 203 | // Treat p as unsigned, so we have a happy compiler. |
| 204 | const unsigned char* pU = (const unsigned char*)p; |
| 205 | |
| 206 | // Code contributed by Fletcher Dunn: (modified by lee) |
| 207 | switch (*pU) |
| 208 | { |
| 209 | case 0: |
| 210 | // We *should* never get here, but in case we do, don't |
| 211 | // advance past the terminating null character, ever |
| 212 | return; |
| 213 | |
| 214 | case '\r': |
| 215 | // bump down to the next line |
| 216 | ++row; |
| 217 | col = 0; |
| 218 | // Eat the character |
| 219 | ++p; |
| 220 | |
| 221 | // Check for \r\n sequence, and treat this as a single character |
| 222 | if (*p == '\n') |
| 223 | { |
| 224 | ++p; |
| 225 | } |
| 226 | break; |
| 227 | |
| 228 | case '\n': |
| 229 | // bump down to the next line |
| 230 | ++row; |
| 231 | col = 0; |
| 232 | |
| 233 | // Eat the character |
| 234 | ++p; |
| 235 | |
| 236 | // Check for \n\r sequence, and treat this as a single |
| 237 | // character. (Yes, this bizarre thing does occur still |
| 238 | // on some arcane platforms...) |
| 239 | if (*p == '\r') |
| 240 | { |
| 241 | ++p; |
| 242 | } |