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++; } } }
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++; }
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++; }
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--; } } }
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); }
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--; } } }
public static string TrimWhitespace(string value) { string result = value; if (!string.IsNullOrEmpty(value)) { int num = 0; int num2 = value.Length; if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[0]))) { num = 1; while (num < num2 && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num]))) { num++; } } if (num != num2) { if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num2 - 1]))) { num2--; while (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num2 - 1]))) { num2--; } } if (num2 - num != value.Length) { result = value.Substring(num, num2 - num); } } else { result = string.Empty; } } return(result); }
public void Write(char[] buffer, int offset, int count) { int end = offset + count; while (offset < end) { if (this.strIndex == 0) { if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(buffer[offset]))) { offset++; continue; } } else if (this.strIndex == this.str.Length) { if (ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(buffer[offset]))) { offset++; continue; } this.definitelyNotEqual = true; break; } if (ParseSupport.ToLowerCase(buffer[offset]) != this.str[this.strIndex]) { this.definitelyNotEqual = true; break; } offset++; this.strIndex++; } }
protected internal bool SkipLeadingWhitespace(LexicalUnit unit, ref FragmentPosition position) { int run = unit.head; if (run != -1) { int runOffset = unit.headOffset; CharClass charClass; RunEntry runEntry = this.runList[run]; uint kind = runEntry.MajorKind; int deltaOffset = 0; do { if (runEntry.Type == RunType.Literal) { if (runEntry.Value > 0xFFFF) { break; } charClass = ParseSupport.GetCharClass((char)runEntry.Value); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } } else if (runEntry.Type == RunType.Normal) { int offset = runOffset; while (offset < runOffset + runEntry.Length) { charClass = ParseSupport.GetCharClass(this.buffer[offset]); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } offset++; } if (offset < runOffset + runEntry.Length) { deltaOffset = offset - runOffset; break; } } runOffset += runEntry.Length; runEntry = this.runList[++run]; }while (runEntry.MajorKindPlusStartFlag == kind); position.run = run; position.runOffset = runOffset; position.runDeltaOffset = deltaOffset; if (run == unit.head || runEntry.MajorKindPlusStartFlag == kind) { return(true); } } return(false); }
protected internal void StripLeadingWhitespace(ref Fragment fragment) { int run = fragment.head; if (run != fragment.tail) { int runOffset = fragment.headOffset; CharClass charClass; if (this.runList[run].Type < RunType.Normal) { this.SkipNonTextRuns(ref run, ref runOffset, fragment.tail); } if (run == fragment.tail) { return; } do { InternalDebug.Assert(this.runList[run].Type >= RunType.Normal); if (this.runList[run].Type == RunType.Literal) { if (this.runList[run].Value > 0xFFFF) { break; } charClass = ParseSupport.GetCharClass((char)this.runList[run].Value); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } } else { int offset = runOffset; while (offset < runOffset + this.runList[run].Length) { charClass = ParseSupport.GetCharClass(this.buffer[offset]); if (!ParseSupport.WhitespaceCharacter(charClass)) { break; } offset++; } if (offset < runOffset + this.runList[run].Length) { this.runList[run].Length -= (offset - runOffset); runOffset = offset; break; } } runOffset += this.runList[run].Length; run++; if (run != fragment.tail && this.runList[run].Type < RunType.Normal) { this.SkipNonTextRuns(ref run, ref runOffset, fragment.tail); } }while (run != fragment.tail); fragment.head = run; fragment.headOffset = runOffset; } }