From cdc52f7bde72e829202df0c241dc8f2203489005 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 26 Oct 2006 06:46:50 +1000 Subject: [PATCH] Add more comments to the history implementation darcs-hash:20061025204650-ac50b-419d37d9ea68de0deee613524d06882a8e4c908e.gz --- history.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/history.c b/history.c index 8186935e6..f3d6e799d 100644 --- a/history.c +++ b/history.c @@ -499,14 +499,19 @@ static void history_populate_from_mmap( history_mode_t *m ) ignore_newline = *pos == '#'; i = item_get( m, pos ); - assert( i!=pos ); if( (i_orig=hash_get( ¤t_mode->session_item, i ) ) ) { + /* + This item comes from this session. Insert the original item at the end of the item list. + */ al_push( &session_item_list, i_orig ); } else { + /* + Old item. Insert pointer directly to the item list + */ al_push( &m->item, pos ); } @@ -664,7 +669,7 @@ static void history_save_mode( void *n, history_mode_t *m ) hash_destroy( &mine ); /* - Add our own items + Add our own items last */ for( i=0; iitem); i++ ) { @@ -676,7 +681,11 @@ static void history_save_mode( void *n, history_mode_t *m ) if( fclose( out ) ) { - + /* + This message does not have high enough priority to + be shown by default. + */ + debug( 2, L"Error when writing history file" ); } else { @@ -804,11 +813,20 @@ const wchar_t *history_prev_match( const wchar_t *needle ) if( !current_mode->has_loaded ) { + /* + We found no match in the list, try loading the history + file and continue the search + */ history_load( current_mode ); return history_prev_match( needle ); } else { + /* + We found no match in the list, and the file is already + loaded. Set poition before first element and return + original search string. + */ current_mode->pos=-1; if( al_peek_long( ¤t_mode->used ) != -1 ) al_push_long( ¤t_mode->used, -1 );