lib/rfeedparser/better_sgmlparser.rb
def goahead(_end)
    rawdata = @rawdata # woo, utf-8 magic
    i = 0
    n = rawdata.length
    while i < n
      if @nomoretags
        # handle_data_range does nothing more than set a "Range" that is never used. wtf?
        handle_data(rawdata[i...n]) # i...n means "range from i to n not including n" 
        i = n
        break
      end
      j = rawdata.index(Interesting, i) 
      j = n unless j
      handle_data(rawdata[i...j]) if i < j
      i = j
      break if (i == n)
      if rawdata[i..i] == '<' # Yeah, ugly, but I prefer it to rawdata[i] == ?<
        if rawdata.index(Starttagopen,i) == i
          if @literal
            handle_data(rawdata[i..i])
            i = i+1
            next
          end
          k = parse_starttag(i)
          break unless k
          i = k
          next
        end
        if rawdata.index(Endtagopen,i) == i #Don't use Endtagopen
          k = parse_endtag(i)
          break unless k
          i = k
          @literal = false
          next
        end
        if @literal
          if n > (i+1)
            handle_data("<")
            i = i+1
          else
            #incomplete
            break
          end
          next
        end
        if rawdata.index(Commentopen,i) == i 
          k = parse_comment(i)
          break unless k
          i = k
          next
        end
        if rawdata.index(Piopenbegin,i) == i # Like Piopen but must be at beginning of rawdata
          k = parse_pi(i)
          break unless k
          i += k
          next
        end
        if rawdata.index(Declopen,i) == i
          # This is some sort of declaration; in "HTML as
          # deployed," this should only be the document type
          # declaration ("<!DOCTYPE html...>").
          k = parse_declaration(i)
          break unless k
          i = k
          next
        end
      elsif rawdata[i..i] == '&'
        if @literal # FIXME BUGME SGMLParser totally does not check this. Bug it.
          handle_data(rawdata[i..i])
          i += 1
          next
        end

        # the Char must come first as its #=~ method is the only one that is UTF-8 safe 
        ni,match = index_match(rawdata, Charref, i)
        if ni && ni == i # See? Ugly
          handle_charref(match[1]) # $1 is just the first group we captured (with parentheses)
          i += match[0].length  # $& is the "all" of the match.. it includes the full match we looked for not just the stuff we put parentheses around to capture. 
          i -= 1 unless rawdata[i-1..i-1] == ";"
          next
        end
        ni,match = index_match(rawdata, Entityref, i)
        if ni && ni == i
          handle_entityref(match[1])
          i += match[0].length
          i -= 1 unless rawdata[i-1..i-1] == ";"
          next
        end
      else
        error('neither < nor & ??')
      end
      # We get here only if incomplete matches but
      # nothing else
      ni,match = index_match(rawdata,Incomplete,i)
      unless ni && ni == 0
        handle_data(rawdata[i...i+1]) # str[i...i+1] == str[i..i]
        i += 1
        next
      end
      j = ni + match[0].length 
      break if j == n # Really incomplete
      handle_data(rawdata[i...j])
      i = j
    end # end while

    if _end && i < n
      handle_data(rawdata[i...n])
      i = n
    end

    @rawdata = rawdata[i..-1] 
    # @offset += i # FIXME BUGME another unused variable in SGMLParser?
  end
# Replaced Tagfind and Charref Regexps with the ones in feedparser.py
# This makes things work. 
Replaced Tagfind and Charref Regexps with the ones in feedparser.py
This makes things work.
Replaced Tagfind and Charref Regexps with the ones in feedparser . py This makes things work .
def goahead(_end)
    rawdata = @rawdata 
    i = 0
    n = rawdata.length
    while i < n
      if @nomoretags
        handle_data(rawdata[i...n]) 
        i = n
        break
      end
      j = rawdata.index(Interesting, i) 
      j = n unless j
      handle_data(rawdata[i...j]) if i < j
      i = j
      break if (i == n)
      if rawdata[i..i] == '<' 
        if rawdata.index(Starttagopen,i) == i
          if @literal
            handle_data(rawdata[i..i])
            i = i+1
            next
          end
          k = parse_starttag(i)
          break unless k
          i = k
          next
        end
        if rawdata.index(Endtagopen,i) == i 
          k = parse_endtag(i)
          break unless k
          i = k
          @literal = false
          next
        end
        if @literal
          if n > (i+1)
            handle_data("<")
            i = i+1
          else
            break
          end
          next
        end
        if rawdata.index(Commentopen,i) == i 
          k = parse_comment(i)
          break unless k
          i = k
          next
        end
        if rawdata.index(Piopenbegin,i) == i 
          k = parse_pi(i)
          break unless k
          i += k
          next
        end
        if rawdata.index(Declopen,i) == i
          k = parse_declaration(i)
          break unless k
          i = k
          next
        end
      elsif rawdata[i..i] == '&'
        if @literal 
          handle_data(rawdata[i..i])
          i += 1
          next
        end
        ni,match = index_match(rawdata, Charref, i)
        if ni && ni == i 
          handle_charref(match[1]) 
          i += match[0].length  
          i -= 1 unless rawdata[i-1..i-1] == ";"
          next
        end
        ni,match = index_match(rawdata, Entityref, i)
        if ni && ni == i
          handle_entityref(match[1])
          i += match[0].length
          i -= 1 unless rawdata[i-1..i-1] == ";"
          next
        end
      else
        error('neither < nor & ??')
      end
      ni,match = index_match(rawdata,Incomplete,i)
      unless ni && ni == 0
        handle_data(rawdata[i...i+1]) 
        i += 1
        next
      end
      j = ni + match[0].length 
      break if j == n 
      handle_data(rawdata[i...j])
      i = j
    end 
    if _end && i < n
      handle_data(rawdata[i...n])
      i = n
    end
    @rawdata = rawdata[i..-1] 
  end
def goahead ( _end ) rawdata = @rawdata i = 0 n = rawdata . length while i < n if @nomoretags handle_data ( rawdata [ i ... n ] ) i = n break end j = rawdata . index ( Interesting , i ) j = n unless j handle_data ( rawdata [ i ... j ] ) if i < j i = j break if ( i == n ) if rawdata [ i .. i ] == '<' if rawdata . index ( Starttagopen , i ) == i if @literal handle_data ( rawdata [ i .. i ] ) i = i + 1 next end k = parse_starttag ( i ) break unless k i = k next end if rawdata . index ( Endtagopen , i ) == i k = parse_endtag ( i ) break unless k i = k @literal = false next end if @literal if n > ( i + 1 ) handle_data ( "<" ) i = i + 1 else break end next end if rawdata . index ( Commentopen , i ) == i k = parse_comment ( i ) break unless k i = k next end if rawdata . index ( Piopenbegin , i ) == i k = parse_pi ( i ) break unless k i += k next end if rawdata . index ( Declopen , i ) == i k = parse_declaration ( i ) break unless k i = k next end elsif rawdata [ i .. i ] == '&' if @literal handle_data ( rawdata [ i .. i ] ) i += 1 next end ni , match = index_match ( rawdata , Charref , i ) if ni && ni == i handle_charref ( match [ 1 ] ) i += match [ 0 ] . length i -= 1 unless rawdata [ i - 1 .. i - 1 ] == ";" next end ni , match = index_match ( rawdata , Entityref , i ) if ni && ni == i handle_entityref ( match [ 1 ] ) i += match [ 0 ] . length i -= 1 unless rawdata [ i - 1 .. i - 1 ] == ";" next end else error ( 'neither < nor & ??' ) end ni , match = index_match ( rawdata , Incomplete , i ) unless ni && ni == 0 handle_data ( rawdata [ i ... i + 1 ] ) i += 1 next end j = ni + match [ 0 ] . length break if j == n handle_data ( rawdata [ i ... j ] ) i = j end if _end && i < n handle_data ( rawdata [ i ... n ] ) i = n end @rawdata = rawdata [ i .. - 1 ] end
Replaced Tagfind and Charref Regexps with the ones in feedparser.py
This makes things work.
Replaced Tagfind and Charref Regexps with the ones in feedparser . py This makes things work .
# woo, utf-8 magic # handle_data_range does nothing more than set a "Range" that is never used. wtf? # i...n means "range from i to n not including n"  # Yeah, ugly, but I prefer it to rawdata[i] == ?< #Don't use Endtagopen #incomplete # Like Piopen but must be at beginning of rawdata # This is some sort of declaration; in "HTML as # deployed," this should only be the document type # declaration ("<!DOCTYPE html...>"). # FIXME BUGME SGMLParser totally does not check this. Bug it. # the Char must come first as its #=~ method is the only one that is UTF-8 safe  # See? Ugly # $1 is just the first group we captured (with parentheses) # $& is the "all" of the match.. it includes the full match we looked for not just the stuff we put parentheses around to capture.  # We get here only if incomplete matches but # nothing else # str[i...i+1] == str[i..i] # Really incomplete # end while # @offset += i # FIXME BUGME another unused variable in SGMLParser?
_end