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