private static unsafe bool ParseNumber(ref char *str, NumberStyles options, ref Number.NumberBuffer number, StringBuilder sb, NumberFormatInfo numfmt, bool parseDecimal)
{
number.scale = 0;
number.sign = false;
string str1 = (string)null;
string str2 = (string)null;
string str3 = (string)null;
string str4 = (string)null;
bool flag1 = false;
string decimalSeparator;
string str5;
if ((options & NumberStyles.AllowCurrencySymbol) != NumberStyles.None)
{
str1 = numfmt.CurrencySymbol;
if (numfmt.ansiCurrencySymbol != null)
{
str2 = numfmt.ansiCurrencySymbol;
}
str3 = numfmt.NumberDecimalSeparator;
str4 = numfmt.NumberGroupSeparator;
decimalSeparator = numfmt.CurrencyDecimalSeparator;
str5 = numfmt.CurrencyGroupSeparator;
flag1 = true;
}
else
{
decimalSeparator = numfmt.NumberDecimalSeparator;
str5 = numfmt.NumberGroupSeparator;
}
int num1 = 0;
bool flag2 = sb != null;
bool flag3 = flag2 && (uint)(options & NumberStyles.AllowHexSpecifier) > 0U;
int num2 = flag2 ? int.MaxValue : 50;
char *p = str;
char ch = *p;
while (true)
{
if (!Number.IsWhite(ch) || (options & NumberStyles.AllowLeadingWhite) == NumberStyles.None || (num1 & 1) != 0 && ((num1 & 1) == 0 || (num1 & 32) == 0 && numfmt.numberNegativePattern != 2))
{
bool flag4;
char *chPtr1;
if ((flag4 = (options & NumberStyles.AllowLeadingSign) != NumberStyles.None && (num1 & 1) == 0) && (IntPtr)(chPtr1 = Number.MatchChars(p, numfmt.positiveSign)) != IntPtr.Zero)
{
num1 |= 1;
p = (char *)((IntPtr)chPtr1 - 2);
}
else
{
char *chPtr2;
if (flag4 && (IntPtr)(chPtr2 = Number.MatchChars(p, numfmt.negativeSign)) != IntPtr.Zero)
{
num1 |= 1;
number.sign = true;
p = (char *)((IntPtr)chPtr2 - 2);
}
else if ((int)ch == 40 && (options & NumberStyles.AllowParentheses) != NumberStyles.None && (num1 & 1) == 0)
{
num1 |= 3;
number.sign = true;
}
else
{
char *chPtr3;
if (str1 != null && (IntPtr)(chPtr3 = Number.MatchChars(p, str1)) != IntPtr.Zero || str2 != null && (IntPtr)(chPtr3 = Number.MatchChars(p, str2)) != IntPtr.Zero)
{
num1 |= 32;
str1 = (string)null;
str2 = (string)null;
p = (char *)((IntPtr)chPtr3 - 2);
}
else
{
break;
}
}
}
}
ch = *(p += 2);
}
int num3 = 0;
int index = 0;
while (true)
{
if ((int)ch >= 48 && (int)ch <= 57 || (options & NumberStyles.AllowHexSpecifier) != NumberStyles.None && ((int)ch >= 97 && (int)ch <= 102 || (int)ch >= 65 && (int)ch <= 70))
{
num1 |= 4;
if ((((int)ch != 48 ? 1 : ((uint)(num1 & 8) > 0U ? 1 : 0)) | (flag3 ? 1 : 0)) != 0)
{
if (num3 < num2)
{
if (flag2)
{
sb.Append(ch);
}
else
{
number.digits[num3++] = ch;
}
if ((int)ch != 48 | parseDecimal)
{
index = num3;
}
}
if ((num1 & 16) == 0)
{
++number.scale;
}
num1 |= 8;
}
else if ((num1 & 16) != 0)
{
--number.scale;
}
}
else
{
char *chPtr1;
if ((options & NumberStyles.AllowDecimalPoint) != NumberStyles.None && (num1 & 16) == 0 && ((IntPtr)(chPtr1 = Number.MatchChars(p, decimalSeparator)) != IntPtr.Zero || flag1 && (num1 & 32) == 0 && (IntPtr)(chPtr1 = Number.MatchChars(p, str3)) != IntPtr.Zero))
{
num1 |= 16;
p = (char *)((IntPtr)chPtr1 - 2);
}
else
{
char *chPtr2;
if ((options & NumberStyles.AllowThousands) != NumberStyles.None && (num1 & 4) != 0 && (num1 & 16) == 0 && ((IntPtr)(chPtr2 = Number.MatchChars(p, str5)) != IntPtr.Zero || flag1 && (num1 & 32) == 0 && (IntPtr)(chPtr2 = Number.MatchChars(p, str4)) != IntPtr.Zero))
{
p = (char *)((IntPtr)chPtr2 - 2);
}
else
{
break;
}
}
}
ch = *(p += 2);
}
bool flag5 = false;
number.precision = index;
if (flag2)
{
sb.Append(char.MinValue);
}
else
{
number.digits[index] = char.MinValue;
}
if ((num1 & 4) != 0)
{
if (((int)ch == 69 || (int)ch == 101) && (options & NumberStyles.AllowExponent) != NumberStyles.None)
{
char *chPtr1 = p;
ch = *(p += 2);
char *chPtr2;
if ((IntPtr)(chPtr2 = Number.MatchChars(p, numfmt.positiveSign)) != IntPtr.Zero)
{
ch = *(p = chPtr2);
}
else
{
char *chPtr3;
if ((IntPtr)(chPtr3 = Number.MatchChars(p, numfmt.negativeSign)) != IntPtr.Zero)
{
ch = *(p = chPtr3);
flag5 = true;
}
}
if ((int)ch >= 48 && (int)ch <= 57)
{
int num4 = 0;
do
{
num4 = num4 * 10 + ((int)ch - 48);
ch = *(p += 2);
if (num4 > 1000)
{
num4 = 9999;
while ((int)ch >= 48 && (int)ch <= 57)
{
ch = *(p += 2);
}
}
}while ((int)ch >= 48 && (int)ch <= 57);
if (flag5)
{
num4 = -num4;
}
number.scale += num4;
}
else
{
p = chPtr1;
ch = *p;
}
}
while (true)
{
if (!Number.IsWhite(ch) || (options & NumberStyles.AllowTrailingWhite) == NumberStyles.None)
{
bool flag4;
char *chPtr1;
if ((flag4 = (options & NumberStyles.AllowTrailingSign) != NumberStyles.None && (num1 & 1) == 0) && (IntPtr)(chPtr1 = Number.MatchChars(p, numfmt.positiveSign)) != IntPtr.Zero)
{
num1 |= 1;
p = (char *)((IntPtr)chPtr1 - 2);
}
else
{
char *chPtr2;
if (flag4 && (IntPtr)(chPtr2 = Number.MatchChars(p, numfmt.negativeSign)) != IntPtr.Zero)
{
num1 |= 1;
number.sign = true;
p = (char *)((IntPtr)chPtr2 - 2);
}
else if ((int)ch == 41 && (num1 & 2) != 0)
{
num1 &= -3;
}
else
{
char *chPtr3;
if (str1 != null && (IntPtr)(chPtr3 = Number.MatchChars(p, str1)) != IntPtr.Zero || str2 != null && (IntPtr)(chPtr3 = Number.MatchChars(p, str2)) != IntPtr.Zero)
{
str1 = (string)null;
str2 = (string)null;
p = (char *)((IntPtr)chPtr3 - 2);
}
else
{
break;
}
}
}
}
ch = *(p += 2);
}
if ((num1 & 2) == 0)
{
if ((num1 & 8) == 0)
{
if (!parseDecimal)
{
number.scale = 0;
}
if ((num1 & 16) == 0)
{
number.sign = false;
}
}
str = p;
return(true);
}
}
str = p;
return(false);
}