FACT++  1.0
void Readline::AddToHistory ( const std::string &  str,
int  skip = 2 
)

Adds the given string to the history buffer of readline's history by calling add_history.

Parameters
strA reference to a string which should be added to readline's history.
skipIf skip is 1 and str matches the last added entry in the history, the entry is skipped. If skip==2, all entries matching str are removed from the history before the new entry is added as last one. <skip==2 is the default>

Definition at line 562 of file Readline.cc.

References fLastLine, Memory::free(), and str.

Referenced by GetName(), and ProcessLine().

563 {
564  if (skip==1 && fLastLine==str)
565  return;
566 
567  if (str.empty())
568  return;
569 
570  int p = -1;
571  while (skip==2)
572  {
573  p = history_search_pos(str.c_str(), 0, p+1);
574  if (p<0)
575  break;
576 
577  HIST_ENTRY *e = remove_history(p--);
578 
579  free(e->line);
580  free(e);
581  }
582 
583  add_history(str.c_str());
584  fLastLine = str;
585 }
char str[80]
Definition: test_client.c:7
std::string fLastLine
Definition: Readline.h:27
void free(void *mem)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: