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

Function xmlSchemaValidateDates

ThirdParty/libxml2/vtklibxml2/xmlschemastypes.c:1778–1987  ·  view source on GitHub ↗

* xmlSchemaValidateDates: * @type: the expected type or XML_SCHEMAS_UNKNOWN * @dateTime: string to analyze * @val: the return computed value * * Check that @dateTime conforms to the lexical space of one of the date types. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise * and -1 in case of internal or API

Source from the content-addressed store, hash-verified

1776 * and -1 in case of internal or API error.
1777 */
1778static int
1779xmlSchemaValidateDates (xmlSchemaValType type,
1780 const xmlChar *dateTime, xmlSchemaValPtr *val,
1781 int collapse) {
1782 xmlSchemaValPtr dt;
1783 int ret;
1784 const xmlChar *cur = dateTime;
1785
1786#define RETURN_TYPE_IF_VALID(t) \
1787 if (IS_TZO_CHAR(*cur)) { \
1788 ret = _xmlSchemaParseTimeZone(&(dt->value.date), &cur); \
1789 if (ret == 0) { \
1790 if (*cur != 0) \
1791 goto error; \
1792 dt->type = t; \
1793 goto done; \
1794 } \
1795 }
1796
1797 if (dateTime == NULL)
1798 return -1;
1799
1800 if (collapse)
1801 while IS_WSP_BLANK_CH(*cur) cur++;
1802
1803 if ((*cur != '-') && (*cur < '0') && (*cur > '9'))
1804 return 1;
1805
1806 dt = xmlSchemaNewValue(XML_SCHEMAS_UNKNOWN);
1807 if (dt == NULL)
1808 return -1;
1809
1810 if ((cur[0] == '-') && (cur[1] == '-')) {
1811 /*
1812 * It's an incomplete date (xs:gMonthDay, xs:gMonth or
1813 * xs:gDay)
1814 */
1815 cur += 2;
1816
1817 /* is it an xs:gDay? */
1818 if (*cur == '-') {
1819 if (type == XML_SCHEMAS_GMONTH)
1820 goto error;
1821 ++cur;
1822 ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
1823 if (ret != 0)
1824 goto error;
1825
1826 RETURN_TYPE_IF_VALID(XML_SCHEMAS_GDAY);
1827
1828 goto error;
1829 }
1830
1831 /*
1832 * it should be an xs:gMonthDay or xs:gMonth
1833 */
1834 ret = _xmlSchemaParseGMonth(&(dt->value.date), &cur);
1835 if (ret != 0)

Callers 1

xmlSchemaValAtomicTypeFunction · 0.85

Calls 7

xmlSchemaNewValueFunction · 0.85
_xmlSchemaParseGDayFunction · 0.85
_xmlSchemaParseGMonthFunction · 0.85
_xmlSchemaParseTimeFunction · 0.85
_xmlSchemaParseGYearFunction · 0.85
_xmlSchemaParseTimeZoneFunction · 0.85
xmlSchemaFreeValueFunction · 0.85

Tested by

no test coverage detected