From 849fc19cab2c3059379b21dde019f521ce772f5c Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 30 Nov 2011 17:00:37 +1100 Subject: [PATCH] html: clean up the z.rawTag calculation in the tokenizer. R=andybalholm CC=golang-dev https://golang.org/cl/5440064 --- src/pkg/html/token.go | 51 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/pkg/html/token.go b/src/pkg/html/token.go index 57e70ffeed5..69af96840c2 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] == '/' {