Skip to content

Commit 120ad09

Browse files
committed
Use more invariant culture in LuaTableTextReader.ReadNumberLiteral .
1 parent db7031f commit 120ad09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Luaon.NET/LuaTableTextReader.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
4+
using System.Globalization;
45
using System.IO;
56
using System.Text;
67

@@ -748,18 +749,18 @@ private object ReadNumberLiteral()
748749
// 2147483647
749750
if (!needFloat && expr.Length < 10)
750751
{
751-
var v = Convert.ToInt32(expr) * signFactor;
752+
var v = Convert.ToInt32(expr, CultureInfo.InvariantCulture) * signFactor;
752753
return v == 0 ? boxedZero : v;
753754
}
754755
// 9223372036854775807
755756
else if (!needFloat && expr.Length < 19)
756757
{
757-
var v = Convert.ToInt64(expr) * signFactor;
758+
var v = Convert.ToInt64(expr, CultureInfo.InvariantCulture) * signFactor;
758759
return v == 0 ? boxedZero : v;
759760
}
760761
else
761762
{
762-
return double.Parse(expr, System.Globalization.CultureInfo.InvariantCulture) * signFactor;
763+
return Convert.ToDouble(expr, CultureInfo.InvariantCulture) * signFactor;
763764
}
764765
}
765766
else if (signFactor == -1) // We have already consumed "-"

0 commit comments

Comments
 (0)