X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Freadline%2Ffunmap.c;h=6b7d351fa047630130fd2c2a1e11cc36eaa8c0a5;hb=ccc6cda312fea9f0468ee65b8f368e9653e1380b;hp=9255974c9ce6ab3e0d18aebc4abcb518266338e7;hpb=726f63884db0132f01745f1fb4465e6621088ccf;p=platform%2Fupstream%2Fbash.git diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c index 9255974..6b7d351 100644 --- a/lib/readline/funmap.c +++ b/lib/readline/funmap.c @@ -21,11 +21,11 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY -#if defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); -#else +#if defined (HAVE_CONFIG_H) +# include +#endif + extern char *xmalloc (), *xrealloc (); -#endif /* STATIC_MALLOC */ #if !defined (BUFSIZ) #include @@ -40,18 +40,17 @@ extern char *xmalloc (), *xrealloc (); #include "rlconf.h" #include "readline.h" -static int qsort_string_compare (); +extern int _rl_qsort_string_compare (); -FUNMAP **funmap = (FUNMAP **)NULL; -static int funmap_size = 0; -static int funmap_entry = 0; +FUNMAP **funmap; +static int funmap_size; +static int funmap_entry; /* After initializing the function map, this is the index of the first program specific function. */ int funmap_program_specific_entry_start; static FUNMAP default_funmap[] = { - { "abort", rl_abort }, { "accept-line", rl_newline }, { "arrow-key-prefix", rl_arrow_keys }, @@ -64,26 +63,35 @@ static FUNMAP default_funmap[] = { { "beginning-of-line", rl_beg_of_line }, { "call-last-kbd-macro", rl_call_last_kbd_macro }, { "capitalize-word", rl_capitalize_word }, + { "character-search", rl_char_search }, + { "character-search-backward", rl_backward_char_search }, { "clear-screen", rl_clear_screen }, { "complete", rl_complete }, + { "copy-backward-word", rl_copy_backward_word }, + { "copy-forward-word", rl_copy_forward_word }, + { "copy-region-as-kill", rl_copy_region_to_kill }, { "delete-char", rl_delete }, { "delete-horizontal-space", rl_delete_horizontal_space }, { "digit-argument", rl_digit_argument }, { "do-lowercase-version", rl_do_lowercase_version }, { "downcase-word", rl_downcase_word }, { "dump-functions", rl_dump_functions }, + { "dump-variables", rl_dump_variables }, { "emacs-editing-mode", rl_emacs_editing_mode }, { "end-kbd-macro", rl_end_kbd_macro }, { "end-of-history", rl_end_of_history }, { "end-of-line", rl_end_of_line }, + { "exchange-point-and-mark", rl_exchange_point_and_mark }, { "forward-char", rl_forward }, { "forward-search-history", rl_forward_search_history }, { "forward-word", rl_forward_word }, { "history-search-backward", rl_history_search_backward }, { "history-search-forward", rl_history_search_forward }, + { "insert-comment", rl_insert_comment }, { "insert-completions", rl_insert_completions }, { "kill-whole-line", rl_kill_full_line }, { "kill-line", rl_kill_line }, + { "kill-region", rl_kill_region }, { "kill-word", rl_kill_word }, { "next-history", rl_get_next_history }, { "non-incremental-forward-search-history", rl_noninc_forward_search }, @@ -98,6 +106,7 @@ static FUNMAP default_funmap[] = { { "reverse-search-history", rl_reverse_search_history }, { "revert-line", rl_revert_line }, { "self-insert", rl_insert }, + { "set-mark", rl_set_mark }, { "start-kbd-macro", rl_start_kbd_macro }, { "tab-insert", rl_tab_insert }, { "tilde-expand", rl_tilde_expand }, @@ -118,6 +127,7 @@ static FUNMAP default_funmap[] = { { "vi-append-eol", rl_vi_append_eol }, { "vi-append-mode", rl_vi_append_mode }, { "vi-arg-digit", rl_vi_arg_digit }, + { "vi-back-to-indent", rl_vi_back_to_indent }, { "vi-bWord", rl_vi_bWord }, { "vi-bracktype", rl_vi_bracktype }, { "vi-bword", rl_vi_bword }, @@ -126,7 +136,6 @@ static FUNMAP default_funmap[] = { { "vi-change-to", rl_vi_change_to }, { "vi-char-search", rl_vi_char_search }, { "vi-column", rl_vi_column }, - { "vi-comment", rl_vi_comment }, { "vi-complete", rl_vi_complete }, { "vi-delete", rl_vi_delete }, { "vi-delete-to", rl_vi_delete_to }, @@ -136,8 +145,10 @@ static FUNMAP default_funmap[] = { { "vi-eof-maybe", rl_vi_eof_maybe }, { "vi-eword", rl_vi_eword }, { "vi-fWord", rl_vi_fWord }, + { "vi-fetch-history", rl_vi_fetch_history }, { "vi-first-print", rl_vi_first_print }, { "vi-fword", rl_vi_fword }, + { "vi-goto-mark", rl_vi_goto_mark }, { "vi-insert-beg", rl_vi_insert_beg }, { "vi-insertion-mode", rl_vi_insertion_mode }, { "vi-match", rl_vi_match }, @@ -151,6 +162,7 @@ static FUNMAP default_funmap[] = { { "vi-replace", rl_vi_replace }, { "vi-search", rl_vi_search }, { "vi-search-again", rl_vi_search_again }, + { "vi-set-mark", rl_vi_set_mark }, { "vi-subst", rl_vi_subst }, { "vi-tilde-expand", rl_vi_tilde_expand }, { "vi-yank-arg", rl_vi_yank_arg }, @@ -160,16 +172,16 @@ static FUNMAP default_funmap[] = { {(char *)NULL, (Function *)NULL } }; +int rl_add_funmap_entry (name, function) char *name; Function *function; { if (funmap_entry + 2 >= funmap_size) - if (!funmap) - funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *)); - else - funmap = - (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *)); + { + funmap_size += 64; + funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *)); + } funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP)); funmap[funmap_entry]->name = name; @@ -179,7 +191,7 @@ rl_add_funmap_entry (name, function) return funmap_entry; } -static int funmap_initialized = 0; +static int funmap_initialized; /* Make the funmap contain all of the default entries. */ void @@ -203,46 +215,28 @@ rl_initialize_funmap () char ** rl_funmap_names () { - char **result = (char **)NULL; + char **result; int result_size, result_index; - result_size = result_index = 0; - /* Make sure that the function map has been initialized. */ rl_initialize_funmap (); - for (result_index = 0; funmap[result_index]; result_index++) + for (result_index = result_size = 0, result = (char **)NULL; funmap[result_index]; result_index++) { if (result_index + 2 > result_size) { - if (!result) - result = (char **)xmalloc ((result_size = 20) * sizeof (char *)); - else - result = (char **) - xrealloc (result, (result_size += 20) * sizeof (char *)); + result_size += 20; + result = (char **)xrealloc (result, result_size * sizeof (char *)); } result[result_index] = funmap[result_index]->name; result[result_index + 1] = (char *)NULL; } - qsort (result, result_index, sizeof (char *), qsort_string_compare); + qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare); return (result); } -/* Stupid comparison routine for qsort () ing strings. */ -static int -qsort_string_compare (s1, s2) - register char **s1, **s2; -{ - int r; - - r = **s1 - **s2; - if (r == 0) - r = strcmp (*s1, *s2); - return r; -} - /* Things that mean `Control'. */ char *possible_control_prefixes[] = { "Control-", "C-", "CTRL-", (char *)NULL @@ -251,49 +245,3 @@ char *possible_control_prefixes[] = { char *possible_meta_prefixes[] = { "Meta", "M-", (char *)NULL }; - -#if defined (STATIC_MALLOC) - -/* **************************************************************** */ -/* */ -/* xmalloc and xrealloc () */ -/* */ -/* **************************************************************** */ - -static void memory_error_and_abort (); - -static char * -xmalloc (bytes) - int bytes; -{ - char *temp = (char *)malloc (bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static char * -xrealloc (pointer, bytes) - char *pointer; - int bytes; -{ - char *temp; - - if (!pointer) - temp = (char *)malloc (bytes); - else - temp = (char *)realloc (pointer, bytes); - - if (!temp) - memory_error_and_abort (); - return (temp); -} - -static void -memory_error_and_abort () -{ - fprintf (stderr, "history: Out of virtual memory!\n"); - abort (); -} -#endif /* STATIC_MALLOC */