1
0
mirror of https://github.com/golang/go synced 2024-11-25 05:57:57 -07:00

srcextract: HTML-escape output if so desired

This functionality was removed with CL 4169041.

Minor simplifications.

R=r, adg
CC=golang-dev
https://golang.org/cl/4171042
This commit is contained in:
Robert Griesemer 2011-02-09 14:08:19 -08:00
parent acc82ad721
commit 2a81292ac3

View File

@ -9,6 +9,7 @@ import (
"go/token" "go/token"
"log" "log"
"os" "os"
"template"
) )
var ( var (
@ -31,11 +32,6 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// create printer
p := &printer.Config{
Mode: 0,
Tabwidth: 8,
}
// create filter // create filter
filter := func(name string) bool { filter := func(name string) bool {
return name == *getName return name == *getName
@ -44,8 +40,9 @@ func main() {
if !ast.FilterFile(file, filter) { if !ast.FilterFile(file, filter) {
os.Exit(1) os.Exit(1)
} }
b := new(bytes.Buffer) // print the AST
p.Fprint(b, fs, file) var b bytes.Buffer
printer.Fprint(&b, fs, file)
// drop package declaration // drop package declaration
if !*showPkg { if !*showPkg {
for { for {
@ -67,5 +64,9 @@ func main() {
} }
} }
// output // output
if *html {
template.HTMLEscape(os.Stdout, b.Bytes())
} else {
b.WriteTo(os.Stdout) b.WriteTo(os.Stdout)
} }
}