Fixes bug in StringWriter, which causes the compiler to

generate a segfault when there are too many string
concatenations. This happens when we convert a file of
about 100kb or larger.

The fix modifies the StringWriter to write the file data
out into a single, long string, without concatenations.

This addresses issue #5
pull/4/head
Jim Teeuwen 2013-07-07 13:02:07 +02:00
parent 0877d93299
commit 10c722dc95
1 changed files with 27 additions and 34 deletions

View File

@ -9,8 +9,6 @@ import (
"io" "io"
) )
var line = []byte("\"+\n\"")
type StringWriter struct { type StringWriter struct {
io.Writer io.Writer
c int c int
@ -22,11 +20,6 @@ func (w *StringWriter) Write(p []byte) (n int, err error) {
} }
for n = range p { for n = range p {
if w.c%16 == 0 {
w.Writer.Write(line)
w.c = 0
}
fmt.Fprintf(w.Writer, "\\x%02x", p[n]) fmt.Fprintf(w.Writer, "\\x%02x", p[n])
w.c++ w.c++
} }