Created
August 27, 2014 21:06
-
-
Save miekg/f1b1fe6dba7d6b088eec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/parse_test.go b/parse_test.go | |
index 12de822..5ddb880 100644 | |
--- a/parse_test.go | |
+++ b/parse_test.go | |
@@ -1049,7 +1049,7 @@ func TestTXT(t *testing.T) { | |
} | |
func TestTypeXXXX(t *testing.T) { | |
- _, err := NewRR("example.com IN TYPE1234 \\# 4 aabbccdd") | |
+ _, err := NewRR("example.com IN type1234 \\# 4 aabbccdd") | |
if err != nil { | |
t.Logf("failed to parse TYPE1234 RR: ", err.Error()) | |
t.Fail() | |
diff --git a/zscan.go b/zscan.go | |
index 433f201..433c8bc 100644 | |
--- a/zscan.go | |
+++ b/zscan.go | |
@@ -88,14 +88,15 @@ func (e *ParseError) Error() (s string) { | |
} | |
type lex struct { | |
- token string // text of the token | |
- length int // lenght 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 | |
+ token string // text of the token | |
+ tokenUpper string // uppercase text of the token | |
+ length int // lenght 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. | |
@@ -496,14 +497,14 @@ func zlexer(s *scan, c chan lex) { | |
l.column = s.position.Column | |
l.line = s.position.Line | |
if stri > maxTok { | |
- l.token = "tok length insufficient for parsing" | |
+ l.token = "token length insufficient for parsing" | |
l.err = true | |
debug.Printf("[%+v]", l.token) | |
c <- l | |
return | |
} | |
if comi > maxTok { | |
- l.token = "com length insufficient for parsing" | |
+ l.token = "comment length insufficient for parsing" | |
l.err = true | |
debug.Printf("[%+v]", l.token) | |
c <- l | |
@@ -553,14 +554,15 @@ func zlexer(s *scan, c chan lex) { | |
} else { | |
l.value = _STRING | |
l.token = string(str[:stri]) | |
+ l.tokenUpper = strings.ToUpper(l.token) | |
l.length = stri | |
if !rrtype { | |
- if t, ok := StringToType[l.token]; ok { | |
+ if t, ok := StringToType[l.tokenUpper]; ok { | |
l.value = _RRTYPE | |
l.torc = t | |
rrtype = true | |
} else { | |
- if strings.HasPrefix(l.token, "TYPE") { | |
+ if strings.HasPrefix(l.tokenUpper, "TYPE") { | |
if t, ok := typeToInt(l.token); !ok { | |
l.token = "unknown RR type" | |
l.err = true | |
@@ -572,11 +574,11 @@ func zlexer(s *scan, c chan lex) { | |
} | |
} | |
} | |
- if t, ok := StringToClass[l.token]; ok { | |
+ if t, ok := StringToClass[l.tokenUpper]; ok { | |
l.value = _CLASS | |
l.torc = t | |
} else { | |
- if strings.HasPrefix(l.token, "CLASS") { | |
+ if strings.HasPrefix(l.tokenUpper, "CLASS") { | |
if t, ok := classToInt(l.token); !ok { | |
l.token = "unknown class" | |
l.err = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment