# File lib/rbreadline.rb, line 5458
  def rl_get_next_history(count, key)
    if (count < 0)
      return (rl_get_previous_history(-count, key))
    end
    if (count == 0)
      return 0
    end
    rl_maybe_replace_line()

    # either not saved by rl_newline or at end of line, so set appropriately.
    if (@_rl_history_saved_point == -1 && (@rl_point!=0 || @rl_end!=0))
      @_rl_history_saved_point = (@rl_point == @rl_end) ? -1 : @rl_point
    end
    temp = nil
    while (count>0)
      temp = next_history()
      if temp.nil?
        break
      end
      count -= 1
    end

    if temp.nil?
      rl_maybe_unsave_line()
    else
      rl_replace_from_history(temp, 0)
      _rl_history_set_point()
    end
    0
  end