lib/pdf/reader/buffer.rb
# Extract the next regular token and stock it in our buffer, ready to be returned.
#
# What each byte means is complex, check out section "3.1.1 Character Set" of the 1.7 spec
# to read up on it.
#
Extract the next regular token and stock it in our buffer, ready to be returned.
What each byte means is complex, check out section "3.1.1 Character Set" of the 1.7 spec
to read up on it.
Extract the next regular token and stock it in our buffer ready to be returned . What each byte means is complex check out section " 3 . 1 . 1 Character Set " of the 1 . 7 spec to read up on it .
def prepare_regular_token
      tok = "".dup
      while byte = @io.getbyte
        case byte
        when 0x25
          done = false
          while !done
            byte = @io.getbyte
            done = true if byte.nil? || byte == 0x0A || byte == 0x0D
          end
        when *TOKEN_WHITESPACE
          @tokens << tok if tok.size > 0
          while TOKEN_WHITESPACE.include?(peek_byte) && tok.size == 0
            @io.getbyte
          end
          tok = "".dup
          break
        when 0x3C
          @tokens << tok if tok.size > 0
          if peek_byte == 0x3C 
            @io.getbyte
            @tokens << "<<"
          else
            @tokens << "<"
          end
          tok = "".dup
          break
        when 0x3E
          @tokens << tok if tok.size > 0
          if peek_byte == 0x3E 
            @io.getbyte
            @tokens << ">>"
          else
            @tokens << ">"
          end
          tok = "".dup
          break
        when 0x28, 0x5B, 0x7B
          @tokens << tok if tok.size > 0
          @tokens << byte.chr
          tok = "".dup
          break
        when 0x29, 0x5D, 0x7D
          @tokens << tok if tok.size > 0
          @tokens << byte.chr
          tok = "".dup
          break
        when 0x2F
          @tokens << tok if tok.size > 0
          @tokens << byte.chr
          @tokens << "" if byte == 0x2F && ([nil, 0x20, 0x0A] + TOKEN_DELIMITER).include?(peek_byte)
          tok = "".dup
          break
        else
          tok << byte
        end
      end
      @tokens << tok if tok.size > 0
    end
def prepare_regular_token tok = "" . dup while byte = @io . getbyte case byte when 0x25 done = false while ! done byte = @io . getbyte done = true if byte . nil? || byte == 0x0A || byte == 0x0D end when * TOKEN_WHITESPACE @tokens << tok if tok . size > 0 while TOKEN_WHITESPACE . include? ( peek_byte ) && tok . size == 0 @io . getbyte end tok = "" . dup break when 0x3C @tokens << tok if tok . size > 0 if peek_byte == 0x3C @io . getbyte @tokens << "<<" else @tokens << "<" end tok = "" . dup break when 0x3E @tokens << tok if tok . size > 0 if peek_byte == 0x3E @io . getbyte @tokens << ">>" else @tokens << ">" end tok = "" . dup break when 0x28 , 0x5B , 0x7B @tokens << tok if tok . size > 0 @tokens << byte . chr tok = "" . dup break when 0x29 , 0x5D , 0x7D @tokens << tok if tok . size > 0 @tokens << byte . chr tok = "" . dup break when 0x2F @tokens << tok if tok . size > 0 @tokens << byte . chr @tokens << "" if byte == 0x2F && ( [ nil , 0x20 , 0x0A ] + TOKEN_DELIMITER ) . include? ( peek_byte ) tok = "" . dup break else tok << byte end end @tokens << tok if tok . size > 0 end
Extract the next regular token and stock it in our buffer, ready to be returned.
Extract the next regular token and stock it in our buffer ready to be returned .
# comment, ignore everything until the next EOL char # white space, token finished #If the token was empty, chomp the rest of the whitespace too # opening delimiter '<', start of new token # check if token is actually '<<' # closing delimiter '>', start of new token # check if token is actually '>>' # opening delimiter, start of new token # closing delimiter # PDF name, start of new token