| 436 | } |
| 437 | |
| 438 | const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) |
| 439 | { |
| 440 | // Presume an entity, and pull it out. |
| 441 | TIXML_STRING ent; |
| 442 | int i; |
| 443 | *length = 0; |
| 444 | |
| 445 | if ( *(p+1) && *(p+1) == '#' && *(p+2) ) |
| 446 | { |
| 447 | unsigned long ucs = 0; |
| 448 | ptrdiff_t delta = 0; |
| 449 | unsigned mult = 1; |
| 450 | |
| 451 | if ( *(p+2) == 'x' ) |
| 452 | { |
| 453 | // Hexadecimal. |
| 454 | if ( !*(p+3) ) return 0; |
| 455 | |
| 456 | const char* q = p+3; |
| 457 | q = strchr( q, ';' ); |
| 458 | |
| 459 | if ( !q || !*q ) return 0; |
| 460 | |
| 461 | delta = q-p; |
| 462 | --q; |
| 463 | |
| 464 | while ( *q != 'x' ) |
| 465 | { |
| 466 | if ( *q >= '0' && *q <= '9' ) |
| 467 | ucs += mult * (*q - '0'); |
| 468 | else if ( *q >= 'a' && *q <= 'f' ) |
| 469 | ucs += mult * (*q - 'a' + 10); |
| 470 | else if ( *q >= 'A' && *q <= 'F' ) |
| 471 | ucs += mult * (*q - 'A' + 10 ); |
| 472 | else |
| 473 | return 0; |
| 474 | mult *= 16; |
| 475 | --q; |
| 476 | } |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | // Decimal. |
| 481 | if ( !*(p+2) ) return 0; |
| 482 | |
| 483 | const char* q = p+2; |
| 484 | q = strchr( q, ';' ); |
| 485 | |
| 486 | if ( !q || !*q ) return 0; |
| 487 | |
| 488 | delta = q-p; |
| 489 | --q; |
| 490 | |
| 491 | while ( *q != '#' ) |
| 492 | { |
| 493 | if ( *q >= '0' && *q <= '9' ) |
| 494 | ucs += mult * (*q - '0'); |
| 495 | else |
nothing calls this directly
no outgoing calls
no test coverage detected