diff -up mc-4.6.2/edit/editcmd.c.etcmc mc-4.6.2/edit/editcmd.c --- mc-4.6.2/edit/editcmd.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/edit/editcmd.c 2009-05-26 18:05:21.000000000 +0200 @@ -51,7 +51,7 @@ #include "../src/tty.h" /* LINES */ #include "../src/widget.h" /* listbox_new() */ #include "../src/layout.h" /* clr_scr() */ -#include "../src/main.h" /* mc_home */ +#include "../src/main.h" /* mc_home, mc_home_alt */ #include "../src/help.h" /* interactive_display() */ #include "../src/key.h" /* XCTRL */ #include "../src/dialog.h" /* do_refresh() */ @@ -2833,12 +2833,15 @@ edit_block_process_cmd (WEdit *edit, con return; } if (!(script_src = fopen (o, "r"))) { - fclose (script_home); - unlink (h); - edit_error_dialog ("", get_sys_error (catstrs - (_("Error reading script:"), - o, (char *) NULL))); - return; + o = catstrs (mc_home_alt, shell_cmd, (char *) NULL); + if (!(script_src = fopen (o, "r"))) { + fclose (script_home); + unlink (h); + edit_error_dialog ("", get_sys_error (catstrs + (_("Error reading script:"), + o, (char *) NULL))); + return; + } } while (fgets (buf, sizeof (buf), script_src)) fputs (buf, script_home); diff -up mc-4.6.2/edit/syntax.c.etcmc mc-4.6.2/edit/syntax.c --- mc-4.6.2/edit/syntax.c.etcmc 2009-02-01 20:30:21.000000000 +0100 +++ mc-4.6.2/edit/syntax.c 2009-05-26 18:05:21.000000000 +0200 @@ -39,7 +39,7 @@ #include "edit.h" #include "edit-widget.h" #include "../src/color.h" /* use_colors */ -#include "../src/main.h" /* mc_home */ +#include "../src/main.h" /* mc_home, mc_home_alt */ #include "../src/wtools.h" /* message() */ /* bytes */ @@ -682,6 +682,12 @@ static FILE *open_include_file (const ch g_free (error_file_name); error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, filename, (char *) NULL); + if (!(f = fopen (error_file_name, "r"))) { + g_free (error_file_name); + error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR, + filename, (char *) NULL); + } else return f; + return fopen (error_file_name, "r"); } diff -up mc-4.6.2/src/charsets.c.etcmc mc-4.6.2/src/charsets.c --- mc-4.6.2/src/charsets.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/charsets.c 2009-05-26 18:05:21.000000000 +0200 @@ -47,12 +47,17 @@ load_codepages_list (void) char *fname; char buf[256]; extern char *mc_home; + extern char *mc_home_alt; extern int display_codepage; char *default_codepage = NULL; fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX); if (!(f = fopen (fname, "r"))) { - fprintf (stderr, _("Warning: file %s not found\n"), fname); + g_free (fname); + fname = mhl_str_dir_plus_file (mc_home_alt, CHARSETS_INDEX); + if (!(f = fopen (fname, "r"))) { + fprintf (stderr, _("Warning: file %s not found\n"), fname); + } g_free (fname); return -1; } diff -up mc-4.6.2/src/cmd.c.etcmc mc-4.6.2/src/cmd.c --- mc-4.6.2/src/cmd.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/cmd.c 2009-05-26 18:05:21.000000000 +0200 @@ -592,8 +592,13 @@ void ext_cmd (void) check_for_default (extdir, buffer); do_edit (buffer); g_free (buffer); - } else if (dir == 1) + } else if (dir == 1) { + if (!exist_file(extdir)) { + g_free (extdir); + extdir = mhl_str_dir_plus_file (mc_home_alt, MC_LIB_EXT); + } do_edit (extdir); + } g_free (extdir); flush_extension_file (); @@ -616,6 +621,11 @@ menu_edit_cmd (int where) ); menufile = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + + if (!exist_file(menufile)) { + g_free (menufile); + menufile = mhl_str_dir_plus_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + } switch (dir) { case 0: @@ -630,6 +640,10 @@ menu_edit_cmd (int where) case 2: buffer = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + if (!exist_file(buffer)) { + g_free (buffer); + buffer = mhl_str_dir_plus_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + } break; default: @@ -688,7 +702,7 @@ 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 = mhl_str_dir_plus_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax"); if (dir == 0) { buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE); diff -up mc-4.6.2/src/ext.c.etcmc mc-4.6.2/src/ext.c --- mc-4.6.2/src/ext.c.etcmc 2009-02-01 20:30:21.000000000 +0100 +++ mc-4.6.2/src/ext.c 2009-05-26 18:05:21.000000000 +0200 @@ -446,6 +446,10 @@ regex_command (const char *filename, con g_free (extension_file); check_stock_mc_ext: extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT); + if (!exist_file (extension_file)) { + g_free (extension_file); + extension_file = mhl_str_dir_plus_file (mc_home_alt, MC_LIB_EXT); + } mc_user_ext = 0; } data = load_file (extension_file); diff -up mc-4.6.2/src/main.c.etcmc mc-4.6.2/src/main.c --- mc-4.6.2/src/main.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/main.c 2009-05-26 18:07:07.000000000 +0200 @@ -291,9 +291,12 @@ char *xterm_title_str = NULL; /* Is the LANG UTF-8 ? */ gboolean is_utf8 = FALSE; -/* mc_home: The home of MC */ +/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ char *mc_home = NULL; +/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ +char *mc_home_alt = NULL; + char cmd_buf[512]; static void @@ -1858,8 +1861,9 @@ OS_Setup (void) if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { mc_home = g_strdup (mc_libdir); } else { - mc_home = g_strdup (DATADIR); + mc_home = g_strdup (SYSCONFDIR); } + mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR); } static void @@ -1989,7 +1993,7 @@ process_args (poptContext ctx, int c, co break; case 'f': - printf ("%s\n", mc_home); + printf ("%s (%s)\n", mc_home, mc_home_alt); exit (0); break; @@ -2339,6 +2343,7 @@ main (int argc, char *argv[]) } g_free (last_wd_string); + g_free (mc_home_alt); g_free (mc_home); done_key (); #ifdef HAVE_CHARSET diff -up mc-4.6.2/src/main.h.etcmc mc-4.6.2/src/main.h --- mc-4.6.2/src/main.h.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/main.h 2009-05-26 18:05:21.000000000 +0200 @@ -114,7 +114,7 @@ void print_vfs_message(const char *msg, extern const char *prompt; extern const char *edit_one_file; -extern char *mc_home; +extern char *mc_home, *mc_home_alt; char *get_mc_lib_dir (void); int maybe_cd (int move_up_dir); diff -up mc-4.6.2/src/Makefile.am.etcmc mc-4.6.2/src/Makefile.am --- mc-4.6.2/src/Makefile.am.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/Makefile.am 2009-05-26 18:05:21.000000000 +0200 @@ -8,9 +8,11 @@ bin_PROGRAMS = mc mcmfmt if CONS_SAVER pkglibexec_PROGRAMS = cons.saver AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ - -DSAVERDIR=\""$(pkglibexecdir)"\" + -DSAVERDIR=\""$(pkglibexecdir)"\" \ + -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" else -AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" +AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ + -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" endif noinst_PROGRAMS = man2hlp diff -up mc-4.6.2/src/Makefile.in.etcmc mc-4.6.2/src/Makefile.in --- mc-4.6.2/src/Makefile.in.etcmc 2009-02-01 20:46:26.000000000 +0100 +++ mc-4.6.2/src/Makefile.in 2009-05-26 18:09:15.000000000 +0200 @@ -294,9 +294,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) pkglibexecdir = $(libexecdir)/@PACKAGE@ -@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -@CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ -@CONS_SAVER_TRUE@ -DSAVERDIR=\""$(pkglibexecdir)"\" +@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" +@CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -DSAVERDIR=\""$(pkglibexecdir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" man2hlp_LDADD = $(GLIB_LIBS) mcmfmt_SOURCES = mfmt.c diff -up mc-4.6.2/src/setup.c.etcmc mc-4.6.2/src/setup.c --- mc-4.6.2/src/setup.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/setup.c 2009-05-26 18:05:21.000000000 +0200 @@ -522,8 +522,15 @@ setup_init (void) if (exist_file (inifile)){ g_free (profile); profile = inifile; - } else + } else { g_free (inifile); + inifile = mhl_str_dir_plus_file (mc_home_alt, "mc.ini"); + if (exist_file (inifile)) { + g_free (profile); + profile = inifile; + } else + g_free (inifile); + } } profile_name = profile; @@ -542,6 +549,11 @@ 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"); + + if (!exist_file(global_profile_name)) { + g_free (global_profile_name); + global_profile_name = mhl_str_dir_plus_file (mc_home_alt, "mc.lib"); + } /* Load integer boolean options */ for (i = 0; int_options[i].opt_name; i++) diff -up mc-4.6.2/src/user.c.etcmc mc-4.6.2/src/user.c --- mc-4.6.2/src/user.c.etcmc 2009-02-01 20:30:21.000000000 +0100 +++ mc-4.6.2/src/user.c 2009-05-26 18:05:21.000000000 +0200 @@ -729,6 +729,11 @@ user_menu_cmd (struct WEdit *edit_widget g_free (menu); menu = mhl_str_dir_plus_file \ (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + if (!exist_file (menu)) { + g_free (menu); + menu = mhl_str_dir_plus_file \ + (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + } } } diff -up mc-4.6.2/src/util.c.etcmc mc-4.6.2/src/util.c --- mc-4.6.2/src/util.c.etcmc 2009-05-26 18:05:21.000000000 +0200 +++ mc-4.6.2/src/util.c 2009-05-26 18:05:21.000000000 +0200 @@ -44,7 +44,7 @@ #include "tty.h" #include "global.h" #include "profile.h" -#include "main.h" /* mc_home */ +#include "main.h" /* mc_home, mc_home_alt */ #include "cmd.h" /* guess_message_value */ #include "mountlist.h" #include "win.h" /* xterm_flag */ @@ -978,16 +978,25 @@ load_mc_home_file (const char *filename, if (!data) { g_free (hintfile); - /* Fall back to the two-letter language code */ - if (lang[0] && lang[1]) - lang[2] = 0; + g_free (hintfile_base); + + hintfile_base = mhl_str_dir_plus_file (mc_home_alt, filename); + hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); data = load_file (hintfile); - + if (!data) { - g_free (hintfile); - hintfile = hintfile_base; - data = load_file (hintfile_base); + /* Fall back to the two-letter language code */ + if (lang[0] && lang[1]) + lang[2] = 0; + hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); + data = load_file (hintfile); + + if (!data) { + g_free (hintfile); + hintfile = hintfile_base; + data = load_file (hintfile_base); + } } } diff -up mc-4.6.2/vfs/extfs.c.etcmc mc-4.6.2/vfs/extfs.c --- mc-4.6.2/vfs/extfs.c.etcmc 2009-02-01 20:30:21.000000000 +0100 +++ mc-4.6.2/vfs/extfs.c 2009-05-26 18:05:21.000000000 +0200 @@ -249,7 +249,7 @@ extfs_open_archive (int fstype, const ch tmp = name_quote (name, 0); } - mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); + mc_extfsdir = mhl_str_dir_plus_file (mc_home_alt, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", local_name ? local_name : tmp, (char *) NULL); @@ -624,7 +624,7 @@ extfs_cmd (const char *extfs_cmd, struct 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 = mhl_str_dir_plus_file (mc_home_alt, "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 +653,7 @@ extfs_run (struct vfs_class *me, const c 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 = mhl_str_dir_plus_file (mc_home_alt, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], " run ", archive_name, " ", q, (char *) NULL); g_free (mc_extfsdir);