summaryrefslogtreecommitdiffstats
path: root/libgo/go/html
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-14 15:41:54 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-14 15:41:54 +0000
commit7da93e24295c8b313ecdcedee0b8bde70b335e61 (patch)
treee3de46cbc89d82ca1f49843fe2e1e670db67795e /libgo/go/html
parentf86a7907050666ce7cab2890b353619f83d6c98b (diff)
downloadppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.tar.gz
ppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.zip
libgo: Update to weekly.2011-12-06.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/html')
-rw-r--r--libgo/go/html/parse.go17
-rw-r--r--libgo/go/html/parse_test.go1
-rw-r--r--libgo/go/html/render_test.go34
-rw-r--r--libgo/go/html/template/css_test.go2
-rw-r--r--libgo/go/html/template/escape.go2
-rw-r--r--libgo/go/html/template/escape_test.go10
-rw-r--r--libgo/go/html/template/template.go15
7 files changed, 47 insertions, 34 deletions
diff --git a/libgo/go/html/parse.go b/libgo/go/html/parse.go
index 97fbc514d82..dd2d8165bdb 100644
--- a/libgo/go/html/parse.go
+++ b/libgo/go/html/parse.go
@@ -515,7 +515,19 @@ func afterHeadIM(p *parser) bool {
implied bool
)
switch p.tok.Type {
- case ErrorToken, TextToken:
+ case ErrorToken:
+ implied = true
+ framesetOK = true
+ case TextToken:
+ s := strings.TrimLeft(p.tok.Data, whitespace)
+ if len(s) < len(p.tok.Data) {
+ // Add the initial whitespace to the current node.
+ p.addText(p.tok.Data[:len(p.tok.Data)-len(s)])
+ if s == "" {
+ return true
+ }
+ p.tok.Data = s
+ }
implied = true
framesetOK = true
case StartTagToken:
@@ -535,7 +547,8 @@ func afterHeadIM(p *parser) bool {
defer p.oe.pop()
return inHeadIM(p)
case "head":
- // TODO.
+ // Ignore the token.
+ return true
default:
implied = true
framesetOK = true
diff --git a/libgo/go/html/parse_test.go b/libgo/go/html/parse_test.go
index e0c19cff6da..5062a6edcb8 100644
--- a/libgo/go/html/parse_test.go
+++ b/libgo/go/html/parse_test.go
@@ -167,6 +167,7 @@ func TestParser(t *testing.T) {
{"tests3.dat", -1},
{"tests4.dat", -1},
{"tests5.dat", -1},
+ {"tests6.dat", 7},
}
for _, tf := range testFiles {
f, err := os.Open("testdata/webkit/" + tf.filename)
diff --git a/libgo/go/html/render_test.go b/libgo/go/html/render_test.go
index d166a3b8736..0584f35abdb 100644
--- a/libgo/go/html/render_test.go
+++ b/libgo/go/html/render_test.go
@@ -14,63 +14,63 @@ func TestRenderer(t *testing.T) {
Type: ElementNode,
Data: "html",
Child: []*Node{
- &Node{
+ {
Type: ElementNode,
Data: "head",
},
- &Node{
+ {
Type: ElementNode,
Data: "body",
Child: []*Node{
- &Node{
+ {
Type: TextNode,
Data: "0<1",
},
- &Node{
+ {
Type: ElementNode,
Data: "p",
Attr: []Attribute{
- Attribute{
+ {
Key: "id",
Val: "A",
},
- Attribute{
+ {
Key: "foo",
Val: `abc"def`,
},
},
Child: []*Node{
- &Node{
+ {
Type: TextNode,
Data: "2",
},
- &Node{
+ {
Type: ElementNode,
Data: "b",
Attr: []Attribute{
- Attribute{
+ {
Key: "empty",
Val: "",
},
},
Child: []*Node{
- &Node{
+ {
Type: TextNode,
Data: "3",
},
},
},
- &Node{
+ {
Type: ElementNode,
Data: "i",
Attr: []Attribute{
- Attribute{
+ {
Key: "backslash",
Val: `\`,
},
},
Child: []*Node{
- &Node{
+ {
Type: TextNode,
Data: "&4",
},
@@ -78,19 +78,19 @@ func TestRenderer(t *testing.T) {
},
},
},
- &Node{
+ {
Type: TextNode,
Data: "5",
},
- &Node{
+ {
Type: ElementNode,
Data: "blockquote",
},
- &Node{
+ {
Type: ElementNode,
Data: "br",
},
- &Node{
+ {
Type: TextNode,
Data: "6",
},
diff --git a/libgo/go/html/template/css_test.go b/libgo/go/html/template/css_test.go
index 0d94bdcf18c..a735638b031 100644
--- a/libgo/go/html/template/css_test.go
+++ b/libgo/go/html/template/css_test.go
@@ -113,7 +113,7 @@ func TestDecodeCSS(t *testing.T) {
func TestHexDecode(t *testing.T) {
for i := 0; i < 0x200000; i += 101 /* coprime with 16 */ {
- s := strconv.Itob(i, 16)
+ s := strconv.FormatInt(int64(i), 16)
if got := int(hexDecode([]byte(s))); got != i {
t.Errorf("%s: want %d but got %d", s, i, got)
}
diff --git a/libgo/go/html/template/escape.go b/libgo/go/html/template/escape.go
index 4a7a9354c93..2f6be3b6c21 100644
--- a/libgo/go/html/template/escape.go
+++ b/libgo/go/html/template/escape.go
@@ -716,7 +716,7 @@ func (e *escaper) editTextNode(n *parse.TextNode, text []byte) {
// commit applies changes to actions and template calls needed to contextually
// autoescape content and adds any derived templates to the set.
func (e *escaper) commit() {
- for name, _ := range e.output {
+ for name := range e.output {
e.template(name).Funcs(funcMap)
}
for _, t := range e.derived {
diff --git a/libgo/go/html/template/escape_test.go b/libgo/go/html/template/escape_test.go
index b4daca7d6bd..cdeed48b822 100644
--- a/libgo/go/html/template/escape_test.go
+++ b/libgo/go/html/template/escape_test.go
@@ -689,11 +689,11 @@ func TestEscapeSet(t *testing.T) {
data := dataItem{
Children: []*dataItem{
- &dataItem{X: "foo"},
- &dataItem{X: "<bar>"},
- &dataItem{
+ {X: "foo"},
+ {X: "<bar>"},
+ {
Children: []*dataItem{
- &dataItem{X: "baz"},
+ {X: "baz"},
},
},
},
@@ -1597,7 +1597,7 @@ func TestRedundantFuncs(t *testing.T) {
for n0, m := range redundantFuncs {
f0 := funcMap[n0].(func(...interface{}) string)
- for n1, _ := range m {
+ for n1 := range m {
f1 := funcMap[n1].(func(...interface{}) string)
for _, input := range inputs {
want := f0(input)
diff --git a/libgo/go/html/template/template.go b/libgo/go/html/template/template.go
index f05ca190f73..fa2ed18874c 100644
--- a/libgo/go/html/template/template.go
+++ b/libgo/go/html/template/template.go
@@ -47,23 +47,22 @@ func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
return t.text.Execute(wr, data)
}
-// ExecuteTemplate applies the template associated with t that has the given name
-// to the specified data object and writes the output to wr.
+// ExecuteTemplate applies the template associated with t that has the given
+// name to the specified data object and writes the output to wr.
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) (err error) {
t.nameSpace.mu.Lock()
tmpl := t.set[name]
- if tmpl == nil {
- t.nameSpace.mu.Unlock()
- return fmt.Errorf("template: no template %q associated with template %q", name, t.Name())
+ if (tmpl == nil) != (t.text.Lookup(name) == nil) {
+ panic("html/template internal error: template escaping out of sync")
}
- if !tmpl.escaped {
+ if tmpl != nil && !tmpl.escaped {
err = escapeTemplates(tmpl, name)
}
t.nameSpace.mu.Unlock()
if err != nil {
return
}
- return tmpl.text.ExecuteTemplate(wr, name, data)
+ return t.text.ExecuteTemplate(wr, name, data)
}
// Parse parses a string into a template. Nested template definitions
@@ -106,7 +105,7 @@ func (t *Template) AddParseTree(name string, tree *parse.Tree) error {
// Clone is unimplemented.
func (t *Template) Clone(name string) error {
- return fmt.Errorf("html/template: Add unimplemented")
+ return fmt.Errorf("html/template: Clone unimplemented")
}
// New allocates a new HTML template with the given name.
OpenPOWER on IntegriCloud