# File lib/html5/tokenizer.rb, line 343
    def close_tag_open_state
      if (@content_model_flag == :RCDATA or @content_model_flag == :CDATA)
        if @current_token
          char_stack = []

          # So far we know that "</" has been consumed. We now need to know
          # whether the next few characters match the name of last emitted
          # start tag which also happens to be the current_token. We also need
          # to have the character directly after the characters that could
          # match the start tag name.
          (@current_token[:name].length + 1).times do
            char_stack.push(@stream.char)
            # Make sure we don't get hit by :EOF
            break if char_stack[-1] == :EOF
          end

          # Since this is just for checking. We put the characters back on
          # the stack.
          @stream.unget(char_stack)
        end

        if @current_token and
          @current_token[:name].downcase == 
          char_stack[0...-1].join('').downcase and
          (SPACE_CHARACTERS + [">", "/", "<", :EOF]).include? char_stack[-1]
          # Because the characters are correct we can safely switch to
          # PCDATA mode now. This also means we don't have to do it when
          # emitting the end tag token.
          @content_model_flag = :PCDATA
        else
          @token_queue << {:type => :Characters, :data => "</"}
          @state = :data_state

          # Need to return here since we don't want the rest of the
          # method to be walked through.
          return true
        end
      end

      data = @stream.char
      if data == :EOF
        @token_queue << {:type => :ParseError, :data => "expected-closing-tag-but-got-eof"}
        @token_queue << {:type => :Characters, :data => "</"}
        @state = :data_state
      elsif ASCII_LETTERS.include? data
        @current_token = {:type => :EndTag, :name => data, :data => []}
        @state = :tag_name_state
      elsif data == ">"
        @token_queue << {:type => :ParseError, :data => "expected-closing-tag-but-got-right-bracket"}
        @state = :data_state
      else
        # XXX data can be _'_...
        @token_queue << {:type => :ParseError, :data => "expected-closing-tag-but-got-char", :datavars => {:data => data}}
        @stream.unget(data)
        @state = :bogus_comment_state
      end

      return true
    end