Everything seem to work now
This commit is contained in:
+5
-1
@@ -28,12 +28,15 @@ func NewCommandBuffer(size int) *Buffer {
|
||||
|
||||
// Skip advances the cursor by N bytes.
|
||||
func (b *Buffer) Skip(n int) {
|
||||
Debugf("Skipped %d bytes: %X\n", n, b.data[b.pos:b.pos+n])
|
||||
b.pos += n
|
||||
}
|
||||
|
||||
// Read returns next N bytes and advances the cursor.
|
||||
func (b *Buffer) Read(n int) []byte {
|
||||
b.pos += n
|
||||
|
||||
Debugf("Read %d bytes: %X\n", n, b.data[b.pos-n:b.pos])
|
||||
return b.data[b.pos-n:]
|
||||
}
|
||||
|
||||
@@ -44,7 +47,8 @@ func (b *Buffer) Cur() []byte {
|
||||
|
||||
// More returns true if there's more to read.
|
||||
func (b *Buffer) More() bool {
|
||||
return b.pos < len(b.data)
|
||||
Debug("*** BUFFER BOUNDS CHECK len:", len(b.data), "pos:", b.pos)
|
||||
return b.pos < len(b.data)-1
|
||||
}
|
||||
|
||||
// Bytes returns entire buffer contents.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/localhots/pretty"
|
||||
)
|
||||
|
||||
// EnableDebug controls debug output.
|
||||
var EnableDebug = false
|
||||
|
||||
// Debug ...
|
||||
func Debug(vals ...interface{}) {
|
||||
if EnableDebug {
|
||||
pretty.Println(vals...)
|
||||
}
|
||||
}
|
||||
|
||||
// Debugf ...
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
if EnableDebug {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user