Commit 2a81292a authored by Robert Griesemer's avatar Robert Griesemer

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
parent acc82ad7
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"go/token" "go/token"
"log" "log"
"os" "os"
"template"
) )
var ( var (
...@@ -31,11 +32,6 @@ func main() { ...@@ -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() { ...@@ -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() { ...@@ -67,5 +64,9 @@ func main() {
} }
} }
// output // output
b.WriteTo(os.Stdout) if *html {
template.HTMLEscape(os.Stdout, b.Bytes())
} else {
b.WriteTo(os.Stdout)
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment