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 6790e98179790f154982fea46f800f47f5f5e32a

Process value of 'fusehome' more accurate
Author: xaizek
Author date (UTC): 2012-10-22 16:12
Committer name: xaizek
Committer date (UTC): 2012-10-22 16:15
Parent(s): ff9b4c0942d5b0680d06b8e450f262a503798017
Signing key:
Tree: 6b26cbe314e1b5c6b0e3341469cba732af28bedf
File Lines added Lines deleted
ChangeLog 2 0
src/background.c 1 1
src/cfg/config.c 21 7
src/cfg/config.h 4 1
src/cfg/info.c 2 2
src/commands.c 10 10
src/commands_completion.c 1 1
src/engine/options.c 2 2
src/engine/variables.c 2 2
src/filelist.c 4 4
src/fileops.c 7 7
src/filetype.c 1 1
src/fuse.c 5 4
src/menus/dirhistory_menu.c 1 1
src/opt_handlers.c 12 5
src/path_env.c 2 2
src/registers.c 1 1
src/undo.c 3 3
src/utils/path.c 20 1
src/utils/path.h 3 0
src/utils/str.c 6 4
src/utils/str.h 3 2
File ChangeLog changed (mode: 100644) (index 58e4b91c3..3a4ad9afb)
18 18 Check TMPDIR, TEMP, TEMPDIR and TMP environment variables to determine Check TMPDIR, TEMP, TEMPDIR and TMP environment variables to determine
19 19 location of directory for temporary files. location of directory for temporary files.
20 20
21 Made processing of value of 'fusehome' option more error prone.
22
21 23 Fixed autotools configuration files. Fixed autotools configuration files.
22 24
23 25 Fixed terminal size resetting after :restart. Fixed terminal size resetting after :restart.
File src/background.c changed (mode: 100644) (index b1a907478..226fb9da3)
... ... error_msg(const char *title, const char *text)
266 266 } }
267 267 else else
268 268 { {
269 replace_string(&job->error, text);
269 (void)replace_string(&job->error, text);
270 270 } }
271 271 } }
272 272 #endif #endif
File src/cfg/config.c changed (mode: 100644) (index eee262ea2..41d8ab43f)
41 41 #include "../utils/fs.h" #include "../utils/fs.h"
42 42 #include "../utils/log.h" #include "../utils/log.h"
43 43 #include "../utils/str.h" #include "../utils/str.h"
44 #ifdef _WIN32
45 44 #include "../utils/path.h" #include "../utils/path.h"
46 #endif
47 45 #include "../utils/string_array.h" #include "../utils/string_array.h"
48 46 #include "../utils/utils.h" #include "../utils/utils.h"
49 47 #include "../bookmarks.h" #include "../bookmarks.h"
 
... ... init_config(void)
119 117 cfg.vi_x_cmd_bg = 0; cfg.vi_x_cmd_bg = 0;
120 118 cfg.use_trash = 1; cfg.use_trash = 1;
121 119
122 cfg.fuse_home = format_str("%s/vifm_FUSE", get_tmpdir());
123 assert(cfg.fuse_home != NULL);
124 #ifdef _WIN32
125 to_forward_slash(cfg.fuse_home);
126 #endif
120 {
121 char fuse_home[PATH_MAX];
122 int update_stat;
123 snprintf(fuse_home, sizeof(fuse_home), "%s/vifm_FUSE", get_tmpdir());
124 update_stat = set_fuse_home(fuse_home);
125 assert(update_stat == 0);
126 }
127 127
128 128 cfg.use_screen = 0; cfg.use_screen = 0;
129 129 cfg.use_vim_help = 0; cfg.use_vim_help = 0;
 
... ... reduce_view_history(FileView *view, size_t size)
749 749 view->history_pos -= delta; view->history_pos -= delta;
750 750 } }
751 751
752 int
753 set_fuse_home(const char new_value[])
754 {
755 char canonicalized[PATH_MAX];
756 #ifdef _WIN32
757 char with_forward_slashes[strlen(new_value) + 1];
758 strcpy(with_forward_slashes, new_value);
759 to_forward_slash(with_forward_slashes);
760 new_value = with_forward_slashes;
761 #endif
762 canonicalize_path(new_value, canonicalized, sizeof(canonicalized));
763 return replace_string(&cfg.fuse_home, canonicalized);
764 }
765
752 766 void void
753 767 free_history_items(const history_t history[], size_t len) free_history_items(const history_t history[], size_t len)
754 768 { {
File src/cfg/config.h changed (mode: 100644) (index 3c2f50936..bd45b3d13)
... ... typedef struct
70 70 int use_iec_prefixes; int use_iec_prefixes;
71 71 int wrap_quick_view; int wrap_quick_view;
72 72 char *time_format; char *time_format;
73 char *fuse_home;
73 char *fuse_home; /* This one should be set using set_fuse_home() function. */
74 74
75 75 char **search_history; char **search_history;
76 76 int search_history_num; int search_history_num;
 
... ... void generate_tmp_file_name(const char prefix[], char buf[], size_t buf_len);
130 130 void create_trash_dir(void); void create_trash_dir(void);
131 131 /* Changes size of all histories. */ /* Changes size of all histories. */
132 132 void resize_history(size_t new_len); void resize_history(size_t new_len);
133 /* Sets value of cfg.fuse_home. Returns non-zero in case of memory allocation
134 * error. */
135 int set_fuse_home(const char new_value[]);
133 136 /* Frees memory previously allocated for specified history items. */ /* Frees memory previously allocated for specified history items. */
134 137 void free_history_items(const history_t history[], size_t len); void free_history_items(const history_t history[], size_t len);
135 138
File src/cfg/info.c changed (mode: 100644) (index 5b10f6f19..4d81dbe43)
... ... read_info_file(int reread)
264 264 } }
265 265 else if(line[0] == 'f') /* left pane filter */ else if(line[0] == 'f') /* left pane filter */
266 266 { {
267 replace_string(&lwin.prev_filter, line + 1);
267 (void)replace_string(&lwin.prev_filter, line + 1);
268 268 set_filename_filter(&lwin, line + 1); set_filename_filter(&lwin, line + 1);
269 269 } }
270 270 else if(line[0] == 'F') /* right pane filter */ else if(line[0] == 'F') /* right pane filter */
271 271 { {
272 replace_string(&rwin.prev_filter, line + 1);
272 (void)replace_string(&rwin.prev_filter, line + 1);
273 273 set_filename_filter(&rwin, line + 1); set_filename_filter(&rwin, line + 1);
274 274 } }
275 275 else if(line[0] == 'i') /* left pane filter inverted */ else if(line[0] == 'i') /* left pane filter inverted */
File src/commands.c changed (mode: 100644) (index ea4db9c45..fdb156d47)
... ... save_history(const char *line, char **hist, int *num, int *len)
739 739
740 740 while(x > 0) while(x > 0)
741 741 { {
742 replace_string(&hist[x], hist[x - 1]);
742 (void)replace_string(&hist[x], hist[x - 1]);
743 743 x--; x--;
744 744 } }
745 745
746 replace_string(&hist[0], line);
746 (void)replace_string(&hist[0], line);
747 747 (*num)++; (*num)++;
748 748 if(*num >= *len) if(*num >= *len)
749 749 *num = *len - 1; *num = *len - 1;
 
... ... apropos_cmd(const cmd_info_t *cmd_info)
1447 1447
1448 1448 if(cmd_info->argc > 0) if(cmd_info->argc > 0)
1449 1449 { {
1450 replace_string(&last_args, cmd_info->args);
1450 (void)replace_string(&last_args, cmd_info->args);
1451 1451 } }
1452 1452 else if(last_args == NULL) else if(last_args == NULL)
1453 1453 { {
 
... ... colorscheme_cmd(const cmd_info_t *cmd_info)
1679 1679 { {
1680 1680 char path[PATH_MAX]; char path[PATH_MAX];
1681 1681 snprintf(path, sizeof(path), "%s/%s", curr_view->curr_dir, directory); snprintf(path, sizeof(path), "%s/%s", curr_view->curr_dir, directory);
1682 replace_string(&directory, path);
1682 (void)replace_string(&directory, path);
1683 1683 } }
1684 1684 } }
1685 1685 if(!is_dir(directory)) if(!is_dir(directory))
 
... ... find_cmd(const cmd_info_t *cmd_info)
2174 2174 last_dir = 1; last_dir = 1;
2175 2175 else else
2176 2176 last_dir = 0; last_dir = 0;
2177 replace_string(&last_args, cmd_info->args);
2177 (void)replace_string(&last_args, cmd_info->args);
2178 2178 } }
2179 2179 else if(last_args == NULL) else if(last_args == NULL)
2180 2180 { {
 
... ... grep_cmd(const cmd_info_t *cmd_info)
2207 2207
2208 2208 if(cmd_info->argc > 0) if(cmd_info->argc > 0)
2209 2209 { {
2210 replace_string(&last_args, cmd_info->args);
2210 (void)replace_string(&last_args, cmd_info->args);
2211 2211 last_invert = cmd_info->emark; last_invert = cmd_info->emark;
2212 2212 } }
2213 2213 else if(last_args == NULL) else if(last_args == NULL)
 
... ... locate_cmd(const cmd_info_t *cmd_info)
2556 2556 static char *last_args; static char *last_args;
2557 2557 if(cmd_info->argc > 0) if(cmd_info->argc > 0)
2558 2558 { {
2559 replace_string(&last_args, cmd_info->args);
2559 (void)replace_string(&last_args, cmd_info->args);
2560 2560 } }
2561 2561 else if(last_args == NULL) else if(last_args == NULL)
2562 2562 { {
 
... ... substitute_cmd(const cmd_info_t *cmd_info)
3183 3183
3184 3184 if(cmd_info->argc >= 1 && cmd_info->argv[0][0] != '\0') if(cmd_info->argc >= 1 && cmd_info->argv[0][0] != '\0')
3185 3185 { {
3186 replace_string(&last_pattern, cmd_info->argv[0]);
3186 (void)replace_string(&last_pattern, cmd_info->argv[0]);
3187 3187 } }
3188 3188
3189 3189 if(cmd_info->argc >= 2) if(cmd_info->argc >= 2)
3190 3190 { {
3191 replace_string(&last_sub, cmd_info->argv[1]);
3191 (void)replace_string(&last_sub, cmd_info->argv[1]);
3192 3192 } }
3193 3193 else if(cmd_info->argc == 1) else if(cmd_info->argc == 1)
3194 3194 { {
3195 replace_string(&last_sub, "");
3195 (void)replace_string(&last_sub, "");
3196 3196 } }
3197 3197
3198 3198 if(last_pattern == NULL) if(last_pattern == NULL)
File src/commands_completion.c changed (mode: 100644) (index da6d855fc..67ca736bd)
... ... filename_completion(const char *str, CompletionType type)
596 596 snprintf(buf, sizeof(buf), "%s", curr_view->curr_dir); snprintf(buf, sizeof(buf), "%s", curr_view->curr_dir);
597 597 strcat(buf, dirname); strcat(buf, dirname);
598 598 chosp(buf); chosp(buf);
599 replace_string(&dirname, buf);
599 (void)replace_string(&dirname, buf);
600 600 } }
601 601 #endif #endif
602 602
File src/engine/options.c changed (mode: 100644) (index e83c24292..2da9c0b86)
... ... set_option(const char name[], optval_t val)
217 217
218 218 if(opt->type == OPT_STR || opt->type == OPT_STRLIST) if(opt->type == OPT_STR || opt->type == OPT_STRLIST)
219 219 { {
220 replace_string(&opt->val.str_val, val.str_val);
220 (void)replace_string(&opt->val.str_val, val.str_val);
221 221 } }
222 222 else else
223 223 { {
 
... ... set_set(opt_t *opt, const char value[])
499 499 { {
500 500 if(opt->val.str_val == NULL || strcmp(opt->val.str_val, value) != 0) if(opt->val.str_val == NULL || strcmp(opt->val.str_val, value) != 0)
501 501 { {
502 replace_string(&opt->val.str_val, value);
502 (void)replace_string(&opt->val.str_val, value);
503 503 *opts_changed = 1; *opts_changed = 1;
504 504 opt->handler(OP_SET, opt->val); opt->handler(OP_SET, opt->val);
505 505 } }
File src/engine/variables.c changed (mode: 100644) (index fdf46237e..cf282eeed)
... ... init_var(const char *env)
116 116 return; return;
117 117 record->from_parent = 1; record->from_parent = 1;
118 118
119 replace_string(&record->initial, p + 1);
120 replace_string(&record->val, p + 1);
119 (void)replace_string(&record->initial, p + 1);
120 (void)replace_string(&record->val, p + 1);
121 121 if(record->initial == NULL || record->val == NULL) if(record->initial == NULL || record->val == NULL)
122 122 { {
123 123 free_record(record); free_record(record);
File src/filelist.c changed (mode: 100644) (index f744d75cb..5829e4455)
... ... prepare_view(FileView *view)
391 391 int i; int i;
392 392
393 393 strncpy(view->regexp, "", sizeof(view->regexp)); strncpy(view->regexp, "", sizeof(view->regexp));
394 replace_string(&view->prev_filter, "");
394 (void)replace_string(&view->prev_filter, "");
395 395 set_filename_filter(view, ""); set_filename_filter(view, "");
396 396 view->invert = 1; view->invert = 1;
397 397 view->prev_invert = view->invert; view->prev_invert = view->invert;
 
... ... save_view_history(FileView *view, const char *path, const char *file, int pos)
1311 1311 if(curr_stats.load_stage < 2) if(curr_stats.load_stage < 2)
1312 1312 return; return;
1313 1313 x = view->history_pos; x = view->history_pos;
1314 replace_string(&view->history[x].file, file);
1314 (void)replace_string(&view->history[x].file, file);
1315 1315 view->history[x].rel_pos = pos - view->top_line; view->history[x].rel_pos = pos - view->top_line;
1316 1316 return; return;
1317 1317 } }
 
... ... toggle_dot_files(FileView *view)
2734 2734 void void
2735 2735 remove_filename_filter(FileView *view) remove_filename_filter(FileView *view)
2736 2736 { {
2737 replace_string(&view->prev_filter, view->filename_filter);
2737 (void)replace_string(&view->prev_filter, view->filename_filter);
2738 2738 set_filename_filter(view, ""); set_filename_filter(view, "");
2739 2739
2740 2740 view->prev_invert = view->invert; view->prev_invert = view->invert;
 
... ... set_filename_filter(FileView *view, const char *filter)
2760 2760 regfree(&view->filter_regex); regfree(&view->filter_regex);
2761 2761 } }
2762 2762
2763 replace_string(&view->filename_filter, filter);
2763 (void)replace_string(&view->filename_filter, filter);
2764 2764 if(view->filename_filter[0] == '\0') if(view->filename_filter[0] == '\0')
2765 2765 { {
2766 2766 view->filter_is_valid = 0; view->filter_is_valid = 0;
File src/fileops.c changed (mode: 100644) (index 6bf89354c..ca98ff4f2)
... ... rename_file_cb(const char *new_name)
551 551 } }
552 552
553 553 filename_ptr = &curr_view->dir_entry[curr_view->list_pos].name; filename_ptr = &curr_view->dir_entry[curr_view->list_pos].name;
554 replace_string(filename_ptr, new);
554 (void)replace_string(filename_ptr, new);
555 555
556 556 load_saving_pos(curr_view, 1); load_saving_pos(curr_view, 1);
557 557 } }
 
... ... perform_renaming(FileView *view, char **files, int *is_dup, int len,
699 699 curr_stats.save_msg = 1; curr_stats.save_msg = 1;
700 700 return 0; return 0;
701 701 } }
702 replace_string(&files[i], unique_name);
702 (void)replace_string(&files[i], unique_name);
703 703 } }
704 704
705 705 for(i = 0; i < len; i++) for(i = 0; i < len; i++)
 
... ... perform_renaming(FileView *view, char **files, int *is_dup, int len,
719 719 pos = find_file_pos_in_list(view, files[i]); pos = find_file_pos_in_list(view, files[i]);
720 720 if(pos == view->list_pos) if(pos == view->list_pos)
721 721 { {
722 replace_string(&view->dir_entry[pos].name, list[i]);
722 (void)replace_string(&view->dir_entry[pos].name, list[i]);
723 723 } }
724 724 } }
725 725 } }
 
... ... incdec_names(FileView *view, int k)
1111 1111 else if(view->dir_entry[view->list_pos].selected || !view->user_selection) else if(view->dir_entry[view->list_pos].selected || !view->user_selection)
1112 1112 { {
1113 1113 char **filename = &view->dir_entry[view->list_pos].name; char **filename = &view->dir_entry[view->list_pos].name;
1114 replace_string(filename, add_to_name(*filename, k));
1114 (void)replace_string(filename, add_to_name(*filename, k));
1115 1115 } }
1116 1116
1117 1117 clean_selected_files(view); clean_selected_files(view);
 
... ... prompt_what_to_do(const char *src_name)
1375 1375
1376 1376 if(src_name != put_confirm.name) if(src_name != put_confirm.name)
1377 1377 { {
1378 replace_string(&put_confirm.name, src_name);
1378 (void)replace_string(&put_confirm.name, src_name);
1379 1379 } }
1380 1380 my_swprintf(buf, ARRAY_LEN(buf), L"Name conflict for %" WPRINTF_MBSTR my_swprintf(buf, ARRAY_LEN(buf), L"Name conflict for %" WPRINTF_MBSTR
1381 1381 L". [r]ename/[s]kip/[o]verwrite/overwrite [a]ll: ", src_name); L". [r]ename/[s]kip/[o]verwrite/overwrite [a]ll: ", src_name);
 
... ... change_in_names(FileView *view, char c, const char *pattern, const char *sub,
2076 2076
2077 2077 if(i == view->list_pos) if(i == view->list_pos)
2078 2078 { {
2079 replace_string(&view->dir_entry[i].name, dest[j]);
2079 (void)replace_string(&view->dir_entry[i].name, dest[j]);
2080 2080 } }
2081 2081
2082 2082 if(mv_file(buf, view->curr_dir, dest[j], view->curr_dir, 0) == 0) if(mv_file(buf, view->curr_dir, dest[j], view->curr_dir, 0) == 0)
 
... ... change_case(FileView *view, int toupper, int count, int *indexes)
2361 2361 pos = find_file_pos_in_list(view, view->selected_filelist[i]); pos = find_file_pos_in_list(view, view->selected_filelist[i]);
2362 2362 if(pos == view->list_pos) if(pos == view->list_pos)
2363 2363 { {
2364 replace_string(&view->dir_entry[pos].name, dest[i]);
2364 (void)replace_string(&view->dir_entry[pos].name, dest[i]);
2365 2365 } }
2366 2366 if(mv_file(view->selected_filelist[i], view->curr_dir, dest[i], if(mv_file(view->selected_filelist[i], view->curr_dir, dest[i],
2367 2367 view->curr_dir, 0) == 0) view->curr_dir, 0) == 0)
File src/filetype.c changed (mode: 100644) (index 7cb20b9cf..7ff64a998)
... ... assoc_viewer(const char *pattern, const char *viewer)
332 332 } }
333 333 else else
334 334 { {
335 replace_string(&fileviewers.list[i].records.list[0].command, viewer);
335 (void)replace_string(&fileviewers.list[i].records.list[0].command, viewer);
336 336 } }
337 337 } }
338 338
File src/fuse.c changed (mode: 100644) (index e0f2721cd..551186a39)
... ... get_mount_by_source(const char *source)
136 136 fuse_mount_t *runner = fuse_mounts; fuse_mount_t *runner = fuse_mounts;
137 137 while(runner != NULL) while(runner != NULL)
138 138 { {
139 if(stroscmp(runner->source_file_name, source) == 0)
139 if(paths_are_equal(runner->source_file_name, source))
140 140 break; break;
141 141 runner = runner->next; runner = runner->next;
142 142 } }
 
... ... fuse_mount(FileView *view, char *file_full_path, const char *param,
239 239 fuse_item = (fuse_mount_t *)malloc(sizeof(fuse_mount_t)); fuse_item = (fuse_mount_t *)malloc(sizeof(fuse_mount_t));
240 240 strcpy(fuse_item->source_file_name, file_full_path); strcpy(fuse_item->source_file_name, file_full_path);
241 241 strcpy(fuse_item->source_file_dir, view->curr_dir); strcpy(fuse_item->source_file_dir, view->curr_dir);
242 strcpy(fuse_item->mount_point, mount_point);
242 canonicalize_path(mount_point, fuse_item->mount_point,
243 sizeof(fuse_item->mount_point));
243 244 fuse_item->mount_point_id = mount_point_id; fuse_item->mount_point_id = mount_point_id;
244 245 fuse_item->next = NULL; fuse_item->next = NULL;
245 246 if(fuse_mounts == NULL) if(fuse_mounts == NULL)
 
... ... get_mount_by_mount_point(const char *dir)
389 390 fuse_mount_t *runner = fuse_mounts; fuse_mount_t *runner = fuse_mounts;
390 391 while(runner != NULL) while(runner != NULL)
391 392 { {
392 if(stroscmp(runner->mount_point, dir) == 0)
393 if(paths_are_equal(runner->mount_point, dir))
393 394 break; break;
394 395 runner = runner->next; runner = runner->next;
395 396 } }
 
... ... try_unmount_fuse(FileView *view)
409 410 trailer = NULL; trailer = NULL;
410 411 while(runner) while(runner)
411 412 { {
412 if(!stroscmp(runner->mount_point, view->curr_dir))
413 if(paths_are_equal(runner->mount_point, view->curr_dir))
413 414 break; break;
414 415
415 416 trailer = runner; trailer = runner;
File src/menus/dirhistory_menu.c changed (mode: 100644) (index 449c6a416..fcf82b4ff)
... ... show_history_menu(FileView *view)
62 62 /* Change the current dir to reflect the current file. */ /* Change the current dir to reflect the current file. */
63 63 if(stroscmp(view->history[i].dir, view->curr_dir) == 0) if(stroscmp(view->history[i].dir, view->curr_dir) == 0)
64 64 { {
65 replace_string(&view->history[i].file,
65 (void)replace_string(&view->history[i].file,
66 66 view->dir_entry[view->list_pos].name); view->dir_entry[view->list_pos].name);
67 67 m.pos = m.len; m.pos = m.len;
68 68 } }
File src/opt_handlers.c changed (mode: 100644) (index 0cfe24363..1eb37040e)
... ... followlinks_handler(OPT_OP op, optval_t val)
674 674 static void static void
675 675 fusehome_handler(OPT_OP op, optval_t val) fusehome_handler(OPT_OP op, optval_t val)
676 676 { {
677 free(cfg.fuse_home);
678 cfg.fuse_home = expand_tilde(strdup(val.str_val));
677 /* Set cfg.fuse_home in the correct way. */
678 char *expanded_path = expand_tilde(strdup(val.str_val));
679 (void)set_fuse_home(expanded_path);
680 free(expanded_path);
681
682 /* Update value of 'fusehome' in options unit to show its real value to
683 * user. */
684 val.str_val = cfg.fuse_home;
685 set_option("fusehome", val);
679 686 } }
680 687
681 688 static void static void
 
... ... load_view_columns_option(FileView *view, const char value[])
996 1003 /* Set value specified by user. Can't use DEFAULT_VIEW_COLUMNS here, /* Set value specified by user. Can't use DEFAULT_VIEW_COLUMNS here,
997 1004 * because empty value of view->view->columns signals about disabled * because empty value of view->view->columns signals about disabled
998 1005 * columns customization. */ * columns customization. */
999 replace_string(&view->view_columns, value);
1006 (void)replace_string(&view->view_columns, value);
1000 1007 redraw_current_view(); redraw_current_view();
1001 1008 } }
1002 1009 } }
 
... ... undolevels_handler(OPT_OP op, optval_t val)
1117 1124 static void static void
1118 1125 vicmd_handler(OPT_OP op, optval_t val) vicmd_handler(OPT_OP op, optval_t val)
1119 1126 { {
1120 replace_string(&cfg.vi_command, val.str_val);
1127 (void)replace_string(&cfg.vi_command, val.str_val);
1121 1128 cfg.vi_cmd_bg = ends_with(cfg.vi_command, "&"); cfg.vi_cmd_bg = ends_with(cfg.vi_command, "&");
1122 1129 if(cfg.vi_cmd_bg) if(cfg.vi_cmd_bg)
1123 1130 cfg.vi_command[strlen(cfg.vi_command) - 1] = '\0'; cfg.vi_command[strlen(cfg.vi_command) - 1] = '\0';
 
... ... vicmd_handler(OPT_OP op, optval_t val)
1126 1133 static void static void
1127 1134 vixcmd_handler(OPT_OP op, optval_t val) vixcmd_handler(OPT_OP op, optval_t val)
1128 1135 { {
1129 replace_string(&cfg.vi_x_command, val.str_val);
1136 (void)replace_string(&cfg.vi_x_command, val.str_val);
1130 1137 cfg.vi_x_cmd_bg = ends_with(cfg.vi_x_command, "&"); cfg.vi_x_cmd_bg = ends_with(cfg.vi_x_command, "&");
1131 1138 if(cfg.vi_x_cmd_bg) if(cfg.vi_x_cmd_bg)
1132 1139 cfg.vi_x_command[strlen(cfg.vi_x_command) - 1] = '\0'; cfg.vi_x_command[strlen(cfg.vi_x_command) - 1] = '\0';
File src/path_env.c changed (mode: 100644) (index 833549256..1d0fe8e62)
... ... path_env_was_changed(int force)
76 76 return force; return force;
77 77 } }
78 78
79 replace_string(&clean_path, path);
79 (void)replace_string(&clean_path, path);
80 80 return 1; return 1;
81 81 } }
82 82
 
... ... split_path_list(void)
234 234 void void
235 235 load_clean_path_env(void) load_clean_path_env(void)
236 236 { {
237 replace_string(&real_path, env_get("PATH"));
237 (void)replace_string(&real_path, env_get("PATH"));
238 238 env_set("PATH", clean_path); env_set("PATH", clean_path);
239 239 } }
240 240
File src/registers.c changed (mode: 100644) (index bf83e4a78..9d8f7c4f9)
... ... rename_in_registers(const char old[], const char new[])
176 176 if(stroscmp(registers[x].files[y], old) != 0) if(stroscmp(registers[x].files[y], old) != 0)
177 177 continue; continue;
178 178
179 replace_string(&registers[x].files[y], new);
179 (void)replace_string(&registers[x].files[y], new);
180 180 break; /* registers don't contain duplicates */ break; /* registers don't contain duplicates */
181 181 } }
182 182 } }
File src/undo.c changed (mode: 100644) (index 27f223e94..50cca9722)
... ... cmd_group_begin(const char *msg)
250 250
251 251 group_opened = 1; group_opened = 1;
252 252
253 replace_string(&group_msg, msg);
253 (void)replace_string(&group_msg, msg);
254 254 last_group = NULL; last_group = NULL;
255 255 } }
256 256
 
... ... replace_group_msg(const char msg[])
273 273 group_msg = (msg != NULL) ? strdup(msg) : NULL; group_msg = (msg != NULL) ? strdup(msg) : NULL;
274 274 if(last_group != NULL && group_msg != NULL) if(last_group != NULL && group_msg != NULL)
275 275 { {
276 replace_string(&last_group->msg, group_msg);
276 (void)replace_string(&last_group->msg, group_msg);
277 277 } }
278 278 return result; return result;
279 279 } }
 
... ... change_filename_in_trash(cmd_t *cmd, const char *filename)
633 633 rename_in_registers(filename, buf); rename_in_registers(filename, buf);
634 634
635 635 old = cmd->buf2; old = cmd->buf2;
636 replace_string(&cmd->buf2, buf);
636 (void)replace_string(&cmd->buf2, buf);
637 637
638 638 update_entry(&cmd->do_op.src, old, cmd->buf2); update_entry(&cmd->do_op.src, old, cmd->buf2);
639 639 update_entry(&cmd->do_op.dst, old, cmd->buf2); update_entry(&cmd->do_op.dst, old, cmd->buf2);
File src/utils/path.c changed (mode: 100644) (index 2df9c6812..a7a41046a)
... ... path_starts_with(const char *path, const char *begin)
74 74 return (path[len] == '\0' || path[len] == '/'); return (path[len] == '\0' || path[len] == '/');
75 75 } }
76 76
77 /* Removes excess slashes, "../" and "./" from the path */
77 int
78 paths_are_equal(const char s[], const char t[])
79 {
80 size_t s_len = strlen(s);
81 size_t t_len = strlen(t);
82
83 if(s_len > 0 && s[s_len - 1] == '/')
84 s_len--;
85 if(t_len > 0 && t[t_len - 1] == '/')
86 t_len--;
87
88 if(s_len == t_len)
89 {
90 return strnoscmp(s, t, s_len) == 0;
91 }
92 return 0;
93 }
94
95 /* Removes excess slashes, "../" and "./" from the path. buf will always
96 * contain trailing forward slash. */
78 97 void void
79 98 canonicalize_path(const char *directory, char *buf, size_t buf_size) canonicalize_path(const char *directory, char *buf, size_t buf_size)
80 99 { {
File src/utils/path.h changed (mode: 100644) (index 3adda0d81..1919c2910)
... ... void chosp(char *path);
26 26 int ends_with_slash(const char *path); int ends_with_slash(const char *path);
27 27 /* Checks if path starts with given base path. */ /* Checks if path starts with given base path. */
28 28 int path_starts_with(const char *path, const char *begin); int path_starts_with(const char *path, const char *begin);
29 /* Checks if two paths point to the same location, treating ending slashes
30 * correctly. Returns non-zero for same path. */
31 int paths_are_equal(const char s[], const char t[]);
29 32 void canonicalize_path(const char *directory, char *buf, size_t buf_size); void canonicalize_path(const char *directory, char *buf, size_t buf_size);
30 33 const char * make_rel_path(const char *path, const char *base); const char * make_rel_path(const char *path, const char *base);
31 34 int is_path_absolute(const char *path); int is_path_absolute(const char *path);
File src/utils/str.c changed (mode: 100644) (index f05c5c0bf..bd0640f3c)
... ... until_first(const char str[], char c)
202 202 return (char *)result; return (char *)result;
203 203 } }
204 204
205 void
205 int
206 206 replace_string(char **str, const char with[]) replace_string(char **str, const char with[])
207 207 { {
208 208 if(*str != with) if(*str != with)
209 209 { {
210 210 char *new = strdup(with); char *new = strdup(with);
211 if(new != NULL)
211 if(new == NULL)
212 212 { {
213 free(*str);
214 *str = new;
213 return 1;
215 214 } }
215 free(*str);
216 *str = new;
216 217 } }
218 return 0;
217 219 } }
218 220
219 221 char * char *
File src/utils/str.h changed (mode: 100644) (index 97ac8a399..4c642e9b0)
... ... char * after_last(const char *str, char c);
59 59 * end. */ * end. */
60 60 char * until_first(const char str[], char c); char * until_first(const char str[], char c);
61 61 /* Replaces *str with a copy of with string. *str can be NULL or equal to /* Replaces *str with a copy of with string. *str can be NULL or equal to
62 * with (then function does nothing). */
63 void replace_string(char **str, const char with[]);
62 * with (then function does nothing). Returns non-zero if memory allocation
63 * failed. */
64 int replace_string(char **str, const char with[]);
64 65 /* Adds a character to the end of a string. */ /* Adds a character to the end of a string. */
65 66 char * strcatch(char *str, char c); char * strcatch(char *str, char c);
66 67 /* A wrapper of swprintf() functions to make its differences on various /* A wrapper of swprintf() functions to make its differences on various
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