aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/template
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-02 19:34:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-02 19:34:41 +0000
commit506cf9aaead4f5519f5549a918d285365b44e989 (patch)
treefe0344f264049738dca876a6dd2f69e96621ca17 /libgo/go/template
parentbfa9b58039ceacb1bae803fbbfb049b93540f2a7 (diff)
downloadgcc-506cf9aaead4f5519f5549a918d285365b44e989.zip
gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.gz
gcc-506cf9aaead4f5519f5549a918d285365b44e989.tar.bz2
libgo: Update to weekly.2011-11-01.
From-SVN: r181938
Diffstat (limited to 'libgo/go/template')
-rw-r--r--libgo/go/template/exec.go2
-rw-r--r--libgo/go/template/exec_test.go4
-rw-r--r--libgo/go/template/funcs.go14
-rw-r--r--libgo/go/template/parse/lex.go16
4 files changed, 18 insertions, 18 deletions
diff --git a/libgo/go/template/exec.go b/libgo/go/template/exec.go
index e7fad72..34c6633 100644
--- a/libgo/go/template/exec.go
+++ b/libgo/go/template/exec.go
@@ -97,7 +97,7 @@ func (t *Template) Execute(wr io.Writer, data interface{}) (err os.Error) {
line: 1,
vars: []variable{{"$", value}},
}
- if t.Root == nil {
+ if t.Tree == nil || t.Root == nil {
state.errorf("must be parsed before execution")
}
state.walk(value, t.Root)
diff --git a/libgo/go/template/exec_test.go b/libgo/go/template/exec_test.go
index 50b0ad2..2d2b402 100644
--- a/libgo/go/template/exec_test.go
+++ b/libgo/go/template/exec_test.go
@@ -98,7 +98,7 @@ var tVal = &T{
Empty3: []int{7, 8},
Empty4: &U{"UinEmpty"},
NonEmptyInterface: new(T),
- Str: os.NewError("foozle"),
+ Str: bytes.NewBuffer([]byte("foozle")),
PI: newInt(23),
PSI: newIntSlice(21, 22, 23),
Tmpl: Must(New("x").Parse("test template")), // "x" is the value of .X
@@ -644,7 +644,7 @@ func TestTree(t *testing.T) {
if err != nil {
t.Fatal("exec error:", err)
}
- stripSpace := func(r int) int {
+ stripSpace := func(r rune) rune {
if r == '\t' || r == '\n' {
return -1
}
diff --git a/libgo/go/template/funcs.go b/libgo/go/template/funcs.go
index feb1fd8..938559e 100644
--- a/libgo/go/template/funcs.go
+++ b/libgo/go/template/funcs.go
@@ -279,7 +279,7 @@ func JSEscape(w io.Writer, b []byte) {
for i := 0; i < len(b); i++ {
c := b[i]
- if !jsIsSpecial(int(c)) {
+ if !jsIsSpecial(rune(c)) {
// fast path: nothing to do
continue
}
@@ -307,12 +307,12 @@ func JSEscape(w io.Writer, b []byte) {
}
} else {
// Unicode rune.
- rune, size := utf8.DecodeRune(b[i:])
- if unicode.IsPrint(rune) {
+ r, size := utf8.DecodeRune(b[i:])
+ if unicode.IsPrint(r) {
w.Write(b[i : i+size])
} else {
// TODO(dsymonds): Do this without fmt?
- fmt.Fprintf(w, "\\u%04X", rune)
+ fmt.Fprintf(w, "\\u%04X", r)
}
i += size - 1
}
@@ -332,12 +332,12 @@ func JSEscapeString(s string) string {
return b.String()
}
-func jsIsSpecial(rune int) bool {
- switch rune {
+func jsIsSpecial(r rune) bool {
+ switch r {
case '\\', '\'', '"', '<', '>':
return true
}
- return rune < ' ' || utf8.RuneSelf <= rune
+ return r < ' ' || utf8.RuneSelf <= r
}
// JSEscaper returns the escaped JavaScript equivalent of the textual
diff --git a/libgo/go/template/parse/lex.go b/libgo/go/template/parse/lex.go
index 16ff590..04c105d 100644
--- a/libgo/go/template/parse/lex.go
+++ b/libgo/go/template/parse/lex.go
@@ -131,21 +131,21 @@ type lexer struct {
}
// next returns the next rune in the input.
-func (l *lexer) next() (rune int) {
+func (l *lexer) next() (r rune) {
if l.pos >= len(l.input) {
l.width = 0
return eof
}
- rune, l.width = utf8.DecodeRuneInString(l.input[l.pos:])
+ r, l.width = utf8.DecodeRuneInString(l.input[l.pos:])
l.pos += l.width
- return rune
+ return r
}
// peek returns but does not consume the next rune in the input.
-func (l *lexer) peek() int {
- rune := l.next()
+func (l *lexer) peek() rune {
+ r := l.next()
l.backup()
- return rune
+ return r
}
// backup steps back one rune. Can only be called once per call of next.
@@ -468,7 +468,7 @@ Loop:
}
// isSpace reports whether r is a space character.
-func isSpace(r int) bool {
+func isSpace(r rune) bool {
switch r {
case ' ', '\t', '\n', '\r':
return true
@@ -477,6 +477,6 @@ func isSpace(r int) bool {
}
// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore.
-func isAlphaNumeric(r int) bool {
+func isAlphaNumeric(r rune) bool {
return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
}