Browse Source

Revert "Removing usage of char.IsWhiteSpace"

This reverts commit 51d9256f1cc997d9ee0cbed0e2964a852b6255f1.
Sebastien Ros 9 years ago
parent
commit
b6d5359a75
2 changed files with 12 additions and 4 deletions
  1. 11 3
      Jint/Native/String/StringPrototype.cs
  2. 1 1
      Jint/Parser/JavascriptParser.cs

+ 11 - 3
Jint/Native/String/StringPrototype.cs

@@ -9,7 +9,6 @@ using Jint.Native.RegExp;
 using Jint.Runtime;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
 using Jint.Runtime.Descriptors;
 using Jint.Runtime.Interop;
 using Jint.Runtime.Interop;
-using Jint.Parser;
 
 
 namespace Jint.Native.String
 namespace Jint.Native.String
 {
 {
@@ -72,6 +71,15 @@ namespace Jint.Native.String
             return s.PrimitiveValue;
             return s.PrimitiveValue;
         }
         }
 
 
+        // http://msdn.microsoft.com/en-us/library/system.char.iswhitespace(v=vs.110).aspx
+        // http://en.wikipedia.org/wiki/Byte_order_mark
+        const char BOM_CHAR = '\uFEFF';
+
+        private static bool IsWhiteSpaceEx(char c)
+        {
+            return char.IsWhiteSpace(c) || c == BOM_CHAR;
+        }
+
         private static string TrimEndEx(string s)
         private static string TrimEndEx(string s)
         {
         {
             if (s.Length == 0)
             if (s.Length == 0)
@@ -80,7 +88,7 @@ namespace Jint.Native.String
             var i = s.Length - 1;
             var i = s.Length - 1;
             while (i >= 0)
             while (i >= 0)
             {
             {
-                if (JavaScriptParser.IsWhiteSpace(s[i]))
+                if (IsWhiteSpaceEx(s[i]))
                     i--;
                     i--;
                 else
                 else
                     break;
                     break;
@@ -99,7 +107,7 @@ namespace Jint.Native.String
             var i = 0;
             var i = 0;
             while (i < s.Length)
             while (i < s.Length)
             {
             {
-                if (JavaScriptParser.IsWhiteSpace(s[i]))
+                if (IsWhiteSpaceEx(s[i]))
                     i++;
                     i++;
                 else
                 else
                     break;
                     break;

+ 1 - 1
Jint/Parser/JavascriptParser.cs

@@ -92,7 +92,7 @@ namespace Jint.Parser
 
 
         // 7.2 White Space
         // 7.2 White Space
 
 
-        public static bool IsWhiteSpace(char ch)
+        private static bool IsWhiteSpace(char ch)
         {
         {
             return (ch == 32) || // space
             return (ch == 32) || // space
                    (ch == 9) || // tab
                    (ch == 9) || // tab