* xmlValidateNMToken: * @value: the value to check * @space: allow spaces in front and end of the string * * Check that a value conforms to the lexical space of NMToken * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API error. */
| 597 | * and -1 in case of internal or API error. |
| 598 | */ |
| 599 | int |
| 600 | xmlValidateNMToken(const xmlChar *value, int space) { |
| 601 | const xmlChar *cur = value; |
| 602 | int c,l; |
| 603 | |
| 604 | if (value == NULL) |
| 605 | return(-1); |
| 606 | /* |
| 607 | * First quick algorithm for ASCII range |
| 608 | */ |
| 609 | if (space) |
| 610 | while (IS_BLANK_CH(*cur)) cur++; |
| 611 | if (((*cur >= 'a') && (*cur <= 'z')) || |
| 612 | ((*cur >= 'A') && (*cur <= 'Z')) || |
| 613 | ((*cur >= '0') && (*cur <= '9')) || |
| 614 | (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) |
| 615 | cur++; |
| 616 | else |
| 617 | goto try_complex; |
| 618 | while (((*cur >= 'a') && (*cur <= 'z')) || |
| 619 | ((*cur >= 'A') && (*cur <= 'Z')) || |
| 620 | ((*cur >= '0') && (*cur <= '9')) || |
| 621 | (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':')) |
| 622 | cur++; |
| 623 | if (space) |
| 624 | while (IS_BLANK_CH(*cur)) cur++; |
| 625 | if (*cur == 0) |
| 626 | return(0); |
| 627 | |
| 628 | try_complex: |
| 629 | /* |
| 630 | * Second check for chars outside the ASCII range |
| 631 | */ |
| 632 | cur = value; |
| 633 | c = CUR_SCHAR(cur, l); |
| 634 | if (space) { |
| 635 | while (IS_BLANK(c)) { |
| 636 | cur += l; |
| 637 | c = CUR_SCHAR(cur, l); |
| 638 | } |
| 639 | } |
| 640 | if (!(IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || |
| 641 | (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c))) |
| 642 | return(1); |
| 643 | cur += l; |
| 644 | c = CUR_SCHAR(cur, l); |
| 645 | while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') || |
| 646 | (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) { |
| 647 | cur += l; |
| 648 | c = CUR_SCHAR(cur, l); |
| 649 | } |
| 650 | if (space) { |
| 651 | while (IS_BLANK(c)) { |
| 652 | cur += l; |
| 653 | c = CUR_SCHAR(cur, l); |
| 654 | } |
| 655 | } |
| 656 | if (c != 0) |
no outgoing calls
no test coverage detected