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

Function xmlValidateName

ThirdParty/libxml2/vtklibxml2/tree.c:530–587  ·  view source on GitHub ↗

* xmlValidateName: * @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 Name * * 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

528 * and -1 in case of internal or API error.
529 */
530int
531xmlValidateName(const xmlChar *value, int space) {
532 const xmlChar *cur = value;
533 int c,l;
534
535 if (value == NULL)
536 return(-1);
537 /*
538 * First quick algorithm for ASCII range
539 */
540 if (space)
541 while (IS_BLANK_CH(*cur)) cur++;
542 if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
543 (*cur == '_') || (*cur == ':'))
544 cur++;
545 else
546 goto try_complex;
547 while (((*cur >= 'a') && (*cur <= 'z')) ||
548 ((*cur >= 'A') && (*cur <= 'Z')) ||
549 ((*cur >= '0') && (*cur <= '9')) ||
550 (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
551 cur++;
552 if (space)
553 while (IS_BLANK_CH(*cur)) cur++;
554 if (*cur == 0)
555 return(0);
556
557try_complex:
558 /*
559 * Second check for chars outside the ASCII range
560 */
561 cur = value;
562 c = CUR_SCHAR(cur, l);
563 if (space) {
564 while (IS_BLANK(c)) {
565 cur += l;
566 c = CUR_SCHAR(cur, l);
567 }
568 }
569 if ((!IS_LETTER(c)) && (c != '_') && (c != ':'))
570 return(1);
571 cur += l;
572 c = CUR_SCHAR(cur, l);
573 while (IS_LETTER(c) || IS_DIGIT(c) || (c == '.') || (c == ':') ||
574 (c == '-') || (c == '_') || IS_COMBINING(c) || IS_EXTENDER(c)) {
575 cur += l;
576 c = CUR_SCHAR(cur, l);
577 }
578 if (space) {
579 while (IS_BLANK(c)) {
580 cur += l;
581 c = CUR_SCHAR(cur, l);
582 }
583 }
584 if (c != 0)
585 return(1);
586 return(0);
587}

Callers 2

xmlSchemaValAtomicTypeFunction · 0.85
xmlCtxtCheckNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected