From d96ffda62e9f9c88a6e43dc1926c5b775a611166 Mon Sep 17 00:00:00 2001 From: Flemming Madsen Date: Sun, 7 Apr 2013 18:47:24 +0200 Subject: ash,hush: history builtin function old new delta show_history - 39 +39 builtin_history - 16 +16 historycmd - 13 +13 bltins1 312 324 +12 builtintab 336 344 +8 popstring 134 140 +6 hush_main 1048 1046 -2 ash_main 1398 1396 -2 size_from_HISTFILESIZE 44 40 -4 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8) Total: 86 bytes Signed-off-by: Flemming Madsen Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libbb/lineedit.c') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 93ab86426..1313dd5d9 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1254,7 +1254,7 @@ line_input_t* FAST_FUNC new_line_input_t(int flags) #if MAX_HISTORY > 0 -unsigned size_from_HISTFILESIZE(const char *hp) +unsigned FAST_FUNC size_from_HISTFILESIZE(const char *hp) { int size = MAX_HISTORY; if (hp) { @@ -1309,6 +1309,17 @@ static int get_next_history(void) return 0; } +/* Lists command history. Used by shell 'history' builtins */ +void FAST_FUNC show_history(const line_input_t *st) +{ + int i; + + if (!st) + return; + for (i = 0; i < st->cnt_history; i++) + printf("%4d %s\n", i, st->history[i]); +} + # if ENABLE_FEATURE_EDITING_SAVEHISTORY /* We try to ensure that concurrent additions to the history * do not overwrite each other. @@ -2749,8 +2760,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman free(command_ps); #endif - if (command_len > 0) + if (command_len > 0) { remember_in_history(command); + } if (break_out > 0) { command[command_len++] = '\n'; -- cgit v1.2.3