Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[System.Numerics] Add support to build with Mono #1

Merged
merged 1 commit into from Jan 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions System.Numerics/System/Numerics/BigNumber.cs
Expand Up @@ -517,12 +517,12 @@ internal struct BigNumberBuffer {

bool decimalFmt = (fmt == 'g' || fmt == 'G' || fmt == 'd' || fmt == 'D' || fmt == 'r' || fmt == 'R');

#if SILVERLIGHT ||FEATURE_NETCORE
#if SILVERLIGHT ||FEATURE_NETCORE || MONO

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, are we sure about this change?

It would require decimalFmt = false.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Mono today also only supports the format specifiers used in decimalFmt: BigInteger.cs#L1458-L1471

if (!decimalFmt) {
// Silverlight supports invariant formats only
throw new FormatException(SR.GetString(SR.Format_InvalidFormatSpecifier));
}
#endif //SILVERLIGHT ||FEATURE_NETCORE
#endif //SILVERLIGHT ||FEATURE_NETCORE || MONO

if (value._bits == null) {
if (fmt == 'g' || fmt == 'G' || fmt == 'r' || fmt == 'R') {
Expand Down
16 changes: 9 additions & 7 deletions mscorlib/system/number.cs
Expand Up @@ -768,9 +768,11 @@ internal unsafe struct NumberBuffer {
Boolean parsingCurrency = false;
if ((options & NumberStyles.AllowCurrencySymbol) != 0) {
currSymbol = numfmt.CurrencySymbol;
#if !MONO
if (numfmt.ansiCurrencySymbol != null) {
ansicurrSymbol = numfmt.ansiCurrencySymbol;
}
#endif
// The idea here is to match the currency separators and on failure match the number separators to keep the perf of VB's IsNumeric fast.
// The values of decSep are setup to use the correct relevant separator (currency in the if part and decimal in the else part).
altdecSep = numfmt.NumberDecimalSeparator;
Expand All @@ -797,13 +799,13 @@ internal unsafe struct NumberBuffer {
while (true) {
// Eat whitespace unless we've found a sign which isn't followed by a currency symbol.
// "-Kr 1231.47" is legal but "- 1231.47" is not.
if (IsWhite(ch) && ((options & NumberStyles.AllowLeadingWhite) != 0) && (((state & StateSign) == 0) || (((state & StateSign) != 0) && (((state & StateCurrency) != 0) || numfmt.numberNegativePattern == 2)))) {
if (IsWhite(ch) && ((options & NumberStyles.AllowLeadingWhite) != 0) && (((state & StateSign) == 0) || (((state & StateSign) != 0) && (((state & StateCurrency) != 0) || numfmt.NumberNegativePattern == 2)))) {
// Do nothing here. We will increase p at the end of the loop.
}
else if ((signflag = (((options & NumberStyles.AllowLeadingSign) != 0) && ((state & StateSign) == 0))) && ((next = MatchChars(p, numfmt.positiveSign)) != null)) {
else if ((signflag = (((options & NumberStyles.AllowLeadingSign) != 0) && ((state & StateSign) == 0))) && ((next = MatchChars(p, numfmt.PositiveSign)) != null)) {
state |= StateSign;
p = next - 1;
} else if (signflag && (next = MatchChars(p, numfmt.negativeSign)) != null) {
} else if (signflag && (next = MatchChars(p, numfmt.NegativeSign)) != null) {
state |= StateSign;
number.sign = true;
p = next - 1;
Expand Down Expand Up @@ -873,10 +875,10 @@ internal unsafe struct NumberBuffer {
if ((ch == 'E' || ch == 'e') && ((options & NumberStyles.AllowExponent) != 0)) {
char* temp = p;
ch = *++p;
if ((next = MatchChars(p, numfmt.positiveSign)) != null) {
if ((next = MatchChars(p, numfmt.PositiveSign)) != null) {
ch = *(p = next);
}
else if ((next = MatchChars(p, numfmt.negativeSign)) != null) {
else if ((next = MatchChars(p, numfmt.NegativeSign)) != null) {
ch = *(p = next);
negExp = true;
}
Expand Down Expand Up @@ -905,10 +907,10 @@ internal unsafe struct NumberBuffer {
while (true) {
if (IsWhite(ch) && ((options & NumberStyles.AllowTrailingWhite) != 0)) {
}
else if ((signflag = (((options & NumberStyles.AllowTrailingSign) != 0) && ((state & StateSign) == 0))) && (next = MatchChars(p, numfmt.positiveSign)) != null) {
else if ((signflag = (((options & NumberStyles.AllowTrailingSign) != 0) && ((state & StateSign) == 0))) && (next = MatchChars(p, numfmt.PositiveSign)) != null) {
state |= StateSign;
p = next - 1;
} else if (signflag && (next = MatchChars(p, numfmt.negativeSign)) != null) {
} else if (signflag && (next = MatchChars(p, numfmt.NegativeSign)) != null) {
state |= StateSign;
number.sign = true;
p = next - 1;
Expand Down