vendor/golang.org/x/net/html/token.go
changeset 251 1c52a0eeb952
parent 242 2a9ec03fe5a1
child 260 445e01aede7e
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
   294 // readAtLeastOneByte wraps an io.Reader so that reading cannot return (0, nil).
   294 // readAtLeastOneByte wraps an io.Reader so that reading cannot return (0, nil).
   295 // It returns io.ErrNoProgress if the underlying r.Read method returns (0, nil)
   295 // It returns io.ErrNoProgress if the underlying r.Read method returns (0, nil)
   296 // too many times in succession.
   296 // too many times in succession.
   297 func readAtLeastOneByte(r io.Reader, b []byte) (int, error) {
   297 func readAtLeastOneByte(r io.Reader, b []byte) (int, error) {
   298 	for i := 0; i < 100; i++ {
   298 	for i := 0; i < 100; i++ {
   299 		n, err := r.Read(b)
   299 		if n, err := r.Read(b); n != 0 || err != nil {
   300 		if n != 0 || err != nil {
       
   301 			return n, err
   300 			return n, err
   302 		}
   301 		}
   303 	}
   302 	}
   304 	return 0, io.ErrNoProgress
   303 	return 0, io.ErrNoProgress
   305 }
   304 }
   345 		c = z.readByte()
   344 		c = z.readByte()
   346 		if z.err != nil {
   345 		if z.err != nil {
   347 			break loop
   346 			break loop
   348 		}
   347 		}
   349 		if c != '/' {
   348 		if c != '/' {
       
   349 			z.raw.end--
   350 			continue loop
   350 			continue loop
   351 		}
   351 		}
   352 		if z.readRawEndTag() || z.err != nil {
   352 		if z.readRawEndTag() || z.err != nil {
   353 			break loop
   353 			break loop
   354 		}
   354 		}
  1065 	return z.tt
  1065 	return z.tt
  1066 }
  1066 }
  1067 
  1067 
  1068 // Raw returns the unmodified text of the current token. Calling Next, Token,
  1068 // Raw returns the unmodified text of the current token. Calling Next, Token,
  1069 // Text, TagName or TagAttr may change the contents of the returned slice.
  1069 // Text, TagName or TagAttr may change the contents of the returned slice.
       
  1070 //
       
  1071 // The token stream's raw bytes partition the byte stream (up until an
       
  1072 // ErrorToken). There are no overlaps or gaps between two consecutive token's
       
  1073 // raw bytes. One implication is that the byte offset of the current token is
       
  1074 // the sum of the lengths of all previous tokens' raw bytes.
  1070 func (z *Tokenizer) Raw() []byte {
  1075 func (z *Tokenizer) Raw() []byte {
  1071 	return z.buf[z.raw.start:z.raw.end]
  1076 	return z.buf[z.raw.start:z.raw.end]
  1072 }
  1077 }
  1073 
  1078 
  1074 // convertNewlines converts "\r" and "\r\n" in s to "\n".
  1079 // convertNewlines converts "\r" and "\r\n" in s to "\n".