1
1

Merge branch '1424_non_config_files'

* 1424_non_config_files:
  Fixed file list in RPM spec.
  Install help files into /usr/share/mc/help instead of /usr/share/mc.
  Install hint files into /usr/share/mc/hints instead of /usr/share/mc.
  Load locale-specific info (help and hints) from /usr/share/mc only.
  Reimplemened codepages storage using GPtrArray.
  Install mc.charsets into /usr/share/mc instead of /etc/mc.
  Minor optimization of [Special dirs] handling.
  Install mc.lib into /usr/share/mc instead of /etc/mc.
  Ticket #1424: install some files into /usr/share/mc instead of /etc/mc.
Этот коммит содержится в:
Andrew Borodin 2010-10-19 18:37:57 +04:00
родитель f581e555c1 84f8ae790f
Коммит ed89a340c4
26 изменённых файлов: 243 добавлений и 250 удалений

9
contrib/dist/redhat/mc.spec.in поставляемый
Просмотреть файл

@ -94,7 +94,7 @@ PKG_CONFIG_PATH="$RESULT_DIR/usr/%{_lib}/pkgconfig:$PKG_CONFIG_PATH" ; export PK
%{_with_screen} \
%{?_with_glib_static} \
--enable-charset \
--with-samba \
--enable-vfs-smb \
--without-x \
--with-gpm-mouse \
--disable-doxygen-doc
@ -140,9 +140,6 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/profile.d/*
%config %{_sysconfdir}/mc/Syntax
%config %{_sysconfdir}/mc/mc.charsets
%config %{_sysconfdir}/mc/mc.lib
%config(noreplace) %{_sysconfdir}/mc/filehighlight.ini
%config(noreplace) %{_sysconfdir}/mc/*edit*
%config(noreplace) %{_sysconfdir}/mc/mc.ext
@ -155,8 +152,10 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_datadir}/mc
%{_datadir}/mc/*
%changelog
* Thu Sep 16 2010 Andrew Borodin <aborodin@vmail.ru>
- Some files are installed now into %%{_datadir}/mc instead of %%{_sysconfdir}/mc.
* Wed Apr 28 2010 Yury V. Zaytsev <yury@shurup.com>
- Added mcdiff to the list of packaged files.

Просмотреть файл

@ -1,11 +1,11 @@
LIBFILES_OUT = mc.ext
pkgdata_DATA = mc.hint mc.hint.cs mc.hint.es mc.hint.hu mc.hint.it \
mc.hint.nl mc.hint.pl mc.hint.ru mc.hint.sr mc.hint.uk \
HINTFILES = \
mc.hint mc.hint.cs mc.hint.es mc.hint.hu mc.hint.it \
mc.hint.nl mc.hint.pl mc.hint.ru mc.hint.sr mc.hint.uk \
mc.hint.zh
hintdir = $(pkgdatadir)/hints
hint_DATA = $(HINTFILES)
# Files processed by configure don't need to be here
EXTRA_DIST = \
$(pkgdata_DATA)
$(HINTFILES)

Просмотреть файл

@ -1,10 +1,11 @@
DIST_SUBDIRS = es hu it pl ru sr
SUBDIRS = $(DOC_LINGUAS)
pkgdata_DATA = mc.hlp
hlpdir = $(pkgdatadir)/help
hlp_DATA = mc.hlp
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
CLEANFILES = $(hlp_DATA)
mc.hlp: $(top_builddir)/doc/man/mc.1 $(srcdir)/xnc.hlp $(top_builddir)/src/man2hlp/man2hlp
- $(top_builddir)/src/man2hlp/man2hlp $(top_builddir)/doc/man/mc.1 $(srcdir)/xnc.hlp mc.hlp

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=es
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

10
doc/hlp/hlp-lang-include.am Обычный файл
Просмотреть файл

@ -0,0 +1,10 @@
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
hlpdir = $(pkgdatadir)/help
hlp_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(hlp_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=hu
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=it
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=pl
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=ru
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

Просмотреть файл

@ -1,9 +1,3 @@
HLP_LANG=sr
MAN2HLP=$(top_builddir)/src/man2hlp/man2hlp
pkgdata_DATA = mc.hlp.$(HLP_LANG)
EXTRA_DIST = xnc.hlp
CLEANFILES = $(pkgdata_DATA)
mc.hlp.$(HLP_LANG): $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp $(MAN2HLP)
- $(MAN2HLP) $(top_builddir)/doc/man/$(HLP_LANG)/mc.1 $(srcdir)/xnc.hlp mc.hlp.$(HLP_LANG)
include ../hlp-lang-include.am

Просмотреть файл

@ -24,9 +24,10 @@
#define MC_GLOBAL_CONFIG_FILE "mc.lib"
#define MC_GLOBAL_MENU "mc.menu"
#define MC_LOCAL_MENU ".mc.menu"
#define MC_HINT "mc.hint"
#define MC_HINT "hints" PATH_SEP_STR "mc.hint"
#define MC_HELP "help" PATH_SEP_STR "mc.hlp"
#define GLOBAL_KEYMAP_FILE "mc.keymap"
#define CHARSETS_INDEX "mc.charsets"
#define CHARSETS_LIST "mc.charsets"
#define MC_LIB_EXT "mc.ext"
#define FISH_PREFIX "fish"

Просмотреть файл

@ -188,8 +188,9 @@ mc_search_prepare (mc_search_t * lc_mc_search)
if (lc_mc_search->is_all_charsets) {
gsize loop1, recoded_str_len;
gchar *buffer;
for (loop1 = 0; loop1 < (gsize) n_codepages; loop1++) {
if (!g_ascii_strcasecmp (codepages[loop1].id, cp_source)) {
for (loop1 = 0; loop1 < codepages->len; loop1++) {
const char *id = ((codepage_desc *) g_ptr_array_index (codepages, loop1))->id;
if (!g_ascii_strcasecmp (id, cp_source)) {
g_ptr_array_add (ret,
mc_search__cond_struct_new (lc_mc_search, lc_mc_search->original,
lc_mc_search->original_len, cp_source));
@ -198,11 +199,11 @@ mc_search_prepare (mc_search_t * lc_mc_search)
buffer =
mc_search__recode_str (lc_mc_search->original, lc_mc_search->original_len, cp_source,
codepages[loop1].id, &recoded_str_len);
id, &recoded_str_len);
g_ptr_array_add (ret,
mc_search__cond_struct_new (lc_mc_search, buffer,
recoded_str_len, codepages[loop1].id));
recoded_str_len, id));
g_free (buffer);
}
} else {

Просмотреть файл

@ -628,43 +628,32 @@ load_file (const char *filename)
}
char *
load_mc_home_file (const char *_mc_home, const char *_mc_home_alt, const char *filename,
char **allocated_filename)
load_mc_home_file (const char *from, const char *filename, char **allocated_filename)
{
char *hintfile_base, *hintfile;
char *lang;
char *data;
hintfile_base = concat_dir_and_file (_mc_home, filename);
hintfile_base = g_build_filename (from, filename, (char *) NULL);
lang = guess_message_value ();
hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
data = load_file (hintfile);
if (!data)
if (data == NULL)
{
/* Fall back to the two-letter language code */
if (lang[0] != '\0' && lang[1] != '\0')
lang[2] = '\0';
g_free (hintfile);
g_free (hintfile_base);
hintfile_base = concat_dir_and_file (_mc_home_alt, filename);
hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
data = load_file (hintfile);
if (!data)
if (data == NULL)
{
/* Fall back to the two-letter language code */
if (lang[0] && lang[1])
lang[2] = 0;
g_free (hintfile);
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);
}
hintfile = hintfile_base;
data = load_file (hintfile_base);
}
}
@ -673,7 +662,7 @@ load_mc_home_file (const char *_mc_home, const char *_mc_home_alt, const char *f
if (hintfile != hintfile_base)
g_free (hintfile_base);
if (allocated_filename)
if (allocated_filename != NULL)
*allocated_filename = hintfile;
else
g_free (hintfile);

Просмотреть файл

@ -100,8 +100,7 @@ char *diff_two_paths (const char *first, const char *second);
const char *x_basename (const char *fname);
char *load_file (const char *filename);
char *load_mc_home_file (const char *, const char *, const char *filename,
char **allocated_filename);
char *load_mc_home_file (const char *from, const char *filename, char **allocated_filename);
/* uid/gid managing */
void init_groups (void);

Просмотреть файл

@ -2,23 +2,20 @@
SUBDIRS = skins syntax
if CHARSET
LIBFILES_ADD = mc.charsets
else
LIBFILES_ADD =
endif
LIBFILES_OUT = mc.ext
noinst_DATA = xterm.ad
pkgdata_DATA =
pkgdata_DATA = \
mc.lib
if CHARSET
pkgdata_DATA += mc.charsets
endif
LIBFILES_CONST = \
cedit.menu \
edit.indent.rc \
edit.spell.rc \
mc.lib \
filehighlight.ini \
mc.keymap \
mc.keymap.default \
@ -32,13 +29,15 @@ CLEANFILES = $(SCRIPTS_OUT)
cfgdir = $(sysconfdir)/@PACKAGE@
cfg_DATA = \
$(LIBFILES_CONST) \
$(LIBFILES_OUT) \
$(LIBFILES_ADD)
$(LIBFILES_OUT)
# Files processed by configure don't need to be here
EXTRA_DIST = \
$(LIBFILES_CONST) \
$(SCRIPTS_IN) \
$(noinst_DATA) \
$(pkgdata_DATA) \
mc.charsets
$(pkgdata_DATA)
#if CHARSET is defined, mc.charsets is already here
if !CHARSET
EXTRA_DIST += mc.charsets
endif

Просмотреть файл

@ -1,4 +1,5 @@
SYNTAXFILES = \
Syntax \
PKGBUILD.syntax \
ada95.syntax \
aspx.syntax \
@ -69,15 +70,9 @@ SYNTAXFILES = \
yum-repo.syntax \
yxx.syntax
SYNTAXCONFFILES = \
Syntax
if USE_EDIT
syntaxdir = $(pkgdatadir)/syntax
syntax_DATA = $(SYNTAXFILES)
syntaxconfdir = $(sysconfdir)/@PACKAGE@
syntaxconf_DATA = $(SYNTAXCONFFILES)
endif
EXTRA_DIST = $(SYNTAXFILES) $(SYNTAXCONFFILES)
EXTRA_DIST = $(SYNTAXFILES)

Просмотреть файл

@ -586,7 +586,8 @@ sel_charset_button (WButton *button, int action)
new_display_codepage = new_dcp;
cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ?
_("Other 8 bit") : codepages[new_display_codepage].name;
_("Other 8 bit") :
((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
if (cpname != NULL)
utf8_display = str_isutf8 (cpname);
/* avoid strange bug with label repainting */
@ -615,7 +616,8 @@ init_disp_bits_box (void)
add_widget (dbits_dlg, label_new (3, 4, _("Input / display codepage:")));
cpname = (new_display_codepage < 0) ? _("Other 8 bit") : codepages[new_display_codepage].name;
cpname = (new_display_codepage < 0) ? _("Other 8 bit")
: ((codepage_desc *) g_ptr_array_index (codepages, new_display_codepage))->name;
cplabel = label_new (4, 4, cpname);
add_widget (dbits_dlg, cplabel);

Просмотреть файл

@ -36,9 +36,7 @@
#include "charsets.h"
#include "main.h"
int n_codepages = 0;
struct codepage_desc *codepages;
GPtrArray *codepages = NULL;
unsigned char conv_displ[256];
unsigned char conv_input[256];
@ -46,98 +44,144 @@ unsigned char conv_input[256];
const char *cp_display = NULL;
const char *cp_source = NULL;
int
load_codepages_list (void)
static codepage_desc *
new_codepage_desc (const char *id, const char *name)
{
codepage_desc *desc;
desc = g_new (codepage_desc, 1);
desc->id = g_strdup (id);
desc->name = g_strdup (name);
return desc;
}
static void
free_codepage_desc (gpointer data, gpointer user_data)
{
codepage_desc *desc = (codepage_desc *) data;
(void) user_data;
g_free (desc->id);
g_free (desc->name);
g_free (desc);
}
/* returns display codepage */
static void
load_codepages_list_from_file (GPtrArray **list, const char *fname)
{
int result = -1;
FILE *f;
char *fname;
guint i;
char buf[BUF_MEDIUM];
char *default_codepage = NULL;
fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
f = fopen (fname, "r");
if (f == NULL) {
fprintf (stderr, _("Warning: file %s not found\n"), fname);
g_free (fname);
if (f == NULL)
return;
fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX);
f = fopen (fname, "r");
if (f == NULL) {
fprintf (stderr, _("Warning: file %s not found\n"), fname);
g_free (fname);
for (i = 0; fgets (buf, sizeof buf, f) != NULL; )
{
/* split string into id and cpname */
char *p = buf;
size_t buflen = strlen (buf);
/* file is not found, add defaullt codepage */
n_codepages = 1;
codepages = g_new0 (struct codepage_desc, n_codepages + 1);
codepages[0].id = g_strdup ("ASCII");
codepages[0].name = g_strdup (_("7-bit ASCII"));
return n_codepages;
}
}
g_free (fname);
if (*p == '\n' || *p == '\0' || *p == '#')
continue;
for (n_codepages = 0; fgets (buf, sizeof (buf), f);)
if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#')
++n_codepages;
rewind (f);
if (buflen > 0 && buf[buflen - 1] == '\n')
buf[buflen - 1] = '\0';
while (*p != '\t' && *p != ' ' && *p != '\0')
++p;
if (*p == '\0')
goto fail;
codepages = g_new0 (struct codepage_desc, n_codepages + 1);
*p++ = '\0';
g_strstrip (p);
if (*p == '\0')
goto fail;
for (n_codepages = 0; fgets (buf, sizeof buf, f);) {
/* split string into id and cpname */
char *p = buf;
size_t buflen = strlen (buf);
if (strcmp (buf, "default") == 0)
default_codepage = g_strdup (p);
else
{
const char *id = buf;
if (*p == '\n' || *p == '\0' || *p == '#')
continue;
if (*list == NULL)
{
*list = g_ptr_array_sized_new (16);
g_ptr_array_add (*list, new_codepage_desc (id, p));
}
else
{
guint i;
codepage_desc *desc;
if (buflen > 0 && buf[buflen - 1] == '\n')
buf[buflen - 1] = '\0';
while (*p != '\t' && *p != ' ' && *p != '\0')
++p;
if (*p == '\0')
goto fail;
/* whether id is already present in list */
/* if yes, overwrite description */
for (i = 0; i < (*list)->len; i++)
{
codepage_desc *desc;
*p++ = '\0';
g_strstrip (p);
if (*p == '\0')
goto fail;
desc = (codepage_desc *) g_ptr_array_index (*list, i);
if (strcmp (buf, "default") == 0)
default_codepage = g_strdup (p);
else {
codepages[n_codepages].id = g_strdup (buf);
codepages[n_codepages].name = g_strdup (p);
++n_codepages;
}
if (strcmp (id, desc->id) == 0)
{
/* found */
g_free (desc->name);
desc->name = g_strdup (p);
break;
}
}
/* not found */
if (i == (*list)->len)
g_ptr_array_add (*list, new_codepage_desc (id, p));
}
}
}
if (default_codepage != NULL) {
display_codepage = get_codepage_index (default_codepage);
g_free (default_codepage);
if (default_codepage != NULL)
{
display_codepage = get_codepage_index (default_codepage);
g_free (default_codepage);
}
result = n_codepages;
fail:
fclose (f);
return result;
}
void
load_codepages_list (void)
{
int result = -1;
char *fname;
/* 1: try load /usr/share/mc/mc.charsets */
fname = g_build_filename (mc_home_alt, CHARSETS_LIST, (char *) NULL);
load_codepages_list_from_file (&codepages, fname);
g_free (fname);
/* 2: try load /etc/mc/mc.charsets */
fname = g_build_filename (mc_home, CHARSETS_LIST, (char *) NULL);
load_codepages_list_from_file (&codepages, fname);
g_free (fname);
if (codepages == NULL)
{
/* files are not found, add defaullt codepage */
fprintf (stderr, "%s\n", _("Warning: cannot load codepages list"));
codepages = g_ptr_array_new ();
g_ptr_array_add (codepages, new_codepage_desc ("ASCII", _("7-bit ASCII")));
}
}
void
free_codepages_list (void)
{
if (n_codepages > 0) {
int i;
for (i = 0; i < n_codepages; i++) {
g_free (codepages[i].id);
g_free (codepages[i].name);
}
n_codepages = 0;
g_free (codepages);
codepages = 0;
}
g_ptr_array_foreach (codepages, free_codepage_desc, NULL);
g_ptr_array_free (codepages, TRUE);
}
#define OTHER_8BIT "Other_8_bit"
@ -145,7 +189,7 @@ free_codepages_list (void)
const char *
get_codepage_id (const int n)
{
return (n < 0) ? OTHER_8BIT : codepages[n].id;
return (n < 0) ? OTHER_8BIT : ((codepage_desc *) g_ptr_array_index (codepages, n))->id;
}
int
@ -156,8 +200,8 @@ get_codepage_index (const char *id)
return -1;
if (codepages == NULL)
return -1;
for (i = 0; i < n_codepages; i++)
if (strcmp (id, codepages[i].id) == 0)
for (i = 0; i < codepages->len; i++)
if (strcmp (id, ((codepage_desc *) g_ptr_array_index (codepages, i))->id) == 0)
return i;
return -1;
}
@ -170,11 +214,13 @@ gboolean
is_supported_encoding (const char *encoding)
{
gboolean result = FALSE;
size_t t;
guint t;
for (t = 0; t < (size_t) n_codepages; t++)
result |= (g_ascii_strncasecmp (encoding, codepages[t].id,
strlen (codepages[t].id)) == 0);
for (t = 0; t < codepages->len; t++)
{
const char *id = ((codepage_desc *) g_ptr_array_index (codepages, t))->id;
result |= (g_ascii_strncasecmp (encoding, id, strlen (id)) == 0);
}
return result;
}
@ -223,8 +269,8 @@ init_translation_table (int cpsource, int cpdisplay)
conv_displ[i] = i;
conv_input[i] = i;
}
cp_source = (char *) codepages[cpsource].id;
cp_display = (char *) codepages[cpdisplay].id;
cp_source = ((codepage_desc *) g_ptr_array_index (codepages, cpsource))->id;
cp_display = ((codepage_desc *) g_ptr_array_index (codepages, cpdisplay))->id;
/* display <- inpit table */

Просмотреть файл

@ -6,27 +6,28 @@
#ifndef MC_CHARSETS_H
#define MC_CHARSETS_H
#include "lib/global.h"
#ifdef HAVE_CHARSET
#define UNKNCHAR '\001'
extern int n_codepages;
extern unsigned char conv_displ[256];
extern unsigned char conv_input[256];
struct codepage_desc {
typedef struct
{
char *id;
char *name;
};
} codepage_desc;
extern const char *cp_display;
extern const char *cp_source;
extern struct codepage_desc *codepages;
extern GPtrArray *codepages;
const char *get_codepage_id (const int n);
int get_codepage_index (const char *id);
int load_codepages_list (void);
void load_codepages_list (void);
void free_codepages_list (void);
gboolean is_supported_encoding (const char *encoding);
char *init_translation_table (int cpsource, int cpdisplay);
@ -90,4 +91,4 @@ convert_from_input_c (int c)
#endif /* HAVE_CHARSET */
#endif
#endif /* MC_CHARSETS_H */

Просмотреть файл

@ -1183,26 +1183,25 @@ get_random_hint (int force)
return g_strdup ("");
last_sec = tv.tv_sec;
data = load_mc_home_file (mc_home, mc_home_alt, MC_HINT, NULL);
if (!data)
return 0;
data = load_mc_home_file (mc_home_alt, MC_HINT, NULL);
if (data == NULL)
return NULL;
/* get a random entry */
srand (tv.tv_sec);
len = strlen (data);
start = rand () % len;
for (; start; start--)
{
for (; start != 0; start--)
if (data[start] == '\n')
{
start++;
break;
}
}
eol = strchr (&data[start], '\n');
if (eol)
*eol = 0;
eol = strchr (data + start, '\n');
if (eol != NULL)
*eol = '\0';
/* hint files are stored in utf-8 */
/* try convert hint file from utf-8 to terminal encoding */
@ -1211,9 +1210,7 @@ get_random_hint (int force)
{
buffer = g_string_new ("");
if (str_convert (conv, &data[start], buffer) != ESTR_FAILURE)
{
result = g_strdup (buffer->str);
}
g_string_free (buffer, TRUE);
str_close_conv (conv);
}

Просмотреть файл

@ -1008,11 +1008,11 @@ edit_load_syntax_file (WEdit * edit)
_("&User"), _("&System Wide"));
}
extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
extdir = g_build_filename (mc_home, "syntax", "Syntax", (char *) NULL);
if (!exist_file (extdir))
{
g_free (extdir);
extdir = concat_dir_and_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax");
extdir = g_build_filename (mc_home_alt, "syntax", "Syntax", (char *) NULL);
}
if (dir == 0)

Просмотреть файл

@ -810,22 +810,19 @@ open_include_file (const char *filename)
return fopen (filename, "r");
g_free (error_file_name);
error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR,
filename, (char *) NULL);
error_file_name = g_build_filename (home_dir, EDIT_DIR, filename, (char *) NULL);
f = fopen (error_file_name, "r");
if (f != NULL)
return f;
g_free (error_file_name);
error_file_name = g_strconcat (mc_home, PATH_SEP_STR, "syntax", PATH_SEP_STR,
filename, (char *) NULL);
error_file_name = g_build_filename (mc_home, "syntax", filename, (char *) NULL);
f = fopen (error_file_name, "r");
if (f != NULL)
return f;
g_free (error_file_name);
error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR,
filename, (char *) NULL);
error_file_name = g_build_filename (mc_home_alt, "syntax", filename, (char *) NULL);
return fopen (error_file_name, "r");
}
@ -1259,7 +1256,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
f = fopen (syntax_file, "r");
if (f == NULL)
{
lib_file = g_build_filename (mc_home, "Syntax", (char *) NULL);
lib_file = g_build_filename (mc_home_alt, "syntax", "Syntax", (char *) NULL);
f = fopen (lib_file, "r");
g_free (lib_file);
if (f == NULL)

Просмотреть файл

@ -57,6 +57,7 @@
#include "lib/tty/mouse.h"
#include "lib/skin.h"
#include "lib/strutil.h"
#include "lib/fileloc.h"
#include "dialog.h" /* For Dlg_head */
#include "widget.h" /* For Widget */
@ -965,7 +966,7 @@ interactive_display (const char *filename, const char *node)
if (filename != NULL)
filedata = load_file (filename);
else
filedata = load_mc_home_file (mc_home, mc_home_alt, "mc.hlp", &hlpfile);
filedata = load_mc_home_file (mc_home_alt, MC_HELP, &hlpfile);
if (filedata == NULL)
message (D_ERROR, MSG_ERROR, _("Cannot open file %s\n%s"),

Просмотреть файл

@ -65,7 +65,7 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
/* Create listbox */
Listbox *listbox = create_listbox_window_centered (center_y, center_x,
n_codepages + 1, ENTRY_LEN + 2,
codepages->len + 1, ENTRY_LEN + 2,
_("Choose codepage"),
"[Codepages Translation]");
@ -74,22 +74,21 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
NULL);
/* insert all the items found */
for (i = 0; i < n_codepages; i++) {
char *name = codepages[i].name;
for (i = 0; i < codepages->len; i++) {
const char *name = ((codepage_desc *) g_ptr_array_index (codepages, i))->name;
g_snprintf (buffer, sizeof (buffer), "%c %s", get_hotkey (i),
name);
LISTBOX_APPEND_TEXT (listbox, get_hotkey (i), buffer, NULL);
}
if (seldisplay) {
g_snprintf (buffer, sizeof (buffer), "%c %s",
get_hotkey (n_codepages), _("Other 8 bit"));
LISTBOX_APPEND_TEXT (listbox, get_hotkey (n_codepages), buffer,
NULL);
unsigned char hotkey = get_hotkey (codepages->len);
g_snprintf (buffer, sizeof (buffer), "%c %s", hotkey, _("Other 8 bit"));
LISTBOX_APPEND_TEXT (listbox, hotkey, buffer, NULL);
}
/* Select the default entry */
i = (seldisplay)
? ((current_charset < 0) ? n_codepages : current_charset)
? ((current_charset < 0) ? codepages->len : current_charset)
: (current_charset + 1);
listbox_select_entry (listbox->list, i);
@ -103,7 +102,7 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
/* some charset has been selected */
if (seldisplay) {
/* charset list is finished with "Other 8 bit" item */
return (i >= n_codepages) ? SELECT_CHARSET_OTHER_8BIT : i;
return ((guint) i >= codepages->len) ? SELECT_CHARSET_OTHER_8BIT : i;
} else {
/* charset list is began with "- < No translation >" item */
return (i - 1);

Просмотреть файл

@ -721,21 +721,20 @@ load_setup (void)
size_t i;
char *buffer;
const char *kt;
#ifdef HAVE_CHARSET
int cpages = -1;
cpages = load_codepages_list ();
#ifdef HAVE_CHARSET
load_codepages_list ();
#endif /* HAVE_CHARSET */
profile = setup_init ();
/* 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 = concat_dir_and_file (mc_home, MC_GLOBAL_CONFIG_FILE);
global_profile_name = g_build_filename (mc_home, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
if (!exist_file (global_profile_name))
{
g_free (global_profile_name);
global_profile_name = concat_dir_and_file (mc_home_alt, MC_GLOBAL_CONFIG_FILE);
global_profile_name = g_build_filename (mc_home_alt, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
}
panels_profile_name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_PANELS_FILE, NULL);
@ -816,7 +815,7 @@ load_setup (void)
/* Remove the temporal entries */
#ifdef HAVE_CHARSET
if (cpages > 0)
if (codepages->len > 1)
{
buffer = mc_config_get_string (mc_main_config, "Misc", "display_codepage", "");
if (buffer[0] != '\0')

Просмотреть файл

@ -733,8 +733,8 @@ void
tree_store_end_check (void)
{
tree_entry *current, *old;
int len;
GList *the_queue, *l;
size_t len;
GList *the_queue;
if (!ts.loaded)
return;
@ -762,11 +762,7 @@ tree_store_end_check (void)
g_free (ts.check_name);
ts.check_name = NULL;
for (l = the_queue; l; l = l->next)
{
g_free (l->data);
}
g_list_foreach (the_queue, (GFunc) g_free, NULL);
g_list_free (the_queue);
}
@ -782,41 +778,38 @@ process_special_dirs (GList ** special_dirs, char *file)
return;
start_buff = buffers = mc_config_get_string_list (cfg, "Special dirs", "list", &buffers_len);
if (buffers == NULL)
if (buffers != NULL)
{
mc_config_deinit (cfg);
return;
while (*buffers != NULL)
{
*special_dirs = g_list_prepend (*special_dirs, *buffers);
*buffers = NULL;
buffers++;
}
g_strfreev (start_buff);
}
while (*buffers)
{
*special_dirs = g_list_prepend (*special_dirs, g_strdup (*buffers));
buffers++;
}
g_strfreev (start_buff);
mc_config_deinit (cfg);
}
static gboolean
should_skip_directory (const char *dir)
{
static GList *special_dirs;
static GList *special_dirs = NULL;
GList *l;
static int loaded;
static gboolean loaded = FALSE;
if (loaded == 0)
if (!loaded)
{
loaded = 1;
loaded = TRUE;
setup_init ();
process_special_dirs (&special_dirs, profile_name);
process_special_dirs (&special_dirs, global_profile_name);
}
for (l = special_dirs; l; l = l->next)
{
for (l = special_dirs; l != NULL; l = g_list_next (l))
if (strncmp (dir, l->data, strlen (l->data)) == 0)
return TRUE;
}
return FALSE;
}