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