Esempio n. 1
0
            public void Write(int ucs32Char)
            {
                if (Token.LiteralLength(ucs32Char) != 1)
                {
                    this.definitelyNotEqual = true;
                    return;
                }

                if (this.strIndex == 0)
                {
                    if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass((char)ucs32Char)))
                    {
                        return;
                    }
                }
                else if (this.strIndex == this.str.Length)
                {
                    if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass((char)ucs32Char)))
                    {
                        return;
                    }

                    this.definitelyNotEqual = true;
                    return;
                }

                if (this.str[this.strIndex] != ParseSupport.ToLowerCase((char)ucs32Char))
                {
                    this.definitelyNotEqual = true;
                    return;
                }

                this.strIndex++;
            }
Esempio n. 2
0
        public void Write(int ucs32Literal, IFallback fallback)
        {
            int count = 1;

            if (ucs32Literal > 65535)
            {
                if (fallback != null && fallback is HtmlWriter)
                {
                    uint num  = (uint)ucs32Literal;
                    int  num2 = (num < 10U) ? 1 : ((num < 100U) ? 2 : ((num < 1000U) ? 3 : ((num < 10000U) ? 4 : ((num < 100000U) ? 5 : ((num < 1000000U) ? 6 : 7)))));
                    int  num3 = 2 + num2;
                    this.stringBuffer[0]    = '&';
                    this.stringBuffer[1]    = '#';
                    this.stringBuffer[num3] = ';';
                    while (num != 0U)
                    {
                        uint num4 = num % 10U;
                        this.stringBuffer[--num3] = (char)(num4 + 48U);
                        num /= 10U;
                    }
                    count = 3 + num2;
                    this.Write(this.stringBuffer, 0, count, null);
                    return;
                }
                this.stringBuffer[0] = ParseSupport.HighSurrogateCharFromUcs4(ucs32Literal);
                this.stringBuffer[1] = ParseSupport.LowSurrogateCharFromUcs4(ucs32Literal);
                count = 2;
            }
            else
            {
                this.stringBuffer[0] = (char)ucs32Literal;
            }
            this.Write(this.stringBuffer, 0, count, fallback);
        }
Esempio n. 3
0
            public void Write(char[] buffer, int offset, int count)
            {
                InternalDebug.Assert(!this.found && this.strIndex < this.str.Length);

                int end = offset + count;

                while (offset < end && this.strIndex < this.str.Length)
                {
                    if (ParseSupport.ToLowerCase(buffer[offset]) == this.str[this.strIndex])
                    {
                        this.strIndex++;
                    }
                    else
                    {
                        this.strIndex = 0;
                    }

                    offset++;
                }

                if (this.strIndex == this.str.Length)
                {
                    this.found = true;
                }
            }
Esempio n. 4
0
        public static int CalculateLowerCase(string obj)
        {
            var hash1 = 5381;
            var hash2 = hash1;

            unsafe
            {
                fixed(char *src = obj)
                {
                    var s   = src;
                    var len = obj.Length;

                    while (len > 0)
                    {
                        hash1 = ((hash1 << 5) + hash1) ^ ParseSupport.ToLowerCase(s[0]);
                        if (len == 1)
                        {
                            break;
                        }
                        hash2 = ((hash2 << 5) + hash2) ^ ParseSupport.ToLowerCase(s[1]);
                        s    += 2;
                        len  -= 2;
                    }
                }
            }

            return(hash1 + (hash2 * 1566083941));
        }
Esempio n. 5
0
 public void Write(char[] buffer, int offset, int count)
 {
     if (this.IsActive)
     {
         int num = offset + count;
         while (offset < num)
         {
             if (this.urlPosition == 0)
             {
                 if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(buffer[offset])))
                 {
                     offset++;
                     continue;
                 }
             }
             else if (this.urlPosition == this.url.Length)
             {
                 if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(buffer[offset])))
                 {
                     offset++;
                     continue;
                 }
                 this.urlPosition = -1;
                 return;
             }
             if (buffer[offset] != this.url[this.urlPosition])
             {
                 this.urlPosition = -1;
                 return;
             }
             offset++;
             this.urlPosition++;
         }
     }
 }
Esempio n. 6
0
        public void Write(int ucs32Char)
        {
            int count;

            if (ucs32Char > 0xFFFF)
            {
                count = this.PrepareToBuffer(2);
                if (count > 0)
                {
                    this.parseBuffer[this.maxTokenSize]     = ParseSupport.HighSurrogateCharFromUcs4(ucs32Char);
                    this.parseBuffer[this.maxTokenSize + 1] = ParseSupport.LowSurrogateCharFromUcs4(ucs32Char);
                    this.maxTokenSize += count;
                    this.parseBuffer[this.maxTokenSize] = '\0';
                }
            }
            else
            {
                count = this.PrepareToBuffer(1);
                if (count > 0)
                {
                    this.parseBuffer[this.maxTokenSize++] = (char)ucs32Char;
                    this.parseBuffer[this.maxTokenSize]   = '\0';
                }
            }
        }
Esempio n. 7
0
        //public unsafe void Advance(char* s, int len)
        //{
        //    if (0 != (offset & 1))
        //    {
        //        hash2 = ((hash2 << 5) + hash2) ^ s[0];
        //        s++;
        //        len--;
        //        offset++;
        //    }

        //    offset += len;

        //    while (len > 0)
        //    {
        //        hash1 = ((hash1 << 5) + hash1) ^ s[0];
        //        if (len == 1)
        //            break;
        //        hash2 = ((hash2 << 5) + hash2) ^ s[1];
        //        s += 2;
        //        len -= 2;
        //    }
        //}

        //public unsafe void AdvanceLowerCase(char* s, int len)
        //{
        //    if (0 != (offset & 1))
        //    {
        //        hash2 = ((hash2 << 5) + hash2) ^ ParseSupport.ToLowerCase(s[0]);
        //        s++;
        //        len--;
        //        offset++;
        //    }

        //    offset += len;

        //    while (len > 0)
        //    {
        //        hash1 = ((hash1 << 5) + hash1) ^ ParseSupport.ToLowerCase(s[0]);
        //        if (len == 1)
        //            break;
        //        hash2 = ((hash2 << 5) + hash2) ^ ParseSupport.ToLowerCase(s[1]);
        //        s += 2;
        //        len -= 2;
        //    }
        //}

        public void Advance(int ucs32)
        {
            // Unicode 32bit literal.

            if (ucs32 >= 0x10000)
            {
                var c1 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
                var c2 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
                if (0 == ((offset += 2) & 1))
                {
                    hash1 = ((hash1 << 5) + hash1) ^ c1;
                    hash2 = ((hash2 << 5) + hash2) ^ c2;
                }
                else
                {
                    hash2 = ((hash2 << 5) + hash2) ^ c1;
                    hash1 = ((hash1 << 5) + hash1) ^ c2;
                }
            }
            else
            {
                if (0 == (offset++ & 1))
                {
                    hash1 = ((hash1 << 5) + hash1) ^ (int)ucs32;
                }
                else
                {
                    hash2 = ((hash2 << 5) + hash2) ^ (int)ucs32;
                }
            }
        }
Esempio n. 8
0
 // Token: 0x060011E2 RID: 4578 RVA: 0x0007EE4C File Offset: 0x0007D04C
 public void Advance(int ucs32)
 {
     if (ucs32 >= 65536)
     {
         char c  = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
         char c2 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
         if (((this.offset += 2) & 1) == 0)
         {
             this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)c);
             this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)c2);
             return;
         }
         this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)c);
         this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)c2);
         return;
     }
     else
     {
         if ((this.offset++ & 1) == 0)
         {
             this.hash1 = ((this.hash1 << 5) + this.hash1 ^ ucs32);
             return;
         }
         this.hash2 = ((this.hash2 << 5) + this.hash2 ^ ucs32);
         return;
     }
 }
Esempio n. 9
0
        private void OutputLastWhitespace(char nextChar)
        {
            if (this.lineLength > 255 && this.autoNewLines)
            {
                if (this.lineLength > this.longestLineLength)
                {
                    this.longestLineLength = this.lineLength;
                }

                this.lineLength = 0;

                if (ParseSupport.FarEastNonHanguelChar(nextChar))
                {
                    this.output.Write(' ');
                    this.lineLength++;
                }
            }
            else
            {
                this.output.Write(' ');
                this.lineLength++;
            }

            this.textLineLength++;
            this.lastWhitespace = false;
        }
Esempio n. 10
0
        // Token: 0x060011DE RID: 4574 RVA: 0x0007EC54 File Offset: 0x0007CE54
        public unsafe static int CalculateLowerCase(char[] buffer, int offset, int length)
        {
            int num  = 5381;
            int num2 = num;

            HashCode.CheckArgs(buffer, offset, length);
            fixed(char *ptr = buffer)
            {
                char *ptr2 = ptr + offset;

                while (length > 0)
                {
                    num = ((num << 5) + num ^ (int)ParseSupport.ToLowerCase(*ptr2));
                    if (length == 1)
                    {
                        break;
                    }
                    num2    = ((num2 << 5) + num2 ^ (int)ParseSupport.ToLowerCase(ptr2[1]));
                    ptr2   += 2;
                    length -= 2;
                }
            }

            return(num + num2 * 1566083941);
        }
Esempio n. 11
0
        public static int CalculateLowerCase(char[] buffer, int offset, int length)
        {
            int hash1 = 5381;
            int hash2 = hash1;

            HashCode.CheckArgs(buffer, offset, length);

            unsafe
            {
                fixed(char *src = buffer)
                {
                    char *s = src + offset;

                    while (length > 0)
                    {
                        hash1 = ((hash1 << 5) + hash1) ^ ParseSupport.ToLowerCase(s[0]);
                        if (length == 1)
                        {
                            break;
                        }
                        hash2   = ((hash2 << 5) + hash2) ^ ParseSupport.ToLowerCase(s[1]);
                        s      += 2;
                        length -= 2;
                    }
                }
            }

            return(hash1 + (hash2 * 1566083941));
        }
Esempio n. 12
0
 public void Write(int ucs32Char)
 {
     if (Token.LiteralLength(ucs32Char) != 1)
     {
         this.urlPosition = -1;
         return;
     }
     if (this.urlPosition == 0)
     {
         if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass((char)ucs32Char)))
         {
             return;
         }
     }
     else if (this.urlPosition == this.url.Length)
     {
         if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass((char)ucs32Char)))
         {
             return;
         }
         this.urlPosition = -1;
         return;
     }
     if ((char)ucs32Char != this.url[this.urlPosition])
     {
         this.urlPosition = -1;
         return;
     }
     this.urlPosition++;
 }
Esempio n. 13
0
 public static char ToLowerCase(char ch)
 {
     if (!ParseSupport.IsUpperCase(ch))
     {
         return(ch);
     }
     return(ch + ' ');
 }
Esempio n. 14
0
 public static CharClass GetCharClass(char ch)
 {
     if (ch > 'ÿ')
     {
         return(ParseSupport.GetHighCharClass(ch));
     }
     return(ParseSupport.lowCharClass[(int)ch]);
 }
Esempio n. 15
0
 // Token: 0x060011E6 RID: 4582 RVA: 0x0007F08C File Offset: 0x0007D28C
 public void AdvanceLowerCase(char c)
 {
     if ((this.offset++ & 1) == 0)
     {
         this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)ParseSupport.ToLowerCase(c));
         return;
     }
     this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)ParseSupport.ToLowerCase(c));
 }
Esempio n. 16
0
 public void AdvanceLowerCase(char c)
 {
     if (0 == (offset++ & 1))
     {
         hash1 = ((hash1 << 5) + hash1) ^ ParseSupport.ToLowerCase(c);
     }
     else
     {
         hash2 = ((hash2 << 5) + hash2) ^ ParseSupport.ToLowerCase(c);
     }
 }
Esempio n. 17
0
        public static int CompareLowerCaseStringToBufferStringIgnoreCase(string left, BufferString right)
        {
            int num = Math.Min(left.Length, right.Length);

            for (int i = 0; i < num; i++)
            {
                int num2 = (int)(left[i] - ParseSupport.ToLowerCase(right[i]));
                if (num2 != 0)
                {
                    return(num2);
                }
            }
            return(left.Length - right.Length);
        }
Esempio n. 18
0
        public void Write(int ucs32Literal, IFallback fallback)
        {
            if (ucs32Literal > 0xFFFF)
            {
                stringBuffer[0] = ParseSupport.HighSurrogateCharFromUcs4(ucs32Literal);
                stringBuffer[1] = ParseSupport.LowSurrogateCharFromUcs4(ucs32Literal);
            }
            else
            {
                stringBuffer[0] = (char)ucs32Literal;
            }

            Write(stringBuffer, 0, ucs32Literal > 0xFFFF ? 2 : 1, fallback);
        }
Esempio n. 19
0
 public bool StartsWithLowerCaseStringIgnoreCase(string rightPart)
 {
     if (this.count < rightPart.Length)
     {
         return(false);
     }
     for (int i = 0; i < rightPart.Length; i++)
     {
         if (ParseSupport.ToLowerCase(this.buffer[this.offset + i]) != rightPart[i])
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 20
0
 public void TrimWhitespace()
 {
     while (this.count != 0 && ParseSupport.WhitespaceCharacter(this.buffer[this.offset]))
     {
         this.offset++;
         this.count--;
     }
     if (this.count != 0)
     {
         int num = this.offset + this.count - 1;
         while (ParseSupport.WhitespaceCharacter(this.buffer[num--]))
         {
             this.count--;
         }
     }
 }
Esempio n. 21
0
        protected internal virtual bool CaseInsensitiveCompareRunEqual(int runOffset, string str, int strOffset)
        {
            int index = strOffset;

            while (index < str.Length)
            {
                InternalDebug.Assert(!ParseSupport.IsUpperCase(str[index]));

                if (ParseSupport.ToLowerCase(this.buffer[runOffset++]) != str[index++])
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 22
0
        public static int CompareLowerCaseStringToBufferStringIgnoreCase(string left, BufferString right)
        {
            var len = Math.Min(left.Length, right.Length);

            for (var i = 0; i < len; i++)
            {
                var cmp = (int)left[i] - (int)ParseSupport.ToLowerCase(right[i]);
                if (cmp != 0)
                {
                    return(cmp);
                }
            }



            return(left.Length - right.Length);
        }
Esempio n. 23
0
        public void TrimWhitespace()
        {
            while (count != 0 && ParseSupport.WhitespaceCharacter(buffer[offset]))
            {
                offset++;
                count--;
            }

            if (count != 0)
            {
                var end = offset + count - 1;
                while (ParseSupport.WhitespaceCharacter(buffer[end--]))
                {
                    count--;
                }
            }
        }
Esempio n. 24
0
 public static string CharsetFromString(string arg, bool lookForWordCharset)
 {
     for (int i = 0; i < arg.Length; i++)
     {
         while (i < arg.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(arg[i])))
         {
             i++;
         }
         if (i == arg.Length)
         {
             break;
         }
         if (!lookForWordCharset || (arg.Length - i >= 7 && string.Equals(arg.Substring(i, 7), "charset", StringComparison.OrdinalIgnoreCase)))
         {
             if (lookForWordCharset)
             {
                 i = arg.IndexOf('=', i + 7);
                 if (i < 0)
                 {
                     break;
                 }
                 i++;
                 while (i < arg.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(arg[i])))
                 {
                     i++;
                 }
                 if (i == arg.Length)
                 {
                     break;
                 }
             }
             int num = i;
             while (num < arg.Length && arg[num] != ';' && !ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(arg[num])))
             {
                 num++;
             }
             return(arg.Substring(i, num - i));
         }
         i = arg.IndexOf(';', i);
         if (i < 0)
         {
             break;
         }
     }
     return(null);
 }
Esempio n. 25
0
        internal ITextSinkEx WriteText()
        {
            if (this.outputState != OutputState.OutsideTag)
            {
                this.WriteTagEnd();
            }

            this.allowWspBeforeFollowingTag = false;

            if (this.lastWhitespace)
            {
                InternalDebug.Assert(ParseSupport.FarEastNonHanguelChar('\x3000'));
                this.OutputLastWhitespace('\x3000');
            }

            this.fallback = this;
            return(this);
        }
Esempio n. 26
0
            public void Write(int ucs32Char)
            {
                InternalDebug.Assert(!this.found && this.strIndex < this.str.Length);

                if (Token.LiteralLength(ucs32Char) != 1 ||
                    this.str[this.strIndex] != ParseSupport.ToLowerCase((char)ucs32Char))
                {
                    this.strIndex = 0;
                    return;
                }

                this.strIndex++;

                if (this.strIndex == this.str.Length)
                {
                    this.found = true;
                }
            }
Esempio n. 27
0
        // Token: 0x060011E3 RID: 4579 RVA: 0x0007EF2C File Offset: 0x0007D12C
        public void AdvanceLowerCase(int ucs32)
        {
            if (ucs32 < 65536)
            {
                this.AdvanceLowerCase((char)ucs32);
                return;
            }
            char c  = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
            char c2 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);

            if (((this.offset += 2) & 1) == 0)
            {
                this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)c);
                this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)c2);
                return;
            }
            this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)c);
            this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)c2);
        }
Esempio n. 28
0
        public bool StartsWithLowerCaseStringIgnoreCase(string rightPart)
        {
            AssertStringIsLowerCase(rightPart);



            if (count < rightPart.Length)
            {
                return(false);
            }

            for (var i = 0; i < rightPart.Length; i++)
            {
                if (ParseSupport.ToLowerCase(buffer[offset + i]) != rightPart[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 29
0
 public void AdvanceLowerCase(int ucs32)
 {
     if (ucs32 >= 0x10000)
     {
         var c1 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
         var c2 = ParseSupport.LowSurrogateCharFromUcs4(ucs32);
         if (0 == ((offset += 2) & 1))
         {
             hash1 = ((hash1 << 5) + hash1) ^ c1;
             hash2 = ((hash2 << 5) + hash2) ^ c2;
         }
         else
         {
             hash2 = ((hash2 << 5) + hash2) ^ c1;
             hash1 = ((hash1 << 5) + hash1) ^ c2;
         }
     }
     else
     {
         AdvanceLowerCase((char)ucs32);
     }
 }
Esempio n. 30
0
 // Token: 0x060011E1 RID: 4577 RVA: 0x0007ED9C File Offset: 0x0007CF9C
 public unsafe void AdvanceLowerCase(char *s, int len)
 {
     if ((this.offset & 1) != 0)
     {
         this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)ParseSupport.ToLowerCase(*s));
         s++;
         len--;
         this.offset++;
     }
     this.offset += len;
     while (len > 0)
     {
         this.hash1 = ((this.hash1 << 5) + this.hash1 ^ (int)ParseSupport.ToLowerCase(*s));
         if (len == 1)
         {
             return;
         }
         this.hash2 = ((this.hash2 << 5) + this.hash2 ^ (int)ParseSupport.ToLowerCase(s[1]));
         s         += 2;
         len       -= 2;
     }
 }