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

Unified Diff: third_party/libxslt/libxslt/numbers.c

Issue 1193533007: Upgrade to libxml 2.9.2 and libxslt 1.1.28 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no iconv Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libxslt/libxslt/namespaces.c ('k') | third_party/libxslt/libxslt/numbersInternals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libxslt/libxslt/numbers.c
diff --git a/third_party/libxslt/libxslt/numbers.c b/third_party/libxslt/libxslt/numbers.c
index 8683ca8b2d7f7b0467d470408ce4edd71a03546b..9cd1cf30591fe7ccec0e6f28c39487a06fdad1d8 100644
--- a/third_party/libxslt/libxslt/numbers.c
+++ b/third_party/libxslt/libxslt/numbers.c
@@ -193,7 +193,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
pointer -= groupingCharacterLen;
xmlCopyCharMultiByte(pointer, groupingCharacter);
}
-
+
val = digit_zero + (int)fmod(number, 10.0);
if (val < 0x80) { /* shortcut if ASCII */
if (pointer <= temp_string) { /* Check enough room */
@@ -203,7 +203,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
*(--pointer) = val;
}
else {
- /*
+ /*
* Here we have a multibyte character. It's a little messy,
* because until we generate the char we don't know how long
* it is. So, we generate it into the buffer temp_char, then
@@ -241,7 +241,7 @@ xsltNumberFormatAlpha(xmlBufferPtr buffer,
pointer = &temp_string[sizeof(temp_string)];
*(--pointer) = 0;
alpha_list = (is_upper) ? alpha_upper_list : alpha_lower_list;
-
+
for (i = 1; i < (int)sizeof(temp_string); i++) {
number--;
*(--pointer) = alpha_list[((int)fmod(number, alpha_size))];
@@ -337,7 +337,7 @@ xsltNumberFormatTokenize(const xmlChar *format,
* There is always such a token in the list, even if NULL
*/
while (! (IS_LETTER(val=xmlStringCurrentChar(NULL, format+ix, &len)) ||
- IS_DIGIT(val)) ) {
+ IS_DIGIT(val)) ) {
if (format[ix] == 0) /* if end of format string */
break; /* while */
ix += len;
@@ -534,8 +534,8 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
static int
xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
xmlNodePtr node,
- const xmlChar *count,
- const xmlChar *from,
+ xsltCompMatchPtr countPat,
+ xsltCompMatchPtr fromPat,
double *array,
xmlDocPtr doc,
xmlNodePtr elem)
@@ -543,14 +543,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
int amount = 0;
int cnt = 0;
xmlNodePtr cur;
- xsltCompMatchPtr countPat = NULL;
- xsltCompMatchPtr fromPat = NULL;
-
- if (count != NULL)
- countPat = xsltCompilePattern(count, doc, elem, NULL, context);
- if (from != NULL)
- fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
-
+
/* select the starting node */
switch (node->type) {
case XML_ELEMENT_NODE:
@@ -571,7 +564,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
while (cur != NULL) {
/* process current node */
- if (count == NULL) {
+ if (countPat == NULL) {
if ((node->type == cur->type) &&
/* FIXME: must use expanded-name instead of local name */
xmlStrEqual(node->name, cur->name)) {
@@ -586,7 +579,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
if (xsltTestCompMatchList(context, cur, countPat))
cnt++;
}
- if ((from != NULL) &&
+ if ((fromPat != NULL) &&
xsltTestCompMatchList(context, cur, fromPat)) {
break; /* while */
}
@@ -613,18 +606,14 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
array[amount++] = (double) cnt;
- if (countPat != NULL)
- xsltFreeCompMatchList(countPat);
- if (fromPat != NULL)
- xsltFreeCompMatchList(fromPat);
return(amount);
}
static int
xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
xmlNodePtr node,
- const xmlChar *count,
- const xmlChar *from,
+ xsltCompMatchPtr countPat,
+ xsltCompMatchPtr fromPat,
double *array,
int max,
xmlDocPtr doc,
@@ -635,17 +624,7 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
xmlNodePtr ancestor;
xmlNodePtr preceding;
xmlXPathParserContextPtr parser;
- xsltCompMatchPtr countPat;
- xsltCompMatchPtr fromPat;
-
- if (count != NULL)
- countPat = xsltCompilePattern(count, doc, elem, NULL, context);
- else
- countPat = NULL;
- if (from != NULL)
- fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
- else
- fromPat = NULL;
+
context->xpathCtxt->node = node;
parser = xmlXPathNewParserContext(NULL, context->xpathCtxt);
if (parser) {
@@ -653,21 +632,21 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
for (ancestor = node;
(ancestor != NULL) && (ancestor->type != XML_DOCUMENT_NODE);
ancestor = xmlXPathNextAncestor(parser, ancestor)) {
-
- if ((from != NULL) &&
+
+ if ((fromPat != NULL) &&
xsltTestCompMatchList(context, ancestor, fromPat))
break; /* for */
-
- if ((count == NULL && node->type == ancestor->type &&
+
+ if ((countPat == NULL && node->type == ancestor->type &&
xmlStrEqual(node->name, ancestor->name)) ||
xsltTestCompMatchList(context, ancestor, countPat)) {
/* count(preceding-sibling::*) */
cnt = 0;
for (preceding = ancestor;
preceding != NULL;
- preceding =
+ preceding =
xmlXPathNextPrecedingSibling(parser, preceding)) {
- if (count == NULL) {
+ if (countPat == NULL) {
if ((preceding->type == ancestor->type) &&
xmlStrEqual(preceding->name, ancestor->name)){
if ((preceding->ns == ancestor->ns) ||
@@ -690,8 +669,6 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
}
xmlXPathFreeParserContext(parser);
}
- xsltFreeCompMatchList(countPat);
- xsltFreeCompMatchList(fromPat);
return amount;
}
@@ -704,7 +681,7 @@ xsltNumberFormatGetValue(xmlXPathContextPtr context,
int amount = 0;
xmlBufferPtr pattern;
xmlXPathObjectPtr obj;
-
+
pattern = xmlBufferCreate();
if (pattern != NULL) {
xmlBufferCCat(pattern, "number(");
@@ -773,14 +750,14 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
&tokens,
output);
}
-
+
} else if (data->level) {
-
+
if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
amount = xsltNumberFormatGetMultipleLevel(ctxt,
node,
- data->count,
- data->from,
+ data->countPat,
+ data->fromPat,
&number,
1,
data->doc,
@@ -797,8 +774,8 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
int max = sizeof(numarray)/sizeof(numarray[0]);
amount = xsltNumberFormatGetMultipleLevel(ctxt,
node,
- data->count,
- data->from,
+ data->countPat,
+ data->fromPat,
numarray,
max,
data->doc,
@@ -813,9 +790,9 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
} else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
amount = xsltNumberFormatGetAnyLevel(ctxt,
node,
- data->count,
- data->from,
- &number,
+ data->countPat,
+ data->fromPat,
+ &number,
data->doc,
data->node);
if (amount > 0) {
@@ -838,7 +815,7 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
if (tokens.tokens[i].separator != NULL)
xmlFree(tokens.tokens[i].separator);
}
-
+
XSLT_NUMBER_FORMAT_END:
if (tempformat == 1) {
/* The format need to be recomputed each time */
@@ -855,9 +832,9 @@ xsltFormatNumberPreSuffix(xsltDecimalFormatPtr self, xmlChar **format, xsltForma
int len;
while (1) {
- /*
- * prefix / suffix ends at end of string or at
- * first 'special' character
+ /*
+ * prefix / suffix ends at end of string or at
+ * first 'special' character
*/
if (**format == 0)
return count;
@@ -870,12 +847,12 @@ xsltFormatNumberPreSuffix(xsltDecimalFormatPtr self, xmlChar **format, xsltForma
return count;
/*
* else treat percent/per-mille as special cases,
- * depending on whether +ve or -ve
+ * depending on whether +ve or -ve
*/
else {
/*
- * for +ve prefix/suffix, allow only a
- * single occurence of either
+ * for +ve prefix/suffix, allow only a
+ * single occurence of either
*/
if (xsltUTF8Charcmp(*format, self->percent) == 0) {
if (info->is_multiplier_set)
@@ -889,14 +866,14 @@ xsltFormatNumberPreSuffix(xsltDecimalFormatPtr self, xmlChar **format, xsltForma
info->is_multiplier_set = TRUE;
}
}
-
+
if ((len=xsltUTF8Size(*format)) < 1)
return -1;
count += len;
*format += len;
}
}
-
+
/**
* xsltFormatNumberConversion:
* @self: the decimal format
@@ -955,9 +932,9 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
int j, len;
int self_grouping_len;
xsltFormatNumberInfo format_info;
- /*
+ /*
* delayed_multiplier allows a 'trailing' percent or
- * permille to be treated as suffix
+ * permille to be treated as suffix
*/
int delayed_multiplier = 0;
/* flag to show no -ve format present for -ve number */
@@ -1013,7 +990,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
/*
* First we process the +ve pattern to get percent / permille,
- * as well as main format
+ * as well as main format
*/
prefix = the_format;
prefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
@@ -1022,18 +999,18 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
goto OUTPUT_NUMBER;
}
- /*
- * Here we process the "number" part of the format. It gets
+ /*
+ * Here we process the "number" part of the format. It gets
* a little messy because of the percent/per-mille - if that
- * appears at the end, it may be part of the suffix instead
- * of part of the number, so the variable delayed_multiplier
- * is used to handle it
+ * appears at the end, it may be part of the suffix instead
+ * of part of the number, so the variable delayed_multiplier
+ * is used to handle it
*/
self_grouping_len = xmlStrlen(self->grouping);
while ((*the_format != 0) &&
(xsltUTF8Charcmp(the_format, self->decimalPoint) != 0) &&
(xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) {
-
+
if (delayed_multiplier != 0) {
format_info.multiplier = delayed_multiplier;
format_info.is_multiplier_set = TRUE;
@@ -1071,7 +1048,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
delayed_multiplier = 1000;
} else
break; /* while */
-
+
if ((len=xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
@@ -1085,9 +1062,9 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
format_info.add_decimal = TRUE;
the_format += xsltUTF8Size(the_format); /* Skip over the decimal */
}
-
+
while (*the_format != 0) {
-
+
if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
if (format_info.frac_hash != 0) {
found_error = 1;
@@ -1135,9 +1112,9 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
}
}
- /*
- * If delayed_multiplier is set after processing the
- * "number" part, should be in suffix
+ /*
+ * If delayed_multiplier is set after processing the
+ * "number" part, should be in suffix
*/
if (delayed_multiplier != 0) {
the_format -= len;
@@ -1147,7 +1124,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
suffix = the_format;
suffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
if ( (suffix_length < 0) ||
- ((*the_format != 0) &&
+ ((*the_format != 0) &&
(xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) ) {
found_error = 1;
goto OUTPUT_NUMBER;
@@ -1170,17 +1147,17 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
else {
/* Skip over pattern separator (accounting for UTF8) */
the_format = (xmlChar *)xmlUTF8Strpos(format, j + 1);
- /*
- * Flag changes interpretation of percent/permille
- * in -ve pattern
+ /*
+ * Flag changes interpretation of percent/permille
+ * in -ve pattern
*/
format_info.is_negative_pattern = TRUE;
format_info.is_multiplier_set = FALSE;
/* First do the -ve prefix */
nprefix = the_format;
- nprefix_length = xsltFormatNumberPreSuffix(self,
- &the_format, &format_info);
+ nprefix_length = xsltFormatNumberPreSuffix(self,
+ &the_format, &format_info);
if (nprefix_length<0) {
found_error = 1;
goto OUTPUT_NUMBER;
@@ -1214,7 +1191,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
/* Finally do the -ve suffix */
if (*the_format != 0) {
nsuffix = the_format;
- nsuffix_length = xsltFormatNumberPreSuffix(self,
+ nsuffix_length = xsltFormatNumberPreSuffix(self,
&the_format, &format_info);
if (nsuffix_length < 0) {
found_error = 1;
@@ -1232,12 +1209,12 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
* if -ve prefix/suffix == +ve ones, discard & use default
*/
if ((nprefix_length != prefix_length) ||
- (nsuffix_length != suffix_length) ||
- ((nprefix_length > 0) &&
+ (nsuffix_length != suffix_length) ||
+ ((nprefix_length > 0) &&
(xmlStrncmp(nprefix, prefix, prefix_length) !=0 )) ||
- ((nsuffix_length > 0) &&
+ ((nsuffix_length > 0) &&
(xmlStrncmp(nsuffix, suffix, suffix_length) !=0 ))) {
- prefix = nprefix;
+ prefix = nprefix;
prefix_length = nprefix_length;
suffix = nsuffix;
suffix_length = nsuffix_length;
@@ -1283,9 +1260,9 @@ OUTPUT_NUMBER:
number = fabs(number) * (double)format_info.multiplier;
scale = pow(10.0, (double)(format_info.frac_digits + format_info.frac_hash));
number = floor((scale * number + 0.5)) / scale;
- if ((self->grouping != NULL) &&
+ if ((self->grouping != NULL) &&
(self->grouping[0] != 0)) {
-
+
len = xmlStrlen(self->grouping);
pchar = xsltGetUTF8Char(self->grouping, &len);
xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
@@ -1314,14 +1291,14 @@ OUTPUT_NUMBER:
/* Next the fractional part, if required */
if (format_info.frac_digits + format_info.frac_hash == 0) {
if (format_info.add_decimal)
- xmlBufferAdd(buffer, self->decimalPoint,
- xsltUTF8Size(self->decimalPoint));
+ xmlBufferAdd(buffer, self->decimalPoint,
+ xsltUTF8Size(self->decimalPoint));
}
else {
number -= floor(number);
if ((number != 0) || (format_info.frac_digits != 0)) {
xmlBufferAdd(buffer, self->decimalPoint,
- xsltUTF8Size(self->decimalPoint));
+ xsltUTF8Size(self->decimalPoint));
number = floor(scale * number + 0.5);
for (j = format_info.frac_hash; j > 0; j--) {
if (fmod(number, 10.0) >= 1.0)
« no previous file with comments | « third_party/libxslt/libxslt/namespaces.c ('k') | third_party/libxslt/libxslt/numbersInternals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698