diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-02-09 12:43:57 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-02-09 12:43:57 +0300 |
commit | 831c620a4715c49a478fd617d55ea7c697a9fb89 (patch) | |
tree | 86c6a0f151059ba78c15c3a4b7b0da19a5f84702 /mcs/class/System.XML/Mono.Xml.Xsl.Operations | |
parent | 48843d089a8fda57e752ffc54f9542de918c9d0e (diff) |
2005-02-09 Atsushi Enomoto <atsushi@ximian.com>
* XslNumber.cs : For group size, use decimal instead of integer to allow
such number that is larger than int.MaxValue. patch by Andrew Skiba.
svn path=/trunk/mcs/; revision=40330
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Xsl.Operations')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs | 34 |
2 files changed, 25 insertions, 14 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog index ce26c4c54f2..747b5775e3d 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog @@ -1,5 +1,10 @@ 2005-02-09 Atsushi Enomoto <atsushi@ximian.com> + * XslNumber.cs : For group size, use decimal instead of integer to allow + such number that is larger than int.MaxValue. patch by Andrew Skiba. + +2005-02-09 Atsushi Enomoto <atsushi@ximian.com> + * XslForEach.cs : Don't bork at <xsl:for-each/>. Patch by Andrew Skiba. 2005-02-08 Atsushi Enomoto <atsushi@ximian.com> diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs index 19d942ccd2a..a7dcddf8522 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslNumber.cs @@ -108,7 +108,7 @@ namespace Mono.Xml.Xsl.Operations { string lang = null; string letterValue = null; char groupingSeparatorChar = '\0'; - int groupingSize = 0; + decimal groupingSize = 0; if (this.format != null) formatStr = this.format.Evaluate (p); @@ -123,9 +123,13 @@ namespace Mono.Xml.Xsl.Operations { groupingSeparatorChar = this.groupingSeparator.Evaluate (p) [0]; if (this.groupingSize != null) - groupingSize = int.Parse (this.groupingSize.Evaluate (p), CultureInfo.InvariantCulture); + groupingSize = decimal.Parse (this.groupingSize.Evaluate (p), CultureInfo.InvariantCulture); - return new XslNumberFormatter (formatStr, lang, letterValue, groupingSeparatorChar, groupingSize); + //FIXME: Negative test compliency: .NET throws exception on negative grouping-size + if (groupingSize > Int32.MaxValue || groupingSize < 1) + groupingSize = 0; + + return new XslNumberFormatter (formatStr, lang, letterValue, groupingSeparatorChar, (int)groupingSize); } string GetFormat (XslTransformProcessor p) @@ -134,8 +138,9 @@ namespace Mono.Xml.Xsl.Operations { if (this.value != null) { double result = p.EvaluateNumber (this.value); - result = (int) ((result - (int) result >= 0.5) ? result + 1 : result); - return nf.Format ((int) result); + //Do we need to round the result here??? + //result = (int) ((result - (int) result >= 0.5) ? result + 1 : result); + return nf.Format (result); } switch (this.level) { @@ -207,7 +212,7 @@ namespace Mono.Xml.Xsl.Operations { return 0; }; } - } while (true);
+ } while (true); } int NumberSingle (XslTransformProcessor p) @@ -304,12 +309,12 @@ namespace Mono.Xml.Xsl.Operations { } // return the format for a single value, ie, if using Single or Any - public string Format (int value) + public string Format (double value) { return Format (value, true); } - public string Format (int value, bool formatContent) + public string Format (double value, bool formatContent) { StringBuilder b = new StringBuilder (); if (firstSep != null) b.Append (firstSep); @@ -379,7 +384,7 @@ namespace Mono.Xml.Xsl.Operations { this.sep = sep; } - public abstract void Format (StringBuilder b, int num); + public abstract void Format (StringBuilder b, double num); public static FormatItem GetItem (string sep, string item, char gpSep, int gpSize) { @@ -410,15 +415,15 @@ namespace Mono.Xml.Xsl.Operations { this.uc = uc; } - public override void Format (StringBuilder b, int num) + public override void Format (StringBuilder b, double num) { alphaSeq (b, num, uc ? ucl : lcl); } - static void alphaSeq (StringBuilder b, int n, char [] alphabet) { + static void alphaSeq (StringBuilder b, double n, char [] alphabet) { if (n > alphabet.Length) alphaSeq (b, (n-1) / alphabet.Length, alphabet); - b.Append (alphabet [(n-1) % alphabet.Length]); + b.Append (alphabet [((int)n-1) % alphabet.Length]); } } @@ -435,7 +440,7 @@ namespace Mono.Xml.Xsl.Operations { static readonly int [] decValues = {1000, 900 , 500, 400 , 100, 90 , 50 , 40 , 10 , 9 , 5 , 4 , 1 }; - public override void Format (StringBuilder b, int num) + public override void Format (StringBuilder b, double num) { if (num < 1 || num > 4999) { b.Append (num); @@ -465,6 +470,7 @@ namespace Mono.Xml.Xsl.Operations { { nfi = new NumberFormatInfo (); nfi.NumberDecimalDigits = 0; + nfi.NumberGroupSizes = new int [] {0}; if (gpSep != '\0' && gpSize > 0) { // ignored if either of them doesn't exist. nfi.NumberGroupSeparator = gpSep.ToString (); @@ -473,7 +479,7 @@ namespace Mono.Xml.Xsl.Operations { decimalSectionLength = len; } - public override void Format (StringBuilder b, int num) + public override void Format (StringBuilder b, double num) { string number = num.ToString ("N", nfi); int len = decimalSectionLength; |