Use the new debbugging

This commit is contained in:
Miek Gieben 2013-03-04 09:42:24 +01:00
parent c413442565
commit a5e9f8010d
1 changed files with 11 additions and 36 deletions

View File

@ -1,7 +1,6 @@
package dns package dns
import ( import (
"fmt"
"io" "io"
"log" "log"
"os" "os"
@ -19,8 +18,6 @@ func (d debugging) Printf(format string, args ...interface{}) {
} }
} }
var _DEBUG = false // Only used when debugging the parser itself.
const maxTok = 2048 // Largest token we can return. const maxTok = 2048 // Largest token we can return.
// Tokinize a RFC 1035 zone file. The tokenizer will normalize it: // Tokinize a RFC 1035 zone file. The tokenizer will normalize it:
@ -487,9 +484,7 @@ func zlexer(s *scan, c chan lex) {
if stri > maxTok { if stri > maxTok {
l.token = "tok length insufficient for parsing" l.token = "tok length insufficient for parsing"
l.err = true l.err = true
if _DEBUG { debug.Printf("[%+v]", l.token)
fmt.Printf("[%+v]", l.token)
}
c <- l c <- l
return return
} }
@ -523,9 +518,7 @@ func zlexer(s *scan, c chan lex) {
case "$GENERATE": case "$GENERATE":
l.value = _DIRGENERATE l.value = _DIRGENERATE
} }
if _DEBUG { debug.Printf("[7 %+v]", l.token)
fmt.Printf("[7 %+v]", l.token)
}
c <- l c <- l
} else { } else {
l.value = _STRING l.value = _STRING
@ -568,9 +561,7 @@ func zlexer(s *scan, c chan lex) {
} }
} }
} }
if _DEBUG { debug.Printf("[6 %+v]", l.token)
fmt.Printf("[6 %+v]", l.token)
}
c <- l c <- l
} }
stri = 0 stri = 0
@ -578,9 +569,7 @@ func zlexer(s *scan, c chan lex) {
if !space && !commt { if !space && !commt {
l.value = _BLANK l.value = _BLANK
l.token = " " l.token = " "
if _DEBUG { debug.Printf("[5 %+v]", l.token)
fmt.Printf("[5 %+v]", l.token)
}
c <- l c <- l
} }
owner = false owner = false
@ -601,9 +590,7 @@ func zlexer(s *scan, c chan lex) {
if stri > 0 { if stri > 0 {
l.value = _STRING l.value = _STRING
l.token = string(str[:stri]) l.token = string(str[:stri])
if _DEBUG { debug.Printf("[4 %+v]", l.token)
fmt.Printf("[4 %+v]", l.token)
}
c <- l c <- l
stri = 0 stri = 0
} }
@ -631,9 +618,7 @@ func zlexer(s *scan, c chan lex) {
owner = true owner = true
l.value = _NEWLINE l.value = _NEWLINE
l.token = "\n" l.token = "\n"
if _DEBUG { debug.Printf("[3 %+v]", l.token)
fmt.Printf("[3 %+v]", l.token)
}
c <- l c <- l
} }
break break
@ -651,16 +636,12 @@ func zlexer(s *scan, c chan lex) {
rrtype = true rrtype = true
} }
} }
if _DEBUG { debug.Printf("[2 %+v]", l.token)
fmt.Printf("[2 %+v]", l.token)
}
c <- l c <- l
} }
l.value = _NEWLINE l.value = _NEWLINE
l.token = "\n" l.token = "\n"
if _DEBUG { debug.Printf("[1 %+v]", l.token)
fmt.Printf("[1 %+v]", l.token)
}
c <- l c <- l
stri = 0 stri = 0
commt = false commt = false
@ -696,9 +677,7 @@ func zlexer(s *scan, c chan lex) {
if stri != 0 { if stri != 0 {
l.value = _STRING l.value = _STRING
l.token = string(str[:stri]) l.token = string(str[:stri])
if _DEBUG { debug.Printf("[%+v]", l.token)
fmt.Printf("[%+v]", l.token)
}
c <- l c <- l
stri = 0 stri = 0
} }
@ -727,9 +706,7 @@ func zlexer(s *scan, c chan lex) {
if brace < 0 { if brace < 0 {
l.token = "extra closing brace" l.token = "extra closing brace"
l.err = true l.err = true
if _DEBUG { debug.Printf("[%+v]", l.token)
fmt.Printf("[%+v]", l.token)
}
c <- l c <- l
return return
} }
@ -752,9 +729,7 @@ func zlexer(s *scan, c chan lex) {
// Send remainder // Send remainder
l.token = string(str[:stri]) l.token = string(str[:stri])
l.value = _STRING l.value = _STRING
if _DEBUG { debug.Printf("[%+v]", l.token)
fmt.Printf("[%+v]", l.token)
}
c <- l c <- l
} }
} }