aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/encoding/xml/xml.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-09-24 21:46:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-09-24 21:46:21 +0000
commitdd931d9b48647e898dc80927c532ae93cc09e192 (patch)
tree71be2295cd79b8a182f6130611658db8628772d5 /libgo/go/encoding/xml/xml.go
parent779d8a5ad09b01428726ea5a0e6c87bd9ac3c0e4 (diff)
downloadgcc-dd931d9b48647e898dc80927c532ae93cc09e192.zip
gcc-dd931d9b48647e898dc80927c532ae93cc09e192.tar.gz
gcc-dd931d9b48647e898dc80927c532ae93cc09e192.tar.bz2
libgo: update to Go 1.11
Reviewed-on: https://go-review.googlesource.com/136435 gotools/: * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to make sure it is writable. (check-go-tools): Likewise. (check-vet): Copy internal/objabi to check-vet-dir. * Makefile.in: Rebuild. From-SVN: r264546
Diffstat (limited to 'libgo/go/encoding/xml/xml.go')
-rw-r--r--libgo/go/encoding/xml/xml.go56
1 files changed, 23 insertions, 33 deletions
diff --git a/libgo/go/encoding/xml/xml.go b/libgo/go/encoding/xml/xml.go
index f408623..ca05944 100644
--- a/libgo/go/encoding/xml/xml.go
+++ b/libgo/go/encoding/xml/xml.go
@@ -7,8 +7,8 @@
package xml
// References:
-// Annotated XML spec: http://www.xml.com/axml/testaxml.htm
-// XML name spaces: http://www.w3.org/TR/REC-xml-names/
+// Annotated XML spec: https://www.xml.com/axml/testaxml.htm
+// XML name spaces: https://www.w3.org/TR/REC-xml-names/
// TODO(rsc):
// Test error handling.
@@ -167,9 +167,9 @@ type Decoder struct {
//
// Setting:
//
- // d.Strict = false;
- // d.AutoClose = HTMLAutoClose;
- // d.Entity = HTMLEntity
+ // d.Strict = false
+ // d.AutoClose = xml.HTMLAutoClose
+ // d.Entity = xml.HTMLEntity
//
// creates a parser that can handle typical HTML.
//
@@ -198,7 +198,7 @@ type Decoder struct {
// charset-conversion readers, converting from the provided
// non-UTF-8 charset into UTF-8. If CharsetReader is nil or
// returns an error, parsing stops with an error. One of the
- // the CharsetReader's result values must be non-nil.
+ // CharsetReader's result values must be non-nil.
CharsetReader func(charset string, input io.Reader) (io.Reader, error)
// DefaultSpace sets the default name space used for unadorned tags,
@@ -271,7 +271,7 @@ func NewTokenDecoder(t TokenReader) *Decoder {
// it will return an error.
//
// Token implements XML name spaces as described by
-// http://www.w3.org/TR/REC-xml-names/. Each of the
+// https://www.w3.org/TR/REC-xml-names/. Each of the
// Name structures contained in the Token has the Space
// set to the URL identifying its name space when known.
// If Token encounters an unrecognized name space prefix,
@@ -806,18 +806,7 @@ func (d *Decoder) rawToken() (Token, error) {
}
d.ungetc(b)
- n := len(attr)
- if n >= cap(attr) {
- nCap := 2 * cap(attr)
- if nCap == 0 {
- nCap = 4
- }
- nattr := make([]Attr, n, nCap)
- copy(nattr, attr)
- attr = nattr
- }
- attr = attr[0 : n+1]
- a := &attr[n]
+ a := Attr{}
if a.Name, ok = d.nsname(); !ok {
if d.err == nil {
d.err = d.syntaxError("expected attribute name in element")
@@ -843,6 +832,7 @@ func (d *Decoder) rawToken() (Token, error) {
}
a.Value = string(data)
}
+ attr = append(attr, a)
}
if empty {
d.needClose = true
@@ -873,7 +863,7 @@ func (d *Decoder) attrval() []byte {
if !ok {
return nil
}
- // http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2
+ // https://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2
if 'a' <= b && b <= 'z' || 'A' <= b && b <= 'Z' ||
'0' <= b && b <= '9' || b == '_' || b == ':' || b == '-' {
d.buf.WriteByte(b)
@@ -1144,13 +1134,13 @@ Input:
}
// Decide whether the given rune is in the XML Character Range, per
-// the Char production of http://www.xml.com/axml/testaxml.htm,
+// the Char production of https://www.xml.com/axml/testaxml.htm,
// Section 2.2 Characters.
func isInCharacterRange(r rune) (inrange bool) {
return r == 0x09 ||
r == 0x0A ||
r == 0x0D ||
- r >= 0x20 && r <= 0xDF77 ||
+ r >= 0x20 && r <= 0xD7FF ||
r >= 0xE000 && r <= 0xFFFD ||
r >= 0x10000 && r <= 0x10FFFF
}
@@ -1273,7 +1263,7 @@ func isNameString(s string) bool {
}
// These tables were generated by cut and paste from Appendix B of
-// the XML spec at http://www.xml.com/axml/testaxml.htm
+// the XML spec at https://www.xml.com/axml/testaxml.htm
// and then reformatting. First corresponds to (Letter | '_' | ':')
// and second corresponds to NameChar.
@@ -1591,7 +1581,9 @@ var second = &unicode.RangeTable{
// HTMLEntity is an entity map containing translations for the
// standard HTML entity characters.
-var HTMLEntity = htmlEntity
+//
+// See the Decoder.Strict and Decoder.Entity fields' documentation.
+var HTMLEntity map[string]string = htmlEntity
var htmlEntity = map[string]string{
/*
@@ -1858,7 +1850,9 @@ var htmlEntity = map[string]string{
// HTMLAutoClose is the set of HTML elements that
// should be considered to close automatically.
-var HTMLAutoClose = htmlAutoClose
+//
+// See the Decoder.Strict and Decoder.Entity fields' documentation.
+var HTMLAutoClose []string = htmlAutoClose
var htmlAutoClose = []string{
/*
@@ -1942,10 +1936,8 @@ func escapeText(w io.Writer, s []byte, escapeNewline bool) error {
}
last = i
}
- if _, err := w.Write(s[last:]); err != nil {
- return err
- }
- return nil
+ _, err := w.Write(s[last:])
+ return err
}
// EscapeString writes to p the properly escaped XML equivalent
@@ -2028,10 +2020,8 @@ func emitCDATA(w io.Writer, s []byte) error {
}
s = s[i:]
}
- if _, err := w.Write(cdataEnd); err != nil {
- return err
- }
- return nil
+ _, err := w.Write(cdataEnd)
+ return err
}
// procInst parses the `param="..."` or `param='...'`