Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1424)

Side by Side Diff: third_party/libxml/src/xmlschemastypes.c

Issue 1977213002: Roll libxml to 8effcb578e0590cc01bbcab0f9dccefc6bdbcdbd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update README.chromium. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * schemastypes.c : implementation of the XML Schema Datatypes 2 * schemastypes.c : implementation of the XML Schema Datatypes
3 * definition and validity checking 3 * definition and validity checking
4 * 4 *
5 * See Copyright for the status of this software. 5 * See Copyright for the status of this software.
6 * 6 *
7 * Daniel Veillard <veillard@redhat.com> 7 * Daniel Veillard <veillard@redhat.com>
8 */ 8 */
9 9
10 #define IN_LIBXML 10 #define IN_LIBXML
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 #define IS_WSP_BLANK_CH(c) IS_BLANK_CH(c) 56 #define IS_WSP_BLANK_CH(c) IS_BLANK_CH(c)
57 57
58 /* Date value */ 58 /* Date value */
59 typedef struct _xmlSchemaValDate xmlSchemaValDate; 59 typedef struct _xmlSchemaValDate xmlSchemaValDate;
60 typedef xmlSchemaValDate *xmlSchemaValDatePtr; 60 typedef xmlSchemaValDate *xmlSchemaValDatePtr;
61 struct _xmlSchemaValDate { 61 struct _xmlSchemaValDate {
62 long year; 62 long year;
63 unsigned int mon :4; /* 1 <= mon <= 12 */ 63 unsigned int mon :4; /* 1 <= mon <= 12 */
64 unsigned int day :5; /* 1 <= day <= 31 */ 64 unsigned int day :5; /* 1 <= day <= 31 */
65 unsigned int» hour» :5;» /* 0 <= hour <= 23 */ 65 unsigned int» hour» :5;» /* 0 <= hour <= 24 */
66 unsigned int min :6; /* 0 <= min <= 59 */ 66 unsigned int min :6; /* 0 <= min <= 59 */
67 double sec; 67 double sec;
68 unsigned int tz_flag :1; /* is tzo explicitely set? */ 68 unsigned int tz_flag :1; /* is tzo explicitely set? */
69 signed int tzo :12; /* -1440 <= tzo <= 1440; 69 signed int tzo :12; /* -1440 <= tzo <= 1440;
70 currently only -840 to +840 are neede d */ 70 currently only -840 to +840 are neede d */
71 }; 71 };
72 72
73 /* Duration value */ 73 /* Duration value */
74 typedef struct _xmlSchemaValDuration xmlSchemaValDuration; 74 typedef struct _xmlSchemaValDuration xmlSchemaValDuration;
75 typedef xmlSchemaValDuration *xmlSchemaValDurationPtr; 75 typedef xmlSchemaValDuration *xmlSchemaValDurationPtr;
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1]) 1132 (IS_LEAP(yr) ? daysInMonthLeap[mon - 1] : daysInMonth[mon - 1])
1133 1133
1134 #define VALID_MDAY(dt) \ 1134 #define VALID_MDAY(dt) \
1135 (IS_LEAP(dt->year) ? \ 1135 (IS_LEAP(dt->year) ? \
1136 (dt->day <= daysInMonthLeap[dt->mon - 1]) : \ 1136 (dt->day <= daysInMonthLeap[dt->mon - 1]) : \
1137 (dt->day <= daysInMonth[dt->mon - 1])) 1137 (dt->day <= daysInMonth[dt->mon - 1]))
1138 1138
1139 #define VALID_DATE(dt) \ 1139 #define VALID_DATE(dt) \
1140 (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) 1140 (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt))
1141 1141
1142 #define VALID_END_OF_DAY(dt) \
1143 ((dt)->hour == 24 && (dt)->min == 0 && (dt)->sec == 0)
1144
1142 #define VALID_TIME(dt) \ 1145 #define VALID_TIME(dt) \
1143 » (VALID_HOUR(dt->hour) && VALID_MIN(dt->min) &&» » \ 1146 » (((VALID_HOUR(dt->hour) && VALID_MIN(dt->min) &&» \
1144 » VALID_SEC(dt->sec) && VALID_TZO(dt->tzo)) 1147 » VALID_SEC(dt->sec)) || VALID_END_OF_DAY(dt)) &&» \
1148 » VALID_TZO(dt->tzo))
1145 1149
1146 #define VALID_DATETIME(dt) \ 1150 #define VALID_DATETIME(dt) \
1147 (VALID_DATE(dt) && VALID_TIME(dt)) 1151 (VALID_DATE(dt) && VALID_TIME(dt))
1148 1152
1149 #define SECS_PER_MIN (60) 1153 #define SECS_PER_MIN (60)
1150 #define SECS_PER_HOUR (60 * SECS_PER_MIN) 1154 #define SECS_PER_HOUR (60 * SECS_PER_MIN)
1151 #define SECS_PER_DAY (24 * SECS_PER_HOUR) 1155 #define SECS_PER_DAY (24 * SECS_PER_HOUR)
1152 1156
1153 static const long dayInYearByMonth[12] = 1157 static const long dayInYearByMonth[12] =
1154 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; 1158 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) { 1352 _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) {
1349 const xmlChar *cur = *str; 1353 const xmlChar *cur = *str;
1350 int ret = 0; 1354 int ret = 0;
1351 int value = 0; 1355 int value = 0;
1352 1356
1353 PARSE_2_DIGITS(value, cur, ret); 1357 PARSE_2_DIGITS(value, cur, ret);
1354 if (ret != 0) 1358 if (ret != 0)
1355 return ret; 1359 return ret;
1356 if (*cur != ':') 1360 if (*cur != ':')
1357 return 1; 1361 return 1;
1358 if (!VALID_HOUR(value)) 1362 if (!VALID_HOUR(value) && value != 24 /* Allow end-of-day hour */)
1359 return 2; 1363 return 2;
1360 cur++; 1364 cur++;
1361 1365
1362 /* the ':' insures this string is xs:time */ 1366 /* the ':' insures this string is xs:time */
1363 dt->hour = value; 1367 dt->hour = value;
1364 1368
1365 PARSE_2_DIGITS(value, cur, ret); 1369 PARSE_2_DIGITS(value, cur, ret);
1366 if (ret != 0) 1370 if (ret != 0)
1367 return ret; 1371 return ret;
1368 if (!VALID_MIN(value)) 1372 if (!VALID_MIN(value))
1369 return 2; 1373 return 2;
1370 dt->min = value; 1374 dt->min = value;
1371 1375
1372 if (*cur != ':') 1376 if (*cur != ':')
1373 return 1; 1377 return 1;
1374 cur++; 1378 cur++;
1375 1379
1376 PARSE_FLOAT(dt->sec, cur, ret); 1380 PARSE_FLOAT(dt->sec, cur, ret);
1377 if (ret != 0) 1381 if (ret != 0)
1378 return ret; 1382 return ret;
1379 1383
1380 if ((!VALID_SEC(dt->sec)) || (!VALID_TZO(dt->tzo))) 1384 if (!VALID_TIME(dt))
1381 return 2; 1385 return 2;
1382 1386
1383 *str = cur; 1387 *str = cur;
1384 return 0; 1388 return 0;
1385 } 1389 }
1386 1390
1387 /** 1391 /**
1388 * _xmlSchemaParseTimeZone: 1392 * _xmlSchemaParseTimeZone:
1389 * @dt: pointer to a date structure 1393 * @dt: pointer to a date structure
1390 * @str: pointer to the string to analyze 1394 * @str: pointer to the string to analyze
(...skipping 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after
5296 */ 5300 */
5297 static int 5301 static int
5298 xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, 5302 xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
5299 xmlSchemaWhitespaceValueType fws, 5303 xmlSchemaWhitespaceValueType fws,
5300 xmlSchemaValType valType, 5304 xmlSchemaValType valType,
5301 const xmlChar *value, 5305 const xmlChar *value,
5302 xmlSchemaValPtr val, 5306 xmlSchemaValPtr val,
5303 xmlSchemaWhitespaceValueType ws) 5307 xmlSchemaWhitespaceValueType ws)
5304 { 5308 {
5305 int ret; 5309 int ret;
5310 int stringType;
5306 5311
5307 if (facet == NULL) 5312 if (facet == NULL)
5308 return(-1); 5313 return(-1);
5309 5314
5310 switch (facet->type) { 5315 switch (facet->type) {
5311 case XML_SCHEMA_FACET_PATTERN: 5316 case XML_SCHEMA_FACET_PATTERN:
5312 /* 5317 /*
5313 * NOTE that for patterns, the @value needs to be the normalized 5318 * NOTE that for patterns, the @value needs to be the normalized
5314 * value, *not* the lexical initial value or the canonical value. 5319 * value, *not* the lexical initial value or the canonical value.
5315 */ 5320 */
5316 if (value == NULL) 5321 if (value == NULL)
5317 return(-1); 5322 return(-1);
5318 » ret = xmlRegexpExec(facet->regexp, value); 5323 » /*
5324 » * If string-derived type, regexp must be tested on the value space o f
5325 » * the datatype.
5326 » * See https://www.w3.org/TR/xmlschema-2/#rf-pattern
5327 » */
5328 » stringType = val && ((val->type >= XML_SCHEMAS_STRING && val->type < = XML_SCHEMAS_NORMSTRING)
5329 » » » || (val->type >= XML_SCHEMAS_TOKEN && val->type <= XML_SCHEMAS_NCNAME));
5330 » ret = xmlRegexpExec(facet->regexp,
5331 » (stringType && val->value.str) ? val->value.str : value);
5319 if (ret == 1) 5332 if (ret == 1)
5320 return(0); 5333 return(0);
5321 if (ret == 0) 5334 if (ret == 0)
5322 return(XML_SCHEMAV_CVC_PATTERN_VALID); 5335 return(XML_SCHEMAV_CVC_PATTERN_VALID);
5323 return(ret); 5336 return(ret);
5324 case XML_SCHEMA_FACET_MAXEXCLUSIVE: 5337 case XML_SCHEMA_FACET_MAXEXCLUSIVE:
5325 ret = xmlSchemaCompareValues(val, facet->val); 5338 ret = xmlSchemaCompareValues(val, facet->val);
5326 if (ret == -2) 5339 if (ret == -2)
5327 return(-1); 5340 return(-1);
5328 if (ret == -1) 5341 if (ret == -1)
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
6130 xmlSchemaGetValType(xmlSchemaValPtr val) 6143 xmlSchemaGetValType(xmlSchemaValPtr val)
6131 { 6144 {
6132 if (val == NULL) 6145 if (val == NULL)
6133 return(XML_SCHEMAS_UNKNOWN); 6146 return(XML_SCHEMAS_UNKNOWN);
6134 return (val->type); 6147 return (val->type);
6135 } 6148 }
6136 6149
6137 #define bottom_xmlschemastypes 6150 #define bottom_xmlschemastypes
6138 #include "elfgcchack.h" 6151 #include "elfgcchack.h"
6139 #endif /* LIBXML_SCHEMAS_ENABLED */ 6152 #endif /* LIBXML_SCHEMAS_ENABLED */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698