>From 14827e421c1fb5c0c63660c5b7a3bcabc217cac2 Mon Sep 17 00:00:00 2001 From: Bernhard R. Link Date: Tue, 10 Jun 2008 15:40:50 +0200 Subject: [PATCH] move all HAVE_HISTORY into history.c --- src/actions.c | 2 -- src/editor.c | 18 ------------------ src/history.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- src/input.c | 2 -- src/main.c | 4 ---- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/actions.c b/src/actions.c index d463286..14f9468 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1672,7 +1672,6 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const cmdret *ret; ret = read_string (spec, s, hist_SHELLCMD, exec_completions, arg); -#ifdef HAVE_HISTORY if (prefix && !ret) { /* store for command history */ char *s = xmalloc (strlen(prefix) + strlen((*arg)->string) + 2); @@ -1680,7 +1679,6 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const history_add (hist_COMMAND, s); free(s); } -#endif return ret; } diff --git a/src/editor.c b/src/editor.c index b2a72f9..0623186 100644 --- a/src/editor.c +++ b/src/editor.c @@ -56,9 +56,7 @@ static edit_status editor_complete_next (rp_input_line *line); static edit_status editor_insert (rp_input_line *line, char *keysym_buf); -#ifdef HAVE_HISTORY static char *saved_command = NULL; -#endif typedef struct edit_binding edit_binding; @@ -358,7 +356,6 @@ editor_backward_kill_line (rp_input_line *line) static edit_status editor_history_previous (rp_input_line *line) { -#ifdef HAVE_HISTORY const char *entry = history_previous (line->history_id); if (entry) @@ -384,18 +381,11 @@ editor_history_previous (rp_input_line *line) } return EDIT_INSERT; - -#else /* HAVE_HISTORY */ - - return EDIT_NO_OP; - -#endif /* HAVE_HISTORY */ } static edit_status editor_history_next (rp_input_line *line) { -#ifdef HAVE_HISTORY const char *entry = history_next (line->history_id); if (entry) @@ -422,10 +412,6 @@ editor_history_next (rp_input_line *line) line->position = line->length; return EDIT_INSERT; - -#else /* HAVE_HISTORY */ - return EDIT_NO_OP; -#endif /* HAVE_HISTORY */ } static edit_status @@ -467,13 +453,10 @@ editor_insert (rp_input_line *line, char *keysym_buf) static edit_status editor_enter (rp_input_line *line) { -#ifdef HAVE_HISTORY int result; char *expansion; -#endif line->buffer[line->length] = '\0'; -#ifdef HAVE_HISTORY result = history_expand_line (line->history_id, line->buffer, &expansion); PRINT_DEBUG (("History Expansion - result: %d\n", result)); @@ -491,7 +474,6 @@ editor_enter (rp_input_line *line) free (line->buffer); line->buffer = expansion; } -#endif /* HAVE_HISTORY */ return EDIT_DONE; } diff --git a/src/history.c b/src/history.c index 4178cf9..9f9b7d1 100644 --- a/src/history.c +++ b/src/history.c @@ -25,8 +25,8 @@ #include "ratpoison.h" #ifdef HAVE_HISTORY - #include "readline/history.h" +#endif static char * get_history_filename (void) @@ -47,6 +47,7 @@ get_history_filename (void) return filename; } +#ifdef HAVE_HISTORY void history_load (void) { @@ -97,6 +98,7 @@ history_add (int history_id, char *item) PRINT_DEBUG (("Adding item: %s\n", item)); add_history (item); } +#endif /* HAVE_HISTORY */ static const char * extract_shell_part (const char *p) @@ -113,6 +115,7 @@ extract_shell_part (const char *p) return NULL; } +#ifdef HAVE_HISTORY const char * history_previous (int history_id) { @@ -158,5 +161,49 @@ int history_expand_line (int history_id, char *string, char **output) { return history_expand (string, output); } +#else /* HAVE_HISTORY */ + +void +history_add (int history_id, char *item) +{ +} + +void +history_load (void) +{ +} + +void +history_save (void) +{ +} + +void +history_reset (void) +{ +} + +void +history_resize (int size) +{ +} + +const char * +history_previous (int history_id) +{ + return NULL; +} + +const char * +history_next (int history_id) +{ + return NULL; +} + +int history_expand_line (int history_id, char *string, char **output) +{ + *output = xstrdup(string); + return 0; +} #endif /* HAVE_HISTORY */ diff --git a/src/input.c b/src/input.c index db36ba7..35454df 100644 --- a/src/input.c +++ b/src/input.c @@ -537,9 +537,7 @@ get_more_input (char *prompt, char *preinput, int history_id, Window focus; int revert; -#ifdef HAVE_HISTORY history_reset(); -#endif /* HAVE_READLINE_HISTORY_H */ /* Create our line structure */ line = input_line_new (prompt, preinput, history_id, compl_fn); diff --git a/src/main.c b/src/main.c index aa2d650..c2eeec5 100644 --- a/src/main.c +++ b/src/main.c @@ -709,9 +709,7 @@ main (int argc, char *argv[]) update_modifier_map (); init_user_commands(); initialize_default_keybindings (); -#ifdef HAVE_HISTORY history_load (); -#endif /* HAVE_HISTORY */ /* Scan for windows */ if (screen_arg) @@ -786,9 +784,7 @@ clean_up (void) { int i; -#ifdef HAVE_HISTORY history_save (); -#endif /* HAVE_HISTORY */ free_keymaps (); free_aliases (); -- 1.4.4.4