From c4134425658eeb3027f6cc2c8c1aea773dbb16d4 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 4 Mar 2013 09:40:45 +0100 Subject: [PATCH] add sane debugging --- zscan.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/zscan.go b/zscan.go index 3f942b5a..b606442d 100644 --- a/zscan.go +++ b/zscan.go @@ -3,11 +3,22 @@ package dns import ( "fmt" "io" + "log" "os" "strconv" "strings" ) +type debugging bool + +const debug debugging = false + +func (d debugging) Printf(format string, args ...interface{}) { + if d { + log.Printf(format, args...) + } +} + var _DEBUG = false // Only used when debugging the parser itself. const maxTok = 2048 // Largest token we can return. @@ -75,12 +86,13 @@ func (e *ParseError) Error() (s string) { } type lex struct { - token string // text of the token - err bool // when true, token text has lexer error - value uint8 // value: _STRING, _BLANK, etc. - line int // line in the file - column int // column in the file - torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar + token string // text of the token + err bool // when true, token text has lexer error + value uint8 // value: _STRING, _BLANK, etc. + line int // line in the file + column int // column in the file + torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar + comment string // any comment text seen } // Tokens are returned when a zone file is parsed. @@ -458,6 +470,8 @@ func zlexer(s *scan, c chan lex) { var l lex str := make([]byte, maxTok) // Should be enough for any token stri := 0 // Offset in str (0 means empty) + com := make([]byte, maxTok) // Hold comment text + comi := 0 quote := false escape := false space := false