Revert "replaced buggy concat_dir_and_file() by mhl_str_dir_plus_file()"

This reverts commit 54d6ec88dc.

Conflicts:

	ChangeLog
	mhl/string.h
	src/command.c
	src/complete.c
	src/util.c
This commit is contained in:
Patrick Winnertz 2009-02-10 13:29:18 +01:00
parent 5bbeba0b8b
commit e4e135399f
31 changed files with 119 additions and 148 deletions

View File

@ -30,9 +30,8 @@
#include <ctype.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <mhl/string.h>
#include <stdlib.h>
#include "../src/global.h"
@ -2666,7 +2665,7 @@ user_menu (WEdit * edit)
int nomark;
struct stat status;
long start_mark, end_mark;
char *block_file = mhl_str_dir_plus_file (home_dir, BLOCK_FILE);
char *block_file = concat_dir_and_file (home_dir, BLOCK_FILE);
int rc = 0;
nomark = eval_marks (edit, &start_mark, &end_mark);

View File

@ -28,6 +28,7 @@
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
@ -35,9 +36,8 @@
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <mhl/string.h>
#include <stdlib.h>
#include "../src/global.h"
#include "../src/history.h"
@ -235,7 +235,7 @@ edit_save_file (WEdit *edit, const char *filename)
return 0;
if (*filename != PATH_SEP && edit->dir) {
savename = mhl_str_dir_plus_file (edit->dir, filename);
savename = concat_dir_and_file (edit->dir, filename);
filename = catstrs (savename, (char *) NULL);
g_free (savename);
}
@ -301,7 +301,7 @@ edit_save_file (WEdit *edit, const char *filename)
savedir[slashpos - filename + 1] = '\0';
} else
savedir = g_strdup (".");
saveprefix = mhl_str_dir_plus_file (savedir, "cooledit");
saveprefix = concat_dir_and_file (savedir, "cooledit");
g_free (savedir);
fd = mc_mkstemps (&savename, saveprefix, NULL);
g_free (saveprefix);

View File

@ -33,9 +33,8 @@
#include <ctype.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <mhl/string.h>
#include <stdlib.h>
#include "../src/global.h"
@ -175,7 +174,7 @@ edit_file (const char *_file, int line)
WButtonBar *edit_bar;
if (!made_directory) {
char *dir = mhl_str_dir_plus_file (home_dir, EDIT_DIR);
char *dir = concat_dir_and_file (home_dir, EDIT_DIR);
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
g_free (dir);
}

View File

@ -30,9 +30,8 @@
#include <ctype.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <mhl/string.h>
#include <stdlib.h>
#include "../src/global.h"
@ -1027,7 +1026,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
f = fopen (syntax_file, "r");
if (!f){
lib_file = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
lib_file = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
f = fopen (lib_file, "r");
g_free (lib_file);
if (!f)
@ -1189,7 +1188,7 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type)
if (!*edit->filename && !type)
return;
}
f = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE);
f = concat_dir_and_file (home_dir, SYNTAX_FILE);
r = edit_read_syntax_file (edit, pnames, f, edit ? edit->filename : 0,
get_first_editor_line (edit), type);
if (r == -1) {

View File

@ -26,12 +26,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/string.h>
#include "../src/global.h"
#include "edit.h"
@ -597,7 +596,7 @@ edit_load_user_map(WEdit *edit)
if (edit_key_emulation != EDIT_KEY_EMULATION_USER)
return TRUE;
file = mhl_str_dir_plus_file(home_dir, MC_USERMAP);
file = concat_dir_and_file(home_dir, MC_USERMAP);
if (stat(file, &s) < 0) {
char *msg = g_strdup_printf(_("%s not found!"), file);

View File

@ -50,7 +50,7 @@ load_codepages_list (void)
extern int display_codepage;
char *default_codepage = NULL;
fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX);
fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
if (!(f = fopen (fname, "r"))) {
fprintf (stderr, _("Warning: file %s not found\n"), fname);
g_free (fname);

View File

@ -34,8 +34,6 @@
#endif
#include <unistd.h>
#include <mhl/string.h>
#include "global.h"
#include "cmd.h" /* Our definitions */
#include "fileopctx.h" /* file_op_context_new() */
@ -364,7 +362,7 @@ mkdir_cmd (void)
if (dir[0] == '/' || dir[0] == '~')
absdir = g_strdup (dir);
else
absdir = mhl_str_dir_plus_file (current_panel->cwd, dir);
absdir = concat_dir_and_file (current_panel->cwd, dir);
save_cwds_stat ();
if (my_mkdir (absdir, 0777) == 0) {
@ -570,10 +568,10 @@ void ext_cmd (void)
_(" Which extension file you want to edit? "), 0, 2,
_("&User"), _("&System Wide"));
}
extdir = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT);
extdir = concat_dir_and_file (mc_home, MC_LIB_EXT);
if (dir == 0){
buffer = mhl_str_dir_plus_file (home_dir, MC_USER_EXT);
buffer = concat_dir_and_file (home_dir, MC_USER_EXT);
check_for_default (extdir, buffer);
do_edit (buffer);
g_free (buffer);
@ -600,7 +598,7 @@ menu_edit_cmd (int where)
_("&Local"), _("&User"), _("&System Wide")
);
menufile = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
switch (dir) {
case 0:
@ -609,12 +607,12 @@ menu_edit_cmd (int where)
break;
case 1:
buffer = mhl_str_dir_plus_file (home_dir, where ? CEDIT_HOME_MENU : MC_HOME_MENU);
buffer = concat_dir_and_file (home_dir, where ? CEDIT_HOME_MENU : MC_HOME_MENU);
check_for_default (menufile, buffer);
break;
case 2:
buffer = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
break;
default:
@ -673,10 +671,10 @@ edit_syntax_cmd (void)
_(" Which syntax file you want to edit? "), 0, 2,
_("&User"), _("&System Wide"));
}
extdir = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
if (dir == 0) {
buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE);
buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);
check_for_default (extdir, buffer);
do_edit (buffer);
g_free (buffer);
@ -807,8 +805,8 @@ compare_dir (WPanel *panel, WPanel *other, enum CompareMode mode)
}
/* Thorough compare on, do byte-by-byte comparison */
src_name = mhl_str_dir_plus_file (panel->cwd, source->fname);
dst_name = mhl_str_dir_plus_file (other->cwd, target->fname);
src_name = concat_dir_and_file (panel->cwd, source->fname);
dst_name = concat_dir_and_file (other->cwd, target->fname);
if (compare_files (src_name, dst_name, source->st.st_size))
do_file_mark (panel, i, 1);
g_free (src_name);
@ -922,10 +920,10 @@ do_link (int symbolic_link, const char *fname)
char *d;
/* suggest the full path for symlink */
s = mhl_str_dir_plus_file (current_panel->cwd, fname);
s = concat_dir_and_file (current_panel->cwd, fname);
if (get_other_type () == view_listing) {
d = mhl_str_dir_plus_file (other_panel->cwd, fname);
d = concat_dir_and_file (other_panel->cwd, fname);
} else {
d = g_strdup (fname);
}

View File

@ -27,10 +27,6 @@
#include <errno.h>
#include <string.h>
#include <mhl/memory.h>
#include <mhl/escape.h>
#include <mhl/string.h>
#include "global.h" /* home_dir */
#include "tty.h"
#include "widget.h" /* WInput */
@ -128,7 +124,7 @@ examine_cd (char *path)
c = *s;
*s = 0;
if (*p) {
r = mhl_str_dir_plus_file (p, q);
r = concat_dir_and_file (p, q);
result = do_cd (r, cd_parse_command);
g_free (r);
}
@ -181,7 +177,7 @@ void do_cd_command (char *cmd)
} else {
char *old = current_panel->cwd;
char *new;
new = mhl_str_dir_plus_file (old, cmd+3);
new = concat_dir_and_file (old, cmd+3);
sync_tree (new);
g_free (new);
}

View File

@ -26,14 +26,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/memory.h>
#include <mhl/escape.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h"
#include "win.h"
@ -520,7 +517,7 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (cur_path >= path_end)
break;
expanded = tilde_expand (*cur_path ? cur_path : ".");
cur_word = mhl_str_dir_plus_file (expanded, text);
cur_word = concat_dir_and_file (expanded, text);
g_free (expanded);
canonicalize_pathname (cur_word);
cur_path = strchr (cur_path, 0) + 1;
@ -815,10 +812,11 @@ try_complete (char *text, int *start, int *end, INPUT_COMPLETE_FLAGS flags)
c = *s;
*s = 0;
if (*cdpath){
r = mhl_str_dir_plus_file (cdpath, word);
SHOW_C_CTX("try_complete:filename_subst_2");
matches = completion_matches (r, filename_completion_function, flags);
g_free (r);
r = concat_dir_and_file (cdpath, word);
ignore_filenames = 1;
matches = completion_matches (r, filename_completion_function);
ignore_filenames = 0;
g_free (r);
}
*s = c;
cdpath = s + 1;

View File

@ -28,8 +28,6 @@
#endif
#include <unistd.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h"
#include "cons.saver.h"
@ -145,7 +143,7 @@ handle_console_linux (unsigned char action)
open ("/dev/null", O_WRONLY);
if (tty_name) {
/* Exec the console save/restore handler */
mc_conssaver = mhl_str_dir_plus_file (SAVERDIR, "cons.saver");
mc_conssaver = concat_dir_and_file (SAVERDIR, "cons.saver");
execl (mc_conssaver, "cons.saver", tty_name, (char *) NULL);
}
/* Console is not a tty or execl() failed */

View File

@ -53,8 +53,6 @@
#endif
#include <unistd.h>
#include <mhl/string.h>
#define LINUX_CONS_SAVER_C
#include "cons.saver.h"

View File

@ -25,9 +25,8 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <mhl/string.h>
#include <unistd.h>
#include "global.h"
#include "tty.h"
@ -441,11 +440,11 @@ regex_command (const char *filename, const char *action, int *move_dir)
int mc_user_ext = 1;
int home_error = 0;
extension_file = mhl_str_dir_plus_file (home_dir, MC_USER_EXT);
extension_file = concat_dir_and_file (home_dir, MC_USER_EXT);
if (!exist_file (extension_file)) {
g_free (extension_file);
check_stock_mc_ext:
extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT);
extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
mc_user_ext = 0;
}
data = load_file (extension_file);

View File

@ -922,7 +922,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
}
/* Dive into subdir if exists */
if (toplevel && ctx->dive_into_subdirs) {
dest_dir = mhl_str_dir_plus_file (d, x_basename (s));
dest_dir = concat_dir_and_file (d, x_basename (s));
} else {
dest_dir = g_strdup (d);
goto dont_mkdir;
@ -968,11 +968,11 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
continue;
/* get the filename and add it to the src directory */
path = mhl_str_dir_plus_file (s, next->d_name);
path = concat_dir_and_file (s, next->d_name);
(*ctx->stat_func) (path, &buf);
if (S_ISDIR (buf.st_mode)) {
mdpath = mhl_str_dir_plus_file (dest_dir, next->d_name);
mdpath = concat_dir_and_file (dest_dir, next->d_name);
/*
* From here, we just intend to recursively copy subdirs, not
* the double functionality of copying different when the target
@ -983,7 +983,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
parent_dirs, progress_count, progress_bytes);
g_free (mdpath);
} else {
dest_file = mhl_str_dir_plus_file (dest_dir, x_basename (path));
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
return_status = copy_file_file (ctx, path, dest_file, 1,
progress_count, progress_bytes, 0);
g_free (dest_file);
@ -1173,7 +1173,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
destdir = g_strdup (d);
move_over = 1;
} else
destdir = mhl_str_dir_plus_file (d, x_basename (s));
destdir = concat_dir_and_file (d, x_basename (s));
if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) {
int msize = COLS - 36;
@ -1330,7 +1330,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
continue;
if (!strcmp (next->d_name, ".."))
continue;
path = mhl_str_dir_plus_file (s, next->d_name);
path = concat_dir_and_file (s, next->d_name);
if (mc_lstat (path, &buf)) {
g_free (path);
mc_closedir (reading);
@ -1521,7 +1521,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total)
if (strcmp (dirent->d_name, "..") == 0)
continue;
fullname = mhl_str_dir_plus_file (dirname, dirent->d_name);
fullname = concat_dir_and_file (dirname, dirent->d_name);
res = mc_lstat (fullname, &s);
@ -1578,7 +1578,7 @@ panel_compute_totals (WPanel *panel, off_t *ret_marked, double *ret_total)
double subdir_bytes = 0;
dir_name =
mhl_str_dir_plus_file (panel->cwd, panel->dir.list[i].fname);
concat_dir_and_file (panel->cwd, panel->dir.list[i].fname);
compute_dir_size (dir_name, &subdir_count, &subdir_bytes);
*ret_marked += subdir_count;
@ -1886,7 +1886,7 @@ panel_operate (void *source_panel, FileOperation operation,
/* The source and src_stat variables have been initialized before */
#ifdef WITH_FULL_PATHS
source_with_path = mhl_str_dir_plus_file (panel->cwd, source);
source_with_path = concat_dir_and_file (panel->cwd, source);
#endif /* WITH_FULL_PATHS */
if (operation == OP_DELETE) {
@ -1901,7 +1901,7 @@ panel_operate (void *source_panel, FileOperation operation,
if (temp == NULL) {
value = transform_error;
} else {
char *temp2 = mhl_str_dir_plus_file (dest, temp);
char *temp2 = concat_dir_and_file (dest, temp);
g_free (dest);
dest = temp2;
temp = NULL;
@ -1979,7 +1979,7 @@ panel_operate (void *source_panel, FileOperation operation,
#ifdef WITH_FULL_PATHS
g_free (source_with_path);
source_with_path = mhl_str_dir_plus_file (panel->cwd, source);
source_with_path = concat_dir_and_file (panel->cwd, source);
#endif /* WITH_FULL_PATHS */
if (operation == OP_DELETE) {
@ -1995,7 +1995,7 @@ panel_operate (void *source_panel, FileOperation operation,
if (temp == NULL)
value = transform_error;
else {
char *temp2 = mhl_str_dir_plus_file (dest, temp);
char *temp2 = concat_dir_and_file (dest, temp);
source_with_path = mhl_shell_unescape_buf(source_with_path);
temp2 = mhl_shell_unescape_buf(temp2);

View File

@ -27,8 +27,6 @@
#include <errno.h>
#include <string.h>
#include <mhl/string.h>
#include "global.h"
static char *
@ -39,7 +37,7 @@ get_absolute_name (const char *file)
if (file[0] == PATH_SEP)
return g_strdup (file);
mc_get_current_wd (dir, MC_MAXPATHLEN);
return mhl_str_dir_plus_file (dir, file);
return concat_dir_and_file (dir, file);
}
static int
@ -62,7 +60,7 @@ my_mkdir_rec (char *s, mode_t mode)
return -1;
}
p = mhl_str_dir_plus_file (s, "..");
p = concat_dir_and_file (s, "..");
q = vfs_canon (p);
g_free (p);

View File

@ -25,9 +25,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <mhl/string.h>
#include <sys/stat.h>
#include "global.h"
#include "tty.h"
@ -355,7 +354,7 @@ push_directory (const char *dir)
dir_stack *new;
new = g_new (dir_stack, 1);
new->name = mhl_str_dir_plus_file (dir, NULL);
new->name = concat_dir_and_file (dir, "");
new->prev = dir_stack_base;
dir_stack_base = new;
}
@ -517,7 +516,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
int file_fd;
int ret_val = 0;
fname = mhl_str_dir_plus_file (directory, filename);
fname = concat_dir_and_file (directory, filename);
if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){
g_free (fname);
@ -693,7 +692,7 @@ do_search (struct Dlg_head *h)
}
if (subdirs_left && find_recursively && directory) { /* Can directory be NULL ? */
char *tmp_name = mhl_str_dir_plus_file (directory, dp->d_name);
char *tmp_name = concat_dir_and_file (directory, dp->d_name);
if (!mc_lstat (tmp_name, &tmp_stat)
&& S_ISDIR (tmp_stat.st_mode)) {
push_directory (tmp_name);
@ -753,8 +752,8 @@ make_fullname (const char *dirname, const char *filename)
if (strcmp(dirname, ".") == 0 || strcmp(dirname, "."PATH_SEP_STR) == 0)
return g_strdup (filename);
if (strncmp(dirname, "."PATH_SEP_STR, 2) == 0)
return mhl_str_dir_plus_file (dirname + 2, filename);
return mhl_str_dir_plus_file (dirname, filename);
return concat_dir_and_file (dirname + 2, filename);
return concat_dir_and_file (dirname, filename);
}
static void

View File

@ -32,12 +32,11 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h" /* COLS */
#include "color.h" /* dialog_colors */
@ -1448,7 +1447,7 @@ load_hotlist (void)
}
if (!hotlist_file_name)
hotlist_file_name = mhl_str_dir_plus_file (home_dir, HOTLIST_FILENAME);
hotlist_file_name = concat_dir_and_file (home_dir, HOTLIST_FILENAME);
hotlist = new_hotlist ();
hotlist->type = HL_TYPE_GROUP;

View File

@ -29,12 +29,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h"
#include "dir.h"
@ -1137,7 +1136,7 @@ copy_readlink (WPanel *panel)
if (S_ISLNK (selection (panel)->st.st_mode)) {
char buffer[MC_MAXPATHLEN];
char *p =
mhl_str_dir_plus_file (panel->cwd, selection (panel)->fname);
concat_dir_and_file (panel->cwd, selection (panel)->fname);
int i;
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);

View File

@ -25,9 +25,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <mhl/string.h>
#include <unistd.h>
#include "global.h"
#include "tty.h"
@ -710,7 +709,7 @@ display_mini_info (WPanel *panel)
char *link, link_target [MC_MAXPATHLEN];
int len;
link = mhl_str_dir_plus_file (panel->cwd, panel->dir.list [panel->selected].fname);
link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1);
g_free (link);
if (len > 0){
@ -1975,7 +1974,7 @@ do_enter_on_file_entry (file_entry *fe)
return 1;
/* Check if the file is executable */
full_name = mhl_str_dir_plus_file (current_panel->cwd, fe->fname);
full_name = concat_dir_and_file (current_panel->cwd, fe->fname);
if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe)) {
g_free (full_name);
return 0;
@ -1994,7 +1993,7 @@ do_enter_on_file_entry (file_entry *fe)
char *tmp;
int ret;
tmp = mhl_str_dir_plus_file (vfs_get_current_dir (), fe->fname);
tmp = concat_dir_and_file (vfs_get_current_dir (), fe->fname);
ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL);
g_free (tmp);
/* We took action only if the dialog was shown or the execution
@ -2031,10 +2030,10 @@ chdir_other_panel (WPanel *panel)
}
if (!S_ISDIR (panel->dir.list [panel->selected].st.st_mode)) {
new_dir = mhl_str_dir_plus_file (panel->cwd, "..");
new_dir = concat_dir_and_file (panel->cwd, "..");
sel_entry = strrchr(panel->cwd, PATH_SEP);
} else
new_dir = mhl_str_dir_plus_file (panel->cwd, panel->dir.list [panel->selected].fname);
new_dir = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
change_panel ();
do_cd (new_dir, cd_exact);
@ -2100,7 +2099,7 @@ chdir_to_readlink (WPanel *panel)
if (*buffer == PATH_SEP)
new_dir = g_strdup (buffer);
else
new_dir = mhl_str_dir_plus_file (panel->cwd, buffer);
new_dir = concat_dir_and_file (panel->cwd, buffer);
change_panel ();
do_cd (new_dir, cd_exact);

View File

@ -20,11 +20,10 @@
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h"
#include "dir.h"
@ -282,7 +281,7 @@ save_layout (void)
int i;
char buffer [BUF_TINY];
profile = mhl_str_dir_plus_file (home_dir, PROFILE_NAME);
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
/* Save integer options */
for (i = 0; layout [i].opt_name; i++){
@ -299,7 +298,7 @@ save_configure (void)
char *profile;
int i;
profile = mhl_str_dir_plus_file (home_dir, PROFILE_NAME);
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
/* Save integer options */
for (i = 0; int_options[i].opt_name; i++)
@ -347,7 +346,7 @@ save_setup (void)
char *profile;
saving_setup = 1;
profile = mhl_str_dir_plus_file (home_dir, PROFILE_NAME);
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
save_configure ();
@ -482,9 +481,9 @@ setup_init (void)
if (profile_name)
return profile_name;
profile = mhl_str_dir_plus_file (home_dir, PROFILE_NAME);
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
if (!exist_file (profile)){
inifile = mhl_str_dir_plus_file (mc_home, "mc.ini");
inifile = concat_dir_and_file (mc_home, "mc.ini");
if (exist_file (inifile)){
g_free (profile);
profile = inifile;
@ -507,7 +506,7 @@ load_setup (void)
/* mc.lib is common for all users, but has priority lower than
~/.mc/ini. FIXME: it's only used for keys and treestore now */
global_profile_name = mhl_str_dir_plus_file (mc_home, "mc.lib");
global_profile_name = concat_dir_and_file (mc_home, "mc.lib");
/* Load integer boolean options */
for (i = 0; int_options[i].opt_name; i++)

View File

@ -37,12 +37,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/string.h>
#include "global.h"
#include "treestore.h"
#include "profile.h"
@ -266,7 +265,7 @@ tree_store_load(void)
char *name;
int retval;
name = mhl_str_dir_plus_file(home_dir, MC_TREE);
name = concat_dir_and_file(home_dir, MC_TREE);
retval = tree_store_load_from(name);
g_free(name);
@ -372,7 +371,7 @@ tree_store_save(void)
char *name;
int retval;
tmp = mhl_str_dir_plus_file(home_dir, MC_TREE_TMP);
tmp = concat_dir_and_file(home_dir, MC_TREE_TMP);
retval = tree_store_save_to(tmp);
if (retval) {
@ -380,7 +379,7 @@ tree_store_save(void)
return retval;
}
name = mhl_str_dir_plus_file(home_dir, MC_TREE);
name = concat_dir_and_file(home_dir, MC_TREE);
retval = rename(tmp, name);
g_free(tmp);
@ -606,7 +605,7 @@ tree_store_mark_checked(const char *subname)
if (ts.check_name[0] == PATH_SEP && ts.check_name[1] == 0)
name = g_strconcat(PATH_SEP_STR, subname, (char *) NULL);
else
name = mhl_str_dir_plus_file(ts.check_name, subname);
name = concat_dir_and_file(ts.check_name, subname);
/* Search for the subdirectory */
current = ts.check_start;
@ -796,7 +795,7 @@ tree_store_rescan(const char *dir)
continue;
}
full_name = mhl_str_dir_plus_file(dir, dp->d_name);
full_name = concat_dir_and_file(dir, dp->d_name);
if (mc_lstat(full_name, &buf) != -1) {
if (S_ISDIR(buf.st_mode))
tree_store_mark_checked(dp->d_name);

View File

@ -23,8 +23,6 @@
#include <stdio.h>
#include <string.h>
#include <mhl/string.h>
#include "global.h"
#include "tty.h"
#include "color.h"
@ -723,11 +721,11 @@ user_menu_cmd (struct WEdit *edit_widget)
menu = g_strdup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
if (!exist_file (menu) || !menu_file_own (menu)){
g_free (menu);
menu = mhl_str_dir_plus_file \
menu = concat_dir_and_file \
(home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU);
if (!exist_file (menu)){
g_free (menu);
menu = mhl_str_dir_plus_file \
menu = concat_dir_and_file \
(mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
}
}

View File

@ -35,9 +35,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <mhl/escape.h>
#include <mhl/string.h>
#include "global.h"
#include "profile.h"
#include "main.h" /* mc_home */
@ -694,7 +691,7 @@ load_mc_home_file (const char *filename, char **allocated_filename)
char *lang;
char *data;
hintfile_base = mhl_str_dir_plus_file (mc_home, filename);
hintfile_base = concat_dir_and_file (mc_home, filename);
lang = guess_message_value ();
hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
@ -1253,6 +1250,18 @@ diff_two_paths (const char *first, const char *second)
return buf;
}
/* If filename is NULL, then we just append PATH_SEP to the dir */
char *
concat_dir_and_file (const char *dir, const char *file)
{
int i = strlen (dir);
if (dir [i-1] == PATH_SEP)
return g_strconcat (dir, file, (char *) NULL);
else
return g_strconcat (dir, PATH_SEP_STR, file, (char *) NULL);
}
/* Append text to GList, remove all entries with the same text */
GList *
list_append_unique (GList *list, char *text)
@ -1313,7 +1322,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
if (strchr (prefix, PATH_SEP) == NULL) {
/* Add prefix first to find the position of XXXXXX */
tmpbase = mhl_str_dir_plus_file (mc_tmpdir (), prefix);
tmpbase = concat_dir_and_file (mc_tmpdir (), prefix);
} else {
tmpbase = g_strdup (prefix);
}
@ -1381,7 +1390,7 @@ load_file_position (const char *filename, long *line, long *column)
*column = 0;
/* open file with positions */
fn = mhl_str_dir_plus_file (home_dir, MC_FILEPOS);
fn = concat_dir_and_file (home_dir, MC_FILEPOS);
f = fopen (fn, "r");
g_free (fn);
if (!f)
@ -1428,8 +1437,8 @@ save_file_position (const char *filename, long line, long column)
len = strlen (filename);
tmp = mhl_str_dir_plus_file (home_dir, MC_FILEPOS_TMP);
fn = mhl_str_dir_plus_file (home_dir, MC_FILEPOS);
tmp = concat_dir_and_file (home_dir, MC_FILEPOS_TMP);
fn = concat_dir_and_file (home_dir, MC_FILEPOS);
/* open temporary file */
t = fopen (tmp, "w");

View File

@ -66,6 +66,7 @@ char *strip_password (char *path, int has_prefix);
const char *strip_home_and_password (const char *dir);
const char *extension (const char *);
char *concat_dir_and_file (const char *dir, const char *file);
const char *unix_error_string (int error_num);
const char *skip_separators (const char *s);
const char *skip_numbers (const char *s);

View File

@ -32,9 +32,8 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <mhl/string.h>
#include <sys/types.h>
#include "global.h"
#include "tty.h"
@ -866,7 +865,7 @@ history_get (const char *input_name)
return NULL;
if (!*input_name)
return NULL;
profile = mhl_str_dir_plus_file (home_dir, HISTORY_FILE_NAME);
profile = concat_dir_and_file (home_dir, HISTORY_FILE_NAME);
for (i = 0;; i++) {
char key_name[BUF_TINY];
char this_entry[BUF_LARGE];
@ -904,7 +903,7 @@ history_put (const char *input_name, GList *h)
if (!num_history_items_recorded) /* this is how to disable */
return;
profile = mhl_str_dir_plus_file (home_dir, HISTORY_FILE_NAME);
profile = concat_dir_and_file (home_dir, HISTORY_FILE_NAME);
if ((i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) != -1)
close (i);

View File

@ -35,9 +35,6 @@
#include <sys/wait.h>
#endif
#include <errno.h>
#include <mhl/string.h>
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */
@ -249,7 +246,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
tmp = name_quote (name, 0);
}
mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR);
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
cmd =
g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
local_name ? local_name : tmp, (char *) NULL);
@ -624,7 +621,7 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
archive_name = name_quote (extfs_get_archive_name (archive), 0);
quoted_localname = name_quote (localname, 0);
mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR);
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
extfs_cmd, archive_name, " ", quoted_file, " ",
quoted_localname, (char *) NULL);
@ -653,7 +650,7 @@ extfs_run (struct vfs_class *me, const char *file)
g_free (p);
archive_name = name_quote (extfs_get_archive_name (archive), 0);
mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR);
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
" run ", archive_name, " ", q, (char *) NULL);
g_free (mc_extfsdir);
@ -1298,7 +1295,7 @@ static int extfs_init (struct vfs_class *me)
(void) me;
mc_extfsini = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
cfg = fopen (mc_extfsini, "r");
/* We may not use vfs_die() message or message or similar,

View File

@ -44,7 +44,7 @@ What to do with this?
int f = !strcmp( remote_path, "/~" );
if (f || !strncmp( remote_path, "/~/", 3 )) {
char *s;
s = mhl_str_dir_plus_file( qhome (*bucket), remote_path +3-f );
s = concat_dir_and_file( qhome (*bucket), remote_path +3-f );
g_free (remote_path);
remote_path = s;
}
@ -69,8 +69,6 @@ What to do with this?
#include <errno.h>
#include <ctype.h>
#include <mhl/string.h>
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */
@ -557,7 +555,7 @@ ftpfs_load_no_proxy_list (void)
if (mc_file)
return;
mc_file = mhl_str_dir_plus_file (mc_home, "mc.no_proxy");
mc_file = concat_dir_and_file (mc_home, "mc.no_proxy");
if (exist_file (mc_file) &&
(npf = fopen (mc_file, "r"))) {
while (fgets (s, sizeof (s), npf)) {
@ -1232,7 +1230,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
ftpfs_open_data_connection (me, super, "LIST -la", 0, TYPE_ASCII, 0);
else {
/* Trailing "/." is necessary if remote_path is a symlink */
char *path = mhl_str_dir_plus_file (remote_path, ".");
char *path = concat_dir_and_file (remote_path, ".");
sock =
ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII,
0);
@ -1888,7 +1886,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
}
/* Load current .netrc */
netrcname = mhl_str_dir_plus_file (home_dir, ".netrc");
netrcname = concat_dir_and_file (home_dir, ".netrc");
netrcp = netrc = load_file (netrcname);
if (netrc == NULL) {
g_free (netrcname);

View File

@ -31,8 +31,6 @@
#include <signal.h>
#include <ctype.h> /* is_digit() */
#include <mhl/string.h>
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */
@ -124,7 +122,7 @@ vfs_getid (struct vfs_class *vclass, const char *dir)
vfsid id = NULL;
/* append slash if needed */
dir1 = mhl_str_dir_plus_file (dir, "");
dir1 = concat_dir_and_file (dir, "");
if (vclass->getid)
id = (*vclass->getid) (vclass, dir1);

View File

@ -406,7 +406,7 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
int f = !strcmp (remote_path, "/~");
if (f || !strncmp (remote_path, "/~/", 3)) {
char *s;
s = mhl_str_dir_plus_file (mcfs_gethome (*mc),
s = concat_dir_and_file (mcfs_gethome (*mc),
remote_path + 3 - f);
g_free (remote_path);
remote_path = s;

View File

@ -34,8 +34,6 @@
#include <stdio.h>
#include <string.h>
#include <mhl/string.h>
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */
@ -338,7 +336,7 @@ static int sfs_init (struct vfs_class *me)
(void) me;
mc_sfsini = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR "sfs.ini");
mc_sfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "sfs.ini");
cfg = fopen (mc_sfsini, "r");
if (!cfg){

View File

@ -1211,7 +1211,7 @@ smbfs_get_path (smbfs_connection ** sc, const char *path)
int f = !strcmp (remote_path, "/~");
if (f || !strncmp (remote_path, "/~/", 3)) {
char *s;
s = mhl_str_dir_plus_file ((*sc)->home, remote_path + 3 - f);
s = concat_dir_and_file ((*sc)->home, remote_path + 3 - f);
g_free (remote_path);
return s;
}

View File

@ -38,8 +38,6 @@
#include <signal.h>
#include <ctype.h> /* is_digit() */
#include <mhl/string.h>
#include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */
@ -658,7 +656,7 @@ vfs_canon (const char *path)
if (*path != PATH_SEP){
char *local, *result;
local = mhl_str_dir_plus_file (current_dir, path);
local = concat_dir_and_file (current_dir, path);
result = vfs_canon (local);
g_free (local);