Ticket #130: mc-etcmc.patch

File mc-etcmc.patch, 12.0 KB (added by slavazanko, 15 years ago)

Original patch from Fedora-10

  • mc-4.6.1a/src/charsets.c

    old new load_codepages_list (void) 
    4545    char *fname; 
    4646    char buf[256]; 
    4747    extern char *mc_home; 
     48    extern char *mc_home_alt; 
    4849    extern int display_codepage; 
    4950    char *default_codepage = NULL; 
    5051 
    5152    fname = concat_dir_and_file (mc_home, CHARSETS_INDEX); 
    5253    if (!(f = fopen (fname, "r"))) { 
    53         fprintf (stderr, _("Warning: file %s not found\n"), fname); 
     54        g_free (fname); 
     55        fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX); 
     56        if (!(f = fopen (fname, "r"))) { 
     57            fprintf (stderr, _("Warning: file %s not found\n"), fname); 
     58        } 
    5459        g_free (fname); 
    5560        return -1; 
    5661    } 
  • mc-4.6.1a/src/main.h

    old new void print_vfs_message(const char *msg,  
    112112 
    113113extern const char *prompt; 
    114114extern const char *edit_one_file; 
    115 extern char *mc_home; 
     115extern char *mc_home, *mc_home_alt; 
    116116char *get_mc_lib_dir (void); 
    117117 
    118118int maybe_cd (int move_up_dir); 
  • mc-4.6.1a/src/ext.c

    old new regex_command (const char *filename, con 
    444444            g_free (extension_file); 
    445445          check_stock_mc_ext: 
    446446            extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT); 
     447            if (!exist_file (extension_file)) { 
     448                g_free (extension_file); 
     449                extension_file = concat_dir_and_file (mc_home_alt, MC_LIB_EXT); 
     450            } 
    447451            mc_user_ext = 0; 
    448452        } 
    449453        data = load_file (extension_file); 
  • mc-4.6.1a/src/setup.c

    old new setup_init (void) 
    481481        if (exist_file (inifile)){ 
    482482            g_free (profile); 
    483483            profile = inifile; 
    484         } else 
     484        } else { 
    485485            g_free (inifile); 
     486            inifile = concat_dir_and_file (mc_home_alt, "mc.ini"); 
     487            if (exist_file (inifile)) { 
     488                g_free (profile); 
     489                profile = inifile; 
     490            } else  
     491                g_free (inifile); 
     492        } 
    486493    } 
    487494 
    488495    profile_name = profile; 
    load_setup (void) 
    501508    /* mc.lib is common for all users, but has priority lower than 
    502509       ~/.mc/ini.  FIXME: it's only used for keys and treestore now */ 
    503510    global_profile_name = concat_dir_and_file (mc_home, "mc.lib"); 
     511     
     512    if (!exist_file(global_profile_name)) { 
     513        g_free (global_profile_name); 
     514        global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib"); 
     515    } 
    504516 
    505517    /* Load integer boolean options */ 
    506518    for (i = 0; int_options[i].opt_name; i++) 
  • mc-4.6.1a/src/Makefile.am

    old new bin_PROGRAMS = mc mcmfmt 
    88if CONS_SAVER 
    99pkglibexec_PROGRAMS = cons.saver 
    1010AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
    11         -DSAVERDIR=\""$(pkglibexecdir)"\" 
     11        -DSAVERDIR=\""$(pkglibexecdir)"\" \ 
     12        -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    1213else 
    13 AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" 
     14AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
     15        -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    1416endif 
    1517 
    1618noinst_PROGRAMS = man2hlp 
  • mc-4.6.1a/src/util.c

    old new  
    4040#include "tty.h" 
    4141#include "global.h" 
    4242#include "profile.h" 
    43 #include "main.h"               /* mc_home */ 
     43#include "main.h"               /* mc_home, mc_home_alt */ 
    4444#include "cmd.h"                /* guess_message_value */ 
    4545#include "mountlist.h" 
    4646#include "win.h"                /* xterm_flag */ 
    load_mc_home_file (const char *filename, 
    950950 
    951951    if (!data) { 
    952952        g_free (hintfile); 
    953         /* Fall back to the two-letter language code */ 
    954         if (lang[0] && lang[1]) 
    955             lang[2] = 0; 
     953        g_free (hintfile_base); 
     954 
     955        hintfile_base = concat_dir_and_file (mc_home_alt, filename); 
     956 
    956957        hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); 
    957958        data = load_file (hintfile); 
    958  
     959         
    959960        if (!data) { 
    960             g_free (hintfile); 
    961             hintfile = hintfile_base; 
    962             data = load_file (hintfile_base); 
     961            /* Fall back to the two-letter language code */ 
     962            if (lang[0] && lang[1]) 
     963                lang[2] = 0; 
     964            hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); 
     965            data = load_file (hintfile); 
     966 
     967            if (!data) { 
     968                g_free (hintfile); 
     969                hintfile = hintfile_base; 
     970                data = load_file (hintfile_base); 
     971            } 
    963972        } 
    964973    } 
    965974 
  • mc-4.6.1a/src/cmd.c

    old new void ext_cmd (void) 
    570570        check_for_default (extdir, buffer); 
    571571        do_edit (buffer); 
    572572        g_free (buffer); 
    573     } else if (dir == 1) 
     573    } else if (dir == 1) { 
     574        if (!exist_file(extdir)) { 
     575            g_free (extdir); 
     576            extdir = concat_dir_and_file (mc_home_alt, MC_LIB_EXT); 
     577        } 
    574578        do_edit (extdir); 
     579    } 
    575580 
    576581   g_free (extdir); 
    577582   flush_extension_file (); 
    menu_edit_cmd (int where) 
    594599    ); 
    595600 
    596601    menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     602     
     603    if (!exist_file(menufile)) { 
     604        g_free (menufile); 
     605        menufile = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     606    } 
    597607 
    598608    switch (dir) { 
    599609        case 0: 
    menu_edit_cmd (int where) 
    608618         
    609619        case 2: 
    610620            buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     621            if (!exist_file(buffer)) { 
     622                g_free (buffer); 
     623                buffer = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     624            } 
    611625            break; 
    612626 
    613627        default: 
    edit_syntax_cmd (void) 
    666680                          _(" Which syntax file you want to edit? "), 0, 2, 
    667681                          _("&User"), _("&System Wide")); 
    668682    } 
    669     extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); 
     683    extdir = concat_dir_and_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax"); 
    670684 
    671685    if (dir == 0) { 
    672686        buffer = concat_dir_and_file (home_dir, SYNTAX_FILE); 
  • mc-4.6.1a/src/main.c

    old new gboolean is_utf8 = FALSE; 
    282282/* The xterm title */ 
    283283char *xterm_title_str = NULL; 
    284284 
    285 /* mc_home: The home of MC */ 
     285/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ 
    286286char *mc_home = NULL; 
    287287 
     288/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ 
     289char *mc_home_alt = NULL; 
     290 
    288291char cmd_buf[512]; 
    289292 
    290293static void 
    OS_Setup (void) 
    18171820    if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { 
    18181821        mc_home = g_strdup (mc_libdir); 
    18191822    } else { 
    1820         mc_home = g_strdup (DATADIR); 
     1823        mc_home = g_strdup (SYSCONFDIR); 
    18211824    } 
     1825    mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR); 
    18221826} 
    18231827 
    18241828static void 
    process_args (poptContext ctx, int c, co 
    19481952        break; 
    19491953 
    19501954    case 'f': 
    1951         printf ("%s\n", mc_home); 
     1955        printf ("%s (%s)\n", mc_home, mc_home_alt); 
    19521956        exit (0); 
    19531957        break; 
    19541958 
    main (int argc, char *argv[]) 
    23262330    } 
    23272331    g_free (last_wd_string); 
    23282332 
     2333    g_free (mc_home_alt); 
    23292334    g_free (mc_home); 
    23302335    done_key (); 
    23312336#ifdef HAVE_CHARSET 
  • mc-4.6.1a/src/Makefile.in

    old new target_alias = @target_alias@ 
    314314AM_CFLAGS = $(GLIB_CFLAGS) 
    315315localedir = $(datadir)/locale 
    316316pkglibexecdir = $(libexecdir)/@PACKAGE@ 
    317 @CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" 
     317@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
     318@CONS_SAVER_FALSE@      -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    318319@CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
    319 @CONS_SAVER_TRUE@       -DSAVERDIR=\""$(pkglibexecdir)"\" 
     320@CONS_SAVER_TRUE@       -DSAVERDIR=\""$(pkglibexecdir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    320321 
    321322man2hlp_LDADD = $(GLIB_LIBS) 
    322323mcmfmt_SOURCES = mfmt.c 
  • mc-4.6.1a/src/user.c

    old new user_menu_cmd (struct WEdit *edit_widget 
    726726            g_free (menu); 
    727727            menu = concat_dir_and_file \ 
    728728                        (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     729            if (!exist_file (menu)) { 
     730                g_free (menu); 
     731                menu = concat_dir_and_file \ 
     732                        (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     733            } 
    729734        } 
    730735    } 
    731736 
  • mc-4.6.1a/edit/editcmd.c

    old new  
    4949#include "../src/tty.h"         /* LINES */ 
    5050#include "../src/widget.h"      /* listbox_new() */ 
    5151#include "../src/layout.h"      /* clr_scr() */ 
    52 #include "../src/main.h"        /* mc_home */ 
     52#include "../src/main.h"        /* mc_home, mc_home_alt */ 
    5353#include "../src/help.h"        /* interactive_display() */ 
    5454#include "../src/key.h"         /* XCTRL */ 
    5555#include "../src/dialog.h"      /* do_refresh() */ 
    edit_block_process_cmd (WEdit *edit, con 
    27902790            return; 
    27912791        } 
    27922792        if (!(script_src = fopen (o, "r"))) { 
    2793             fclose (script_home); 
    2794             unlink (h); 
    2795             edit_error_dialog ("", get_sys_error (catstrs 
    2796                                                   (_("Error reading script:"), 
    2797                                                    o, (char *) NULL))); 
    2798             return; 
     2793            o = catstrs (mc_home_alt, shell_cmd, (char *) NULL); 
     2794            if (!(script_src = fopen (o, "r"))) { 
     2795                fclose (script_home); 
     2796                unlink (h); 
     2797                edit_error_dialog ("", get_sys_error (catstrs 
     2798                                                      (_("Error reading script:"), 
     2799                                                      o, (char *) NULL))); 
     2800                return; 
     2801            } 
    27992802        } 
    28002803        while (fgets (buf, sizeof (buf), script_src)) 
    28012804            fputs (buf, script_home); 
  • mc-4.6.1a/edit/syntax.c

    old new  
    3737#include "edit.h" 
    3838#include "edit-widget.h" 
    3939#include "../src/color.h"       /* use_colors */ 
    40 #include "../src/main.h"        /* mc_home */ 
     40#include "../src/main.h"        /* mc_home, mc_home_alt */ 
    4141#include "../src/wtools.h"      /* message() */ 
    4242 
    4343/* bytes */ 
    static FILE *open_include_file (const ch 
    680680    g_free (error_file_name); 
    681681    error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, 
    682682                                   filename, (char *) NULL); 
     683    if (!(f = fopen (error_file_name, "r"))) { 
     684        g_free (error_file_name); 
     685        error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR, 
     686                                       filename, (char *) NULL); 
     687    } else return f; 
     688     
    683689    return fopen (error_file_name, "r"); 
    684690} 
    685691 
  • mc-4.6.1a/vfs/extfs.c

    old new extfs_open_archive (int fstype, const ch 
    242242        tmp = name_quote (name, 0); 
    243243    } 
    244244 
    245     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     245    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    246246    cmd = 
    247247        g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", 
    248248                     local_name ? local_name : tmp, (char *) NULL); 
    extfs_cmd (const char *extfs_cmd, struct 
    617617    archive_name = name_quote (extfs_get_archive_name (archive), 0); 
    618618    quoted_localname = name_quote (localname, 0); 
    619619 
    620     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     620    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    621621    cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], 
    622622                       extfs_cmd, archive_name, " ", quoted_file, " ", 
    623623                       quoted_localname, (char *) NULL); 
    extfs_run (struct vfs_class *me, const c 
    646646    g_free (p); 
    647647 
    648648    archive_name = name_quote (extfs_get_archive_name (archive), 0); 
    649     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     649    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    650650    cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], 
    651651                       " run ", archive_name, " ", q, (char *) NULL); 
    652652    g_free (mc_extfsdir);