From 0dba8d406b795d5c7c67d4a5d823cbf3b3aeeec3 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 7 May 2015 13:10:00 -0600 Subject: [PATCH] NextBlock() doesn't enter an empty block --- config/parse/dispenser.go | 4 ++++ config/parse/dispenser_test.go | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/parse/dispenser.go b/config/parse/dispenser.go index 13789f12..cf902a17 100644 --- a/config/parse/dispenser.go +++ b/config/parse/dispenser.go @@ -109,6 +109,10 @@ func (d *Dispenser) NextBlock() bool { return false } d.Next() + if d.Val() == "}" { + // Open and then closed right away + return false + } d.nesting++ return true } diff --git a/config/parse/dispenser_test.go b/config/parse/dispenser_test.go index bfcb30a3..20a7ddca 100644 --- a/config/parse/dispenser_test.go +++ b/config/parse/dispenser_test.go @@ -149,9 +149,8 @@ func TestDispenser_NextBlock(t *testing.T) { assertNextBlock(true, 3, 1) assertNextBlock(true, 4, 1) assertNextBlock(false, 5, 0) - d.Next() // foobar2 - assertNextBlock(true, 8, 1) - assertNextBlock(false, 8, 0) + d.Next() // foobar2 + assertNextBlock(false, 8, 0) // empty block is as if it didn't exist } func TestDispenser_Args(t *testing.T) {