[runtime] Disable a test which asserts because of an abi break in recent xcode/clang...
[mono.git] / mcs / class / System.Web.Extensions / System.Web.Script.Serialization / JsonDeserializer.cs
index 94262ec23cb018394c116b78c7aa180b0b3ce771..29e6cfb92b86bd69a4e665ccb7ab5a94d7cb4732 100644 (file)
@@ -2,9 +2,10 @@
 // JsonDeserializer.cs
 //
 // Author:
-//   Marek Habersack <mhabersack@novell.com>
+//   Marek Habersack <grendel@twistedcode.net>
 //
 // (C) 2008 Novell, Inc.  http://novell.com/
+// Copyright 2011, Xamarin, Inc (http://xamarin.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 // Code is based on JSON_checker (http://www.json.org/JSON_checker/) and JSON_parser
-// (http://fara.cs.uni-potsdam.de/~jsg/json_parser/) C sources. License for the original code
-// follows:
-
-#region Original License
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-#endregion
+// (http://fara.cs.uni-potsdam.de/~jsg/json_parser/) C sources.
 
 using System;
 using System.Collections;
@@ -252,7 +226,7 @@ namespace System.Web.Script.Serialization
                        /*colon    CO*/ {CO,CO,__,__,__,__,CA,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__},
                        /*value    VA*/ {VA,VA,OS,__,AB,__,__,__,SB,__,__,PX,MX,__,ZX,IX,__,__,__,__,__,FA,__,NU,__,__,TR,__,__,__,__,__,I1,__,__,V1},
                        /*array    AR*/ {AR,AR,OS,__,AB,AE,__,__,SB,__,__,PX,MX,__,ZX,IX,__,__,__,__,__,FA,__,NU,__,__,TR,__,__,__,__,__,I1,__,__,V1},
-                       /*string   ST*/ {ST,__,ST,ST,ST,ST,ST,ST,SE,EX,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST},
+                       /*string   ST*/ {ST,ST,ST,ST,ST,ST,ST,ST,SE,EX,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST,ST},
                        /*escape   ES*/ {__,__,__,__,__,__,__,__,ST,ST,ST,__,__,__,__,__,__,ST,__,__,__,ST,__,ST,ST,__,ST,U1,__,__,__,__,__,__,__,__},
                        /*u1       U1*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,U2,U2,U2,U2,U2,U2,U2,U2,__,__,__,__,__,__,U2,U2,__,__,__,__,__,__},
                        /*u2       U2*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,U3,U3,U3,U3,U3,U3,U3,U3,__,__,__,__,__,__,U3,U3,__,__,__,__,__,__},
@@ -277,8 +251,8 @@ namespace System.Web.Script.Serialization
                        /*null     N3*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,OK,__,__,__,__,__,__,__,__,__,__,__,__,__},
                        /*_.       FX*/ {OK,OK,__,OE,__,AE,__,CM,__,__,__,__,__,__,FR,FR,__,__,__,__,E1,__,__,__,__,__,__,__,__,E1,__,__,__,__,__,__},
                        /*inval.   IV*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__},
-                       /*unq.key  UK*/ {__,UI,__,__,__,__,UE,__,__,__,__,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,__,UK,UK,UK,UK},
-                       /*unq.ign. UI*/ {__,UI,__,__,__,__,UE,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__},
+                       /*unq.key  UK*/ {UI,UI,__,__,__,__,UE,__,__,__,__,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,UK,__,UK,UK,UK,UK},
+                       /*unq.ign. UI*/ {UI,UI,__,__,__,__,UE,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__},
                        /*i1       I1*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,I2,__,__,__,__,__,__,__,__,__,__,__,__},
                        /*i2       I2*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,I3,__,__,__,__,__,__,__,__,__,__,__,__,__,__},
                        /*i3       I3*/ {__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,I4,__,__},
@@ -302,7 +276,6 @@ namespace System.Web.Script.Serialization
                JsonType jsonType;
                
                bool escaped;
-               bool negated;
                int state;
                Stack <string> currentKey;
                StringBuilder buffer;
@@ -500,43 +473,43 @@ namespace System.Web.Script.Serialization
                                case JsonType.INTEGER:
                                        /* MS AJAX.NET JSON parser promotes big integers to double */
                                        
-                                       if (Int32.TryParse (s, out intValue))
+                                       if (Int32.TryParse (s, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue))
                                                result = intValue;
-                                       else if (Int64.TryParse (s, out longValue))
+                                       else if (Int64.TryParse (s, NumberStyles.Integer, CultureInfo.InvariantCulture, out longValue))
                                                result = longValue;
-                                       else if (Decimal.TryParse (s, out decimalValue))
+                                       else if (Decimal.TryParse (s, NumberStyles.Integer, CultureInfo.InvariantCulture, out decimalValue))
                                                result = decimalValue;
-                                       else if (Double.TryParse (s, out doubleValue))
+                                       else if (Double.TryParse (s, NumberStyles.Integer, CultureInfo.InvariantCulture, out doubleValue))
                                                result = doubleValue;
                                        else
                                                converted = false;
                                        break;
 
                                case JsonType.FLOAT:
-                                       if (Decimal.TryParse (s, out decimalValue))
+                                       if (Decimal.TryParse (s, NumberStyles.Float, CultureInfo.InvariantCulture, out decimalValue))
                                                result = decimalValue;
-                                       else if (Double.TryParse (s, out doubleValue))
+                                       else if (Double.TryParse (s, NumberStyles.Float, CultureInfo.InvariantCulture, out doubleValue))
                                                result = doubleValue;
                                        else
                                                converted = false;
                                        break;
 
                                case JsonType.TRUE:
-                                       if (String.Compare (s, "true", StringComparison.Ordinal) == 0)
+                                       if (String.Compare (s.Trim (), "true", StringComparison.Ordinal) == 0)
                                                result = true;
                                        else
                                                converted = false;
                                        break;
 
                                case JsonType.FALSE:
-                                       if (String.Compare (s, "false", StringComparison.Ordinal) == 0)
+                                       if (String.Compare (s.Trim (), "false", StringComparison.Ordinal) == 0)
                                                result = false;
                                        else
                                                converted = false;
                                        break;
 
                                case JsonType.NULL:
-                                       if (String.Compare (s, "null", StringComparison.Ordinal) != 0)
+                                       if (String.Compare (s.Trim (), "null", StringComparison.Ordinal) != 0)
                                                converted = false;
                                        break;