Fixed some bd in which temp files and directory were left around.
[deliverable/binutils-gdb.git] / readline / funmap.c
1 /* funmap.c -- attach names to functions. */
2
3 /* Copyright (C) 1988,1989 Free Software Foundation, Inc.
4
5 This file is part of GNU Readline, a library for reading lines
6 of text with interactive input and history editing.
7
8 Readline is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 1, or (at your option) any
11 later version.
12
13 Readline is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Readline; see the file COPYING. If not, write to the Free
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 #define STATIC_MALLOC
23 #ifndef STATIC_MALLOC
24 extern char *xmalloc (), *xrealloc ();
25 #else
26 static char *xmalloc (), *xrealloc ();
27 #endif
28
29 #ifndef FILE
30 #include <stdio.h>
31 #endif /* FILE */
32
33 #include "readline.h"
34
35 FUNMAP **funmap = (FUNMAP **)NULL;
36 static int funmap_size = 0;
37 static int funmap_entry = 0;
38
39 static FUNMAP default_funmap[] = {
40 { "beginning-of-line", rl_beg_of_line },
41 { "backward-char", rl_backward },
42 { "delete-char", rl_delete },
43 { "end-of-line", rl_end_of_line },
44 { "forward-char", rl_forward },
45 { "accept-line", rl_newline },
46 { "kill-line", rl_kill_line },
47 { "clear-screen", rl_clear_screen },
48 { "next-history", rl_get_next_history },
49 { "previous-history", rl_get_previous_history },
50 { "quoted-insert", rl_quoted_insert },
51 { "reverse-search-history", rl_reverse_search_history },
52 { "forward-search-history", rl_forward_search_history },
53 { "transpose-chars", rl_transpose_chars },
54 { "unix-line-discard", rl_unix_line_discard },
55 { "unix-word-rubout", rl_unix_word_rubout },
56 { "yank", rl_yank },
57 { "yank-pop", rl_yank_pop },
58 { "yank-nth-arg", rl_yank_nth_arg },
59 { "backward-delete-char", rl_rubout },
60 { "backward-word", rl_backward_word },
61 { "kill-word", rl_kill_word },
62 { "forward-word", rl_forward_word },
63 { "tab-insert", rl_tab_insert },
64 { "backward-kill-word", rl_backward_kill_word },
65 { "backward-kill-line", rl_backward_kill_line },
66 { "transpose-words", rl_transpose_words },
67 { "digit-argument", rl_digit_argument },
68 { "complete", rl_complete },
69 { "possible-completions", rl_possible_completions },
70 { "do-lowercase-version", rl_do_lowercase_version },
71 { "digit-argument", rl_digit_argument },
72 { "universal-argument", rl_universal_argument },
73 { "abort", rl_abort },
74 { "undo", rl_undo_command },
75 { "upcase-word", rl_upcase_word },
76 { "downcase-word", rl_downcase_word },
77 { "capitalize-word", rl_capitalize_word },
78 { "revert-line", rl_revert_line },
79 { "beginning-of-history", rl_beginning_of_history },
80 { "end-of-history", rl_end_of_history },
81 { "self-insert", rl_insert },
82 { "start-kbd-macro", rl_start_kbd_macro },
83 { "end-kbd-macro", rl_end_kbd_macro },
84 { "re-read-init-file", rl_re_read_init_file },
85 #ifdef VI_MODE
86 { "vi-movement-mode", rl_vi_movement_mode },
87 { "vi-insertion-mode", rl_vi_insertion_mode },
88 { "vi-arg-digit", rl_vi_arg_digit },
89 { "vi-prev-word", rl_vi_prev_word },
90 { "vi-next-word", rl_vi_next_word },
91 { "vi-char-search", rl_vi_char_search },
92 { "vi-editing-mode", rl_vi_editing_mode },
93 { "vi-eof-maybe", rl_vi_eof_maybe },
94 { "vi-append-mode", rl_vi_append_mode },
95 { "vi-put", rl_vi_put },
96 { "vi-append-eol", rl_vi_append_eol },
97 { "vi-insert-beg", rl_vi_insert_beg },
98 { "vi-delete", rl_vi_delete },
99 { "vi-comment", rl_vi_comment },
100 { "vi-first-print", rl_vi_first_print },
101 { "vi-fword", rl_vi_fword },
102 { "vi-fWord", rl_vi_fWord },
103 { "vi-bword", rl_vi_bword },
104 { "vi-bWord", rl_vi_bWord },
105 { "vi-eword", rl_vi_eword },
106 { "vi-eWord", rl_vi_eWord },
107 { "vi-end-word", rl_vi_end_word },
108 { "vi-change-case", rl_vi_change_case },
109 { "vi-match", rl_vi_match },
110 { "vi-bracktype", rl_vi_bracktype },
111 { "vi-change-char", rl_vi_change_char },
112 { "vi-yank-arg", rl_vi_yank_arg },
113 { "vi-search", rl_vi_search },
114 { "vi-search-again", rl_vi_search_again },
115 { "vi-dosearch", rl_vi_dosearch },
116 { "vi-subst", rl_vi_subst },
117 { "vi-overstrike", rl_vi_overstrike },
118 { "vi-overstrike-delete", rl_vi_overstrike_delete },
119 { "vi-replace, ", rl_vi_replace },
120 { "vi-column", rl_vi_column },
121 { "vi-delete-to", rl_vi_delete_to },
122 { "vi-change-to", rl_vi_change_to },
123 { "vi-yank-to", rl_vi_yank_to },
124 { "vi-complete", rl_vi_complete },
125 #endif /* VI_MODE */
126
127 {(char *)NULL, (Function *)NULL }
128 };
129
130 rl_add_funmap_entry (name, function)
131 char *name;
132 Function *function;
133 {
134 if (funmap_entry + 2 >= funmap_size)
135 if (!funmap)
136 funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *));
137 else
138 funmap =
139 (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *));
140
141 funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
142 funmap[funmap_entry]->name = name;
143 funmap[funmap_entry]->function = function;
144
145 funmap[++funmap_entry] = (FUNMAP *)NULL;
146 }
147
148 static int funmap_initialized = 0;
149
150 /* Make the funmap contain all of the default entries. */
151 rl_initialize_funmap ()
152 {
153 register int i;
154
155 if (funmap_initialized)
156 return;
157
158 for (i = 0; default_funmap[i].name; i++)
159 rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
160
161 funmap_initialized = 1;
162 }
163
164 /* Things that mean `Control'. */
165 char *possible_control_prefixes[] = {
166 "Control-", "C-", "CTRL-", (char *)NULL
167 };
168
169 char *possible_meta_prefixes[] = {
170 "Meta", "M-", (char *)NULL
171 };
172
173 #ifdef STATIC_MALLOC
174 \f
175 /* **************************************************************** */
176 /* */
177 /* xmalloc and xrealloc () */
178 /* */
179 /* **************************************************************** */
180
181 static void memory_error_and_abort ();
182
183 static char *
184 xmalloc (bytes)
185 int bytes;
186 {
187 char *temp = (char *)malloc (bytes);
188
189 if (!temp)
190 memory_error_and_abort ();
191 return (temp);
192 }
193
194 static char *
195 xrealloc (pointer, bytes)
196 char *pointer;
197 int bytes;
198 {
199 char *temp = (char *)realloc (pointer, bytes);
200
201 if (!temp)
202 memory_error_and_abort ();
203 return (temp);
204 }
205
206 static void
207 memory_error_and_abort ()
208 {
209 fprintf (stderr, "history: Out of virtual memory!\n");
210 abort ();
211 }
212 #endif /* STATIC_MALLOC */
This page took 0.040492 seconds and 4 git commands to generate.