| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/bind.def |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | static int query_bindings (char *); | - | ||||||||||||||||||
| 19 | static int unbind_command (char *); | - | ||||||||||||||||||
| 20 | static int unbind_keyseq (char *); | - | ||||||||||||||||||
| 21 | int | - | ||||||||||||||||||
| 22 | bind_builtin (list) | - | ||||||||||||||||||
| 23 | WORD_LIST *list; | - | ||||||||||||||||||
| 24 | { | - | ||||||||||||||||||
| 25 | int return_code; | - | ||||||||||||||||||
| 26 | Keymap kmap, saved_keymap; | - | ||||||||||||||||||
| 27 | int flags, opt; | - | ||||||||||||||||||
| 28 | char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t; | - | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | if (no_line_editing
| 0 | ||||||||||||||||||
| 31 | { | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | builtin_warning ( | - | ||||||||||||||||||
| 37 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 38 | "line editing not enabled" | - | ||||||||||||||||||
| 39 | , 5) | - | ||||||||||||||||||
| 40 | ); | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | } never executed: end of block | 0 | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | kmap = saved_keymap = (Keymap) | - | ||||||||||||||||||
| 45 | ((void *)0) | - | ||||||||||||||||||
| 46 | ; | - | ||||||||||||||||||
| 47 | flags = 0; | - | ||||||||||||||||||
| 48 | initfile = map_name = fun_name = unbind_name = remove_seq = cmd_seq = (char *) | - | ||||||||||||||||||
| 49 | ((void *)0) | - | ||||||||||||||||||
| 50 | ; | - | ||||||||||||||||||
| 51 | return_code = 0; | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | if (bash_readline_initialized == 0
| 0 | ||||||||||||||||||
| 54 | initialize_readline (); never executed: initialize_readline (); | 0 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | begin_unwind_frame ("bind_builtin"); | - | ||||||||||||||||||
| 57 | unwind_protect_mem ((char *)&(rl_outstream), sizeof (rl_outstream)); | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | rl_outstream = | - | ||||||||||||||||||
| 60 | stdout | - | ||||||||||||||||||
| 61 | ; | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | reset_internal_getopt (); | - | ||||||||||||||||||
| 64 | while ((
| 0 | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | switch (opt) | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | case never executed: 'l':case 'l':never executed: case 'l': | 0 | ||||||||||||||||||
| 69 | flags |= 0x0001; | - | ||||||||||||||||||
| 70 | break; never executed: break; | 0 | ||||||||||||||||||
| 71 | case never executed: 'v':case 'v':never executed: case 'v': | 0 | ||||||||||||||||||
| 72 | flags |= 0x0008; | - | ||||||||||||||||||
| 73 | break; never executed: break; | 0 | ||||||||||||||||||
| 74 | case never executed: 'p':case 'p':never executed: case 'p': | 0 | ||||||||||||||||||
| 75 | flags |= 0x0002; | - | ||||||||||||||||||
| 76 | break; never executed: break; | 0 | ||||||||||||||||||
| 77 | case never executed: 'f':case 'f':never executed: case 'f': | 0 | ||||||||||||||||||
| 78 | flags |= 0x0004; | - | ||||||||||||||||||
| 79 | initfile = list_optarg; | - | ||||||||||||||||||
| 80 | break; never executed: break; | 0 | ||||||||||||||||||
| 81 | case never executed: 'm':case 'm':never executed: case 'm': | 0 | ||||||||||||||||||
| 82 | flags |= 0x0020; | - | ||||||||||||||||||
| 83 | map_name = list_optarg; | - | ||||||||||||||||||
| 84 | break; never executed: break; | 0 | ||||||||||||||||||
| 85 | case never executed: 'q':case 'q':never executed: case 'q': | 0 | ||||||||||||||||||
| 86 | flags |= 0x0010; | - | ||||||||||||||||||
| 87 | fun_name = list_optarg; | - | ||||||||||||||||||
| 88 | break; never executed: break; | 0 | ||||||||||||||||||
| 89 | case never executed: 'u':case 'u':never executed: case 'u': | 0 | ||||||||||||||||||
| 90 | flags |= 0x0800; | - | ||||||||||||||||||
| 91 | unbind_name = list_optarg; | - | ||||||||||||||||||
| 92 | break; never executed: break; | 0 | ||||||||||||||||||
| 93 | case never executed: 'r':case 'r':never executed: case 'r': | 0 | ||||||||||||||||||
| 94 | flags |= 0x0040; | - | ||||||||||||||||||
| 95 | remove_seq = list_optarg; | - | ||||||||||||||||||
| 96 | break; never executed: break; | 0 | ||||||||||||||||||
| 97 | case never executed: 'V':case 'V':never executed: case 'V': | 0 | ||||||||||||||||||
| 98 | flags |= 0x0100; | - | ||||||||||||||||||
| 99 | break; never executed: break; | 0 | ||||||||||||||||||
| 100 | case never executed: 'P':case 'P':never executed: case 'P': | 0 | ||||||||||||||||||
| 101 | flags |= 0x0080; | - | ||||||||||||||||||
| 102 | break; never executed: break; | 0 | ||||||||||||||||||
| 103 | case never executed: 's':case 's':never executed: case 's': | 0 | ||||||||||||||||||
| 104 | flags |= 0x0200; | - | ||||||||||||||||||
| 105 | break; never executed: break; | 0 | ||||||||||||||||||
| 106 | case never executed: 'S':case 'S':never executed: case 'S': | 0 | ||||||||||||||||||
| 107 | flags |= 0x0400; | - | ||||||||||||||||||
| 108 | break; never executed: break; | 0 | ||||||||||||||||||
| 109 | case never executed: 'x':case 'x':never executed: case 'x': | 0 | ||||||||||||||||||
| 110 | flags |= 0x1000; | - | ||||||||||||||||||
| 111 | cmd_seq = list_optarg; | - | ||||||||||||||||||
| 112 | break; never executed: break; | 0 | ||||||||||||||||||
| 113 | case never executed: 'X':case 'X':never executed: case 'X': | 0 | ||||||||||||||||||
| 114 | flags |= 0x2000; | - | ||||||||||||||||||
| 115 | break; never executed: break; | 0 | ||||||||||||||||||
| 116 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||
| 117 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 118 | builtin_usage (); | - | ||||||||||||||||||
| 119 | do { return_code = 258; goto never executed: bind_exit;goto bind_exit;never executed: } while (0);goto bind_exit; | 0 | ||||||||||||||||||
| 120 | } | - | ||||||||||||||||||
| 121 | } | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | list = loptend; | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | if ((
| 0 | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | kmap = rl_get_keymap_by_name (map_name); | - | ||||||||||||||||||
| 131 | if (kmap == 0
| 0 | ||||||||||||||||||
| 132 | { | - | ||||||||||||||||||
| 133 | builtin_error ( | - | ||||||||||||||||||
| 134 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 135 | "`%s': invalid keymap name" | - | ||||||||||||||||||
| 136 | , 5) | - | ||||||||||||||||||
| 137 | , map_name); | - | ||||||||||||||||||
| 138 | do { return_code = 1; goto never executed: bind_exit;goto bind_exit;never executed: } while (0);goto bind_exit; | 0 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | } never executed: end of block | 0 | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | if (kmap
| 0 | ||||||||||||||||||
| 143 | { | - | ||||||||||||||||||
| 144 | saved_keymap = rl_get_keymap (); | - | ||||||||||||||||||
| 145 | rl_set_keymap (kmap); | - | ||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | if (flags & 0x0001
| 0 | ||||||||||||||||||
| 152 | rl_list_funmap_names (); never executed: rl_list_funmap_names (); | 0 | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | if (flags & 0x0002
| 0 | ||||||||||||||||||
| 155 | rl_function_dumper (1); never executed: rl_function_dumper (1); | 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | if (flags & 0x0080
| 0 | ||||||||||||||||||
| 158 | rl_function_dumper (0); never executed: rl_function_dumper (0); | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (flags & 0x0200
| 0 | ||||||||||||||||||
| 161 | rl_macro_dumper (1); never executed: rl_macro_dumper (1); | 0 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | if (flags & 0x0400
| 0 | ||||||||||||||||||
| 164 | rl_macro_dumper (0); never executed: rl_macro_dumper (0); | 0 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | if (flags & 0x0008
| 0 | ||||||||||||||||||
| 167 | rl_variable_dumper (1); never executed: rl_variable_dumper (1); | 0 | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | if (flags & 0x0100
| 0 | ||||||||||||||||||
| 170 | rl_variable_dumper (0); never executed: rl_variable_dumper (0); | 0 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | if ((
| 0 | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | if (rl_read_init_file (initfile) != 0
| 0 | ||||||||||||||||||
| 175 | { | - | ||||||||||||||||||
| 176 | t = printable_filename (initfile, 0); | - | ||||||||||||||||||
| 177 | builtin_error ( | - | ||||||||||||||||||
| 178 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 179 | "%s: cannot read: %s" | - | ||||||||||||||||||
| 180 | , 5) | - | ||||||||||||||||||
| 181 | , t, strerror ( | - | ||||||||||||||||||
| 182 | (*__errno_location ()) | - | ||||||||||||||||||
| 183 | )); | - | ||||||||||||||||||
| 184 | if (t != initfile
| 0 | ||||||||||||||||||
| 185 | sh_xfree((t), "./bind.def", 254); never executed: sh_xfree((t), "./bind.def", 254); | 0 | ||||||||||||||||||
| 186 | do { return_code = 1; goto never executed: bind_exit;goto bind_exit;never executed: } while (0);goto bind_exit; | 0 | ||||||||||||||||||
| 187 | } | - | ||||||||||||||||||
| 188 | } never executed: end of block | 0 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | if ((
| 0 | ||||||||||||||||||
| 191 | return_code = query_bindings (fun_name); never executed: return_code = query_bindings (fun_name); | 0 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | if ((
| 0 | ||||||||||||||||||
| 194 | return_code = unbind_command (unbind_name); never executed: return_code = unbind_command (unbind_name); | 0 | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | if ((
| 0 | ||||||||||||||||||
| 197 | { | - | ||||||||||||||||||
| 198 | opt = unbind_keyseq (remove_seq); | - | ||||||||||||||||||
| 199 | do { return_code = opt; goto never executed: bind_exit;goto bind_exit;never executed: } while (0);goto bind_exit; | 0 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | if (flags & 0x1000
| 0 | ||||||||||||||||||
| 203 | return_code = bind_keyseq_to_unix_command (cmd_seq); never executed: return_code = bind_keyseq_to_unix_command (cmd_seq); | 0 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | if (flags & 0x2000
| 0 | ||||||||||||||||||
| 206 | return_code = print_unix_command_map (); never executed: return_code = print_unix_command_map (); | 0 | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | while (list
| 0 | ||||||||||||||||||
| 210 | { | - | ||||||||||||||||||
| 211 | rl_parse_and_bind (list->word->word); | - | ||||||||||||||||||
| 212 | list = list->next; | - | ||||||||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | bind_exit: code before this statement never executed: bind_exit: | 0 | ||||||||||||||||||
| 216 | if (saved_keymap
| 0 | ||||||||||||||||||
| 217 | rl_set_keymap (saved_keymap); never executed: rl_set_keymap (saved_keymap); | 0 | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | run_unwind_frame ("bind_builtin"); | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | return never executed: (sh_chkwrite (return_code));return (sh_chkwrite (return_code));never executed: return (sh_chkwrite (return_code)); | 0 | ||||||||||||||||||
| 222 | } | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | static int | - | ||||||||||||||||||
| 225 | query_bindings (name) | - | ||||||||||||||||||
| 226 | char *name; | - | ||||||||||||||||||
| 227 | { | - | ||||||||||||||||||
| 228 | rl_command_func_t *function; | - | ||||||||||||||||||
| 229 | char **keyseqs; | - | ||||||||||||||||||
| 230 | int j; | - | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | function = rl_named_function (name); | - | ||||||||||||||||||
| 233 | if (function == 0
| 0 | ||||||||||||||||||
| 234 | { | - | ||||||||||||||||||
| 235 | builtin_error ( | - | ||||||||||||||||||
| 236 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 237 | "`%s': unknown function name" | - | ||||||||||||||||||
| 238 | , 5) | - | ||||||||||||||||||
| 239 | , name); | - | ||||||||||||||||||
| 240 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 241 | } | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | keyseqs = rl_invoking_keyseqs (function); | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | if (!keyseqs
| 0 | ||||||||||||||||||
| 246 | { | - | ||||||||||||||||||
| 247 | printf ( | - | ||||||||||||||||||
| 248 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 249 | "%s is not bound to any keys.\n" | - | ||||||||||||||||||
| 250 | , 5) | - | ||||||||||||||||||
| 251 | , name); | - | ||||||||||||||||||
| 252 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 253 | } | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | printf ( | - | ||||||||||||||||||
| 256 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 257 | "%s can be invoked via " | - | ||||||||||||||||||
| 258 | , 5) | - | ||||||||||||||||||
| 259 | , name); | - | ||||||||||||||||||
| 260 | for (j = 0; j < 5
| 0 | ||||||||||||||||||
| 261 | printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n"); never executed: printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n"); | 0 | ||||||||||||||||||
| 262 | if (keyseqs[j]
| 0 | ||||||||||||||||||
| 263 | printf ("...\n"); never executed: printf ("...\n"); | 0 | ||||||||||||||||||
| 264 | strvec_dispose (keyseqs); | - | ||||||||||||||||||
| 265 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 266 | } | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | static int | - | ||||||||||||||||||
| 269 | unbind_command (name) | - | ||||||||||||||||||
| 270 | char *name; | - | ||||||||||||||||||
| 271 | { | - | ||||||||||||||||||
| 272 | rl_command_func_t *function; | - | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | function = rl_named_function (name); | - | ||||||||||||||||||
| 275 | if (function == 0
| 0 | ||||||||||||||||||
| 276 | { | - | ||||||||||||||||||
| 277 | builtin_error ( | - | ||||||||||||||||||
| 278 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 279 | "`%s': unknown function name" | - | ||||||||||||||||||
| 280 | , 5) | - | ||||||||||||||||||
| 281 | , name); | - | ||||||||||||||||||
| 282 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 283 | } | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | rl_unbind_function_in_map (function, rl_get_keymap ()); | - | ||||||||||||||||||
| 286 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 287 | } | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | static int | - | ||||||||||||||||||
| 290 | unbind_keyseq (seq) | - | ||||||||||||||||||
| 291 | char *seq; | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | char *kseq; | - | ||||||||||||||||||
| 294 | int kslen; | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | kseq = (char *)sh_xmalloc(((2 * strlen (seq)) + 1), "./bind.def", 349); | - | ||||||||||||||||||
| 297 | if (rl_translate_keyseq (seq, kseq, &kslen)
| 0 | ||||||||||||||||||
| 298 | { | - | ||||||||||||||||||
| 299 | sh_xfree((kseq), "./bind.def", 352); | - | ||||||||||||||||||
| 300 | builtin_error ( | - | ||||||||||||||||||
| 301 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 302 | "`%s': cannot unbind" | - | ||||||||||||||||||
| 303 | , 5) | - | ||||||||||||||||||
| 304 | , seq); | - | ||||||||||||||||||
| 305 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 306 | } | - | ||||||||||||||||||
| 307 | if (rl_function_of_keyseq (kseq, (Keymap)0, (int *)0) == 0
| 0 | ||||||||||||||||||
| 308 | { | - | ||||||||||||||||||
| 309 | sh_xfree((kseq), "./bind.def", 358); | - | ||||||||||||||||||
| 310 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||
| 311 | } | - | ||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | if (rl_bind_keyseq (seq, (rl_command_func_t *)
| 0 | ||||||||||||||||||
| 317 | ((void *)0)
| 0 | ||||||||||||||||||
| 318 | ) != 0
| 0 | ||||||||||||||||||
| 319 | { | - | ||||||||||||||||||
| 320 | sh_xfree((kseq), "./bind.def", 367); | - | ||||||||||||||||||
| 321 | builtin_error ( | - | ||||||||||||||||||
| 322 | dcgettext (((void *)0), | - | ||||||||||||||||||
| 323 | "`%s': cannot unbind" | - | ||||||||||||||||||
| 324 | , 5) | - | ||||||||||||||||||
| 325 | , seq); | - | ||||||||||||||||||
| 326 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||
| 327 | } | - | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | sh_xfree((kseq), "./bind.def", 372); | - | ||||||||||||||||||
| 330 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||
| 331 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |