# File lib/rbreadline.rb, line 5006
  def replace_history_data(which,old, new)
    new = new.dup if new
    if (which < -2 || which >= @history_length || @history_length == 0 || @the_history.nil?)
      return
    end
    if (which >= 0)
      entry = @the_history[which]
      if (entry && entry.data == old)
        entry.data = new
      end
      return
    end

    last = -1
    for i in 0 ... @history_length
      entry = @the_history[i]
      if entry.nil?
        next
      end
      if (entry.data == old)
        last = i
        if (which == -1)
          entry.data = new
        end
      end
    end
    if (which == -2 && last >= 0)
      entry = @the_history[last]
      entry.data = new  # XXX - we don't check entry->old
    end
  end