summaryrefslogtreecommitdiff
path: root/libgo/go/html
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
commit2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch)
tree7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/html
parent02e9018f1616b23f1276151797216717b3564202 (diff)
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/html')
-rw-r--r--libgo/go/html/escape.go3
-rw-r--r--libgo/go/html/parse.go7
-rw-r--r--libgo/go/html/parse_test.go15
-rw-r--r--libgo/go/html/render.go14
-rw-r--r--libgo/go/html/token.go5
-rw-r--r--libgo/go/html/token_test.go6
6 files changed, 24 insertions, 26 deletions
diff --git a/libgo/go/html/escape.go b/libgo/go/html/escape.go
index 69e0028e445..b8e6571a292 100644
--- a/libgo/go/html/escape.go
+++ b/libgo/go/html/escape.go
@@ -6,7 +6,6 @@ package html
import (
"bytes"
- "os"
"strings"
"utf8"
)
@@ -195,7 +194,7 @@ func lower(b []byte) []byte {
const escapedChars = `&'<>"`
-func escape(w writer, s string) os.Error {
+func escape(w writer, s string) error {
i := strings.IndexAny(s, escapedChars)
for i != -1 {
if _, err := w.WriteString(s[:i]); err != nil {
diff --git a/libgo/go/html/parse.go b/libgo/go/html/parse.go
index 54f7e2e8a55..c9f016588d0 100644
--- a/libgo/go/html/parse.go
+++ b/libgo/go/html/parse.go
@@ -6,7 +6,6 @@ package html
import (
"io"
- "os"
"strings"
)
@@ -240,7 +239,7 @@ func (p *parser) reconstructActiveFormattingElements() {
// read reads the next token. This is usually from the tokenizer, but it may
// be the synthesized end tag implied by a self-closing tag.
-func (p *parser) read() os.Error {
+func (p *parser) read() error {
if p.hasSelfClosingToken {
p.hasSelfClosingToken = false
p.tok.Type = EndTagToken
@@ -1136,7 +1135,7 @@ func afterAfterBodyIM(p *parser) (insertionMode, bool) {
// Parse returns the parse tree for the HTML from the given Reader.
// The input is assumed to be UTF-8 encoded.
-func Parse(r io.Reader) (*Node, os.Error) {
+func Parse(r io.Reader) (*Node, error) {
p := &parser{
tokenizer: NewTokenizer(r),
doc: &Node{
@@ -1150,7 +1149,7 @@ func Parse(r io.Reader) (*Node, os.Error) {
for {
if consumed {
if err := p.read(); err != nil {
- if err == os.EOF {
+ if err == io.EOF {
break
}
return nil, err
diff --git a/libgo/go/html/parse_test.go b/libgo/go/html/parse_test.go
index b9572fa1234..3fa40374eae 100644
--- a/libgo/go/html/parse_test.go
+++ b/libgo/go/html/parse_test.go
@@ -7,6 +7,7 @@ package html
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -15,7 +16,7 @@ import (
"testing"
)
-func pipeErr(err os.Error) io.Reader {
+func pipeErr(err error) io.Reader {
pr, pw := io.Pipe()
pw.CloseWithError(err)
return pr
@@ -76,13 +77,13 @@ func dumpIndent(w io.Writer, level int) {
}
}
-func dumpLevel(w io.Writer, n *Node, level int) os.Error {
+func dumpLevel(w io.Writer, n *Node, level int) error {
dumpIndent(w, level)
switch n.Type {
case ErrorNode:
- return os.NewError("unexpected ErrorNode")
+ return errors.New("unexpected ErrorNode")
case DocumentNode:
- return os.NewError("unexpected DocumentNode")
+ return errors.New("unexpected DocumentNode")
case ElementNode:
fmt.Fprintf(w, "<%s>", n.Data)
for _, a := range n.Attr {
@@ -97,9 +98,9 @@ func dumpLevel(w io.Writer, n *Node, level int) os.Error {
case DoctypeNode:
fmt.Fprintf(w, "<!DOCTYPE %s>", n.Data)
case scopeMarkerNode:
- return os.NewError("unexpected scopeMarkerNode")
+ return errors.New("unexpected scopeMarkerNode")
default:
- return os.NewError("unknown node type")
+ return errors.New("unknown node type")
}
io.WriteString(w, "\n")
for _, c := range n.Child {
@@ -110,7 +111,7 @@ func dumpLevel(w io.Writer, n *Node, level int) os.Error {
return nil
}
-func dump(n *Node) (string, os.Error) {
+func dump(n *Node) (string, error) {
if n == nil || len(n.Child) == 0 {
return "", nil
}
diff --git a/libgo/go/html/render.go b/libgo/go/html/render.go
index 0522b6ef92a..c815f35f1e1 100644
--- a/libgo/go/html/render.go
+++ b/libgo/go/html/render.go
@@ -6,15 +6,15 @@ package html
import (
"bufio"
+ "errors"
"fmt"
"io"
- "os"
)
type writer interface {
io.Writer
- WriteByte(byte) os.Error
- WriteString(string) (int, os.Error)
+ WriteByte(byte) error
+ WriteString(string) (int, error)
}
// Render renders the parse tree n to the given writer.
@@ -41,7 +41,7 @@ type writer interface {
// text node would become a tree containing <html>, <head> and <body> elements.
// Another example is that the programmatic equivalent of "a<head>b</head>c"
// becomes "<html><head><head/><body>abc</body></html>".
-func Render(w io.Writer, n *Node) os.Error {
+func Render(w io.Writer, n *Node) error {
if x, ok := w.(writer); ok {
return render(x, n)
}
@@ -52,11 +52,11 @@ func Render(w io.Writer, n *Node) os.Error {
return buf.Flush()
}
-func render(w writer, n *Node) os.Error {
+func render(w writer, n *Node) error {
// Render non-element nodes; these are the easy cases.
switch n.Type {
case ErrorNode:
- return os.NewError("html: cannot render an ErrorNode node")
+ return errors.New("html: cannot render an ErrorNode node")
case TextNode:
return escape(w, n.Data)
case DocumentNode:
@@ -88,7 +88,7 @@ func render(w writer, n *Node) os.Error {
}
return w.WriteByte('>')
default:
- return os.NewError("html: unknown node type")
+ return errors.New("html: unknown node type")
}
// Render the <xxx> opening tag.
diff --git a/libgo/go/html/token.go b/libgo/go/html/token.go
index 952d17468bd..c5b8a1c710e 100644
--- a/libgo/go/html/token.go
+++ b/libgo/go/html/token.go
@@ -7,7 +7,6 @@ package html
import (
"bytes"
"io"
- "os"
"strconv"
"strings"
)
@@ -127,7 +126,7 @@ type Tokenizer struct {
// Next call would set z.err to os.EOF but return a TextToken, and all
// subsequent Next calls would return an ErrorToken.
// err is never reset. Once it becomes non-nil, it stays non-nil.
- err os.Error
+ err error
// buf[raw.start:raw.end] holds the raw bytes of the current token.
// buf[raw.end:] is buffered input that will yield future tokens.
raw span
@@ -152,7 +151,7 @@ type Tokenizer struct {
// Error returns the error associated with the most recent ErrorToken token.
// This is typically os.EOF, meaning the end of tokenization.
-func (z *Tokenizer) Error() os.Error {
+func (z *Tokenizer) Error() error {
if z.tt != ErrorToken {
return nil
}
diff --git a/libgo/go/html/token_test.go b/libgo/go/html/token_test.go
index a5efdf2d498..76cc9f835da 100644
--- a/libgo/go/html/token_test.go
+++ b/libgo/go/html/token_test.go
@@ -6,7 +6,7 @@ package html
import (
"bytes"
- "os"
+ "io"
"strings"
"testing"
)
@@ -438,7 +438,7 @@ loop:
}
}
z.Next()
- if z.Error() != os.EOF {
+ if z.Error() != io.EOF {
t.Errorf("%s: want EOF got %q", tt.desc, z.Error())
}
}
@@ -543,7 +543,7 @@ loop:
tt := z.Next()
switch tt {
case ErrorToken:
- if z.Error() != os.EOF {
+ if z.Error() != io.EOF {
t.Error(z.Error())
}
break loop