From 88134e6da1628c7e73ced45e237e156985010e84 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 7 Oct 2015 18:04:02 +0200 Subject: Simplify --- ber/class.go | 2 +- ber/dump.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ber/class.go b/ber/class.go index 5cc0603..049efc7 100644 --- a/ber/class.go +++ b/ber/class.go @@ -21,7 +21,7 @@ const ( var classNames = map[Class]string{ classUniversal: "Universal", classApplication: "Application", - classContextSpecific: "Context", + classContextSpecific: "Context Specific", classPrivate: "Private", } diff --git a/ber/dump.go b/ber/dump.go index d207366..75d7f52 100644 --- a/ber/dump.go +++ b/ber/dump.go @@ -8,7 +8,10 @@ func Dump(b []byte) string { return newState(b).dump(0) } -func (s *state) universal(h Header) string { +func (s *state) primitive(h Header) string { + if h.Class != classUniversal { + return fmt.Sprint(s.next()) + } switch h.Tag { case tagInteger, tagEnumerated: return fmt.Sprint(s.unmarshalInt()) @@ -34,12 +37,7 @@ func (s *state) dump(indent int) (ret string) { ret += fmt.Sprintf("%3d: %*s", s.Len(), 2*indent, "") switch h.Kind { case kindPrimitive: - switch h.Class { - case classUniversal: - ret += fmt.Sprintln(h, "=", s.universal(h)) - default: - ret += fmt.Sprintln(h, "=", s.next()) - } + ret += fmt.Sprintln(h, "=", s.primitive(h)) case kindConstructed: ret += fmt.Sprintln(h, "→") ret += s.subState().dump(indent + 1) -- cgit v1.2.3