MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlValidateNMToken

Function xmlValidateNMToken

ThirdParty/libxml2/vtklibxml2/tree.c:599–659  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

597 * and -1 in case of internal or API error.
598 */
599int
600xmlValidateNMToken(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
628try_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)

Callers 1

xmlSchemaValAtomicTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected