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