xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 919f9e7ebbaa0c7bb3dbd811a6e5ed4f16ceb595

Improve body of cmd_handlers.c:do_map()
* Move variable declarations to their use.
* Get rid of `error` variable.
* Don't restore original argument string before leaving, this shouldn't
be necessary.
Author: xaizek
Author date (UTC): 2025-05-25 10:26
Committer name: xaizek
Committer date (UTC): 2025-05-25 10:26
Parent(s): 8af72875d9a4809fff7faa876ee2246227f6292f
Signing key: 99DC5E4DB05F6BE2
Tree: 43037d768b92e5b81f2ef806726f2b4dd7f89b78
File Lines added Lines deleted
src/cmd_handlers.c 9 17
File src/cmd_handlers.c changed (mode: 100644) (index e5153a604..33934813f)
... ... static int
5392 5392 do_map(const cmd_info_t *cmd_info, const char map_type[], int mode, do_map(const cmd_info_t *cmd_info, const char map_type[], int mode,
5393 5393 int no_remap) int no_remap)
5394 5394 { {
5395 wchar_t *keys, *mapping;
5396 char *raw_rhs, *rhs;
5397 char t;
5398
5399 5395 if(cmd_info->argc <= 1) if(cmd_info->argc <= 1)
5400 5396 { {
5401 keys = substitute_specs(cmd_info->args);
5397 wchar_t *keys = substitute_specs(cmd_info->args);
5402 5398 if(keys != NULL) if(keys != NULL)
5403 5399 { {
5404 5400 int save_msg = show_map_menu(curr_view, map_type, mode, keys); int save_msg = show_map_menu(curr_view, map_type, mode, keys);
 
... ... do_map(const cmd_info_t *cmd_info, const char map_type[], int mode,
5414 5410 const int flags = (no_remap ? KEYS_FLAG_NOREMAP : KEYS_FLAG_NONE) const int flags = (no_remap ? KEYS_FLAG_NOREMAP : KEYS_FLAG_NONE)
5415 5411 | parse_map_args(&args); | parse_map_args(&args);
5416 5412
5417 raw_rhs = vle_cmds_past_arg(args);
5418 t = *raw_rhs;
5413 char *raw_rhs = vle_cmds_past_arg(args);
5419 5414 *raw_rhs = '\0'; *raw_rhs = '\0';
5420 5415
5421 int error = 0;
5422 rhs = vle_cmds_at_arg(raw_rhs + 1);
5423 keys = substitute_specs(args);
5424 mapping = substitute_specs(rhs);
5416 char *rhs = vle_cmds_at_arg(raw_rhs + 1);
5417 wchar_t *keys = substitute_specs(args);
5418 wchar_t *mapping = substitute_specs(rhs);
5425 5419 if(keys != NULL && mapping != NULL) if(keys != NULL && mapping != NULL)
5426 5420 { {
5427 error = vle_keys_user_add(keys, mapping, mode, flags);
5421 if(vle_keys_user_add(keys, mapping, mode, flags) != 0)
5422 {
5423 show_error_msg("Mapping Error", "Unable to allocate enough memory");
5424 }
5428 5425 } }
5429 5426 else else
5430 5427 { {
 
... ... do_map(const cmd_info_t *cmd_info, const char map_type[], int mode,
5434 5431 free(mapping); free(mapping);
5435 5432 free(keys); free(keys);
5436 5433
5437 *raw_rhs = t;
5438
5439 if(error)
5440 show_error_msg("Mapping Error", "Unable to allocate enough memory");
5441
5442 5434 return 0; return 0;
5443 5435 } }
5444 5436
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master