From: Nigel Tao Date: Wed, 30 Nov 2011 06:00:37 +0000 (+1100) Subject: html: clean up the z.rawTag calculation in the tokenizer. X-Git-Tag: weekly.2011-12-01~17 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=849fc19cab2c3059379b21dde019f521ce772f5c;p=gostls13.git html: clean up the z.rawTag calculation in the tokenizer. R=andybalholm CC=golang-dev https://golang.org/cl/5440064 --- diff --git a/src/pkg/html/token.go b/src/pkg/html/token.go index 57e70ffeed..69af96840c 100644 --- a/src/pkg/html/token.go +++ b/src/pkg/html/token.go @@ -379,6 +379,28 @@ func (z *Tokenizer) readMarkupDeclaration() TokenType { return DoctypeToken } +// startTagIn returns whether the start tag in z.buf[z.data.start:z.data.end] +// case-insensitively matches any element of ss. +func (z *Tokenizer) startTagIn(ss ...string) bool { +loop: + for _, s := range ss { + if z.data.end-z.data.start != len(s) { + continue loop + } + for i := 0; i < len(s); i++ { + c := z.buf[z.data.start+i] + if 'A' <= c && c <= 'Z' { + c += 'a' - 'A' + } + if c != s[i] { + continue loop + } + } + return true + } + return false +} + // readStartTag reads the next start tag token. The opening "". if z.err == nil && z.buf[z.raw.end-2] == '/' {