From 05bec3968af02201d7de062038cb176d365c9210 Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Thu, 28 Aug 2014 13:34:00 -0400 Subject: [PATCH] Addressed cases when tokenUpper makes sense to be used. --- zscan.go | 4 +++- zscan_rr.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/zscan.go b/zscan.go index e051d8e5..91df3429 100644 --- a/zscan.go +++ b/zscan.go @@ -671,9 +671,11 @@ func zlexer(s *scan, c chan lex) { if stri != 0 { l.value = _STRING l.token = string(str[:stri]) + l.tokenUpper = strings.ToUpper(l.token) + l.length = stri if !rrtype { - if t, ok := StringToType[strings.ToUpper(l.token)]; ok { + if t, ok := StringToType[l.tokenUpper]; ok { l.value = _RRTYPE l.torc = t rrtype = true diff --git a/zscan_rr.go b/zscan_rr.go index 42f488f1..c58c91c6 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -1147,7 +1147,7 @@ func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { l := <-c if t, ok := StringToType[l.tokenUpper]; !ok { if strings.HasPrefix(l.tokenUpper, "TYPE") { - if t, ok = typeToInt(l.token); !ok { + if t, ok = typeToInt(l.tokenUpper); !ok { return nil, &ParseError{f, "bad RRSIG Typecovered", l}, "" } else { rr.TypeCovered = t @@ -1261,8 +1261,8 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { case _BLANK: // Ok case _STRING: - if k, ok = StringToType[strings.ToUpper(l.token)]; !ok { - if k, ok = typeToInt(l.token); !ok { + if k, ok = StringToType[l.tokenUpper]; !ok { + if k, ok = typeToInt(l.tokenUpper); !ok { return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, "" } } @@ -1323,8 +1323,8 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { case _BLANK: // Ok case _STRING: - if k, ok = StringToType[strings.ToUpper(l.token)]; !ok { - if k, ok = typeToInt(l.token); !ok { + if k, ok = StringToType[l.tokenUpper]; !ok { + if k, ok = typeToInt(l.tokenUpper); !ok { return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, "" } } @@ -1580,7 +1580,7 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) { <-c // _BLANK l = <-c if i, e := strconv.Atoi(l.token); e != nil { - if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok { + if i, ok := StringToAlgorithm[l.tokenUpper]; !ok { return nil, &ParseError{f, "bad DS Algorithm", l}, "" } else { rr.Algorithm = i @@ -1681,7 +1681,7 @@ func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) { <-c // _BLANK l = <-c if i, e := strconv.Atoi(l.token); e != nil { - if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok { + if i, ok := StringToAlgorithm[l.tokenUpper]; !ok { return nil, &ParseError{f, "bad CDS Algorithm", l}, "" } else { rr.Algorithm = i @@ -1716,7 +1716,7 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError, string) { <-c // _BLANK l = <-c if i, e := strconv.Atoi(l.token); e != nil { - if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok { + if i, ok := StringToAlgorithm[l.tokenUpper]; !ok { return nil, &ParseError{f, "bad DLV Algorithm", l}, "" } else { rr.Algorithm = i @@ -1751,7 +1751,7 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError, string) { <-c // _BLANK l = <-c if i, e := strconv.Atoi(l.token); e != nil { - if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok { + if i, ok := StringToAlgorithm[l.tokenUpper]; !ok { return nil, &ParseError{f, "bad TA Algorithm", l}, "" } else { rr.Algorithm = i