lib/pdf/reader/buffer.rb
def prepare_literal_token
      str = "".dup
      count = 1

      while count > 0
        byte = @io.getbyte
        if byte.nil?
          count = 0 # unbalanced params
        elsif byte == 0x5C
          str << byte << @io.getbyte
        elsif byte == 0x28 # "("
          str << "("
          count += 1
        elsif byte == 0x29 # ")"
          count -= 1
          str << ")" unless count == 0
        else
          str << byte unless count == 0
        end
      end

      @tokens << str if str.size > 0
      @tokens << ")"
    end
# if we're currently inside a literal string we more or less just read bytes until
# we find the closing ) delimiter. Lots of bytes that would otherwise indicate the
# start of a new token in regular mode are left untouched when inside a literal
# string.
#
# The entire literal string will be returned as a single token. It will need further
# processing to fix things like escaped new lines, but that's someone else's
# problem.
#
if we're currently inside a literal string we more or less just read bytes until
we find the closing ) delimiter. Lots of bytes that would otherwise indicate the
start of a new token in regular mode are left untouched when inside a literal
string.

The entire literal string will be returned as a single token. It will need further
processing to fix things like escaped new lines, but that's someone else's
problem.
if we ' re currently inside a literal string we more or less just read bytes until we find the closing ) delimiter . Lots of bytes that would otherwise indicate the start of a new token in regular mode are left untouched when inside a literal string . The entire literal string will be returned as a single token . It will need further processing to fix things like escaped new lines but that ' s someone else ' s problem .
def prepare_literal_token
      str = "".dup
      count = 1
      while count > 0
        byte = @io.getbyte
        if byte.nil?
          count = 0 
        elsif byte == 0x5C
          str << byte << @io.getbyte
        elsif byte == 0x28 
          str << "("
          count += 1
        elsif byte == 0x29 
          count -= 1
          str << ")" unless count == 0
        else
          str << byte unless count == 0
        end
      end
      @tokens << str if str.size > 0
      @tokens << ")"
    end
def prepare_literal_token str = "" . dup count = 1 while count > 0 byte = @io . getbyte if byte . nil? count = 0 elsif byte == 0x5C str << byte << @io . getbyte elsif byte == 0x28 str << "(" count += 1 elsif byte == 0x29 count -= 1 str << ")" unless count == 0 else str << byte unless count == 0 end end @tokens << str if str . size > 0 @tokens << ")" end
if we're currently inside a literal string we more or less just read bytes until
we find the closing ) delimiter.
if we ' re currently inside a literal string we more or less just read bytes until we find the closing ) delimiter .
# unbalanced params # "(" # ")"