linux-0.11调试教程,load_history ()调用过程

shell.c

main ()

    load_history ()

    reader_loop ()



/* Load the history list from the history file. */
load_history ()
{
  char *hf;

  /* Truncate history file for interactive shells which desire it.
     Note that the history file is automatically truncated to the
     size of HISTSIZE if the user does not explicitly set the size
     differently. */
  set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
  stupidly_hack_special_variables ("HISTFILESIZE");

  /* Read the history in HISTFILE into the history list. */
  hf = get_string_value ("HISTFILE");

  if (hf && *hf)
    {
      struct stat buf;

      if (stat (hf, &buf) == 0)
    {
      read_history (hf);
      using_history ();
      history_lines_in_file = where_history ();
    }
    }
}


lib/readline/history.c

/* Add the contents of FILENAME to the history list, a line at a time.
   If FILENAME is NULL, then read from ~/.history.  Returns 0 if
   successful, or errno if not. */
int
read_history (filename)
     char *filename;
{
  return (read_history_range (filename, 0, -1));
}

read_history_range ()

    add_history ()

你可能感兴趣的:(linux-0.11调试教程,load_history ()调用过程)