Merge branch '3607_cleanup'

* 3607_cleanup: (43 commits)
  Replace obsolete `INTLLIBS` with `LIBINTL` for `libmc`
  filehighlight: add more common file formats
  Move definition of reset_hp_softkeys variable to lib/tty/tty-slang.[ch].
  (feed_subshell): change type of fail_on_error from int to gboolean.
  Sync with gnulib 6ed53f13bc39d9a0252549e98a2a59441fb2351f.
  lib/widget/input_complete.c: apply coding guidelines.
  (command_completion_function): cleanup cppcheck warning.
  (dview_save_options): clarify boolean options.
  Get rid of global variables mc_main_config and mc_panels_config.
  (mc_realpath): cleanup cppcheck warning.
  (update_split): cleanup cppcheck warning.
  lib/vfs/direntry.c: cleanup cppcheck warnings.
  (mc_shell_get_installed_in_system): fix description.
  Fix typo.
  Clarify type cast in tgetsrt() calls.
  Clarify type cast in SLtt_tgetsrt() calls.
  MidnightCommander/mc#95: update Java syntax: add missing keywords: _ assert strictfp.
  MidnightCommander/mc#89: add webp extension to file highlight and extension files.
  MidnightCommander/mc#97: src/filemanager/mountlist.c: add makedev() declaration.
  (dlg_set_top_or_bottom_widget): move to proper file section.
  ...
This commit is contained in:
Andrew Borodin 2016-05-07 16:29:09 +03:00
commit 82fc95fb77
104 changed files with 988 additions and 6024 deletions

View File

@ -103,6 +103,9 @@ Marcelo Roccasalva <mfroccas@raiz.uncu.edu.ar>
Massimo Fontanelli <MC8737@mclink.it>
Mooffie <mooffie@gmail.com>
New high-level mouse API
Oliver Lange <modarin@bloody.in-berlin.de>
modarin256: set of 256-color skins

View File

@ -141,14 +141,14 @@ Where to get more information
There is a webpage for GNU Midnight Commander at
http://www.midnight-commander.org/
https://www.midnight-commander.org/
This page also has current information about mailing lists and some
useful advices how to report bugs.
You can download the latest version of GNU Midnight Commander from
http://www.midnight-commander.org/downloads/
https://www.midnight-commander.org/downloads/
Reporting problems
@ -156,7 +156,7 @@ Reporting problems
You can report bug on our site, please read
http://midnight-commander.org/wiki/defectReports
https://www.midnight-commander.org/wiki/doc/reportDefects
Also you can use mc mailing lists to discuss problems.

View File

@ -74,4 +74,4 @@ else
libmc_la_LIBADD += $(GLIB_LIBS)
endif
libmc_la_LIBADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
libmc_la_LIBADD += $(PCRE_LIBS) $(LIBICONV) $(LIBINTL)

View File

@ -95,22 +95,12 @@
#include "fs.h"
#include "shell.h"
#include "mcconfig.h"
#ifdef USE_MAINTAINER_MODE
#include "lib/logging.h"
#endif
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#define min(x, y) ((x) > (y) ? (y) : (x))
#define max(x, y) ((x) > (y) ? (x) : (y))
/* Just for keeping Your's brains from invention a proper size of the buffer :-) */
#define BUF_10K 10240L
#define BUF_8K 8192L
@ -192,6 +182,9 @@ typedef struct
/* share_data_dir: Area for default settings from developers */
char *share_data_dir;
mc_config_t *main_config;
mc_config_t *panels_config;
#ifdef HAVE_CHARSET
/* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
int source_codepage;

View File

@ -84,7 +84,7 @@ is_logging_enabled (void)
return logging_enabled;
logging_enabled =
mc_config_get_bool (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME, FALSE);
mc_config_get_bool (mc_global.main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME, FALSE);
logging_initialized = TRUE;
return logging_enabled;
@ -101,8 +101,9 @@ get_log_filename (void)
if (env_filename != NULL)
return g_strdup (env_filename);
if (mc_config_has_param (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE))
return mc_config_get_string (mc_main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE, NULL);
if (mc_config_has_param (mc_global.main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE))
return mc_config_get_string (mc_global.main_config, CONFIG_GROUP_NAME, CONFIG_KEY_NAME_FILE,
NULL);
return mc_config_get_full_path ("mc.log");
}

View File

@ -23,9 +23,6 @@ typedef struct mc_config_t
/*** global variables defined in .c file *********************************************************/
extern mc_config_t *mc_main_config;
extern mc_config_t *mc_panels_config;
/*** declarations of public functions ************************************************************/
/* mcconfig/common.c: */

View File

@ -34,9 +34,6 @@
/*** global variables **************************************************/
mc_config_t *mc_main_config;
mc_config_t *mc_panels_config;
/*** file scope macro definitions **************************************/
/*** file scope type declarations **************************************/

View File

@ -153,7 +153,7 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro
mc_return_val_if_error (mcerror, FALSE);
full_path = g_build_filename (path_base, subdir, NULL);
full_path = g_build_filename (path_base, subdir, (char *) NULL);
if (g_file_test (full_path, G_FILE_TEST_EXISTS))
{
if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
@ -179,7 +179,7 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro
static char *
mc_config_get_deprecated_path (void)
{
return g_build_filename (mc_config_get_home_dir (), MC_OLD_USERCONF_DIR, NULL);
return g_build_filename (mc_config_get_home_dir (), MC_OLD_USERCONF_DIR, (char *) NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -224,8 +224,8 @@ mc_config_copy (const char *old_name, const char *new_name, GError ** mcerror)
{
char *old_name2, *new_name2;
old_name2 = g_build_filename (old_name, dir_name, NULL);
new_name2 = g_build_filename (new_name, dir_name, NULL);
old_name2 = g_build_filename (old_name, dir_name, (char *) NULL);
new_name2 = g_build_filename (new_name, dir_name, (char *) NULL);
mc_config_copy (old_name2, new_name2, mcerror);
g_free (new_name2);
g_free (old_name2);
@ -247,7 +247,7 @@ mc_config_fix_migrated_rules (void)
old_name =
g_build_filename (*mc_config_migrate_rules_fix[rule_index].old_basedir,
mc_config_migrate_rules_fix[rule_index].filename, NULL);
mc_config_migrate_rules_fix[rule_index].filename, (char *) NULL);
if (g_file_test (old_name, G_FILE_TEST_EXISTS))
{
@ -255,7 +255,7 @@ mc_config_fix_migrated_rules (void)
const char *basedir = *mc_config_migrate_rules_fix[rule_index].new_basedir;
const char *filename = mc_config_migrate_rules_fix[rule_index].filename;
new_name = g_build_filename (basedir, filename, NULL);
new_name = g_build_filename (basedir, filename, (char *) NULL);
rename (old_name, new_name);
g_free (new_name);
}
@ -469,7 +469,8 @@ mc_config_migrate_from_old_place (GError ** mcerror, char **msg)
continue;
old_name =
g_build_filename (old_dir, mc_config_files_reference[rule_index].old_filename, NULL);
g_build_filename (old_dir, mc_config_files_reference[rule_index].old_filename,
(char *) NULL);
if (g_file_test (old_name, G_FILE_TEST_EXISTS))
{
@ -477,7 +478,7 @@ mc_config_migrate_from_old_place (GError ** mcerror, char **msg)
const char *basedir = *mc_config_files_reference[rule_index].new_basedir;
const char *filename = mc_config_files_reference[rule_index].new_filename;
new_name = g_build_filename (basedir, filename, NULL);
new_name = g_build_filename (basedir, filename, (char *) NULL);
mc_config_copy (old_name, new_name, mcerror);
g_free (new_name);
}
@ -524,7 +525,8 @@ mc_config_get_full_path (const char *config_name)
if (strcmp (config_name, mc_config_files_reference[rule_index].new_filename) == 0)
{
return g_build_filename (*mc_config_files_reference[rule_index].new_basedir,
mc_config_files_reference[rule_index].new_filename, NULL);
mc_config_files_reference[rule_index].new_filename,
(char *) NULL);
}
}
return NULL;

View File

@ -168,7 +168,7 @@ mc_search__cond_struct_new_regex_accum_append (const char *charset, GString * st
one_char =
mc_search__get_one_symbol (charset, &(str_from->str[loop]),
min (str_from->len - loop, 6), &just_letters);
MIN (str_from->len - loop, 6), &just_letters);
one_char_len = strlen (one_char);
if (one_char_len == 0)

View File

@ -53,7 +53,7 @@ static char rp_shell[PATH_MAX];
/**
* Get a system shell.
*
* @return newly allocated string with shell name
* @return newly allocated mc_shell_t object with shell name
*/
static mc_shell_t *

View File

@ -76,7 +76,7 @@ mc_skin_get_default_name (void)
return g_strdup (tmp_str);
/* from config. Or 'default' if no present in config */
return mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "skin", "default");
return mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION, "skin", "default");
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -101,7 +101,7 @@ mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir
{
char *file_name, *file_name2;
file_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, mc_skin->name, NULL);
file_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, mc_skin->name, (char *) NULL);
if (exist_file (file_name))
{
mc_skin->config = mc_config_init (file_name, TRUE);
@ -111,7 +111,7 @@ mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir
g_free (file_name);
file_name2 = g_strdup_printf ("%s.ini", mc_skin->name);
file_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, file_name2, NULL);
file_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, file_name2, (char *) NULL);
g_free (file_name2);
if (exist_file (file_name))

View File

@ -231,7 +231,7 @@ str_8bit_length (const char *text)
static int
str_8bit_length2 (const char *text, int size)
{
return (size >= 0) ? min (strlen (text), (gsize) size) : strlen (text);
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -441,7 +441,7 @@ str_8bit_term_trim (const char *text, int width)
static int
str_8bit_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? min (strlen (text), length) : strlen (text);
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -659,7 +659,7 @@ str_8bit_compare (const char *t1, const char *t2)
static int
str_8bit_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, min (strlen (t1), strlen (t2)));
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */
@ -707,7 +707,7 @@ str_8bit_ncasecmp (const char *s1, const char *s2)
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
n = min (strlen (s1), strlen (s2));
n = MIN (strlen (s1), strlen (s2));
/* code from GLib */

View File

@ -204,7 +204,7 @@ str_ascii_length (const char *text)
static int
str_ascii_length2 (const char *text, int size)
{
return (size >= 0) ? min (strlen (text), (gsize) size) : strlen (text);
return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -421,7 +421,7 @@ str_ascii_term_trim (const char *text, int width)
static int
str_ascii_term_width2 (const char *text, size_t length)
{
return (length != (size_t) (-1)) ? min (strlen (text), length) : strlen (text);
return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
}
/* --------------------------------------------------------------------------------------------- */
@ -640,7 +640,7 @@ str_ascii_compare (const char *t1, const char *t2)
static int
str_ascii_ncompare (const char *t1, const char *t2)
{
return strncmp (t1, t2, min (strlen (t1), strlen (t2)));
return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */
@ -656,7 +656,7 @@ str_ascii_casecmp (const char *t1, const char *t2)
static int
str_ascii_ncasecmp (const char *t1, const char *t2)
{
return g_ascii_strncasecmp (t1, t2, min (strlen (t1), strlen (t2)));
return g_ascii_strncasecmp (t1, t2, MIN (strlen (t1), strlen (t2)));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -44,7 +44,7 @@ struct utf8_tool
{
char *actual;
size_t remain;
const char *cheked;
const char *checked;
int ident;
gboolean compose;
};
@ -358,7 +358,7 @@ str_utf8_length2 (const char *text, int size)
{
if (start != end)
{
result += g_utf8_strlen (start, min (end - start, size));
result += g_utf8_strlen (start, MIN (end - start, size));
size -= end - start;
}
result += (size > 0);
@ -369,7 +369,7 @@ str_utf8_length2 (const char *text, int size)
if (start == text)
result = g_utf8_strlen (text, size);
else if (start[0] != '\0' && start != end && size > 0)
result += g_utf8_strlen (start, min (end - start, size));
result += g_utf8_strlen (start, MIN (end - start, size));
return result;
}
@ -538,12 +538,12 @@ utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
{
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
while (tool->checked[0] != '\0')
{
gunichar uni;
size_t left;
uni = g_utf8_get_char (tool->cheked);
uni = g_utf8_get_char (tool->checked);
tool->compose = tool->compose || str_unichar_iscombiningmark (uni);
left = g_unichar_to_utf8 (uni, NULL);
if (tool->remain <= left)
@ -551,7 +551,7 @@ utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
left = g_unichar_to_utf8 (uni, tool->actual);
tool->actual += left;
tool->remain -= left;
tool->cheked = g_utf8_next_char (tool->cheked);
tool->checked = g_utf8_next_char (tool->checked);
}
return TRUE;
@ -566,13 +566,13 @@ utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
{
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
while (tool->checked[0] != '\0')
{
gunichar uni;
size_t left;
int w = 0;
uni = g_utf8_get_char (tool->cheked);
uni = g_utf8_get_char (tool->checked);
if (str_unichar_iscombiningmark (uni))
tool->compose = TRUE;
else
@ -590,7 +590,7 @@ utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
left = g_unichar_to_utf8 (uni, tool->actual);
tool->actual += left;
tool->remain -= left;
tool->cheked = g_utf8_next_char (tool->cheked);
tool->checked = g_utf8_next_char (tool->checked);
tool->ident += w;
}
@ -638,23 +638,23 @@ utf8_tool_skip_chars_to (struct utf8_tool *tool, int to_ident)
{
gunichar uni;
while (to_ident > tool->ident && tool->cheked[0] != '\0')
while (to_ident > tool->ident && tool->checked[0] != '\0')
{
uni = g_utf8_get_char (tool->cheked);
uni = g_utf8_get_char (tool->checked);
if (!str_unichar_iscombiningmark (uni))
{
tool->ident++;
if (g_unichar_iswide (uni))
tool->ident++;
}
tool->cheked = g_utf8_next_char (tool->cheked);
tool->checked = g_utf8_next_char (tool->checked);
}
uni = g_utf8_get_char (tool->cheked);
uni = g_utf8_get_char (tool->checked);
while (str_unichar_iscombiningmark (uni))
{
tool->cheked = g_utf8_next_char (tool->cheked);
uni = g_utf8_get_char (tool->cheked);
tool->checked = g_utf8_next_char (tool->checked);
uni = g_utf8_get_char (tool->checked);
}
return TRUE;
@ -682,7 +682,7 @@ str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
struct utf8_tool tool;
pre_form = str_utf8_make_make_term_form (text, (size_t) (-1));
tool.cheked = pre_form->text;
tool.checked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = FALSE;
@ -762,7 +762,7 @@ str_utf8_term_trim (const char *text, int width)
pre_form = str_utf8_make_make_term_form (text, (size_t) (-1));
tool.cheked = pre_form->text;
tool.checked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = FALSE;
@ -833,7 +833,7 @@ str_utf8_term_substring (const char *text, int start, int width)
pre_form = str_utf8_make_make_term_form (text, (size_t) (-1));
tool.cheked = pre_form->text;
tool.checked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = FALSE;
@ -864,7 +864,7 @@ str_utf8_trunc (const char *text, int width)
pre_form = str_utf8_make_make_term_form (text, (size_t) (-1));
tool.cheked = pre_form->text;
tool.checked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = FALSE;
@ -1198,7 +1198,7 @@ str_utf8_ncompare (const char *t1, const char *t2)
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
result = strncmp (n1, n2, MIN (l1, l2));
g_free (n1);
g_free (n2);
@ -1239,7 +1239,7 @@ str_utf8_ncasecmp (const char *t1, const char *t2)
l1 = strlen (n1);
l2 = strlen (n2);
result = strncmp (n1, n2, min (l1, l2));
result = strncmp (n1, n2, MIN (l1, l2));
g_free (n1);
g_free (n2);

View File

@ -142,30 +142,47 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
base = 1024;
if (strchr (valid_suffixes, '0') != NULL)
switch (**p)
{
/* The "valid suffix" '0' is a special flag meaning that
an optional second suffix is allowed, which can change
the base. A suffix "B" (e.g. "100MB") stands for a power
of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for
a power of 1024. If no suffix (e.g. "100M"), assume
power-of-1024. */
switch (p[0][1])
case 'E':
case 'G':
case 'g':
case 'k':
case 'K':
case 'M':
case 'm':
case 'P':
case 'T':
case 't':
case 'Y':
case 'Z':
if (strchr (valid_suffixes, '0') != NULL)
{
case 'i':
if (p[0][2] == 'B')
suffixes += 2;
break;
/* The "valid suffix" '0' is a special flag meaning that
an optional second suffix is allowed, which can change
the base. A suffix "B" (e.g. "100MB") stands for a power
of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for
a power of 1024. If no suffix (e.g. "100M"), assume
power-of-1024. */
case 'B':
case 'D': /* 'D' is obsolescent */
base = 1000;
suffixes++;
break;
default:
break;
switch (p[0][1])
{
case 'i':
if (p[0][2] == 'B')
suffixes += 2;
break;
case 'B':
case 'D': /* 'D' is obsolescent */
base = 1000;
suffixes++;
break;
default:
break;
}
}
default:
break;
}
switch (**p)
@ -175,6 +192,9 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
break;
case 'B':
/* This obsolescent first suffix is distinct from the 'B'
second suffix above. E.g., 'tar -L 1000B' means change
the tape after writing 1000 KiB of data. */
overflow = bkm_scale (&tmp, 1024);
break;

View File

@ -101,14 +101,14 @@ i18n_checktimelength (void)
{
strftime (buf, sizeof (buf) - 1, user_recent_timeformat, lt);
tlen = (size_t) str_term_width1 (buf);
length = max (tlen, length);
length = MAX (tlen, length);
strftime (buf, sizeof (buf) - 1, user_old_timeformat, lt);
tlen = (size_t) str_term_width1 (buf);
length = max (tlen, length);
length = MAX (tlen, length);
}
tlen = (size_t) str_term_width1 (_(INVALID_TIME_TEXT));
length = max (tlen, length);
length = MAX (tlen, length);
}
/* Don't handle big differences. Use standard value (email bug, please) */

View File

@ -614,7 +614,7 @@ try_channels (int set_timeout)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set); /* Add stdin */
maxfdp = max (add_selects (&select_set), input_fd);
maxfdp = MAX (add_selects (&select_set), input_fd);
if (set_timeout)
{
@ -1710,7 +1710,7 @@ is_idle (void)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set);
nfd = max (0, input_fd) + 1;
nfd = MAX (0, input_fd) + 1;
time_out.tv_sec = 0;
time_out.tv_usec = 0;
#ifdef HAVE_LIBGPM
@ -1719,7 +1719,7 @@ is_idle (void)
if (gpm_fd >= 0)
{
FD_SET (gpm_fd, &select_set);
nfd = max (nfd, gpm_fd + 1);
nfd = MAX (nfd, gpm_fd + 1);
}
else
{
@ -1988,7 +1988,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set);
nfd = max (add_selects (&select_set), max (0, input_fd)) + 1;
nfd = MAX (add_selects (&select_set), MAX (0, input_fd)) + 1;
#ifdef HAVE_LIBGPM
if (mouse_enabled && (use_mouse_p == MOUSE_GPM))
@ -1996,7 +1996,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
if (gpm_fd >= 0)
{
FD_SET (gpm_fd, &select_set);
nfd = max (nfd, gpm_fd + 1);
nfd = MAX (nfd, gpm_fd + 1);
}
else
{

View File

@ -631,7 +631,7 @@ tty_print_string (const char *s)
s = str_term_form (s);
len = str_term_width1 (s);
/* line is upper or below the screen or entire line is before or after scrren */
/* line is upper or below the screen or entire line is before or after screen */
if (mc_curs_row < 0 || mc_curs_row >= LINES || mc_curs_col + len <= 0 || mc_curs_col >= COLS)
{
mc_curs_col += len;
@ -673,7 +673,8 @@ char *
tty_tgetstr (const char *cap)
{
char *unused = NULL;
return tgetstr (cap, &unused);
return tgetstr ((NCURSES_CONST char *) cap, &unused);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -57,6 +57,11 @@
/*** global variables ****************************************************************************/
/* If true program softkeys (HP terminals only) on startup and after every
command ran in the subshell to the description found in the termcap/terminfo
database */
int reset_hp_softkeys = 0;
/*** file scope macro definitions ****************************************************************/
#ifndef SLTT_MAX_SCREEN_COLS
@ -174,7 +179,7 @@ slang_reset_softkeys (void)
char *send;
g_snprintf (tmp, sizeof (tmp), "k%d", key);
send = (char *) SLtt_tgetstr (tmp);
send = SLtt_tgetstr (tmp);
if (send != NULL)
{
g_snprintf (tmp, sizeof (tmp), ESC_STR "&f%dk%dd%dL%s%s", key,
@ -191,7 +196,7 @@ do_define_key (int code, const char *strcap)
{
char *seq;
seq = (char *) SLtt_tgetstr ((char *) strcap);
seq = SLtt_tgetstr ((SLFUTURE_CONST char *) strcap);
if (seq != NULL)
define_sequence (code, seq, MCKEY_NOACTION);
}
@ -353,7 +358,7 @@ tty_shutdown (void)
/* Load the op capability to reset the colors to those that were
* active when the program was started up
*/
op_cap = SLtt_tgetstr ((char *) "op");
op_cap = SLtt_tgetstr ((SLFUTURE_CONST char *) "op");
if (op_cap != NULL)
{
fputs (op_cap, stdout);
@ -448,7 +453,7 @@ tty_keypad (gboolean set)
{
char *keypad_string;
keypad_string = (char *) SLtt_tgetstr ((char *) (set ? "ks" : "ke"));
keypad_string = SLtt_tgetstr ((SLFUTURE_CONST char *) (set ? "ks" : "ke"));
if (keypad_string != NULL)
SLtt_write_string (keypad_string);
if (set && reset_hp_softkeys)
@ -743,7 +748,7 @@ tty_printf (const char *fmt, ...)
char *
tty_tgetstr (const char *cap)
{
return SLtt_tgetstr ((char *) cap);
return SLtt_tgetstr ((SLFUTURE_CONST char *) cap);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -41,6 +41,8 @@ enum
/*** global variables defined in .c file *********************************************************/
extern int reset_hp_softkeys;
/*** declarations of public functions ************************************************************/
/*** inline functions ****************************************************************************/

View File

@ -50,13 +50,6 @@
/*** global variables ****************************************************************************/
#ifdef HAVE_SLANG
/* If true program softkeys (HP terminals only) on startup and after every
command ran in the subshell to the description found in the termcap/terminfo
database */
int reset_hp_softkeys = 0;
#endif
int mc_tty_frm[MC_TTY_FRM_MAX];
/*** file scope macro definitions ****************************************************************/

View File

@ -65,12 +65,6 @@ extern int mc_tty_frm[];
extern char *tty_tgetstr (const char *name);
/* {{{ Input }}} */
#ifdef HAVE_SLANG
extern int reset_hp_softkeys;
#endif
/*** declarations of public functions ************************************************************/
extern void tty_beep (void);

View File

@ -1216,7 +1216,7 @@ save_file_position (const vfs_path_t * filename_vpath, long line, long column, o
gboolean src_error = FALSE;
if (filepos_max_saved_entries == 0)
filepos_max_saved_entries = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
filepos_max_saved_entries = mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION,
"filepos_max_saved_entries", 1024);
fn = mc_config_get_full_path (MC_FILEPOS_FILE);

View File

@ -604,7 +604,7 @@ mc_pread (mc_pipe_t * p, GError ** error)
if (read_err)
{
FD_SET (p->err.fd, &fds);
maxfd = max (maxfd, p->err.fd);
maxfd = MAX (maxfd, p->err.fd);
}
/* no timeout */
@ -1106,12 +1106,14 @@ char *
mc_realpath (const char *path, char *resolved_path)
{
char copy_path[PATH_MAX];
char link_path[PATH_MAX];
char got_path[PATH_MAX];
char *new_path = got_path;
char *max_path;
#ifdef S_IFLNK
char link_path[PATH_MAX];
int readlinks = 0;
int n;
#endif /* S_IFLNK */
/* Make a copy of the source path since we may need to modify it. */
if (strlen (path) >= PATH_MAX - 2)

View File

@ -118,7 +118,7 @@ vfs_s_automake (struct vfs_class *me, struct vfs_s_inode *dir, char *path, int f
if (sep != NULL)
*sep = '\0';
res = vfs_s_generate_entry (me, path, dir, flags & FL_MKDIR ? (0777 | S_IFDIR) : 0777);
res = vfs_s_generate_entry (me, path, dir, (flags & FL_MKDIR) != 0 ? (0777 | S_IFDIR) : 0777);
vfs_s_insert_entry (me, dir, res);
if (sep != NULL)
@ -383,13 +383,14 @@ vfs_s_inode_from_path (const vfs_path_t * vpath, int flags)
ino =
vfs_s_find_inode (path_element->class, super, q,
flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, flags & ~FL_FOLLOW);
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
flags & ~FL_FOLLOW);
if ((!ino) && (!*q))
/* We are asking about / directory of ftp server: assume it exists */
ino =
vfs_s_find_inode (path_element->class, super, q,
flags & FL_FOLLOW ? LINK_FOLLOW :
LINK_NO_FOLLOW, FL_DIR | (flags & ~FL_FOLLOW));
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
FL_DIR | (flags & ~FL_FOLLOW));
return ino;
}

View File

@ -294,24 +294,29 @@ mc_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
/* *INDENT-OFF* */
#define MC_HANDLEOP(name, inarg, callarg) \
ssize_t mc_##name inarg \
#define MC_HANDLEOP(name) \
ssize_t mc_##name (int handle, C void *buf, size_t count) \
{ \
struct vfs_class *vfs; \
void *fsinfo = NULL; \
int result; \
if (handle == -1) \
return -1; \
vfs = vfs_class_find_by_handle (handle); \
vfs = vfs_class_find_by_handle (handle, &fsinfo); \
if (vfs == NULL) \
return -1; \
result = vfs->name != NULL ? vfs->name callarg : -1; \
result = vfs->name != NULL ? vfs->name (fsinfo, buf, count) : -1; \
if (result == -1) \
errno = vfs->name != NULL ? vfs_ferrno (vfs) : E_NOTSUPP; \
return result; \
}
MC_HANDLEOP (read, (int handle, void *buffer, size_t count), (vfs_class_data_find_by_handle (handle), buffer, count))
MC_HANDLEOP (write, (int handle, const void *buf, size_t nbyte), (vfs_class_data_find_by_handle (handle), buf, nbyte))
#define C
MC_HANDLEOP (read)
#undef C
#define C const
MC_HANDLEOP (write)
#undef C
/* --------------------------------------------------------------------------------------------- */
@ -353,12 +358,14 @@ MC_RENAMEOP (rename)
int
mc_ctl (int handle, int ctlop, void *arg)
{
struct vfs_class *vfs = vfs_class_find_by_handle (handle);
struct vfs_class *vfs;
void *fsinfo = NULL;
vfs = vfs_class_find_by_handle (handle, &fsinfo);
if (vfs == NULL)
return 0;
return vfs->ctl ? (*vfs->ctl) (vfs_class_data_find_by_handle (handle), ctlop, arg) : 0;
return vfs->ctl != NULL ? vfs->ctl (fsinfo, ctlop, arg) : 0;
}
/* --------------------------------------------------------------------------------------------- */
@ -387,13 +394,14 @@ int
mc_close (int handle)
{
struct vfs_class *vfs;
void *fsinfo = NULL;
int result;
if (handle == -1 || !vfs_class_data_find_by_handle (handle))
if (handle == -1)
return -1;
vfs = vfs_class_find_by_handle (handle);
if (vfs == NULL)
vfs = vfs_class_find_by_handle (handle, &fsinfo);
if (vfs == NULL || fsinfo == NULL)
return -1;
if (handle < 3)
@ -401,7 +409,7 @@ mc_close (int handle)
if (!vfs->close)
vfs_die ("VFS must support close.\n");
result = (*vfs->close) (vfs_class_data_find_by_handle (handle));
result = (*vfs->close) (fsinfo);
vfs_free_handle (handle);
if (result == -1)
errno = vfs_ferrno (vfs);
@ -460,6 +468,7 @@ mc_readdir (DIR * dirp)
{
int handle;
struct vfs_class *vfs;
void *fsinfo = NULL;
struct dirent *entry = NULL;
vfs_path_element_t *vfs_path_element;
@ -485,11 +494,11 @@ mc_readdir (DIR * dirp)
}
handle = *(int *) dirp;
vfs = vfs_class_find_by_handle (handle);
if (vfs == NULL)
vfs = vfs_class_find_by_handle (handle, &fsinfo);
if (vfs == NULL || fsinfo == NULL)
return NULL;
vfs_path_element = vfs_class_data_find_by_handle (handle);
vfs_path_element = (vfs_path_element_t *) fsinfo;
if (vfs->readdir)
{
entry = (*vfs->readdir) (vfs_path_element->dir.info);
@ -515,15 +524,20 @@ mc_readdir (DIR * dirp)
int
mc_closedir (DIR * dirp)
{
int handle = *(int *) dirp;
int handle;
struct vfs_class *vfs;
void *fsinfo = NULL;
int result = -1;
vfs = vfs_class_find_by_handle (handle);
if (vfs != NULL)
if (dirp == NULL)
return result;
handle = *(int *) dirp;
vfs = vfs_class_find_by_handle (handle, &fsinfo);
if (vfs != NULL && fsinfo != NULL)
{
vfs_path_element_t *vfs_path_element;
vfs_path_element = vfs_class_data_find_by_handle (handle);
vfs_path_element_t *vfs_path_element = (vfs_path_element_t *) fsinfo;
#ifdef HAVE_CHARSET
if (vfs_path_element->dir.converter != str_cnv_from_term)
@ -593,18 +607,19 @@ int
mc_fstat (int handle, struct stat *buf)
{
struct vfs_class *vfs;
void *fsinfo = NULL;
int result;
if (handle == -1)
return -1;
vfs = vfs_class_find_by_handle (handle);
vfs = vfs_class_find_by_handle (handle, &fsinfo);
if (vfs == NULL)
return -1;
result = vfs->fstat ? (*vfs->fstat) (vfs_class_data_find_by_handle (handle), buf) : -1;
result = vfs->fstat ? (*vfs->fstat) (fsinfo, buf) : -1;
if (result == -1)
errno = vfs->name ? vfs_ferrno (vfs) : E_NOTSUPP;
errno = vfs->fstat ? vfs_ferrno (vfs) : E_NOTSUPP;
return result;
}
@ -746,16 +761,17 @@ off_t
mc_lseek (int fd, off_t offset, int whence)
{
struct vfs_class *vfs;
void *fsinfo = NULL;
off_t result;
if (fd == -1)
return -1;
vfs = vfs_class_find_by_handle (fd);
vfs = vfs_class_find_by_handle (fd, &fsinfo);
if (vfs == NULL)
return -1;
result = vfs->lseek ? (*vfs->lseek) (vfs_class_data_find_by_handle (fd), offset, whence) : -1;
result = vfs->lseek ? (*vfs->lseek) (fsinfo, offset, whence) : -1;
if (result == -1)
errno = vfs->lseek ? vfs_ferrno (vfs) : E_NOTSUPP;
return result;

View File

@ -152,14 +152,14 @@ vfs_canon (const char *path)
encoding prefix placed at start of string without the leading slash
should be autofixed by adding the leading slash
*/
local = mc_build_filename (PATH_SEP_STR, path, NULL);
local = mc_build_filename (PATH_SEP_STR, path, (char *) NULL);
}
else
{
const char *curr_dir;
curr_dir = vfs_get_current_dir ();
local = mc_build_filename (curr_dir, path, NULL);
local = mc_build_filename (curr_dir, path, (char *) NULL);
}
result = vfs_canon (local);
g_free (local);
@ -1272,7 +1272,7 @@ vfs_path_append_new (const vfs_path_t * vpath, const char *first_element, ...)
va_end (args);
result_str = vfs_path_as_str (vpath);
ret_vpath = vfs_path_build_filename (result_str, str_path, NULL);
ret_vpath = vfs_path_build_filename (result_str, str_path, (char *) NULL);
g_free (str_path);
return ret_vpath;

View File

@ -147,7 +147,7 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
slash = NULL;
ms = (slash != NULL) ? slash - semi : (int) strlen (semi);
ms = min ((unsigned int) ms, sizeof (encoding) - 1);
ms = MIN ((unsigned int) ms, sizeof (encoding) - 1);
/* limit encoding size (ms) to path size (size) */
if (semi + ms > path + size)
ms = path + size - semi;
@ -224,30 +224,23 @@ vfs_free_handle (int handle)
}
/* --------------------------------------------------------------------------------------------- */
/** Find private file data by file handle */
void *
vfs_class_data_find_by_handle (int handle)
{
struct vfs_openfile *h;
h = vfs_get_openfile (handle);
return h == NULL ? NULL : h->fsinfo;
}
/* --------------------------------------------------------------------------------------------- */
/** Find VFS class by file handle */
struct vfs_class *
vfs_class_find_by_handle (int handle)
vfs_class_find_by_handle (int handle, void **fsinfo)
{
struct vfs_openfile *h;
h = vfs_get_openfile (handle);
return h == NULL ? NULL : h->vclass;
if (h == NULL)
return NULL;
if (fsinfo != NULL)
*fsinfo = h->fsinfo;
return h->vclass;
}
/* --------------------------------------------------------------------------------------------- */
@ -636,24 +629,20 @@ vfs_preallocate (int dest_vfs_fd, off_t src_fsize, off_t dest_fsize)
return 0;
#else /* HAVE_POSIX_FALLOCATE */
int *dest_fd;
void *dest_fd = NULL;
struct vfs_class *dest_class;
if (!mc_global.vfs.preallocate_space)
return 0;
dest_class = vfs_class_find_by_handle (dest_vfs_fd);
if ((dest_class->flags & VFSF_LOCAL) == 0)
return 0;
dest_fd = (int *) vfs_class_data_find_by_handle (dest_vfs_fd);
if (dest_fd == NULL)
return 0;
if (src_fsize == 0)
return 0;
return posix_fallocate (*dest_fd, dest_fsize, src_fsize - dest_fsize);
dest_class = vfs_class_find_by_handle (dest_vfs_fd, &dest_fd);
if ((dest_class->flags & VFSF_LOCAL) == 0 || dest_fd == NULL)
return 0;
return posix_fallocate (*(int *) dest_fd, dest_fsize, src_fsize - dest_fsize);
#endif /* HAVE_POSIX_FALLOCATE */
}

View File

@ -265,9 +265,7 @@ int vfs_ferrno (struct vfs_class *vfs);
int vfs_new_handle (struct vfs_class *vclass, void *fsinfo);
struct vfs_class *vfs_class_find_by_handle (int handle);
void *vfs_class_data_find_by_handle (int handle);
struct vfs_class *vfs_class_find_by_handle (int handle, void **fsinfo);
void vfs_free_handle (int handle);

View File

@ -230,7 +230,7 @@ dialog_switch_list (void)
if (mc_global.midnight_shutdown || mc_current == NULL)
return;
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
lines = MIN ((size_t) (LINES * 2 / 3), dlg_num);
cols = COLS * 2 / 3;
listbox = create_listbox_window (lines, cols, _("Screens"), "[Screen selector]");

View File

@ -601,6 +601,31 @@ dlg_find_widget_by_id (gconstpointer a, gconstpointer b)
return w->id == id ? 0 : 1;
}
/* --------------------------------------------------------------------------------------------- */
static void
dlg_set_top_or_bottom_widget (void *w, gboolean set_top)
{
Widget *widget = WIDGET (w);
WDialog *h = widget->owner;
GList *l;
l = g_list_find (h->widgets, w);
if (l == NULL)
abort (); /* widget is not in dialog, this should not happen */
/* unfocus prevoius widget and focus current one before widget reordering */
if (set_top && h->state == DLG_ACTIVE)
do_select_widget (h, l, SELECT_EXACT);
/* widget reordering */
h->widgets = g_list_remove_link (h->widgets, l);
if (set_top)
h->widgets = g_list_concat (h->widgets, l);
else
h->widgets = g_list_concat (l, h->widgets);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -1042,7 +1067,7 @@ find_widget_type (const WDialog * h, widget_cb_fn callback)
{
GList *w;
w = g_list_find_custom (h->widgets, callback, dlg_find_widget_callback);
w = g_list_find_custom (h->widgets, (gconstpointer) callback, dlg_find_widget_callback);
return (w == NULL) ? NULL : WIDGET (w->data);
}
@ -1086,31 +1111,6 @@ dlg_select_widget (void *w)
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
}
/* --------------------------------------------------------------------------------------------- */
static void
dlg_set_top_or_bottom_widget (void *w, gboolean set_top)
{
Widget *widget = WIDGET (w);
WDialog *h = widget->owner;
GList *l;
l = g_list_find (h->widgets, w);
if (l == NULL)
abort (); /* widget is not in dialog, this should not happen */
/* unfocus prevoius widget and focus current one before widget reordering */
if (set_top && h->state == DLG_ACTIVE)
do_select_widget (h, l, SELECT_EXACT);
/* widget reordering */
h->widgets = g_list_remove_link (h->widgets, l);
if (set_top)
h->widgets = g_list_concat (h->widgets, l);
else
h->widgets = g_list_concat (l, h->widgets);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Set widget at top of widget list and make it current.

View File

@ -87,13 +87,13 @@ history_dlg_reposition (WDialog * dlg_head)
if (he <= y || y > (LINES - 6))
{
he = min (he, y - 1);
he = MIN (he, y - 1);
y -= he;
}
else
{
y++;
he = min (he, LINES - y);
he = MIN (he, LINES - y);
}
if (data->widget->x > 2)
@ -103,7 +103,7 @@ history_dlg_reposition (WDialog * dlg_head)
if ((wi + x) > COLS)
{
wi = min (wi, COLS);
wi = MIN (wi, COLS);
x = COLS - wi;
}
@ -305,7 +305,7 @@ history_show (GList ** history, Widget * widget, int current)
size_t i;
i = str_term_width1 ((char *) z->data);
maxlen = max (maxlen, i);
maxlen = MAX (maxlen, i);
count++;
entry = g_new0 (WLEntry, 1);

View File

@ -138,8 +138,8 @@ input_eval_marks (WInput * in, long *start_mark, long *end_mark)
{
if (in->mark >= 0)
{
*start_mark = min (in->mark, in->point);
*end_mark = max (in->mark, in->point);
*start_mark = MIN (in->mark, in->point);
*end_mark = MAX (in->mark, in->point);
return TRUE;
}
@ -152,8 +152,8 @@ input_eval_marks (WInput * in, long *start_mark, long *end_mark)
static void
delete_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
int first = MIN (x_first, x_last);
int last = MAX (x_first, x_last);
size_t len;
input_mark_cmd (in, FALSE);
@ -223,7 +223,7 @@ input_history_strip_password (char *url)
return g_strdup (url);
*colon = '\0';
return g_strconcat (url, at, NULL);
return g_strconcat (url, at, (char *) NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -486,8 +486,8 @@ delete_char (WInput * in)
static void
copy_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
int first = MIN (x_first, x_last);
int last = MAX (x_first, x_last);
if (last == first)
{
@ -767,7 +767,7 @@ input_execute_cmd (WInput * in, long command)
input_mark_cmd (in, TRUE);
break;
case CK_Remove:
delete_region (in, in->point, max (in->mark, 0));
delete_region (in, in->point, MAX (in->mark, 0));
break;
case CK_DeleteToEnd:
kill_line (in);
@ -776,13 +776,13 @@ input_execute_cmd (WInput * in, long command)
clear_line (in);
break;
case CK_Store:
copy_region (in, max (in->mark, 0), in->point);
copy_region (in, MAX (in->mark, 0), in->point);
break;
case CK_Cut:
{
long m;
m = max (in->mark, 0);
m = MAX (in->mark, 0);
copy_region (in, m, in->point);
delete_region (in, in->point, m);
}
@ -1208,7 +1208,7 @@ input_assign_text (WInput * in, const char *text)
in->charpoint = 0;
text_len = strlen (text);
buffer_len = 1 + max ((size_t) w->cols, text_len);
buffer_len = 1 + MAX ((size_t) w->cols, text_len);
in->current_max_size = buffer_len;
if (buffer_len > (size_t) w->cols)
in->buffer = g_realloc (in->buffer, buffer_len);
@ -1219,6 +1219,14 @@ input_assign_text (WInput * in, const char *text)
/* --------------------------------------------------------------------------------------------- */
gboolean
input_is_empty (const WInput * in)
{
return (in == NULL || in->buffer == NULL || in->buffer[0] == '\0');
}
/* --------------------------------------------------------------------------------------------- */
/* Inserts text in input line */
void
input_insert (WInput * in, const char *text, gboolean insert_extra_space)
@ -1240,7 +1248,7 @@ input_set_point (WInput * in, int pos)
int max_pos;
max_pos = str_length (in->buffer);
pos = min (pos, max_pos);
pos = MIN (pos, max_pos);
if (pos != in->point)
input_free_completions (in);
in->point = pos;
@ -1272,7 +1280,7 @@ input_update (WInput * in, gboolean clear_first)
buf_len = str_length (in->buffer);
/* Adjust the mark */
in->mark = min (in->mark, buf_len);
in->mark = MIN (in->mark, buf_len);
pw = str_term_width2 (in->buffer, in->point);
@ -1325,7 +1333,7 @@ input_update (WInput * in, gboolean clear_first)
widget_move (in, 0, m1 - in->term_first_shown);
buf_width = str_term_width2 (in->buffer, m1);
sel_width =
min (m2 - m1, (w->cols - has_history) - (buf_width - in->term_first_shown));
MIN (m2 - m1, (w->cols - has_history) - (buf_width - in->term_first_shown));
tty_print_string (str_term_substring (in->buffer, m1, sel_width));
}
}

View File

@ -92,6 +92,7 @@ void input_set_default_colors (void);
cb_ret_t input_handle_char (WInput * in, int key);
int input_key_is_in_map (WInput * in, int key);
void input_assign_text (WInput * in, const char *text);
gboolean input_is_empty (const WInput * in);
void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
void input_set_point (WInput * in, int pos);
void input_update (WInput * in, gboolean clear_first);

View File

@ -118,13 +118,13 @@ show_c_flags (input_complete_t flags)
{
static char s_cf[] = "FHCVUDS";
s_cf[0] = (flags & INPUT_COMPLETE_FILENAMES) ? 'F' : ' ';
s_cf[1] = (flags & INPUT_COMPLETE_HOSTNAMES) ? 'H' : ' ';
s_cf[2] = (flags & INPUT_COMPLETE_COMMANDS) ? 'C' : ' ';
s_cf[3] = (flags & INPUT_COMPLETE_VARIABLES) ? 'V' : ' ';
s_cf[4] = (flags & INPUT_COMPLETE_USERNAMES) ? 'U' : ' ';
s_cf[5] = (flags & INPUT_COMPLETE_CD) ? 'D' : ' ';
s_cf[6] = (flags & INPUT_COMPLETE_SHELL_ESC) ? 'S' : ' ';
s_cf[0] = (flags & INPUT_COMPLETE_FILENAMES) != 0 ? 'F' : ' ';
s_cf[1] = (flags & INPUT_COMPLETE_HOSTNAMES) != 0 ? 'H' : ' ';
s_cf[2] = (flags & INPUT_COMPLETE_COMMANDS) != 0 ? 'C' : ' ';
s_cf[3] = (flags & INPUT_COMPLETE_VARIABLES) != 0 ? 'V' : ' ';
s_cf[4] = (flags & INPUT_COMPLETE_USERNAMES) != 0 ? 'U' : ' ';
s_cf[5] = (flags & INPUT_COMPLETE_CD) != 0 ? 'D' : ' ';
s_cf[6] = (flags & INPUT_COMPLETE_SHELL_ESC) != 0 ? 'S' : ' ';
return s_cf;
}
@ -139,15 +139,15 @@ filename_completion_function (const char *text, int state, input_complete_t flag
static char *filename = NULL;
static char *dirname = NULL;
static char *users_dirname = NULL;
static size_t filename_len;
int isdir = 1, isexec = 0;
static size_t filename_len = 0;
static vfs_path_t *dirname_vpath = NULL;
gboolean isdir = TRUE, isexec = FALSE;
struct dirent *entry = NULL;
SHOW_C_CTX ("filename_completion_function");
if (text && (flags & INPUT_COMPLETE_SHELL_ESC))
if (text != NULL && (flags & INPUT_COMPLETE_SHELL_ESC) != 0)
{
char *u_text;
char *result;
@ -203,7 +203,7 @@ filename_completion_function (const char *text, int state, input_complete_t flag
/* Now that we have some state, we can read the directory. */
while (directory && (entry = mc_readdir (directory)))
while (directory != NULL && (entry = mc_readdir (directory)) != NULL)
{
if (!str_is_valid_string (entry->d_name))
continue;
@ -221,11 +221,13 @@ filename_completion_function (const char *text, int state, input_complete_t flag
it may be a match. */
if ((entry->d_name[0] != filename[0]) ||
((NLENGTH (entry)) < filename_len) ||
strncmp (filename, entry->d_name, filename_len))
strncmp (filename, entry->d_name, filename_len) != 0)
continue;
}
isdir = 1;
isexec = 0;
isdir = TRUE;
isexec = FALSE;
{
struct stat tempstat;
vfs_path_t *tmp_vpath;
@ -235,37 +237,42 @@ filename_completion_function (const char *text, int state, input_complete_t flag
/* Unix version */
if (mc_stat (tmp_vpath, &tempstat) == 0)
{
uid_t my_uid = getuid ();
gid_t my_gid = getgid ();
uid_t my_uid;
gid_t my_gid;
my_uid = getuid ();
my_gid = getgid ();
if (!S_ISDIR (tempstat.st_mode))
{
isdir = 0;
if ((!my_uid && (tempstat.st_mode & 0111)) ||
(my_uid == tempstat.st_uid && (tempstat.st_mode & 0100)) ||
(my_gid == tempstat.st_gid && (tempstat.st_mode & 0010)) ||
(tempstat.st_mode & 0001))
isexec = 1;
isdir = FALSE;
if ((my_uid == 0 && (tempstat.st_mode & 0111) != 0) ||
(my_uid == tempstat.st_uid && (tempstat.st_mode & 0100) != 0) ||
(my_gid == tempstat.st_gid && (tempstat.st_mode & 0010) != 0) ||
(tempstat.st_mode & 0001) != 0)
isexec = TRUE;
}
}
else
{
/* stat failed, strange. not a dir in any case */
isdir = 0;
isdir = FALSE;
}
vfs_path_free (tmp_vpath);
}
if ((flags & INPUT_COMPLETE_COMMANDS) && (isexec || isdir))
if ((flags & INPUT_COMPLETE_COMMANDS) != 0 && (isexec || isdir))
break;
if ((flags & INPUT_COMPLETE_CD) && isdir)
if ((flags & INPUT_COMPLETE_CD) != 0 && isdir)
break;
if (flags & (INPUT_COMPLETE_FILENAMES))
if ((flags & INPUT_COMPLETE_FILENAMES) != 0)
break;
}
if (entry == NULL)
{
if (directory)
if (directory != NULL)
{
mc_closedir (directory);
directory = NULL;
@ -306,8 +313,8 @@ filename_completion_function (const char *text, int state, input_complete_t flag
static char *
username_completion_function (const char *text, int state, input_complete_t flags)
{
static struct passwd *entry;
static size_t userlen;
static struct passwd *entry = NULL;
static size_t userlen = 0;
(void) flags;
SHOW_C_CTX ("username_completion_function");
@ -319,12 +326,13 @@ username_completion_function (const char *text, int state, input_complete_t flag
setpwent ();
userlen = strlen (text + 1);
}
while ((entry = getpwent ()) != NULL)
{
/* Null usernames should result in all users as possible completions. */
if (userlen == 0)
break;
if (text[1] == entry->pw_name[0] && !strncmp (text + 1, entry->pw_name, userlen))
if (text[1] == entry->pw_name[0] && strncmp (text + 1, entry->pw_name, userlen) == 0)
break;
}
@ -342,25 +350,26 @@ username_completion_function (const char *text, int state, input_complete_t flag
static char *
variable_completion_function (const char *text, int state, input_complete_t flags)
{
static char **env_p;
static unsigned int isbrace;
static size_t varlen;
const char *p = NULL;
static char **env_p = NULL;
static gboolean isbrace = FALSE;
static size_t varlen = 0;
const char *p;
(void) flags;
SHOW_C_CTX ("variable_completion_function");
if (state == 0)
{ /* Initialization stuff */
isbrace = (text[1] == '{') ? 1 : 0;
isbrace = (text[1] == '{');
varlen = strlen (text + 1 + isbrace);
env_p = environ;
}
while (*env_p)
while (*env_p != NULL)
{
p = strchr (*env_p, '=');
if (p && ((size_t) (p - *env_p) >= varlen) && !strncmp (text + 1 + isbrace, *env_p, varlen))
if (p != NULL && ((size_t) (p - *env_p) >= varlen)
&& strncmp (text + 1 + isbrace, *env_p, varlen) == 0)
break;
env_p++;
}
@ -373,7 +382,7 @@ variable_completion_function (const char *text, int state, input_complete_t flag
temp = g_string_new_len (*env_p, p - *env_p);
if (isbrace != 0)
if (isbrace)
{
g_string_prepend_c (temp, '{');
g_string_append_c (temp, '}');
@ -391,30 +400,34 @@ variable_completion_function (const char *text, int state, input_complete_t flag
static void
fetch_hosts (const char *filename)
{
FILE *file = fopen (filename, "r");
char buffer[256], *name;
FILE *file;
char buffer[256];
char *name;
char *lc_start;
char *bi;
if (!file)
file = fopen (filename, "r");
if (file == NULL)
return;
while (fgets (buffer, sizeof (buffer) - 1, file) != NULL)
{
/* Skip to first character. */
for (bi = buffer; bi[0] != '\0' && str_isspace (bi); str_next_char (&bi));
for (bi = buffer; bi[0] != '\0' && str_isspace (bi); str_next_char (&bi))
;
/* Ignore comments... */
if (bi[0] == '#')
continue;
/* Handle $include. */
if (!strncmp (bi, "$include ", 9))
if (strncmp (bi, "$include ", 9) == 0)
{
char *includefile = bi + 9;
char *t;
char *includefile, *t;
/* Find start of filename. */
while (*includefile && whitespace (*includefile))
includefile = bi + 9;
while (*includefile != '\0' && whitespace (*includefile))
includefile++;
t = includefile;
@ -438,27 +451,31 @@ fetch_hosts (const char *filename)
str_next_char (&bi);
if (bi[0] == '#')
continue;
for (lc_start = bi; bi[0] != '\0' && !str_isspace (bi); str_next_char (&bi));
for (lc_start = bi; bi[0] != '\0' && !str_isspace (bi); str_next_char (&bi))
;
if (bi - lc_start == 0)
if (bi == lc_start)
continue;
name = g_strndup (lc_start, bi - lc_start);
{
char **host_p;
int j;
if (hosts_p - hosts >= hosts_alloclen)
j = hosts_p - hosts;
if (j >= hosts_alloclen)
{
int j;
j = hosts_p - hosts;
hosts_alloclen += 30;
hosts = g_renew (char *, hosts, hosts_alloclen + 1);
hosts_p = hosts + j;
}
for (host_p = hosts; host_p < hosts_p; host_p++)
if (!strcmp (name, *host_p))
if (strcmp (name, *host_p) == 0)
break; /* We do not want any duplicates */
if (host_p == hosts_p)
{
*(hosts_p++) = name;
@ -469,6 +486,7 @@ fetch_hosts (const char *filename)
}
}
}
fclose (file);
}
@ -477,9 +495,9 @@ fetch_hosts (const char *filename)
static char *
hostname_completion_function (const char *text, int state, input_complete_t flags)
{
static char **host_p;
static unsigned int textstart;
static size_t textlen;
static char **host_p = NULL;
static size_t textstart = 0;
static size_t textlen = 0;
(void) flags;
SHOW_C_CTX ("hostname_completion_function");
@ -538,18 +556,17 @@ hostname_completion_function (const char *text, int state, input_complete_t flag
*/
static char *
command_completion_function (const char *_text, int state, input_complete_t flags)
command_completion_function (const char *text, int state, input_complete_t flags)
{
char *text;
static const char *path_end;
static gboolean isabsolute;
static int phase;
static size_t text_len;
static const char *const *words;
static char *path;
static char *cur_path;
static char *cur_word;
static int init_state;
static const char *path_end = NULL;
static gboolean isabsolute = FALSE;
static int phase = 0;
static size_t text_len = 0;
static const char *const *words = NULL;
static char *path = NULL;
static char *cur_path = NULL;
static char *cur_word = NULL;
static int init_state = 0;
static const char *const bash_reserved[] = {
"if", "then", "else", "elif", "fi", "case", "esac", "for",
"select", "while", "until", "do", "done", "in", "function", 0
@ -563,25 +580,26 @@ command_completion_function (const char *_text, int state, input_complete_t flag
"shift", "source", "suspend", "test", "times", "trap", "type",
"typeset", "ulimit", "umask", "unalias", "unset", "wait", 0
};
char *u_text;
char *p, *found;
/* cppcheck-suppress uninitvar */
SHOW_C_CTX ("command_completion_function");
if (!(flags & INPUT_COMPLETE_COMMANDS))
return 0;
if ((flags & INPUT_COMPLETE_COMMANDS) == 0)
return NULL;
text = strutils_shell_unescape (_text);
u_text = strutils_shell_unescape (text);
flags &= ~INPUT_COMPLETE_SHELL_ESC;
if (state == 0)
{ /* Initialize us a little bit */
isabsolute = strchr (text, PATH_SEP) != NULL;
isabsolute = strchr (u_text, PATH_SEP) != NULL;
if (!isabsolute)
{
words = bash_reserved;
phase = 0;
text_len = strlen (text);
text_len = strlen (u_text);
if (path == NULL)
{
@ -591,9 +609,7 @@ command_completion_function (const char *_text, int state, input_complete_t flag
p = path;
path_end = strchr (p, '\0');
while ((p = strchr (p, PATH_ENV_SEP)) != NULL)
{
*p++ = '\0';
}
}
}
}
@ -601,7 +617,7 @@ command_completion_function (const char *_text, int state, input_complete_t flag
if (isabsolute)
{
p = filename_completion_function (text, state, flags);
p = filename_completion_function (u_text, state, flags);
if (p != NULL)
{
@ -611,7 +627,7 @@ command_completion_function (const char *_text, int state, input_complete_t flag
g_free (temp_p);
}
g_free (text);
g_free (u_text);
return p;
}
@ -620,45 +636,48 @@ command_completion_function (const char *_text, int state, input_complete_t flag
{
case 0: /* Reserved words */
for (; *words != NULL; words++)
if (strncmp (*words, text, text_len) == 0)
if (strncmp (*words, u_text, text_len) == 0)
{
g_free (text);
g_free (u_text);
return g_strdup (*(words++));
}
phase++;
words = bash_builtins;
/* fallthrough */
case 1: /* Builtin commands */
for (; *words != NULL; words++)
if (strncmp (*words, text, text_len) == 0)
if (strncmp (*words, u_text, text_len) == 0)
{
g_free (text);
g_free (u_text);
return g_strdup (*(words++));
}
phase++;
if (!path)
if (path == NULL)
break;
cur_path = path;
cur_word = NULL;
/* fallthrough */
case 2: /* And looking through the $PATH */
while (!found)
while (found == NULL)
{
if (!cur_word)
if (cur_word == NULL)
{
char *expanded;
if (cur_path >= path_end)
break;
expanded = tilde_expand (*cur_path ? cur_path : ".");
cur_word = mc_build_filename (expanded, text, NULL);
expanded = tilde_expand (*cur_path != '\0' ? cur_path : ".");
cur_word = mc_build_filename (expanded, u_text, (char *) NULL);
g_free (expanded);
canonicalize_pathname (cur_word);
cur_path = strchr (cur_path, 0) + 1;
cur_path = strchr (cur_path, '\0') + 1;
init_state = state;
}
found = filename_completion_function (cur_word, state - init_state, flags);
if (!found)
if (found == NULL)
MC_PTR_FREE (cur_word);
}
/* fallthrough */
default:
break;
}
@ -671,12 +690,13 @@ command_completion_function (const char *_text, int state, input_complete_t flag
if (p != NULL)
{
char *tmp = found;
found = strutils_shell_escape (p + 1);
g_free (tmp);
}
}
g_free (text);
g_free (u_text);
return found;
}
@ -726,9 +746,10 @@ completion_matches (const char *text, CompletionFunction entry_function, input_c
/* If there were any matches, then look through them finding out the
lowest common denominator. That then becomes match_list[0]. */
if (matches)
if (matches == 0)
MC_PTR_FREE (match_list); /* There were no matches. */
else
{
/* If only one match, just use that. */
if (matches == 1)
{
@ -753,7 +774,7 @@ completion_matches (const char *text, CompletionFunction entry_function, input_c
char *si, *sj;
char *ni, *nj;
for (si = match_list[i], sj = match_list[j]; si[0] && sj[0];)
for (si = match_list[i], sj = match_list[j]; si[0] != '\0' && sj[0] != '\0';)
{
ni = str_get_next_char (si);
@ -788,8 +809,6 @@ completion_matches (const char *text, CompletionFunction entry_function, input_c
match_list[0] = g_strndup (match_list[1], low);
}
}
else /* There were no matches. */
MC_PTR_FREE (match_list);
return match_list;
}
@ -861,9 +880,9 @@ try_complete_commands_prepare (try_complete_automation_state_t * state, char *te
static void
try_complete_find_start_sign (try_complete_automation_state_t * state)
{
if (state->flags & INPUT_COMPLETE_COMMANDS)
if ((state->flags & INPUT_COMPLETE_COMMANDS) != 0)
state->p = strrchr (state->word, '`');
if (state->flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES))
if ((state->flags & (INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES)) != 0)
{
state->q = strrchr (state->word, '$');
@ -880,9 +899,9 @@ try_complete_find_start_sign (try_complete_automation_state_t * state)
state->q = NULL;
}
}
if (state->flags & INPUT_COMPLETE_HOSTNAMES)
if ((state->flags & INPUT_COMPLETE_HOSTNAMES) != 0)
state->r = strrchr (state->word, '@');
if (state->q && state->q[1] == '(' && (state->flags & INPUT_COMPLETE_COMMANDS))
if (state->q != NULL && state->q[1] == '(' && (state->flags & INPUT_COMPLETE_COMMANDS) != 0)
{
if (state->q > state->p)
state->p = str_get_next_char (state->q);
@ -915,23 +934,26 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,
{
state->q = text + *lc_start;
for (state->p = text;
*state->p && state->p < state->q && (*state->p == ' ' || *state->p == '\t');
*state->p != '\0' && state->p < state->q && (*state->p == ' '
|| *state->p == '\t');
str_next_char (&state->p))
;
if (!strncmp (state->p, "cd", 2))
if (strncmp (state->p, "cd", 2) == 0)
for (state->p += 2;
*state->p && state->p < state->q && (*state->p == ' ' || *state->p == '\t');
*state->p != '\0' && state->p < state->q && (*state->p == ' '
|| *state->p == '\t');
str_next_char (&state->p))
;
if (state->p == state->q)
{
char *const cdpath_ref = g_strdup (getenv ("CDPATH"));
char *cdpath = cdpath_ref;
char *cdpath_ref, *cdpath;
char c;
cdpath_ref = g_strdup (getenv ("CDPATH"));
cdpath = cdpath_ref;
c = (cdpath == NULL) ? '\0' : ':';
while (!matches && c == ':')
while (matches == NULL && c == ':')
{
char *s;
@ -943,7 +965,7 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,
*s = '\0';
if (*cdpath != '\0')
{
state->r = mc_build_filename (cdpath, state->word, NULL);
state->r = mc_build_filename (cdpath, state->word, (char *) NULL);
SHOW_C_CTX ("try_complete:filename_subst_2");
matches =
completion_matches (state->r, filename_completion_function,
@ -965,10 +987,12 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,
static gboolean
insert_text (WInput * in, char *text, ssize_t size)
{
size_t text_len;
int buff_len;
text_len = strlen (text);
buff_len = str_length (in->buffer);
size = min (size, (ssize_t) strlen (text)) + start - end;
size = MIN (size, (ssize_t) text_len) + start - end;
if (strlen (in->buffer) + size >= (size_t) in->current_max_size)
{
/* Expand the buffer */
@ -991,6 +1015,7 @@ insert_text (WInput * in, char *text, ssize_t size)
input_update (in, TRUE);
end += size;
}
return size != 0;
}
@ -1081,6 +1106,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
buff[bl++] = (char) parm;
buff[bl] = '\0';
switch (str_is_valid_char (buff, bl))
{
case -1:
@ -1173,8 +1199,8 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
/* --------------------------------------------------------------------------------------------- */
/** Returns 1 if the user would like to see us again */
static int
/** Returns TRUE if the user would like to see us again */
static gboolean
complete_engine (WInput * in, int what_to_do)
{
if (in->completions != NULL && str_offset_to_pos (in->buffer, in->point) != end)
@ -1183,24 +1209,24 @@ complete_engine (WInput * in, int what_to_do)
if (in->completions == NULL)
complete_engine_fill_completions (in);
if (in->completions != NULL)
if (in->completions == NULL)
tty_beep ();
else
{
if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1]))
if ((what_to_do & DO_INSERTION) != 0
|| ((what_to_do & DO_QUERY) != 0 && in->completions[1] == NULL))
{
char *lc_complete = in->completions[0];
if (insert_text (in, lc_complete, strlen (lc_complete)))
{
if (in->completions[1])
tty_beep ();
else
input_free_completions (in);
}
else
if (!insert_text (in, lc_complete, strlen (lc_complete)) || in->completions[1] != NULL)
tty_beep ();
else
input_free_completions (in);
}
if ((what_to_do & DO_QUERY) && in->completions && in->completions[1])
if ((what_to_do & DO_QUERY) != 0 && in->completions != NULL && in->completions[1] != NULL)
{
int maxlen = 0, i, count = 0;
int maxlen = 0, count = 0, i;
int x, y, w, h;
int start_x, start_y;
char **p, *q;
@ -1213,6 +1239,7 @@ complete_engine (WInput * in, int what_to_do)
if (i > maxlen)
maxlen = i;
}
start_x = WIDGET (in)->x;
start_y = WIDGET (in)->y;
if (start_y - 2 >= count)
@ -1220,18 +1247,15 @@ complete_engine (WInput * in, int what_to_do)
y = start_y - 2 - count;
h = 2 + count;
}
else if (start_y >= LINES - start_y - 1)
{
y = 0;
h = start_y;
}
else
{
if (start_y >= LINES - start_y - 1)
{
y = 0;
h = start_y;
}
else
{
y = start_y + 1;
h = LINES - start_y - 1;
}
y = start_y + 1;
h = LINES - start_y - 1;
}
x = start - in->term_first_shown - 2 + start_x;
w = maxlen + 4;
@ -1241,36 +1265,39 @@ complete_engine (WInput * in, int what_to_do)
x = 0;
if (x + w > COLS)
w = COLS;
input = in;
min_end = end;
query_height = h;
query_width = w;
query_dlg = dlg_create (TRUE, y, x, query_height, query_width,
dialog_colors, query_callback, NULL,
"[Completion]", NULL, DLG_COMPACT);
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
add_widget (query_dlg, query_list);
for (p = in->completions + 1; *p; p++)
for (p = in->completions + 1; *p != NULL; p++)
listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL, FALSE);
dlg_run (query_dlg);
i = dlg_run (query_dlg);
q = NULL;
if (query_dlg->ret_value == B_ENTER)
if (i == B_ENTER)
{
listbox_get_current (query_list, &q, NULL);
if (q)
if (q != NULL)
insert_text (in, q, strlen (q));
}
if (q || end != min_end)
if (q != NULL || end != min_end)
input_free_completions (in);
i = query_dlg->ret_value; /* B_USER if user wants to start over again */
dlg_destroy (query_dlg);
if (i == B_USER)
return 1;
/* B_USER if user wants to start over again */
return (i == B_USER);
}
}
else
tty_beep ();
return 0;
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
@ -1296,7 +1323,7 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
the start of the line (ignoring preceding whitespace), or if it
appears after a character that separates commands. And we have to
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
if (!state.is_cd && (flags & INPUT_COMPLETE_COMMANDS))
if (!state.is_cd && (flags & INPUT_COMPLETE_COMMANDS) != 0)
try_complete_commands_prepare (&state, text, lc_start);
try_complete_find_start_sign (&state);
@ -1308,7 +1335,7 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
matches = completion_matches (str_cget_next_char (state.p),
command_completion_function,
state.flags & (~INPUT_COMPLETE_FILENAMES));
if (matches)
if (matches != NULL)
*lc_start += str_get_next_char (state.p) - state.word;
}
@ -1317,7 +1344,7 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
{
SHOW_C_CTX ("try_complete:var_subst");
matches = completion_matches (state.q, variable_completion_function, state.flags);
if (matches)
if (matches != NULL)
*lc_start += state.q - state.word;
}
@ -1327,14 +1354,14 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
{
SHOW_C_CTX ("try_complete:host_subst");
matches = completion_matches (state.r, hostname_completion_function, state.flags);
if (matches)
if (matches != NULL)
*lc_start += state.r - state.word;
}
/* Starts with '~' and there is no slash in the word, then
try completing this word as a username. */
if (!matches && *state.word == '~' && (state.flags & INPUT_COMPLETE_USERNAMES)
&& !strchr (state.word, PATH_SEP))
if (matches == NULL && *state.word == '~' && (state.flags & INPUT_COMPLETE_USERNAMES) != 0
&& strchr (state.word, PATH_SEP) == NULL)
{
SHOW_C_CTX ("try_complete:user_subst");
matches = completion_matches (state.word, username_completion_function, state.flags);

View File

@ -66,17 +66,17 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
dlg_flags_t dlg_flags = DLG_TRYUP;
/* Adjust sizes */
lines = min (lines, LINES - 6);
lines = MIN (lines, LINES - 6);
if (title != NULL)
{
int len;
len = str_term_width1 (title) + 4;
cols = max (cols, len);
cols = MAX (cols, len);
}
cols = min (cols, COLS - 6);
cols = MIN (cols, COLS - 6);
/* adjust position */
if ((center_y < 0) || (center_x < 0))

View File

@ -221,7 +221,7 @@ listbox_check_hotkey (WListbox * l, int key)
static int
listbox_y_pos (WListbox * l, int y)
{
return min (l->top + y, LISTBOX_LAST (l));
return MIN (l->top + y, LISTBOX_LAST (l));
}
/* --------------------------------------------------------------------------------------------- */
@ -240,7 +240,7 @@ listbox_fwd (WListbox * l, gboolean wrap)
static void
listbox_fwd_n (WListbox * l, int n)
{
listbox_select_entry (l, min (l->pos + n, LISTBOX_LAST (l)));
listbox_select_entry (l, MIN (l->pos + n, LISTBOX_LAST (l)));
}
/* --------------------------------------------------------------------------------------------- */
@ -259,7 +259,7 @@ listbox_back (WListbox * l, gboolean wrap)
static void
listbox_back_n (WListbox * l, int n)
{
listbox_select_entry (l, max (l->pos - n, 0));
listbox_select_entry (l, MAX (l->pos - n, 0));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -96,7 +96,7 @@ menu_arrange (menu_t * menu, dlg_shortcut_str get_shortcut)
size_t len;
len = (size_t) hotkey_width (entry->text);
menu->max_hotkey_len = max (menu->max_hotkey_len, len);
menu->max_hotkey_len = MAX (menu->max_hotkey_len, len);
if (get_shortcut != NULL)
entry->shortcut = get_shortcut (entry->command);
@ -104,7 +104,7 @@ menu_arrange (menu_t * menu, dlg_shortcut_str get_shortcut)
if (entry->shortcut != NULL)
{
len = (size_t) str_term_width1 (entry->shortcut);
max_shortcut_len = max (max_shortcut_len, len);
max_shortcut_len = MAX (max_shortcut_len, len);
}
}
}

View File

@ -104,7 +104,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu
in.quick_widget = quick_widget;
g_array_append_val (widgets, in);
*width = max (label.widget->cols, in.widget->cols);
*width = MAX (label.widget->cols, in.widget->cols);
break;
case input_label_left:
@ -140,7 +140,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu
*y += label.widget->lines - 1;
g_array_append_val (widgets, label);
*width = max (label.widget->cols, in.widget->cols);
*width = MAX (label.widget->cols, in.widget->cols);
break;
default:
@ -185,7 +185,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
int return_val;
len = str_term_width1 (I18N (quick_dlg->title)) + 6;
quick_dlg->cols = max (quick_dlg->cols, len);
quick_dlg->cols = MAX (quick_dlg->cols, len);
y = 1;
x = x1;
@ -210,9 +210,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_button:
@ -227,9 +227,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_input:
@ -249,9 +249,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_label:
@ -262,9 +262,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
break;
case quick_radio:
@ -288,9 +288,9 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
if (g != NULL)
width += 2;
if (two_columns)
width2 = max (width2, width);
width2 = MAX (width2, width);
else
width1 = max (width1, width);
width1 = MAX (width1, width);
}
break;
@ -339,7 +339,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
case quick_stop_columns:
x = x1;
y = max (y1, y);
y = MAX (y1, y);
g_array_append_val (widgets, item);
two_columns = FALSE;
break;
@ -383,7 +383,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
}
/* adjust dialog width */
quick_dlg->cols = max (quick_dlg->cols, blen + 6);
quick_dlg->cols = MAX (quick_dlg->cols, blen + 6);
if (have_groupbox)
{
if (width1 != 0)
@ -397,10 +397,10 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
{
len = width2 * 2 + 7;
if (width1 != 0)
len = max (len, width1 + 6);
len = MAX (len, width1 + 6);
}
quick_dlg->cols = max (quick_dlg->cols, len);
quick_dlg->cols = MAX (quick_dlg->cols, len);
width1 = quick_dlg->cols - 6;
width2 = (quick_dlg->cols - 7) / 2;

View File

@ -186,7 +186,7 @@ radio_new (int y, int x, int count, const char **texts)
r->texts[i] = parse_hotkey (texts[i]);
width = hotkey_width (r->texts[i]);
wmax = max (width, wmax);
wmax = MAX (width, wmax);
}
/* 4 is width of "(*) " */

View File

@ -364,7 +364,10 @@ mouse_get_local (const Gpm_Event * global, const Widget * w)
local.buttons = global->buttons;
#ifdef HAVE_LIBGPM
local.clicks = 0;
local.margin = 0;
local.modifiers = 0;
local.vc = 0;
#endif
local.x = global->x - w->x;
local.y = global->y - w->y;

View File

@ -299,7 +299,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
/* count coordinates */
str_msg_term_size (text, &lines, &cols);
cols = 6 + max (win_len, max (str_term_width1 (header), cols));
cols = 6 + MAX (win_len, MAX (str_term_width1 (header), cols));
lines += 4 + (count > 0 ? 2 : 0);
/* prepare dialog */
@ -585,7 +585,7 @@ status_msg_init (status_msg_t * sm, const char *title, double delay, status_msg_
start = mc_timer_elapsed (mc_global.timer);
sm->dlg = dlg_create (TRUE, 0, 0, 7, min (max (40, COLS / 2), COLS), dialog_colors,
sm->dlg = dlg_create (TRUE, 0, 0, 7, MIN (MAX (40, COLS / 2), COLS), dialog_colors,
NULL, NULL, NULL, title, DLG_CENTER);
sm->start = start;
sm->delay = (guint64) (delay * G_USEC_PER_SEC);
@ -697,7 +697,7 @@ simple_status_msg_init_cb (status_msg_t * sm)
#endif
b_width = str_term_width1 (b_name) + 4;
wd_width = max (wd->cols, b_width + 6);
wd_width = MAX (wd->cols, b_width + 6);
y = 2;
ssm->label = label_new (y++, 3, "");

View File

@ -50,7 +50,7 @@ AC_DEFUN([mc_CHECK_NCURSES_BY_PATH], [
if test x"$found_ncurses" = x"yes"; then
screen_type=ncurses
screen_msg="Ncurses library"
screen_msg="NCurses"
AC_DEFINE(HAVE_NCURSES, 1,
[Define to use ncurses library for screen management])
@ -103,7 +103,7 @@ AC_DEFUN([mc_WITH_NCURSES], [
[AC_MSG_ERROR([Cannot find ncurses library])])
screen_type=ncurses
screen_msg="Ncurses library"
screen_msg="NCurses"
AC_DEFINE(USE_NCURSES, 1,
[Define to use ncurses for screen management])
else
@ -127,7 +127,7 @@ AC_DEFUN([mc_WITH_NCURSES], [
fi
screen_type=ncurses
screen_msg="Ncurses library"
screen_msg="NCurses"
AC_DEFINE(USE_NCURSES, 1,
[Define to use ncurses for screen management])
fi
@ -177,7 +177,7 @@ AC_DEFUN([mc_WITH_NCURSESW], [
fi
screen_type=ncursesw
screen_msg="Ncursesw library"
screen_msg="NCursesw"
AC_DEFINE(USE_NCURSESW, 1,
[Define to use ncursesw for screen management])

View File

@ -137,9 +137,6 @@ int main (void)
fi
if test x"$found_slang" = x"yes"; then
screen_type=slang
screen_msg="S-Lang library"
MCLIBS="$ac_slang_lib_path -lslang $MCLIBS"
dnl do not reset CPPFLAGS
dnl if CPPFLAGS are reset then cpp does not find the specified header
@ -206,6 +203,8 @@ AC_DEFUN([mc_WITH_SLANG], [
fi
fi
screen_type=slang
screen_msg="S-Lang"
AC_DEFINE(HAVE_SLANG, 1, [Define to use S-Lang library for screen management])
mc_CHECK_SLANG_HEADER

View File

@ -31,16 +31,16 @@
extensions=7z;Z;ace;arc;arj;ark;bz2;cab;gz;lha;lz;lz4;lzh;lzma;rar;rpm;tar;tbz;tbz2;tgz;tlz;xz;zip;zoo
[doc]
extensions=chm;css;ctl;diz;doc;docm;docx;dtd;htm;html;letter;lsm;mail;man;me;msg;nroff;pdf;po;pptm;pptx;ps;rtf;sgml;shtml;tex;text;txt;xlsm;xlsx;xml;xsd;xslt
extensions=chm;css;ctl;diz;doc;docm;docx;dtd;htm;html;letter;lsm;mail;man;me;msg;nroff;odp;ods;odt;pdf;po;ppt;pptm;pptx;ps;rtf;sgml;shtml;tex;text;txt;xls;xlsm;xlsx;xml;xsd;xslt
[source]
extensions=ada;asm;awk;bash;c;caml;cc;cgi;cpp;cxx;diff;erl;h;hh;hi;hpp;hs;inc;jasm;jav;java;js;m4;mak;ml;mli;mll;mlp;mly;pas;patch;php;phps;pl;pm;prg;py;sas;sh;sl;st;tcl;tk
extensions=ada;asm;awk;bash;c;caml;cc;cgi;cpp;cxx;diff;erl;h;hh;hi;hpp;hs;inc;jasm;jav;java;js;m4;mak;ml;mli;mll;mlp;mly;pas;patch;php;phps;pl;pm;prg;py;rb;sas;sh;sl;st;tcl;tk;xq
[media]
extensions=3gp;ape;asf;avi;flac;flv;it;m3u;med;mid;midi;mkv;mod;mol;mov;mp2;mp3;mp4;mpeg;mpg;mpl;ogg;ogv;s3m;umx;vob;wav;webm;wma;wmv;xm
[graph]
extensions=ai;bmp;cdr;eps;gif;ico;jpeg;jpg;omf;pcx;pic;png;rle;tif;wmf;xbm;xpm
extensions=ai;bmp;cdr;eps;gif;ico;jpeg;jpg;omf;pcx;pic;png;rle;svg;tif;tiff;webp;wmf;xbm;xcf;xpm
[database]
extensions=cdx;dat;db;dbf;dbi;dbx;fox;mdb;mdn;mdx;msql;mssql;pgsql;sql;ssql;xls
extensions=cdx;dat;db;dbf;dbi;dbx;fox;mdb;mdn;mdx;msql;mssql;pgsql;sql;ssql

View File

@ -2,9 +2,14 @@
#
# Authors:
# lol_zimmerli%headbanger.ch@mail.headbanger.ch, 1999
#
# 2016-03-21 Konrad Twardowski
# * Added missing keywords: _ assert strictfp
context default
keyword whole _ yellow
keyword whole abstract yellow
keyword whole assert yellow
keyword whole boolean yellow
keyword whole break yellow
keyword whole byte yellow
@ -58,6 +63,7 @@ context default
keyword whole return yellow
keyword whole short yellow
keyword whole static yellow
keyword whole strictfp yellow
keyword whole super yellow
keyword whole switch yellow
keyword whole synchronized yellow

File diff suppressed because it is too large Load Diff

View File

@ -177,7 +177,7 @@ static const GOptionEntry argument_main_table[] = {
{
/* handle arguments manually */
"view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
parse_mc_v_argument,
(gpointer) parse_mc_v_argument,
N_("Launches the file viewer on a file"),
"<file>"
},
@ -185,7 +185,7 @@ static const GOptionEntry argument_main_table[] = {
{
/* handle arguments manually */
"edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
parse_mc_e_argument,
(gpointer) parse_mc_e_argument,
N_("Edit files"),
"<file> ..." },

View File

@ -209,7 +209,7 @@ handle_console_linux (console_action_t action)
char *mc_conssaver;
/* Exec the console save/restore handler */
mc_conssaver = mc_build_filename (SAVERDIR, "cons.saver", NULL);
mc_conssaver = mc_build_filename (SAVERDIR, "cons.saver", (char *) NULL);
execl (mc_conssaver, "cons.saver", tty_name, (char *) NULL);
}
/* Console is not a tty or execl() failed */

View File

@ -554,20 +554,19 @@ p_close (FBUF * fs)
/**
* Get one char (byte) from string
*
* @param char * str, gboolean * result
* @return int as character or 0 and result == FALSE if fail
* @param str ...
* @param ch ...
* @return TRUE on success, FALSE otherwise
*/
static int
dview_get_byte (char *str, gboolean * result)
static gboolean
dview_get_byte (const char *str, int *ch)
{
if (str == NULL)
{
*result = FALSE;
return 0;
}
*result = TRUE;
return (unsigned char) *str;
return FALSE;
*ch = (unsigned char) (*str);
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
@ -576,40 +575,35 @@ dview_get_byte (char *str, gboolean * result)
/**
* Get utf multibyte char from string
*
* @param char * str, int * char_length, gboolean * result
* @return int as utf character or 0 and result == FALSE if fail
* @param str ...
* @param ch ...
* @param ch_length ...
* @return TRUE on success, FALSE otherwise
*/
static int
dview_get_utf (const char *str, int *char_length, gboolean * result)
static gboolean
dview_get_utf (const char *str, int *ch, int *ch_length)
{
int res = -1;
gunichar ch;
int ch_len = 0;
*result = TRUE;
if (str == NULL)
return FALSE;
*ch = g_utf8_get_char_validated (str, -1);
if (*ch < 0)
{
*result = FALSE;
return 0;
*ch = (unsigned char) (*str);
*ch_length = 1;
}
res = g_utf8_get_char_validated (str, -1);
if (res < 0)
ch = *str;
else
{
gchar *next_ch;
char *next_ch;
ch = res;
/* Calculate UTF-8 char length */
next_ch = g_utf8_next_char (str);
ch_len = next_ch - str;
*ch_length = next_ch - str;
}
*char_length = ch_len;
return ch;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
@ -644,7 +638,7 @@ dview_str_utf8_offset_to_pos (const char *text, size_t length)
result = g_utf8_offset_to_pointer (tmpbuf, length) - tmpbuf;
g_free (buffer);
}
return max (length, (size_t) result);
return MAX (length, (size_t) result);
}
#endif /*HAVE_CHARSET */
@ -1414,13 +1408,13 @@ cvt_mget (const char *src, size_t srcsize, char *dst, int dstsize, int skip, int
else if (skip > 0)
{
#ifdef HAVE_CHARSET
gboolean res;
int ch_len = 1;
int ch = 0;
int ch_length = 1;
(void) dview_get_utf ((char *) src, &ch_len, &res);
(void) dview_get_utf (src, &ch, &ch_length);
if (ch_len > 1)
skip += ch_len - 1;
if (ch_length > 1)
skip += ch_length - 1;
#endif
skip--;
@ -1517,12 +1511,12 @@ cvt_mgeta (const char *src, size_t srcsize, char *dst, int dstsize, int skip, in
else if (skip != 0)
{
#ifdef HAVE_CHARSET
gboolean res;
int ch_len = 1;
int ch = 0;
int ch_length = 1;
(void) dview_get_utf ((char *) src, &ch_len, &res);
if (ch_len > 1)
skip += ch_len - 1;
(void) dview_get_utf (src, &ch, &ch_length);
if (ch_length > 1)
skip += ch_length - 1;
#endif
skip--;
@ -1573,7 +1567,7 @@ cvt_fget (FBUF * f, off_t off, char *dst, size_t dstsize, int skip, int ts, gboo
size_t sz;
int lastch = '\0';
const char *q = NULL;
char tmp[BUFSIZ]; /* XXX capacity must be >= max{dstsize + 1, amount} */
char tmp[BUFSIZ]; /* XXX capacity must be >= MAX{dstsize + 1, amount} */
char cvt[BUFSIZ]; /* XXX capacity must be >= MAX_TAB_WIDTH * amount */
if (sizeof (tmp) < amount || sizeof (tmp) <= dstsize || sizeof (cvt) < 8 * amount)
@ -2022,9 +2016,9 @@ get_current_hunk (WDiff * dview, int *start_line1, int *end_line1, int *start_li
l0 = ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->line;
l1 = ((DIFFLN *) & g_array_index (a1, DIFFLN, pos))->line;
if (l0 > 0)
*end_line1 = max (*start_line1, l0);
*end_line1 = MAX (*start_line1, l0);
if (l1 > 0)
*end_line2 = max (*start_line2, l1);
*end_line2 = MAX (*start_line2, l1);
pos++;
}
}
@ -2570,7 +2564,7 @@ dview_display_file (const WDiff * dview, diff_place_t ord, int r, int c, int hei
for (i = dview->skip_rows, j = 0; i < dview->a[ord]->len && j < height; j++, i++)
{
int ch, next_ch, col;
int ch, next_ch = 0, col;
size_t cnt;
p = (DIFFLN *) & g_array_index (dview->a[ord], DIFFLN, i);
@ -2620,17 +2614,17 @@ dview_display_file (const WDiff * dview, diff_place_t ord, int r, int c, int hei
#ifdef HAVE_CHARSET
if (dview->utf8)
{
int ch_len = 0;
int ch_length = 0;
next_ch = dview_get_utf (buf + cnt, &ch_len, &ch_res);
if (ch_len > 1)
cnt += ch_len - 1;
ch_res = dview_get_utf (buf + cnt, &next_ch, &ch_length);
if (ch_length > 1)
cnt += ch_length - 1;
if (!g_unichar_isprint (next_ch))
next_ch = '.';
}
else
#endif
next_ch = dview_get_byte (buf + cnt, &ch_res);
ch_res = dview_get_byte (buf + cnt, &next_ch);
if (ch_res)
{
@ -2697,17 +2691,18 @@ dview_display_file (const WDiff * dview, diff_place_t ord, int r, int c, int hei
#ifdef HAVE_CHARSET
if (dview->utf8)
{
int ch_len = 0;
int ch_length = 0;
next_ch = dview_get_utf (buf + cnt, &ch_len, &ch_res);
if (ch_len > 1)
cnt += ch_len - 1;
ch_res = dview_get_utf (buf + cnt, &next_ch, &ch_length);
if (ch_length > 1)
cnt += ch_length - 1;
if (!g_unichar_isprint (next_ch))
next_ch = '.';
}
else
#endif
next_ch = dview_get_byte (buf + cnt, &ch_res);
ch_res = dview_get_byte (buf + cnt, &next_ch);
if (ch_res)
{
#ifdef HAVE_CHARSET
@ -3011,23 +3006,24 @@ dview_do_save (WDiff * dview)
static void
dview_save_options (WDiff * dview)
{
mc_config_set_bool (mc_main_config, "DiffView", "show_symbols",
dview->display_symbols != 0 ? TRUE : FALSE);
mc_config_set_bool (mc_main_config, "DiffView", "show_numbers",
dview->display_numbers != 0 ? TRUE : FALSE);
mc_config_set_int (mc_main_config, "DiffView", "tab_size", dview->tab_size);
mc_config_set_bool (mc_global.main_config, "DiffView", "show_symbols",
dview->display_symbols != 0);
mc_config_set_bool (mc_global.main_config, "DiffView", "show_numbers",
dview->display_numbers != 0);
mc_config_set_int (mc_global.main_config, "DiffView", "tab_size", dview->tab_size);
mc_config_set_int (mc_main_config, "DiffView", "diff_quality", dview->opt.quality);
mc_config_set_int (mc_global.main_config, "DiffView", "diff_quality", dview->opt.quality);
mc_config_set_bool (mc_main_config, "DiffView", "diff_ignore_tws",
mc_config_set_bool (mc_global.main_config, "DiffView", "diff_ignore_tws",
dview->opt.strip_trailing_cr);
mc_config_set_bool (mc_main_config, "DiffView", "diff_ignore_all_space",
mc_config_set_bool (mc_global.main_config, "DiffView", "diff_ignore_all_space",
dview->opt.ignore_all_space);
mc_config_set_bool (mc_main_config, "DiffView", "diff_ignore_space_change",
mc_config_set_bool (mc_global.main_config, "DiffView", "diff_ignore_space_change",
dview->opt.ignore_space_change);
mc_config_set_bool (mc_main_config, "DiffView", "diff_tab_expansion",
mc_config_set_bool (mc_global.main_config, "DiffView", "diff_tab_expansion",
dview->opt.ignore_tab_expansion);
mc_config_set_bool (mc_main_config, "DiffView", "diff_ignore_case", dview->opt.ignore_case);
mc_config_set_bool (mc_global.main_config, "DiffView", "diff_ignore_case",
dview->opt.ignore_case);
}
/* --------------------------------------------------------------------------------------------- */
@ -3038,30 +3034,30 @@ dview_load_options (WDiff * dview)
gboolean show_numbers, show_symbols;
int tab_size;
show_symbols = mc_config_get_bool (mc_main_config, "DiffView", "show_symbols", FALSE);
show_symbols = mc_config_get_bool (mc_global.main_config, "DiffView", "show_symbols", FALSE);
if (show_symbols)
dview->display_symbols = 1;
show_numbers = mc_config_get_bool (mc_main_config, "DiffView", "show_numbers", FALSE);
show_numbers = mc_config_get_bool (mc_global.main_config, "DiffView", "show_numbers", FALSE);
if (show_numbers)
dview->display_numbers = calc_nwidth ((const GArray * const *) dview->a);
tab_size = mc_config_get_int (mc_main_config, "DiffView", "tab_size", 8);
tab_size = mc_config_get_int (mc_global.main_config, "DiffView", "tab_size", 8);
if (tab_size > 0 && tab_size < 9)
dview->tab_size = tab_size;
else
dview->tab_size = 8;
dview->opt.quality = mc_config_get_int (mc_main_config, "DiffView", "diff_quality", 0);
dview->opt.quality = mc_config_get_int (mc_global.main_config, "DiffView", "diff_quality", 0);
dview->opt.strip_trailing_cr =
mc_config_get_bool (mc_main_config, "DiffView", "diff_ignore_tws", FALSE);
mc_config_get_bool (mc_global.main_config, "DiffView", "diff_ignore_tws", FALSE);
dview->opt.ignore_all_space =
mc_config_get_bool (mc_main_config, "DiffView", "diff_ignore_all_space", FALSE);
mc_config_get_bool (mc_global.main_config, "DiffView", "diff_ignore_all_space", FALSE);
dview->opt.ignore_space_change =
mc_config_get_bool (mc_main_config, "DiffView", "diff_ignore_space_change", FALSE);
mc_config_get_bool (mc_global.main_config, "DiffView", "diff_ignore_space_change", FALSE);
dview->opt.ignore_tab_expansion =
mc_config_get_bool (mc_main_config, "DiffView", "diff_tab_expansion", FALSE);
mc_config_get_bool (mc_global.main_config, "DiffView", "diff_tab_expansion", FALSE);
dview->opt.ignore_case =
mc_config_get_bool (mc_main_config, "DiffView", "diff_ignore_case", FALSE);
mc_config_get_bool (mc_global.main_config, "DiffView", "diff_ignore_case", FALSE);
dview->new_frame = TRUE;
}
@ -3542,7 +3538,8 @@ dview_diff_cmd (const void *f0, const void *f1)
const WPanel *panel0 = (const WPanel *) f0;
const WPanel *panel1 = (const WPanel *) f1;
file0 = vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname, NULL);
file0 =
vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname, (char *) NULL);
is_dir0 = S_ISDIR (selection (panel0)->st.st_mode);
if (is_dir0)
{
@ -3551,7 +3548,8 @@ dview_diff_cmd (const void *f0, const void *f1)
goto ret;
}
file1 = vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname, NULL);
file1 =
vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname, (char *) NULL);
is_dir1 = S_ISDIR (selection (panel1)->st.st_mode);
if (is_dir1)
{

View File

@ -194,7 +194,7 @@ void edit_mark_current_word_cmd (WEdit * edit);
void edit_mark_current_line_cmd (WEdit * edit);
void edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2);
void edit_push_markers (WEdit * edit);
void edit_replace_cmd (WEdit * edit, int again);
void edit_replace_cmd (WEdit * edit, gboolean again);
void edit_search_cmd (WEdit * edit, gboolean again);
mc_search_cbret_t edit_search_cmd_callback (const void *user_data, gsize char_offset,
int *current_char);

View File

@ -49,6 +49,7 @@
#include "lib/tty/tty.h" /* attrset() */
#include "lib/tty/key.h" /* is_idle() */
#include "lib/skin.h" /* EDITOR_NORMAL_COLOR */
#include "lib/fileloc.h" /* EDIT_BLOCK_FILE */
#include "lib/vfs/vfs.h"
#include "lib/strutil.h" /* utf string functions */
#include "lib/util.h" /* load_file_position(), save_file_position() */
@ -158,7 +159,7 @@ edit_load_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
rsm->first = FALSE;
@ -710,12 +711,12 @@ edit_find_line (WEdit * edit, long line)
i = 3 + (rand () % (N_LINE_CACHES - 3));
if (line > edit->line_numbers[j])
edit->line_offsets[i] =
edit_buffer_move_forward (&edit->buffer, edit->line_offsets[j],
line - edit->line_numbers[j], 0);
edit_buffer_get_forward_offset (&edit->buffer, edit->line_offsets[j],
line - edit->line_numbers[j], 0);
else
edit->line_offsets[i] =
edit_buffer_move_backward (&edit->buffer, edit->line_offsets[j],
edit->line_numbers[j] - line);
edit_buffer_get_backward_offset (&edit->buffer, edit->line_offsets[j],
edit->line_numbers[j] - line);
edit->line_numbers[i] = line;
return edit->line_offsets[i];
}
@ -798,7 +799,7 @@ static void
edit_begin_page (WEdit * edit)
{
edit_update_curs_row (edit);
edit_move_up (edit, edit->curs_row, 0);
edit_move_up (edit, edit->curs_row, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
@ -807,7 +808,7 @@ static void
edit_end_page (WEdit * edit)
{
edit_update_curs_row (edit);
edit_move_down (edit, WIDGET (edit)->lines - edit->curs_row - 1, 0);
edit_move_down (edit, WIDGET (edit)->lines - edit->curs_row - 1, FALSE);
}
@ -835,7 +836,7 @@ edit_move_to_bottom (WEdit * edit)
{
if (edit->buffer.curs_line < edit->buffer.lines)
{
edit_move_down (edit, edit->buffer.lines - edit->curs_row, 0);
edit_move_down (edit, edit->buffer.lines - edit->curs_row, FALSE);
edit->start_display = edit->buffer.size;
edit->start_line = edit->buffer.lines;
edit_scroll_upward (edit, WIDGET (edit)->lines - 1);
@ -1067,8 +1068,8 @@ edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean directi
edit_scroll_downward (edit, lines);
}
p = edit_buffer_get_current_bol (&edit->buffer);
p = direction ? edit_buffer_move_backward (&edit->buffer, p, lines) :
edit_buffer_move_forward (&edit->buffer, p, lines, 0);
p = direction ? edit_buffer_get_backward_offset (&edit->buffer, p, lines) :
edit_buffer_get_forward_offset (&edit->buffer, p, lines, 0);
edit_cursor_move (edit, p - edit->buffer.curs1);
edit_move_to_prev_col (edit, p);
@ -1382,7 +1383,7 @@ edit_auto_indent (WEdit * edit)
p = edit->buffer.curs1;
/* use the previous line as a template */
p = edit_buffer_move_backward (&edit->buffer, p, 1);
p = edit_buffer_get_backward_offset (&edit->buffer, p, 1);
/* copy the leading whitespace of the line */
while (TRUE)
{ /* no range check - the line _is_ \n-terminated */
@ -2527,9 +2528,6 @@ edit_insert (WEdit * edit, int c)
edit->last_get_rule += (edit->last_get_rule > edit->buffer.curs1) ? 1 : 0;
edit_buffer_insert (&edit->buffer, c);
/* update file length */
edit->buffer.size++;
}
/* --------------------------------------------------------------------------------------------- */
@ -2562,8 +2560,6 @@ edit_insert_ahead (WEdit * edit, int c)
edit->last_get_rule += (edit->last_get_rule >= edit->buffer.curs1) ? 1 : 0;
edit_buffer_insert_ahead (&edit->buffer, c);
edit->buffer.size++;
}
/* --------------------------------------------------------------------------------------------- */
@ -2620,7 +2616,6 @@ edit_delete (WEdit * edit, gboolean byte_delete)
p = edit_buffer_delete (&edit->buffer);
edit->buffer.size--;
edit_push_undo_action (edit, p + 256);
}
@ -2681,7 +2676,6 @@ edit_backspace (WEdit * edit, gboolean byte_delete)
p = edit_buffer_backspace (&edit->buffer);
edit->buffer.size--;
edit_push_undo_action (edit, p);
}
edit_modification (edit);
@ -2868,7 +2862,8 @@ edit_scroll_upward (WEdit * edit, long i)
if (i != 0)
{
edit->start_line -= i;
edit->start_display = edit_buffer_move_backward (&edit->buffer, edit->start_display, i);
edit->start_display =
edit_buffer_get_backward_offset (&edit->buffer, edit->start_display, i);
edit->force |= REDRAW_PAGE;
edit->force &= (0xfff - REDRAW_CHAR_ONLY);
}
@ -2889,7 +2884,8 @@ edit_scroll_downward (WEdit * edit, long i)
if (i > lines_below)
i = lines_below;
edit->start_line += i;
edit->start_display = edit_buffer_move_forward (&edit->buffer, edit->start_display, i, 0);
edit->start_display =
edit_buffer_get_forward_offset (&edit->buffer, edit->start_display, i, 0);
edit->force |= REDRAW_PAGE;
edit->force &= (0xfff - REDRAW_CHAR_ONLY);
}
@ -3003,9 +2999,9 @@ void
edit_move_to_line (WEdit * e, long line)
{
if (line < e->buffer.curs_line)
edit_move_up (e, e->buffer.curs_line - line, 0);
edit_move_up (e, e->buffer.curs_line - line, FALSE);
else
edit_move_down (e, line - e->buffer.curs_line, 0);
edit_move_down (e, line - e->buffer.curs_line, FALSE);
edit_scroll_screen_over_cursor (e);
}
@ -3103,7 +3099,7 @@ edit_mark_current_word_cmd (WEdit * edit)
if ((my_type_of (c1) & my_type_of (c2)) == 0)
break;
}
edit->mark2 = min (pos + 1, edit->buffer.size);
edit->mark2 = MIN (pos + 1, edit->buffer.size);
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
}
@ -3527,13 +3523,13 @@ edit_execute_cmd (WEdit * edit, long command, int char_for_insertion)
edit->column_highlight = 1;
case CK_PageUp:
case CK_MarkPageUp:
edit_move_up (edit, w->lines - 1, 1);
edit_move_up (edit, w->lines - 1, TRUE);
break;
case CK_MarkColumnPageDown:
edit->column_highlight = 1;
case CK_PageDown:
case CK_MarkPageDown:
edit_move_down (edit, w->lines - 1, 1);
edit_move_down (edit, w->lines - 1, TRUE);
break;
case CK_MarkColumnLeft:
edit->column_highlight = 1;
@ -3584,37 +3580,37 @@ edit_execute_cmd (WEdit * edit, long command, int char_for_insertion)
edit->column_highlight = 1;
case CK_Up:
case CK_MarkUp:
edit_move_up (edit, 1, 0);
edit_move_up (edit, 1, FALSE);
break;
case CK_MarkColumnDown:
edit->column_highlight = 1;
case CK_Down:
case CK_MarkDown:
edit_move_down (edit, 1, 0);
edit_move_down (edit, 1, FALSE);
break;
case CK_MarkColumnParagraphUp:
edit->column_highlight = 1;
case CK_ParagraphUp:
case CK_MarkParagraphUp:
edit_move_up_paragraph (edit, 0);
edit_move_up_paragraph (edit, FALSE);
break;
case CK_MarkColumnParagraphDown:
edit->column_highlight = 1;
case CK_ParagraphDown:
case CK_MarkParagraphDown:
edit_move_down_paragraph (edit, 0);
edit_move_down_paragraph (edit, FALSE);
break;
case CK_MarkColumnScrollUp:
edit->column_highlight = 1;
case CK_ScrollUp:
case CK_MarkScrollUp:
edit_move_up (edit, 1, 1);
edit_move_up (edit, 1, TRUE);
break;
case CK_MarkColumnScrollDown:
edit->column_highlight = 1;
case CK_ScrollDown:
case CK_MarkScrollDown:
edit_move_down (edit, 1, 1);
edit_move_down (edit, 1, TRUE);
break;
case CK_Home:
case CK_MarkToHome:
@ -3819,10 +3815,10 @@ edit_execute_cmd (WEdit * edit, long command, int char_for_insertion)
edit_search_cmd (edit, TRUE);
break;
case CK_Replace:
edit_replace_cmd (edit, 0);
edit_replace_cmd (edit, FALSE);
break;
case CK_ReplaceContinue:
edit_replace_cmd (edit, 1);
edit_replace_cmd (edit, TRUE);
break;
case CK_Complete:
/* if text marked shift block */

View File

@ -14,7 +14,6 @@
#define MC__EDIT_H
#include "lib/global.h" /* PATH_SEP_STR */
#include "lib/fileloc.h"
#include "lib/vfs/vfs.h" /* vfs_path_t */
/*** typedefs(not structures) and defined constants **********************************************/

View File

@ -330,8 +330,8 @@ edit_buffer_count_lines (const edit_buffer_t * buf, off_t first, off_t last)
{
long lines = 0;
first = max (first, 0);
last = min (last, buf->size);
first = MAX (first, 0);
last = MIN (last, buf->size);
while (first < last)
if (edit_buffer_get_byte (buf, first++) == '\n')
@ -457,6 +457,9 @@ edit_buffer_insert (edit_buffer_t * buf, int c)
/* update cursor position */
buf->curs1++;
/* update file length */
buf->size++;
}
/* --------------------------------------------------------------------------------------------- */
@ -486,6 +489,9 @@ edit_buffer_insert_ahead (edit_buffer_t * buf, int c)
/* update cursor position */
buf->curs2++;
/* update file length */
buf->size++;
}
/* --------------------------------------------------------------------------------------------- */
@ -523,6 +529,9 @@ edit_buffer_delete (edit_buffer_t * buf)
buf->curs2 = prev;
/* update file length */
buf->size--;
return c;
}
@ -561,6 +570,9 @@ edit_buffer_backspace (edit_buffer_t * buf)
buf->curs1 = prev;
/* update file length */
buf->size--;
return c;
}
@ -579,12 +591,12 @@ edit_buffer_backspace (edit_buffer_t * buf)
*/
off_t
edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines, off_t upto)
edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long lines, off_t upto)
{
if (upto != 0)
return (off_t) edit_buffer_count_lines (buf, current, upto);
lines = max (lines, 0);
lines = MAX (lines, 0);
while (lines-- != 0)
{
@ -611,9 +623,9 @@ edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines,
*/
off_t
edit_buffer_move_backward (const edit_buffer_t * buf, off_t current, long lines)
edit_buffer_get_backward_offset (const edit_buffer_t * buf, off_t current, long lines)
{
lines = max (lines, 0);
lines = MAX (lines, 0);
current = edit_buffer_get_bol (buf, current);
while (lines-- != 0 && current != 0)

View File

@ -54,8 +54,9 @@ void edit_buffer_insert_ahead (edit_buffer_t * buf, int c);
int edit_buffer_delete (edit_buffer_t * buf);
int edit_buffer_backspace (edit_buffer_t * buf);
off_t edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines, off_t upto);
off_t edit_buffer_move_backward (const edit_buffer_t * buf, off_t current, long lines);
off_t edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long lines,
off_t upto);
off_t edit_buffer_get_backward_offset (const edit_buffer_t * buf, off_t current, long lines);
off_t edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size,
edit_buffer_read_file_status_msg_t * sm, gboolean * aborted);

View File

@ -55,6 +55,7 @@
#include "lib/mcconfig.h"
#include "lib/skin.h"
#include "lib/strutil.h" /* utf string functions */
#include "lib/fileloc.h"
#include "lib/lock.h"
#include "lib/util.h" /* tilde_expand() */
#include "lib/vfs/vfs.h"
@ -144,7 +145,7 @@ edit_search_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
esm->first = FALSE;
@ -279,7 +280,7 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
savedir = g_strdup (".");
/* Token-related function never return leading slash, so we need add it manually */
saveprefix = mc_build_filename (PATH_SEP_STR, savedir, "cooledit", NULL);
saveprefix = mc_build_filename (PATH_SEP_STR, savedir, "cooledit", (char *) NULL);
g_free (savedir);
fd = mc_mkstemps (&savename_vpath, saveprefix, NULL);
g_free (saveprefix);
@ -542,11 +543,11 @@ edit_delete_column_of_text (WEdit * edit)
long b, c, d;
eval_marks (edit, &m1, &m2);
n = edit_buffer_move_forward (&edit->buffer, m1, 0, m2) + 1;
n = edit_buffer_get_forward_offset (&edit->buffer, m1, 0, m2) + 1;
c = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m1), 0, m1);
d = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m2), 0, m2);
b = max (min (c, d), min (edit->column1, edit->column2));
c = max (c, max (edit->column1, edit->column2));
b = MAX (MIN (c, d), MIN (edit->column1, edit->column2));
c = MAX (c, MAX (edit->column1, edit->column2));
while (n--)
{
@ -568,8 +569,8 @@ edit_delete_column_of_text (WEdit * edit)
if (n)
/* move to next line except on the last delete */
edit_cursor_move (edit,
edit_buffer_move_forward (&edit->buffer, edit->buffer.curs1, 1,
0) - edit->buffer.curs1);
edit_buffer_get_forward_offset (&edit->buffer, edit->buffer.curs1, 1,
0) - edit->buffer.curs1);
}
}
@ -600,8 +601,8 @@ edit_block_delete (WEdit * edit)
return 1;
}
}
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
edit->column1 = c1;
edit->column2 = c2;
@ -857,7 +858,7 @@ editcmd_find (edit_search_status_msg_t * esm, gsize * len)
else
{
if (edit_search_options.backwards)
end_mark = max (1, edit->buffer.curs1) - 1;
end_mark = MAX (1, edit->buffer.curs1) - 1;
}
/* search */
@ -1234,7 +1235,7 @@ edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
return 0;
entire_file =
mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION,
mc_config_get_bool (mc_global.main_config, CONFIG_APP_SECTION,
"editor_wordcompletion_collect_entire_file", 0);
last_byte = entire_file ? edit->buffer.size : word_start;
@ -1287,7 +1288,7 @@ edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
{
if (strncmp
((char *) &compl[i]->str[word_len],
(char *) &temp->str[word_len], max (len, compl[i]->len) - word_len) == 0)
(char *) &temp->str[word_len], MAX (len, compl[i]->len) - word_len) == 0)
{
GString *this = compl[i];
for (++i; i < *num; i++)
@ -2178,11 +2179,13 @@ edit_load_menu_file (WDialog * h)
_("Which menu file do you want to edit?"), D_NORMAL,
geteuid () != 0 ? 2 : 3, _("&Local"), _("&User"), _("&System wide"));
menufile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU, NULL);
menufile_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU, (char *) NULL);
if (!exist_file (vfs_path_get_last_path_str (menufile_vpath)))
{
vfs_path_free (menufile_vpath);
menufile_vpath = vfs_path_build_filename (mc_global.share_data_dir, EDIT_GLOBAL_MENU, NULL);
menufile_vpath =
vfs_path_build_filename (mc_global.share_data_dir, EDIT_GLOBAL_MENU, (char *) NULL);
}
switch (dir)
@ -2199,12 +2202,13 @@ edit_load_menu_file (WDialog * h)
break;
case 2:
buffer_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU, NULL);
buffer_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU, (char *) NULL);
if (!exist_file (vfs_path_get_last_path_str (buffer_vpath)))
{
vfs_path_free (buffer_vpath);
buffer_vpath =
vfs_path_build_filename (mc_global.share_data_dir, EDIT_GLOBAL_MENU, NULL);
vfs_path_build_filename (mc_global.share_data_dir, EDIT_GLOBAL_MENU, (char *) NULL);
}
break;
@ -2286,13 +2290,13 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
if (edit->mark2 >= 0)
{
*start_mark = min (edit->mark1, edit->mark2);
*end_mark = max (edit->mark1, edit->mark2);
*start_mark = MIN (edit->mark1, edit->mark2);
*end_mark = MAX (edit->mark1, edit->mark2);
}
else
{
*start_mark = min (edit->mark1, end_mark_curs);
*end_mark = max (edit->mark1, end_mark_curs);
*start_mark = MIN (edit->mark1, end_mark_curs);
*end_mark = MAX (edit->mark1, end_mark_curs);
edit->column2 = edit->curs_col + edit->over_col;
}
@ -2309,8 +2313,8 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
start_eol = edit_buffer_get_eol (&edit->buffer, start_bol - 1) + 1;
end_bol = edit_buffer_get_bol (&edit->buffer, *end_mark);
end_eol = edit_buffer_get_eol (&edit->buffer, *end_mark);
col1 = min (edit->column1, edit->column2);
col2 = max (edit->column1, edit->column2);
col1 = MIN (edit->column1, edit->column2);
col2 = MAX (edit->column1, edit->column2);
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
edit_move_forward3 (edit, start_bol, col1, 0);
@ -2319,8 +2323,8 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
*start_mark -= diff1;
*end_mark += diff2;
*start_mark = max (*start_mark, start_eol);
*end_mark = min (*end_mark, end_eol);
*start_mark = MAX (*start_mark, start_eol);
*end_mark = MIN (*end_mark, end_eol);
}
return TRUE;
}
@ -2403,8 +2407,8 @@ edit_block_move_cmd (WEdit * edit)
long c1, c2, b_width;
long x, x2;
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
b_width = c2 - c1;
edit_update_curs_col (edit);
@ -2431,7 +2435,7 @@ edit_block_move_cmd (WEdit * edit)
/* remove current selection */
edit_block_delete_cmd (edit);
edit->over_col = max (0, edit->over_col - b_width);
edit->over_col = MAX (0, edit->over_col - b_width);
/* calculate the cursor pos after delete block */
current = edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), x, 0);
edit_cursor_move (edit, current - edit->buffer.curs1);
@ -2497,7 +2501,7 @@ edit_block_delete_cmd (WEdit * edit)
/** call with edit = 0 before shutdown to close memory leaks */
void
edit_replace_cmd (WEdit * edit, int again)
edit_replace_cmd (WEdit * edit, gboolean again)
{
/* 1 = search string, 2 = replace with */
static char *saved1 = NULL; /* saved default[123] */
@ -2521,7 +2525,7 @@ edit_replace_cmd (WEdit * edit, int again)
edit->force |= REDRAW_COMPLETELY;
if (again && !saved1 && !saved2)
again = 0;
again = FALSE;
if (again)
{
@ -2936,7 +2940,7 @@ edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish)
buf = g_malloc0 (TEMP_BUF_LEN);
while (start != finish)
{
end = min (finish, start + TEMP_BUF_LEN);
end = MIN (finish, start + TEMP_BUF_LEN);
for (; i < end; i++)
buf[i - start] = edit_buffer_get_byte (&edit->buffer, i);
len -= mc_write (file, (char *) buf, end - start);

View File

@ -317,7 +317,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
w = str_term_width1 (heading) + 6;
wq = str_term_width1 (query);
w = max (w, wq + 3 * 2 + 1 + 2);
w = MAX (w, wq + 3 * 2 + 1 + 2);
raw_dlg =
dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, dialog_colors, editcmd_dialog_raw_key_query_cb,

View File

@ -603,8 +603,8 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
long c1, c2;
x = (long) edit_move_forward3 (edit, b, 0, q);
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
c1 = MIN (edit->column1, edit->column2);
c2 = MAX (edit->column1, edit->column2);
if (x >= c1 && x < c2)
p->style |= MOD_MARKED;
}
@ -918,13 +918,13 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_PAGE) != 0)
{
row = start_row;
b = edit_buffer_move_forward (&edit->buffer, edit->start_display, start_row, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, edit->start_display, start_row, 0);
while (row <= end_row)
{
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
row++;
}
}
@ -943,7 +943,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
}
}
@ -959,13 +959,13 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_AFTER_CURSOR) != 0 && end_row > curs_row)
{
row = curs_row + 1 < start_row ? start_row : curs_row + 1;
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
while (row <= end_row)
{
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
row++;
}
}
@ -973,8 +973,9 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_LINE_ABOVE) != 0 && curs_row >= 1)
{
row = curs_row - 1;
b = edit_buffer_move_backward (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer), 1);
b = edit_buffer_get_backward_offset (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer),
1);
if (row >= start_row && row <= end_row)
{
if (key_pending (edit))
@ -987,7 +988,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
{
row = curs_row + 1;
b = edit_buffer_get_current_bol (&edit->buffer);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
if (row >= start_row && row <= end_row)
{
if (key_pending (edit))
@ -1091,8 +1092,8 @@ edit_scroll_screen_over_cursor (WEdit * edit)
t_extreme = EDIT_TOP_EXTREME;
if (edit->found_len != 0)
{
b_extreme = max (w->lines / 4, b_extreme);
t_extreme = max (w->lines / 4, t_extreme);
b_extreme = MAX (w->lines / 4, b_extreme);
t_extreme = MAX (w->lines / 4, t_extreme);
}
if (b_extreme + t_extreme + 1 > w->lines)
{

View File

@ -45,6 +45,7 @@
#include "lib/tty/key.h" /* is_idle() */
#include "lib/tty/color.h" /* tty_setcolor() */
#include "lib/skin.h"
#include "lib/fileloc.h" /* EDIT_DIR */
#include "lib/strutil.h" /* str_term_trim() */
#include "lib/util.h" /* mc_build_filename() */
#include "lib/widget.h"
@ -326,7 +327,7 @@ edit_window_list (const WDialog * h)
int i = 0;
int rv;
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
lines = MIN ((size_t) (LINES * 2 / 3), dlg_num);
cols = COLS * 2 / 3;
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
@ -735,9 +736,9 @@ edit_update_cursor (WEdit * edit, const mouse_event_t * event)
}
if (y > edit->curs_row)
edit_move_down (edit, y - edit->curs_row, 0);
edit_move_down (edit, y - edit->curs_row, FALSE);
else if (y < edit->curs_row)
edit_move_up (edit, edit->curs_row - y, 0);
edit_move_up (edit, edit->curs_row - y, FALSE);
else
edit_move_to_prev_col (edit, edit_buffer_get_current_bol (&edit->buffer));
@ -1044,8 +1045,8 @@ edit_mouse_handle_move_resize (Widget * w, mouse_msg_t msg, mouse_event_t * even
}
else if (edit->drag_state == MCEDIT_DRAG_RESIZE)
{
w->lines = max (WINDOW_MIN_LINES, global_y - w->y + 1);
w->cols = max (WINDOW_MIN_COLS, global_x - w->x + 1);
w->lines = MAX (WINDOW_MIN_LINES, global_y - w->y + 1);
w->cols = MAX (WINDOW_MIN_COLS, global_x - w->x + 1);
}
edit->force |= REDRAW_COMPLETELY; /* Not really needed as WEdit's MSG_DRAW already does this. */
@ -1152,12 +1153,12 @@ edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
break;
case MSG_MOUSE_SCROLL_UP:
edit_move_up (edit, 2, 1);
edit_move_up (edit, 2, TRUE);
edit_total_update (edit);
break;
case MSG_MOUSE_SCROLL_DOWN:
edit_move_down (edit, 2, 1);
edit_move_down (edit, 2, TRUE);
edit_total_update (edit);
break;
@ -1206,15 +1207,15 @@ edit_files (const GList * files)
{
char *dir;
dir = mc_build_filename (mc_config_get_cache_path (), EDIT_DIR, NULL);
dir = mc_build_filename (mc_config_get_cache_path (), EDIT_DIR, (char *) NULL);
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
g_free (dir);
dir = mc_build_filename (mc_config_get_path (), EDIT_DIR, NULL);
dir = mc_build_filename (mc_config_get_path (), EDIT_DIR, (char *) NULL);
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
g_free (dir);
dir = mc_build_filename (mc_config_get_data_path (), EDIT_DIR, NULL);
dir = mc_build_filename (mc_config_get_data_path (), EDIT_DIR, (char *) NULL);
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
g_free (dir);
}

View File

@ -81,9 +81,9 @@ line_start (const edit_buffer_t * buf, long line)
p = buf->curs1;
if (line < l)
p = edit_buffer_move_backward (buf, p, l - line);
p = edit_buffer_get_backward_offset (buf, p, l - line);
else if (line > l)
p = edit_buffer_move_forward (buf, p, line - l, 0);
p = edit_buffer_get_forward_offset (buf, p, line - l, 0);
p = edit_buffer_get_bol (buf, p);
while (strchr ("\t ", edit_buffer_get_byte (buf, p)) != NULL)
@ -136,8 +136,8 @@ begin_paragraph (WEdit * edit, gboolean force, long *lines)
*lines = edit->buffer.curs_line - i;
return edit_buffer_move_backward (&edit->buffer, edit_buffer_get_current_bol (&edit->buffer),
*lines);
return edit_buffer_get_backward_offset (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer), *lines);
}
/* --------------------------------------------------------------------------------------------- */
@ -160,10 +160,10 @@ end_paragraph (WEdit * edit, gboolean force)
}
return edit_buffer_get_eol (&edit->buffer,
edit_buffer_move_forward (&edit->buffer,
edit_buffer_get_current_bol
(&edit->buffer),
i - edit->buffer.curs_line, 0));
edit_buffer_get_forward_offset (&edit->buffer,
edit_buffer_get_current_bol
(&edit->buffer),
i - edit->buffer.curs_line, 0));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -99,15 +99,15 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
cancel_button = button_new (11, 28, B_CANCEL, NORMAL_BUTTON, _("&Cancel"), 0);
cancel_len = button_get_len (cancel_button);
max_btn_len = max (replace_len, skip_len);
max_btn_len = max (max_btn_len, cancel_len);
max_btn_len = MAX (replace_len, skip_len);
max_btn_len = MAX (max_btn_len, cancel_len);
lang_label = g_strdup_printf ("%s: %s", _("Language"), aspell_get_lang ());
word_label = g_strdup_printf ("%s: %s", _("Misspelled"), word);
word_label_len = str_term_width1 (word_label) + 5;
sug_dlg_w += max_btn_len;
sug_dlg_w = max (sug_dlg_w, word_label_len) + 1;
sug_dlg_w = MAX (sug_dlg_w, word_label_len) + 1;
sug_dlg = dlg_create (TRUE, ypos, xpos, sug_dlg_h, sug_dlg_w,
dialog_colors, NULL, NULL, "[ASpell]", _("Check word"), DLG_COMPACT);

View File

@ -56,6 +56,7 @@
#include "lib/global.h"
#include "lib/search.h" /* search engine */
#include "lib/skin.h"
#include "lib/fileloc.h" /* EDIT_DIR, EDIT_SYNTAX_FILE */
#include "lib/strutil.h" /* utf string functions */
#include "lib/util.h"
#include "lib/widget.h" /* message() */

View File

@ -233,7 +233,8 @@ execute_get_opts_from_cfg (const char *command, const char *default_str)
char *str_from_config;
str_from_config =
mc_config_get_string_raw (mc_main_config, CONFIG_EXT_EDITOR_VIEWER_SECTION, command, NULL);
mc_config_get_string_raw (mc_global.main_config, CONFIG_EXT_EDITOR_VIEWER_SECTION, command,
NULL);
if (str_from_config == NULL)
{

View File

@ -836,7 +836,7 @@ chown_advanced_cmd (void)
/* Number of files at startup */
int files_on_begin;
files_on_begin = max (1, current_panel->marked);
files_on_begin = MAX (1, current_panel->marked);
do
{ /* do while any files remaining */

View File

@ -585,7 +585,8 @@ appearance_box (void)
};
if (quick_dialog (&qdlg) == B_ENTER)
mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, "skin", current_skin_name);
mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, "skin",
current_skin_name);
else
skin_apply (NULL);
}
@ -602,7 +603,7 @@ panel_options_box (void)
{
int simple_swap;
simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
simple_swap = mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
"simple_swap", FALSE) ? 1 : 0;
{
const char *qsearch_options[] = {
@ -662,7 +663,7 @@ panel_options_box (void)
return;
}
mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
"simple_swap", (gboolean) (simple_swap & C_BOOL));
if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
@ -700,7 +701,7 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, int *use
for (i = 0; i < LIST_TYPES; i++)
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
section = g_strconcat ("Temporal:", p, (char *) NULL);
if (!mc_config_has_group (mc_main_config, section))
if (!mc_config_has_group (mc_global.main_config, section))
{
g_free (section);
section = g_strdup (p);
@ -1235,7 +1236,7 @@ jobs_cmd (void)
}
x += (int) n_but - 1;
cols = max (cols, x + 6);
cols = MAX (cols, x + 6);
jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, NULL, NULL,
"[Background jobs]", _("Background jobs"), DLG_CENTER);

View File

@ -157,7 +157,7 @@ chmod_i18n (void)
for (i = 0; i < check_perm_num; i++)
{
len = str_term_width1 (check_perm[i].text);
check_perm_len = max (check_perm_len, len);
check_perm_len = MAX (check_perm_len, len);
}
check_perm_len += 1 + 3 + 1; /* mark, [x] and space */
@ -165,7 +165,7 @@ chmod_i18n (void)
for (i = 0; i < file_info_labels_num; i++)
{
len = str_term_width1 (file_info_labels[i]) + 2; /* spaces around */
file_info_labels_len = max (file_info_labels_len, len);
file_info_labels_len = MAX (file_info_labels_len, len);
}
for (i = 0; i < chmod_but_num; i++)
@ -292,7 +292,7 @@ init_chmod (const char *fname, const struct stat *sf_stat)
perm_gb_len = check_perm_len + 2;
file_gb_len = file_info_labels_len + 2;
cols = str_term_width1 (fname) + 2 + 1;
file_gb_len = max (file_gb_len, cols);
file_gb_len = MAX (file_gb_len, cols);
lines = single_set ? 20 : 23;
cols = perm_gb_len + file_gb_len + 1 + 6;

View File

@ -332,8 +332,8 @@ compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode)
{
vfs_path_t *src_name, *dst_name;
src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, NULL);
dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, NULL);
src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, (char *) NULL);
dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, (char *) NULL);
if (compare_files (src_name, dst_name, source->st.st_size))
do_file_mark (panel, i, 1);
vfs_path_free (src_name);
@ -370,10 +370,10 @@ do_link (link_type_t link_type, const char *fname)
/* suggest the full path for symlink, and either the full or
relative path to the file it points to */
s = vfs_path_append_new (current_panel->cwd_vpath, fname, NULL);
s = vfs_path_append_new (current_panel->cwd_vpath, fname, (char *) NULL);
if (get_other_type () == view_listing)
d = vfs_path_append_new (other_panel->cwd_vpath, fname, NULL);
d = vfs_path_append_new (other_panel->cwd_vpath, fname, (char *) NULL);
else
d = vfs_path_from_str (fname);
@ -672,7 +672,7 @@ view_filtered_cmd (void)
char *command;
const char *initial_command;
if (cmdline->buffer[0] == '\0')
if (input_is_empty (cmdline))
initial_command = selection (current_panel)->fname;
else
initial_command = cmdline->buffer;
@ -874,7 +874,7 @@ mkdir_cmd (void)
if (dir[0] == '\\' && dir[1] == '~')
tmpdir = dir + 1;
absdir = vfs_path_append_new (current_panel->cwd_vpath, tmpdir, NULL);
absdir = vfs_path_append_new (current_panel->cwd_vpath, tmpdir, (char *) NULL);
}
save_cwds_stat ();
@ -975,7 +975,7 @@ ext_cmd (void)
_("Which extension file you want to edit?"), D_NORMAL, 2,
_("&User"), _("&System Wide"));
}
extdir_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, NULL);
extdir_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, (char *) NULL);
if (dir == 0)
{
@ -991,7 +991,8 @@ ext_cmd (void)
if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
{
vfs_path_free (extdir_vpath);
extdir_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_LIB_EXT, NULL);
extdir_vpath =
vfs_path_build_filename (mc_global.share_data_dir, MC_LIB_EXT, (char *) NULL);
}
do_edit (extdir_vpath);
}
@ -1014,12 +1015,14 @@ edit_mc_menu_cmd (void)
_("Which menu file do you want to edit?"),
D_NORMAL, geteuid ()? 2 : 3, _("&Local"), _("&User"), _("&System Wide"));
menufile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, NULL);
menufile_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, (char *) NULL);
if (!exist_file (vfs_path_get_last_path_str (menufile_vpath)))
{
vfs_path_free (menufile_vpath);
menufile_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, NULL);
menufile_vpath =
vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, (char *) NULL);
}
switch (dir)
@ -1036,11 +1039,13 @@ edit_mc_menu_cmd (void)
break;
case 2:
buffer_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, NULL);
buffer_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, (char *) NULL);
if (!exist_file (vfs_path_get_last_path_str (buffer_vpath)))
{
vfs_path_free (buffer_vpath);
buffer_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, NULL);
buffer_vpath =
vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, (char *) NULL);
}
break;
@ -1071,7 +1076,8 @@ edit_fhl_cmd (void)
_("Which highlighting file you want to edit?"), D_NORMAL, 2,
_("&User"), _("&System Wide"));
}
fhlfile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL);
fhlfile_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, (char *) NULL);
if (dir == 0)
{
@ -1088,7 +1094,7 @@ edit_fhl_cmd (void)
{
vfs_path_free (fhlfile_vpath);
fhlfile_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL);
vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, (char *) NULL);
}
do_edit (fhlfile_vpath);
}

View File

@ -224,7 +224,7 @@ handle_cdpath (const char *path)
{
vfs_path_t *r_vpath;
r_vpath = vfs_path_build_filename (p, path, NULL);
r_vpath = vfs_path_build_filename (p, path, (char *) NULL);
result = do_cd (r_vpath, cd_parse_command);
vfs_path_free (r_vpath);
}
@ -426,7 +426,9 @@ do_cd_command (char *orig_cmd)
if (IS_PATH_SEP (cmd[operand_pos]))
new_vpath = vfs_path_from_str (cmd + operand_pos);
else
new_vpath = vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos, NULL);
new_vpath =
vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos,
(char *) NULL);
sync_tree (new_vpath);
}

View File

@ -208,7 +208,7 @@ dir_get_dotdot_stat (const vfs_path_t * vpath, struct stat *st)
{
vfs_path_t *tmp_vpath;
tmp_vpath = vfs_path_append_new (vpath, "..", NULL);
tmp_vpath = vfs_path_append_new (vpath, "..", (char *) NULL);
ret = mc_stat (tmp_vpath, st) == 0;
vfs_path_free (tmp_vpath);
}
@ -287,7 +287,7 @@ dir_list_grow (dir_list * list, int delta)
list->size = size;
}
list->len = clear_flag ? 0 : min (list->len, size);
list->len = clear_flag ? 0 : MIN (list->len, size);
return TRUE;
}

View File

@ -805,11 +805,12 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
{
g_free (extension_file);
check_stock_mc_ext:
extension_file = mc_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, NULL);
extension_file = mc_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, (char *) NULL);
if (!exist_file (extension_file))
{
g_free (extension_file);
extension_file = mc_build_filename (mc_global.share_data_dir, MC_LIB_EXT, NULL);
extension_file =
mc_build_filename (mc_global.share_data_dir, MC_LIB_EXT, (char *) NULL);
}
mc_user_ext = FALSE;
}

View File

@ -560,7 +560,7 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, dirsize_status_msg_t * ds
if (DIR_IS_DOT (dirent->d_name) || DIR_IS_DOTDOT (dirent->d_name))
continue;
tmp_vpath = vfs_path_append_new (dirname_vpath, dirent->d_name, NULL);
tmp_vpath = vfs_path_append_new (dirname_vpath, dirent->d_name, (char *) NULL);
res = mc_lstat (tmp_vpath, &s);
if (res == 0)
@ -1128,7 +1128,7 @@ recursive_erase (file_op_total_context_t * tctx, file_op_context_t * ctx, const
if (DIR_IS_DOT (next->d_name) || DIR_IS_DOTDOT (next->d_name))
continue;
tmp_vpath = vfs_path_append_new (vpath, next->d_name, NULL);
tmp_vpath = vfs_path_append_new (vpath, next->d_name, (char *) NULL);
if (mc_lstat (tmp_vpath, &buf) != 0)
{
mc_closedir (reading);
@ -1294,7 +1294,7 @@ panel_compute_totals (const WPanel * panel, dirsize_status_msg_t * sm, size_t *
vfs_path_t *p;
FileProgressStatus status;
p = vfs_path_append_new (panel->cwd_vpath, panel->dir.list[i].fname, NULL);
p = vfs_path_append_new (panel->cwd_vpath, panel->dir.list[i].fname, (char *) NULL);
status = compute_dir_size (p, sm, &dir_count, ret_count, ret_total, compute_symlinks);
vfs_path_free (p);
@ -2142,7 +2142,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
vfs_path_t *tmp;
tmp = dst_vpath;
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL);
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), (char *) NULL);
vfs_path_free (tmp);
}
@ -2210,7 +2210,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
continue;
/* get the filename and add it to the src directory */
path = mc_build_filename (s, next->d_name, NULL);
path = mc_build_filename (s, next->d_name, (char *) NULL);
tmp_vpath = vfs_path_from_str (path);
(*ctx->stat_func) (tmp_vpath, &buf);
@ -2218,7 +2218,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
{
char *mdpath;
mdpath = mc_build_filename (d, next->d_name, NULL);
mdpath = mc_build_filename (d, next->d_name, (char *) NULL);
/*
* From here, we just intend to recursively copy subdirs, not
* the double functionality of copying different when the target
@ -2233,7 +2233,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
{
char *dest_file;
dest_file = mc_build_filename (d, x_basename (path), NULL);
dest_file = mc_build_filename (d, x_basename (path), (char *) NULL);
return_status = copy_file_file (tctx, ctx, path, dest_file);
g_free (dest_file);
}
@ -2331,7 +2331,7 @@ move_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
vfs_path_t *tmp;
tmp = dst_vpath;
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL);
dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), (char *) NULL);
vfs_path_free (tmp);
}
@ -2498,7 +2498,7 @@ dirsize_status_init_cb (status_msg_t * sm)
if (dsm->allow_skip)
b_width += str_term_width1 (b2_name) + 4 + 1;
ui_width = max (COLS / 2, b_width + 6);
ui_width = MAX (COLS / 2, b_width + 6);
dsm->dirname = label_new (2, 3, "");
add_widget (sm->dlg, dsm->dirname);
dsm->count_size = label_new (3, 3, "");
@ -2877,7 +2877,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
goto clean_up;
}
temp2 = mc_build_filename (repl_dest, temp, NULL);
temp2 = mc_build_filename (repl_dest, temp, (char *) NULL);
g_free (temp);
g_free (repl_dest);
g_free (dest);
@ -2988,7 +2988,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
goto clean_up;
}
temp2 = mc_build_filename (repl_dest, temp, NULL);
temp2 = mc_build_filename (repl_dest, temp, (char *) NULL);
g_free (temp);
g_free (repl_dest);
source_with_path_str =

View File

@ -500,7 +500,7 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
* longest of "Overwrite..." labels
* (assume "Target date..." are short enough)
*/
l1 = max (widgets_len[9], widgets_len[4]);
l1 = MAX (widgets_len[9], widgets_len[4]);
/* longest of button rows */
l = l2 = 0;
@ -511,17 +511,17 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
if (row != rd_widgets[i].ypos)
{
row = rd_widgets[i].ypos;
l2 = max (l2, l);
l2 = MAX (l2, l);
l = 0;
}
l += widgets_len[i] + 4;
}
l2 = max (l2, l); /* last row */
rd_xlen = max (rd_xlen, l1 + l2 + 8);
/* rd_xlen = max (rd_xlen, str_term_width1 (title) + 2); */
l2 = MAX (l2, l); /* last row */
rd_xlen = MAX (rd_xlen, l1 + l2 + 8);
/* rd_xlen = MAX (rd_xlen, str_term_width1 (title) + 2); */
stripped_name_len = str_term_width1 (stripped_name);
rd_xlen = max (rd_xlen, min (COLS, stripped_name_len + 8));
rd_xlen = MAX (rd_xlen, MIN (COLS, stripped_name_len + 8));
/* Now place widgets */
l1 += 5; /* start of first button in the row */
@ -557,12 +557,12 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
size_trunc_len (fsize_buffer, sizeof (fsize_buffer), ui->s_stat->st_size, 0,
panels_options.kilobyte_si);
ADD_RD_LABEL (2, file_date (ui->s_stat->st_mtime), fsize_buffer, y++);
rd_xlen = max (rd_xlen, label2->cols + 8);
rd_xlen = MAX (rd_xlen, label2->cols + 8);
/* destination date and size */
size_trunc_len (fsize_buffer, sizeof (fsize_buffer), ui->d_stat->st_size, 0,
panels_options.kilobyte_si);
ADD_RD_LABEL (3, file_date (ui->d_stat->st_mtime), fsize_buffer, y++);
rd_xlen = max (rd_xlen, label2->cols + 8);
rd_xlen = MAX (rd_xlen, label2->cols + 8);
add_widget (ui->replace_dlg, hline_new (y++, -1, -1));
@ -844,11 +844,11 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
add_widget (ui->op_dlg, progress_buttons[3].w);
buttons_width = 2 +
progress_buttons[0].len + max (progress_buttons[1].len, progress_buttons[2].len) +
progress_buttons[0].len + MAX (progress_buttons[1].len, progress_buttons[2].len) +
progress_buttons[3].len;
/* adjust dialog sizes */
dlg_set_size (ui->op_dlg, y + 3, max (COLS * 2 / 3, buttons_width + 6));
dlg_set_size (ui->op_dlg, y + 3, MAX (COLS * 2 / 3, buttons_width + 6));
place_progress_buttons (ui->op_dlg, FALSE);
@ -1209,7 +1209,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation,
if (format_len + text_len <= max_len)
{
fmd_xlen = format_len + text_len + 6;
fmd_xlen = max (fmd_xlen, 68);
fmd_xlen = MAX (fmd_xlen, 68);
}
else
{
@ -1222,7 +1222,7 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation,
else
{
fmd_xlen = COLS * 2 / 3;
fmd_xlen = max (fmd_xlen, 68);
fmd_xlen = MAX (fmd_xlen, 68);
g_snprintf (fmd_buf, sizeof (fmd_buf), format, *(const int *) text);
}

View File

@ -92,7 +92,7 @@ my_mkdir_rec (const vfs_path_t * s_vpath, mode_t mode)
return (-1);
}
q = vfs_path_append_new (s_vpath, "..", NULL);
q = vfs_path_append_new (s_vpath, "..", (char *) NULL);
result = my_mkdir_rec (q, mode);
vfs_path_free (q);

View File

@ -284,27 +284,29 @@ find_load_options (void)
loaded = TRUE;
options.file_case_sens =
mc_config_get_bool (mc_main_config, "FindFile", "file_case_sens", TRUE);
mc_config_get_bool (mc_global.main_config, "FindFile", "file_case_sens", TRUE);
options.file_pattern =
mc_config_get_bool (mc_main_config, "FindFile", "file_shell_pattern", TRUE);
options.find_recurs = mc_config_get_bool (mc_main_config, "FindFile", "file_find_recurs", TRUE);
mc_config_get_bool (mc_global.main_config, "FindFile", "file_shell_pattern", TRUE);
options.find_recurs =
mc_config_get_bool (mc_global.main_config, "FindFile", "file_find_recurs", TRUE);
options.skip_hidden =
mc_config_get_bool (mc_main_config, "FindFile", "file_skip_hidden", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "file_skip_hidden", FALSE);
options.file_all_charsets =
mc_config_get_bool (mc_main_config, "FindFile", "file_all_charsets", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "file_all_charsets", FALSE);
options.content_case_sens =
mc_config_get_bool (mc_main_config, "FindFile", "content_case_sens", TRUE);
mc_config_get_bool (mc_global.main_config, "FindFile", "content_case_sens", TRUE);
options.content_regexp =
mc_config_get_bool (mc_main_config, "FindFile", "content_regexp", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "content_regexp", FALSE);
options.content_first_hit =
mc_config_get_bool (mc_main_config, "FindFile", "content_first_hit", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "content_first_hit", FALSE);
options.content_whole_words =
mc_config_get_bool (mc_main_config, "FindFile", "content_whole_words", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "content_whole_words", FALSE);
options.content_all_charsets =
mc_config_get_bool (mc_main_config, "FindFile", "content_all_charsets", FALSE);
mc_config_get_bool (mc_global.main_config, "FindFile", "content_all_charsets", FALSE);
options.ignore_dirs_enable =
mc_config_get_bool (mc_main_config, "FindFile", "ignore_dirs_enable", TRUE);
options.ignore_dirs = mc_config_get_string (mc_main_config, "FindFile", "ignore_dirs", "");
mc_config_get_bool (mc_global.main_config, "FindFile", "ignore_dirs_enable", TRUE);
options.ignore_dirs =
mc_config_get_string (mc_global.main_config, "FindFile", "ignore_dirs", "");
if (options.ignore_dirs[0] == '\0')
MC_PTR_FREE (options.ignore_dirs);
@ -315,21 +317,27 @@ find_load_options (void)
static void
find_save_options (void)
{
mc_config_set_bool (mc_main_config, "FindFile", "file_case_sens", options.file_case_sens);
mc_config_set_bool (mc_main_config, "FindFile", "file_shell_pattern", options.file_pattern);
mc_config_set_bool (mc_main_config, "FindFile", "file_find_recurs", options.find_recurs);
mc_config_set_bool (mc_main_config, "FindFile", "file_skip_hidden", options.skip_hidden);
mc_config_set_bool (mc_main_config, "FindFile", "file_all_charsets", options.file_all_charsets);
mc_config_set_bool (mc_main_config, "FindFile", "content_case_sens", options.content_case_sens);
mc_config_set_bool (mc_main_config, "FindFile", "content_regexp", options.content_regexp);
mc_config_set_bool (mc_main_config, "FindFile", "content_first_hit", options.content_first_hit);
mc_config_set_bool (mc_main_config, "FindFile", "content_whole_words",
mc_config_set_bool (mc_global.main_config, "FindFile", "file_case_sens",
options.file_case_sens);
mc_config_set_bool (mc_global.main_config, "FindFile", "file_shell_pattern",
options.file_pattern);
mc_config_set_bool (mc_global.main_config, "FindFile", "file_find_recurs", options.find_recurs);
mc_config_set_bool (mc_global.main_config, "FindFile", "file_skip_hidden", options.skip_hidden);
mc_config_set_bool (mc_global.main_config, "FindFile", "file_all_charsets",
options.file_all_charsets);
mc_config_set_bool (mc_global.main_config, "FindFile", "content_case_sens",
options.content_case_sens);
mc_config_set_bool (mc_global.main_config, "FindFile", "content_regexp",
options.content_regexp);
mc_config_set_bool (mc_global.main_config, "FindFile", "content_first_hit",
options.content_first_hit);
mc_config_set_bool (mc_global.main_config, "FindFile", "content_whole_words",
options.content_whole_words);
mc_config_set_bool (mc_main_config, "FindFile", "content_all_charsets",
mc_config_set_bool (mc_global.main_config, "FindFile", "content_all_charsets",
options.content_all_charsets);
mc_config_set_bool (mc_main_config, "FindFile", "ignore_dirs_enable",
mc_config_set_bool (mc_global.main_config, "FindFile", "ignore_dirs_enable",
options.ignore_dirs_enable);
mc_config_set_string (mc_main_config, "FindFile", "ignore_dirs", options.ignore_dirs);
mc_config_set_string (mc_global.main_config, "FindFile", "ignore_dirs", options.ignore_dirs);
}
/* --------------------------------------------------------------------------------------------- */
@ -802,7 +810,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
*pattern = g_strdup (in_name->buffer);
else
*pattern = g_strdup (options.file_pattern ? "*" : ".*");
*start_dir = in_start->buffer[0] != '\0' ? in_start->buffer : (char *) ".";
*start_dir = !input_is_empty (in_start) ? in_start->buffer : (char *) ".";
if (in_start_dir != INPUT_LAST_TEXT)
g_free (in_start_dir);
in_start_dir = g_strdup (*start_dir);

View File

@ -697,7 +697,7 @@ init_i18n_stuff (int list_type, int cols)
(len[0])--;
(len[1])--;
cols = max (cols, max (len[0], len[1]));
cols = MAX (cols, MAX (len[0], len[1]));
/* arrange buttons */
for (i = 0; i < hotlist_but_num; i++)
@ -742,7 +742,7 @@ init_hotlist (hotlist_t list_type)
cols = init_i18n_stuff (list_type, COLS - 6);
hotlist_state.expanded =
mc_config_get_int (mc_main_config, "HotlistConfig", "expanded_view_of_groups", 0);
mc_config_get_int (mc_global.main_config, "HotlistConfig", "expanded_view_of_groups", 0);
#ifdef ENABLE_VFS
if (list_type == LIST_VFSLIST)
@ -1179,21 +1179,21 @@ load_group (struct hotlist *grp)
group_section = find_group_section (grp);
keys = mc_config_get_keys (mc_main_config, group_section, NULL);
keys = mc_config_get_keys (mc_global.main_config, group_section, NULL);
current_group = grp;
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
add2hotlist (mc_config_get_string (mc_main_config, group_section, *profile_keys, ""),
add2hotlist (mc_config_get_string (mc_global.main_config, group_section, *profile_keys, ""),
g_strdup (*profile_keys), HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
g_free (group_section);
g_strfreev (keys);
keys = mc_config_get_keys (mc_main_config, grp->directory, NULL);
keys = mc_config_get_keys (mc_global.main_config, grp->directory, NULL);
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
add2hotlist (mc_config_get_string (mc_main_config, group_section, *profile_keys, ""),
add2hotlist (mc_config_get_string (mc_global.main_config, group_section, *profile_keys, ""),
g_strdup (*profile_keys), HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END);
g_strfreev (keys);
@ -1404,20 +1404,20 @@ clean_up_hotlist_groups (const char *section)
char *grp_section;
grp_section = g_strconcat (section, ".Group", (char *) NULL);
if (mc_config_has_group (mc_main_config, section))
mc_config_del_group (mc_main_config, section);
if (mc_config_has_group (mc_global.main_config, section))
mc_config_del_group (mc_global.main_config, section);
if (mc_config_has_group (mc_main_config, grp_section))
if (mc_config_has_group (mc_global.main_config, grp_section))
{
char **profile_keys, **keys;
keys = mc_config_get_keys (mc_main_config, grp_section, NULL);
keys = mc_config_get_keys (mc_global.main_config, grp_section, NULL);
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
clean_up_hotlist_groups (*profile_keys);
g_strfreev (keys);
mc_config_del_group (mc_main_config, grp_section);
mc_config_del_group (mc_global.main_config, grp_section);
}
g_free (grp_section);
}
@ -1484,8 +1484,8 @@ load_hotlist (void)
GError *mcerror = NULL;
clean_up_hotlist_groups ("Hotlist");
if (!mc_config_save_file (mc_main_config, &mcerror))
setup_save_config_show_error (mc_main_config->ini_path, &mcerror);
if (!mc_config_save_file (mc_global.main_config, &mcerror))
setup_save_config_show_error (mc_global.main_config->ini_path, &mcerror);
mc_error_message (&mcerror, NULL);
}

View File

@ -228,7 +228,7 @@ update_split (const WDialog * h)
check_options[0].widget->state = panels_layout.vertical_equal ? 1 : 0;
widget_redraw (WIDGET (check_options[0].widget));
tty_setcolor (check_options[0].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);
tty_setcolor ((check_options[0].widget->state & C_BOOL) ? DISABLED_COLOR : COLOR_NORMAL);
widget_move (h, 6, 5);
if (panels_layout.horizontal_split)
@ -1088,7 +1088,7 @@ swap_panels (void)
panel2 = PANEL (panels[1].widget);
if (panels[0].type == view_listing && panels[1].type == view_listing &&
!mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE))
!mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE))
{
WPanel panel;

View File

@ -748,7 +748,7 @@ put_link (WPanel * panel)
vfs_path_t *vpath;
int i;
vpath = vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname, NULL);
vpath = vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname, (char *) NULL);
i = mc_readlink (vpath, buffer, sizeof (buffer) - 1);
vfs_path_free (vpath);
@ -966,7 +966,7 @@ prepend_cwd_on_local (const char *filename)
vfs_path_free (vpath);
return vfs_path_append_new (vfs_get_raw_current_dir (), filename, NULL);
return vfs_path_append_new (vfs_get_raw_current_dir (), filename, (char *) NULL);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -186,6 +186,7 @@
#include "lib/global.h"
#include "lib/strutil.h" /* str_verscmp() */
#include "lib/unixcompat.h" /* makedev */
#include "mountlist.h"
/*** global variables ****************************************************************************/

View File

@ -831,9 +831,9 @@ format_file (WPanel * panel, int file_index, int width, int attr, gboolean issta
*field_length = len + 1;
str_len = str_length (txt);
i = max (0, str_len - len);
panel->max_shift = max (panel->max_shift, i);
i = min (panel->content_shift, i);
i = MAX (0, str_len - len);
panel->max_shift = MAX (panel->max_shift, i);
i = MIN (panel->content_shift, i);
if (i > -1)
{
@ -1008,7 +1008,8 @@ display_mini_info (WPanel * panel)
int len;
lc_link_vpath =
vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname, NULL);
vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname,
(char *) NULL);
len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1);
vfs_path_free (lc_link_vpath);
if (len > 0)
@ -1309,7 +1310,7 @@ show_dir (const WPanel * panel)
tty_setcolor (REVERSE_COLOR);
tmp = panel_correct_path_to_show (panel);
tty_printf (" %s ", str_term_trim (tmp, min (max (w->cols - 12, 0), w->cols)));
tty_printf (" %s ", str_term_trim (tmp, MIN (MAX (w->cols - 12, 0), w->cols)));
g_free (tmp);
if (!panels_options.show_mini_info)
@ -2452,7 +2453,7 @@ mark_file_right (WPanel * panel)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = panel_lines (panel);
lines = min (lines, panel->dir.len - panel->selected - 1);
lines = MIN (lines, panel->dir.len - panel->selected - 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);
@ -2472,7 +2473,7 @@ mark_file_left (WPanel * panel)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = panel_lines (panel);
lines = min (lines, panel->selected + 1);
lines = MIN (lines, panel->selected + 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);
@ -2771,7 +2772,7 @@ do_enter_on_file_entry (file_entry_t * fe)
return TRUE;
}
full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, NULL);
full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, (char *) NULL);
/* Try associated command */
ok = regex_command (full_name_vpath, "Open") != 0;
@ -2780,7 +2781,7 @@ do_enter_on_file_entry (file_entry_t * fe)
return TRUE;
/* Check if the file is executable */
full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, NULL);
full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, (char *) NULL);
ok = (is_exe (fe->st.st_mode) && if_link_is_exe (full_name_vpath, fe));
vfs_path_free (full_name_vpath);
if (!ok)
@ -2799,7 +2800,7 @@ do_enter_on_file_entry (file_entry_t * fe)
int ret;
vfs_path_t *tmp_vpath;
tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, NULL);
tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, (char *) NULL);
ret = mc_setctl (tmp_vpath, VFS_SETCTL_RUN, NULL);
vfs_path_free (tmp_vpath);
/* We took action only if the dialog was shown or the execution
@ -2846,7 +2847,7 @@ chdir_other_panel (WPanel * panel)
set_display_type (get_other_index (), view_listing);
if (S_ISDIR (entry->st.st_mode) || entry->f.link_to_dir)
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname, NULL);
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname, (char *) NULL);
else
{
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, "..", (char *) NULL);
@ -2931,7 +2932,7 @@ chdir_to_readlink (WPanel * panel)
if (IS_PATH_SEP (*buffer))
new_dir_vpath = vfs_path_from_str (buffer);
else
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, buffer, NULL);
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, buffer, (char *) NULL);
change_panel ();
do_cd (new_dir_vpath, cd_exact);
@ -4162,7 +4163,8 @@ panel_recursive_cd_to_parent (const vfs_path_t * vpath)
tmp_vpath = vfs_path_vtokens_get (cwd_vpath, 0, -1);
vfs_path_free (cwd_vpath);
cwd_vpath = vfs_path_build_filename (PATH_SEP_STR, vfs_path_as_str (tmp_vpath), NULL);
cwd_vpath =
vfs_path_build_filename (PATH_SEP_STR, vfs_path_as_str (tmp_vpath), (char *) NULL);
vfs_path_free (tmp_vpath);
}
@ -4314,7 +4316,7 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
panel->frame_size = frame_half;
section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
if (!mc_config_has_group (mc_main_config, section))
if (!mc_config_has_group (mc_global.main_config, section))
{
g_free (section);
section = g_strdup (panel->panel_name);

View File

@ -165,7 +165,7 @@ init_panelize (void)
}
panelize_cols = COLS - 6;
panelize_cols = max (panelize_cols, blen + 4);
panelize_cols = MAX (panelize_cols, blen + 4);
panelize_dlg =
dlg_create (TRUE, 0, 0, 20, panelize_cols, dialog_colors, panelize_callback, NULL,
@ -256,7 +256,7 @@ add2panelize (char *label, char *command)
static void
add2panelize_cmd (void)
{
if (pname->buffer != NULL && *pname->buffer != '\0')
if (!input_is_empty (pname))
{
char *label;
@ -419,7 +419,7 @@ do_panelize_cd (WPanel * panel)
tmp_vpath =
vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname,
NULL);
(char *) NULL);
fname = vfs_path_as_str (tmp_vpath);
list->list[i].fnamelen = strlen (fname);
list->list[i].fname = g_strndup (fname, list->list[i].fnamelen);
@ -501,8 +501,6 @@ cd_panelize_cmd (void)
void
external_panelize (void)
{
char *target = NULL;
if (!vfs_current_is_local ())
{
message (D_ERROR, MSG_ERROR, _("Cannot run external panelize in a non-local directory"));
@ -533,11 +531,11 @@ external_panelize (void)
}
case B_ENTER:
target = pname->buffer;
if (target != NULL && *target)
if (!input_is_empty (pname))
{
char *cmd = g_strdup (target);
char *cmd;
cmd = g_strdup (pname->buffer);
dlg_destroy (panelize_dlg);
do_external_panelize (cmd);
g_free (cmd);
@ -560,7 +558,7 @@ load_panelize (void)
{
char **keys;
keys = mc_config_get_keys (mc_main_config, panelize_section, NULL);
keys = mc_config_get_keys (mc_global.main_config, panelize_section, NULL);
add2panelize (g_strdup (_("Other command")), g_strdup (""));
@ -596,8 +594,8 @@ load_panelize (void)
}
add2panelize (g_string_free (buffer, FALSE),
mc_config_get_string (mc_main_config, panelize_section, *profile_keys,
""));
mc_config_get_string (mc_global.main_config, panelize_section,
*profile_keys, ""));
}
str_close_conv (conv);
@ -613,11 +611,11 @@ save_panelize (void)
{
struct panelize *current = panelize;
mc_config_del_group (mc_main_config, panelize_section);
mc_config_del_group (mc_global.main_config, panelize_section);
for (; current; current = current->next)
{
if (strcmp (current->label, _("Other command")))
mc_config_set_string (mc_main_config,
mc_config_set_string (mc_global.main_config,
panelize_section, current->label, current->command);
}
}

View File

@ -745,9 +745,9 @@ tree_store_mark_checked (const char *subname)
cname = vfs_path_as_str (ts.check_name);
if (IS_PATH_SEP (cname[0]) && cname[1] == '\0')
name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL);
name = vfs_path_build_filename (PATH_SEP_STR, subname, (char *) NULL);
else
name = vfs_path_append_new (ts.check_name, subname, NULL);
name = vfs_path_append_new (ts.check_name, subname, (char *) NULL);
/* Search for the subdirectory */
current = ts.check_start;
@ -923,7 +923,7 @@ tree_store_rescan (const vfs_path_t * vpath)
if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name))
continue;
tmp_vpath = vfs_path_append_new (vpath, dp->d_name, NULL);
tmp_vpath = vfs_path_append_new (vpath, dp->d_name, (char *) NULL);
if (mc_lstat (tmp_vpath, &buf) != -1 && S_ISDIR (buf.st_mode))
tree_store_mark_checked (dp->d_name);
vfs_path_free (tmp_vpath);

View File

@ -37,6 +37,7 @@
#include <string.h>
#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/tty/tty.h"
#include "lib/skin.h"
#include "lib/search.h"
@ -956,21 +957,22 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
g_free (menu);
menu =
mc_build_filename (mc_config_get_home_dir (),
edit_widget != NULL ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU, NULL);
edit_widget != NULL ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU,
(char *) NULL);
if (!exist_file (menu))
{
g_free (menu);
menu =
mc_build_filename (mc_global.sysconfig_dir,
edit_widget != NULL ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU,
NULL);
(char *) NULL);
if (!exist_file (menu))
{
g_free (menu);
menu =
mc_build_filename (mc_global.share_data_dir,
edit_widget != NULL ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU,
NULL);
(char *) NULL);
}
}
}
@ -1067,7 +1069,7 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
menu_lines++;
accept_entry = TRUE;
}
max_cols = max (max_cols, col);
max_cols = MAX (max_cols, col);
col = 0;
}
else
@ -1091,7 +1093,7 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
{
Listbox *listbox;
max_cols = min (max (max_cols, col), MAX_ENTRY_LEN);
max_cols = MIN (MAX (max_cols, col), MAX_ENTRY_LEN);
/* Create listbox */
listbox = create_listbox_window (menu_lines, max_cols + 2, _("User menu"),

View File

@ -73,7 +73,7 @@
#define MAXLINKNAME 80
#define HISTORY_SIZE 20
#define HELP_WINDOW_WIDTH min(80, COLS - 16)
#define HELP_WINDOW_WIDTH MIN(80, COLS - 16)
#define STRING_LINK_START "\01"
#define STRING_LINK_POINTER "\02"
@ -867,7 +867,7 @@ help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
{
WButtonBar *bb;
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18));
dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4);
bb = find_buttonbar (h);
widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS);
@ -1093,7 +1093,7 @@ help_interactive_display (const gchar * event_group_name, const gchar * event_na
}
}
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18));
whelp =
dlg_create (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,

View File

@ -302,7 +302,7 @@ init_learn (void)
label = _(key_name_conv_tab[i].longname);
padding = 16 - str_term_width1 (label);
padding = max (0, padding);
padding = MAX (0, padding);
g_snprintf (buffer, sizeof (buffer), "%s%*s", label, padding, "");
learnkeys[i].button =
@ -361,8 +361,8 @@ learn_save (void)
char *esc_str;
esc_str = strutils_escape (learnkeys[i].sequence, -1, ";\\", TRUE);
mc_config_set_string_raw_value (mc_main_config, section, key_name_conv_tab[i].name,
esc_str);
mc_config_set_string_raw_value (mc_global.main_config, section,
key_name_conv_tab[i].name, esc_str);
g_free (esc_str);
profile_changed = TRUE;
@ -375,7 +375,7 @@ learn_save (void)
* disk is much worse.
*/
if (profile_changed)
mc_config_save_file (mc_main_config, NULL);
mc_config_save_file (mc_global.main_config, NULL);
g_free (section);
}

View File

@ -108,7 +108,7 @@ check_codeset (void)
if (mc_global.display_codepage == -1)
mc_global.display_codepage = 0;
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
cp_display);
}
}
@ -287,7 +287,7 @@ main (int argc, char *argv[])
char *buffer;
vfs_path_t *vpath;
buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
buffer = mc_config_get_string (mc_global.panels_config, "Dirs", "other_dir", ".");
vpath = vfs_path_from_str (buffer);
if (vfs_file_is_local (vpath))
saved_other_dir = buffer;

View File

@ -451,9 +451,9 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
return NULL;
if (subdir != NULL)
ret = g_build_filename (mc_config_get_path (), subdir, lc_basename, NULL);
ret = g_build_filename (mc_config_get_path (), subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_config_get_path (), lc_basename, NULL);
ret = g_build_filename (mc_config_get_path (), lc_basename, (char *) NULL);
if (exist_file (ret))
{
@ -464,9 +464,9 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
g_free (ret);
if (subdir != NULL)
ret = g_build_filename (mc_global.sysconfig_dir, subdir, lc_basename, NULL);
ret = g_build_filename (mc_global.sysconfig_dir, subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_global.sysconfig_dir, lc_basename, NULL);
ret = g_build_filename (mc_global.sysconfig_dir, lc_basename, (char *) NULL);
if (exist_file (ret))
{
@ -477,9 +477,9 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
g_free (ret);
if (subdir != NULL)
ret = g_build_filename (mc_global.share_data_dir, subdir, lc_basename, NULL);
ret = g_build_filename (mc_global.share_data_dir, subdir, lc_basename, (char *) NULL);
else
ret = g_build_filename (mc_global.share_data_dir, lc_basename, NULL);
ret = g_build_filename (mc_global.share_data_dir, lc_basename, (char *) NULL);
g_free (lc_basename);
@ -587,10 +587,10 @@ load_layout (void)
int first_panel_size;
/* legacy options */
panels_layout.horizontal_split = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
panels_layout.horizontal_split = mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION,
"horizontal_split", 0);
equal_split = mc_config_get_int (mc_main_config, "Layout", "equal_split", 1);
first_panel_size = mc_config_get_int (mc_main_config, "Layout", "first_panel_size", 1);
equal_split = mc_config_get_int (mc_global.main_config, "Layout", "equal_split", 1);
first_panel_size = mc_config_get_int (mc_global.main_config, "Layout", "first_panel_size", 1);
if (panels_layout.horizontal_split)
{
panels_layout.horizontal_equal = equal_split;
@ -604,13 +604,13 @@ load_layout (void)
/* actual options override legacy ones */
for (i = 0; layout[i].opt_name != NULL; i++)
*layout[i].opt_addr = mc_config_get_int (mc_main_config, CONFIG_LAYOUT_SECTION,
*layout[i].opt_addr = mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION,
layout[i].opt_name, *layout[i].opt_addr);
/* remove legacy options */
mc_config_del_key (mc_main_config, CONFIG_APP_SECTION, "horizontal_split");
mc_config_del_key (mc_main_config, "Layout", "equal_split");
mc_config_del_key (mc_main_config, "Layout", "first_panel_size");
mc_config_del_key (mc_global.main_config, CONFIG_APP_SECTION, "horizontal_split");
mc_config_del_key (mc_global.main_config, "Layout", "equal_split");
mc_config_del_key (mc_global.main_config, "Layout", "first_panel_size");
}
/* --------------------------------------------------------------------------------------------- */
@ -730,11 +730,12 @@ load_setup_get_keymap_profile_config (gboolean load_from_file)
/* load and merge global keymaps */
/* 1) /usr/share/mc (mc_global.share_data_dir) */
share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, NULL);
share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, share_keymap, TRUE);
/* 2) /etc/mc (mc_global.sysconfig_dir) */
sysconfig_keymap = g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL);
sysconfig_keymap =
g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, (char *) NULL);
load_setup_init_config_from_file (&keymap_config, sysconfig_keymap, TRUE);
/* then load and merge one of user-defined keymap */
@ -758,7 +759,7 @@ load_setup_get_keymap_profile_config (gboolean load_from_file)
g_free (fname);
/* 5) main config; [Midnight Commander] -> keymap */
fname2 = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", NULL);
fname2 = mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION, "keymap", NULL);
if (fname2 != NULL && *fname2 != '\0')
fname = load_setup_get_full_config_name (NULL, fname2);
g_free (fname2);
@ -791,7 +792,7 @@ setup__load_panel_state (const char *section)
panel_view_mode_t mode = view_listing;
/* Load the display mode */
buffer = mc_config_get_string (mc_panels_config, section, "display", "listing");
buffer = mc_config_get_string (mc_global.panels_config, section, "display", "listing");
for (i = 0; panel_types[i].opt_name != NULL; i++)
if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0)
@ -815,7 +816,8 @@ panel_save_type (const char *section, panel_view_mode_t type)
for (i = 0; panel_types[i].opt_name != NULL; i++)
if (panel_types[i].opt_type == type)
{
mc_config_set_string (mc_panels_config, section, "display", panel_types[i].opt_name);
mc_config_set_string (mc_global.panels_config, section, "display",
panel_types[i].opt_name);
break;
}
}
@ -828,18 +830,18 @@ panel_save_type (const char *section, panel_view_mode_t type)
static void
panels_load_options (void)
{
if (mc_config_has_group (mc_main_config, CONFIG_PANELS_SECTION))
if (mc_config_has_group (mc_global.main_config, CONFIG_PANELS_SECTION))
{
size_t i;
int qmode;
for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
*panels_ini_options[i].opt_addr =
mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
panels_ini_options[i].opt_name,
*panels_ini_options[i].opt_addr);
qmode = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION,
qmode = mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION,
"quick_search_mode", (int) panels_options.qsearch_mode);
if (qmode < 0)
panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
@ -849,7 +851,7 @@ panels_load_options (void)
panels_options.qsearch_mode = (qsearch_mode_t) qmode;
panels_options.select_flags =
mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION, "select_flags",
mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION, "select_flags",
(int) panels_options.select_flags);
}
}
@ -865,12 +867,12 @@ panels_save_options (void)
size_t i;
for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION,
"quick_search_mode", (int) panels_options.qsearch_mode);
mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION,
"select_flags", (int) panels_options.select_flags);
}
@ -883,12 +885,12 @@ save_config (void)
/* Save integer options */
for (i = 0; int_options[i].opt_name != NULL; i++)
mc_config_set_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
mc_config_set_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
*int_options[i].opt_addr);
/* Save string options */
for (i = 0; str_options[i].opt_name != NULL; i++)
mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
*str_options[i].opt_addr);
}
@ -901,7 +903,7 @@ save_layout (void)
/* Save integer options */
for (i = 0; layout[i].opt_name != NULL; i++)
mc_config_set_int (mc_main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name,
mc_config_set_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name,
*layout[i].opt_addr);
}
@ -929,20 +931,21 @@ save_panel_types (void)
char *dirs;
dirs = get_panel_dir_for (other_panel);
mc_config_set_string (mc_panels_config, "Dirs", "other_dir", dirs);
mc_config_set_string (mc_global.panels_config, "Dirs", "other_dir", dirs);
g_free (dirs);
}
if (current_panel != NULL)
mc_config_set_bool (mc_panels_config, "Dirs", "current_is_left", get_current_index () == 0);
mc_config_set_bool (mc_global.panels_config, "Dirs", "current_is_left",
get_current_index () == 0);
if (mc_panels_config->ini_path == NULL)
mc_panels_config->ini_path = g_strdup (panels_profile_name);
if (mc_global.panels_config->ini_path == NULL)
mc_global.panels_config->ini_path = g_strdup (panels_profile_name);
mc_config_del_group (mc_panels_config, "Temporal:New Left Panel");
mc_config_del_group (mc_panels_config, "Temporal:New Right Panel");
mc_config_del_group (mc_global.panels_config, "Temporal:New Left Panel");
mc_config_del_group (mc_global.panels_config, "Temporal:New Right Panel");
mc_config_save_file (mc_panels_config, NULL);
mc_config_save_file (mc_global.panels_config, NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -961,7 +964,7 @@ setup_init (void)
{
char *inifile;
inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", NULL);
inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", (char *) NULL);
if (exist_file (inifile))
{
g_free (profile);
@ -970,7 +973,7 @@ setup_init (void)
else
{
g_free (inifile);
inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", NULL);
inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", (char *) NULL);
if (!exist_file (inifile))
g_free (inifile);
else
@ -1018,17 +1021,17 @@ load_setup (void)
panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
mc_main_config = mc_config_init (profile, FALSE);
mc_global.main_config = mc_config_init (profile, FALSE);
if (!exist_file (panels_profile_name))
setup__move_panels_config_into_separate_file (profile);
mc_panels_config = mc_config_init (panels_profile_name, FALSE);
mc_global.panels_config = mc_config_init (panels_profile_name, FALSE);
/* Load integer boolean options */
for (i = 0; int_options[i].opt_name != NULL; i++)
*int_options[i].opt_addr =
mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
*int_options[i].opt_addr);
#ifndef USE_INTERNAL_EDIT
/* reset forced in case of build without internal editor */
@ -1051,8 +1054,8 @@ load_setup (void)
/* Load string options */
for (i = 0; str_options[i].opt_name != NULL; i++)
*str_options[i].opt_addr =
mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
str_options[i].opt_defval);
mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION,
str_options[i].opt_name, str_options[i].opt_defval);
load_layout ();
panels_load_options ();
@ -1065,29 +1068,33 @@ load_setup (void)
if (startup_left_mode != view_listing && startup_right_mode != view_listing)
startup_left_mode = view_listing;
boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE);
boot_current_is_left =
mc_config_get_bool (mc_global.panels_config, "Dirs", "current_is_left", TRUE);
/* Load time formats */
user_recent_timeformat =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_recent", FMTTIME);
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "timeformat_recent",
FMTTIME);
user_old_timeformat =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_old", FMTYEAR);
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "timeformat_old",
FMTYEAR);
#ifdef ENABLE_VFS_FTP
ftpfs_proxy_host =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate");
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate");
ftpfs_ignore_chattr_errors =
mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors", TRUE);
mc_config_get_bool (mc_global.main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors",
TRUE);
ftpfs_init_passwd ();
#endif /* ENABLE_VFS_FTP */
/* The default color and the terminal dependent color */
mc_global.tty.setup_color_string =
mc_config_get_string (mc_main_config, "Colors", "base_color", "");
mc_config_get_string (mc_global.main_config, "Colors", "base_color", "");
mc_global.tty.term_color_string =
mc_config_get_string (mc_main_config, "Colors", getenv ("TERM"), "");
mc_config_get_string (mc_global.main_config, "Colors", getenv ("TERM"), "");
mc_global.tty.color_terminal_string =
mc_config_get_string (mc_main_config, "Colors", "color_terminals", "");
mc_config_get_string (mc_global.main_config, "Colors", "color_terminals", "");
/* Load the directory history */
/* directory_history_load (); */
@ -1096,14 +1103,18 @@ load_setup (void)
#ifdef HAVE_CHARSET
if (codepages->len > 1)
{
buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", "");
buffer =
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
"");
if (buffer[0] != '\0')
{
mc_global.display_codepage = get_codepage_index (buffer);
cp_display = get_codepage_id (mc_global.display_codepage);
}
g_free (buffer);
buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage", "");
buffer =
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "source_codepage",
"");
if (buffer[0] != '\0')
{
default_source_codepage = get_codepage_index (buffer);
@ -1114,7 +1125,7 @@ load_setup (void)
}
autodetect_codeset =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", "");
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset", "");
if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0))
is_autodetect_codeset_enabled = TRUE;
@ -1126,13 +1137,13 @@ load_setup (void)
#ifdef HAVE_ASPELL
spell_language =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en");
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language", "en");
#endif /* HAVE_ASPELL */
clipboard_store_path =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", "");
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store", "");
clipboard_paste_path =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", "");
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste", "");
}
/* --------------------------------------------------------------------------------------------- */
@ -1160,34 +1171,34 @@ save_setup (gboolean save_options, gboolean save_panel_options)
/* directory_history_save (); */
#ifdef ENABLE_VFS_FTP
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "ftpfs_password",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password",
ftpfs_anonymous_passwd);
if (ftpfs_proxy_host)
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host",
ftpfs_proxy_host);
#endif /* ENABLE_VFS_FTP */
#ifdef HAVE_CHARSET
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
get_codepage_id (mc_global.display_codepage));
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "source_codepage",
get_codepage_id (default_source_codepage));
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset",
autodetect_codeset);
#endif /* HAVE_CHARSET */
#ifdef HAVE_ASPELL
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language",
spell_language);
#endif /* HAVE_ASPELL */
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store",
clipboard_store_path);
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste",
mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste",
clipboard_paste_path);
tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE);
ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
ret = mc_config_save_to_file (mc_global.main_config, tmp_profile, NULL);
g_free (tmp_profile);
}
@ -1211,8 +1222,8 @@ done_setup (void)
g_free (mc_global.tty.setup_color_string);
g_free (profile_name);
g_free (panels_profile_name);
mc_config_deinit (mc_main_config);
mc_config_deinit (mc_panels_config);
mc_config_deinit (mc_global.main_config);
mc_config_deinit (mc_global.panels_config);
g_free (user_recent_timeformat);
g_free (user_old_timeformat);
@ -1268,8 +1279,8 @@ load_key_defs (void)
mc_config_deinit (mc_global_config);
}
load_keys_from_section ("general", mc_main_config);
load_keys_from_section (getenv ("TERM"), mc_main_config);
load_keys_from_section ("general", mc_global.main_config);
load_keys_from_section (getenv ("TERM"), mc_global.main_config);
}
/* --------------------------------------------------------------------------------------------- */
@ -1280,7 +1291,8 @@ load_anon_passwd (void)
{
char *buffer;
buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftpfs_password", "");
buffer =
mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password", "");
if ((buffer != NULL) && (buffer[0] != '\0'))
return buffer;
@ -1412,14 +1424,15 @@ panel_load_setup (WPanel * panel, const char *section)
size_t i;
char *buffer, buffer2[BUF_TINY];
panel->sort_info.reverse = mc_config_get_int (mc_panels_config, section, "reverse", 0);
panel->sort_info.reverse = mc_config_get_int (mc_global.panels_config, section, "reverse", 0);
panel->sort_info.case_sensitive =
mc_config_get_int (mc_panels_config, section, "case_sensitive",
mc_config_get_int (mc_global.panels_config, section, "case_sensitive",
OS_SORT_CASE_SENSITIVE_DEFAULT);
panel->sort_info.exec_first = mc_config_get_int (mc_panels_config, section, "exec_first", 0);
panel->sort_info.exec_first =
mc_config_get_int (mc_global.panels_config, section, "exec_first", 0);
/* Load sort order */
buffer = mc_config_get_string (mc_panels_config, section, "sort_order", "name");
buffer = mc_config_get_string (mc_global.panels_config, section, "sort_order", "name");
panel->sort_field = panel_get_field_by_id (buffer);
if (panel->sort_field == NULL)
panel->sort_field = panel_get_field_by_id ("name");
@ -1427,7 +1440,7 @@ panel_load_setup (WPanel * panel, const char *section)
g_free (buffer);
/* Load the listing mode */
buffer = mc_config_get_string (mc_panels_config, section, "list_mode", "full");
buffer = mc_config_get_string (mc_global.panels_config, section, "list_mode", "full");
panel->list_type = list_full;
for (i = 0; list_types[i].key != NULL; i++)
if (g_ascii_strcasecmp (list_types[i].key, buffer) == 0)
@ -1437,22 +1450,23 @@ panel_load_setup (WPanel * panel, const char *section)
}
g_free (buffer);
panel->brief_cols = mc_config_get_int (mc_panels_config, section, "brief_cols", 2);
panel->brief_cols = mc_config_get_int (mc_global.panels_config, section, "brief_cols", 2);
/* User formats */
g_free (panel->user_format);
panel->user_format =
mc_config_get_string (mc_panels_config, section, "user_format", DEFAULT_USER_FORMAT);
mc_config_get_string (mc_global.panels_config, section, "user_format", DEFAULT_USER_FORMAT);
for (i = 0; i < LIST_TYPES; i++)
{
g_free (panel->user_status_format[i]);
g_snprintf (buffer2, sizeof (buffer2), "user_status%lld", (long long) i);
panel->user_status_format[i] =
mc_config_get_string (mc_panels_config, section, buffer2, DEFAULT_USER_FORMAT);
mc_config_get_string (mc_global.panels_config, section, buffer2, DEFAULT_USER_FORMAT);
}
panel->user_mini_status = mc_config_get_int (mc_panels_config, section, "user_mini_status", 0);
panel->user_mini_status =
mc_config_get_int (mc_global.panels_config, section, "user_mini_status", 0);
}
/* --------------------------------------------------------------------------------------------- */
@ -1463,31 +1477,33 @@ panel_save_setup (WPanel * panel, const char *section)
char buffer[BUF_TINY];
size_t i;
mc_config_set_int (mc_panels_config, section, "reverse", panel->sort_info.reverse);
mc_config_set_int (mc_panels_config, section, "case_sensitive",
mc_config_set_int (mc_global.panels_config, section, "reverse", panel->sort_info.reverse);
mc_config_set_int (mc_global.panels_config, section, "case_sensitive",
panel->sort_info.case_sensitive);
mc_config_set_int (mc_panels_config, section, "exec_first", panel->sort_info.exec_first);
mc_config_set_int (mc_global.panels_config, section, "exec_first", panel->sort_info.exec_first);
mc_config_set_string (mc_panels_config, section, "sort_order", panel->sort_field->id);
mc_config_set_string (mc_global.panels_config, section, "sort_order", panel->sort_field->id);
for (i = 0; list_types[i].key != NULL; i++)
if (list_types[i].list_type == (int) panel->list_type)
{
mc_config_set_string (mc_panels_config, section, "list_mode", list_types[i].key);
mc_config_set_string (mc_global.panels_config, section, "list_mode", list_types[i].key);
break;
}
mc_config_set_int (mc_panels_config, section, "brief_cols", panel->brief_cols);
mc_config_set_int (mc_global.panels_config, section, "brief_cols", panel->brief_cols);
mc_config_set_string (mc_panels_config, section, "user_format", panel->user_format);
mc_config_set_string (mc_global.panels_config, section, "user_format", panel->user_format);
for (i = 0; i < LIST_TYPES; i++)
{
g_snprintf (buffer, sizeof (buffer), "user_status%lld", (long long) i);
mc_config_set_string (mc_panels_config, section, buffer, panel->user_status_format[i]);
mc_config_set_string (mc_global.panels_config, section, buffer,
panel->user_status_format[i]);
}
mc_config_set_int (mc_panels_config, section, "user_mini_status", panel->user_mini_status);
mc_config_set_int (mc_global.panels_config, section, "user_mini_status",
panel->user_mini_status);
}

View File

@ -293,7 +293,7 @@ init_subshell_child (const char *pty_name)
input_file = mc_config_get_full_path ("inputrc");
if (exist_file (input_file))
{
putenv_str = g_strconcat ("INPUTRC=", input_file, NULL);
putenv_str = g_strconcat ("INPUTRC=", input_file, (char *) NULL);
putenv (putenv_str);
}
g_free (input_file);
@ -314,7 +314,7 @@ init_subshell_child (const char *pty_name)
}
/* Put init file to ENV variable used by ash */
putenv_str = g_strconcat ("ENV=", init_file, NULL);
putenv_str = g_strconcat ("ENV=", init_file, (char *) NULL);
putenv (putenv_str);
/* Do not use "g_free (putenv_str)" here, otherwise ENV will be undefined! */
@ -493,7 +493,7 @@ synchronize (void)
/** Feed the subshell our keyboard input until it says it's finished */
static gboolean
feed_subshell (int how, int fail_on_error)
feed_subshell (int how, gboolean fail_on_error)
{
fd_set read_set; /* For 'select' */
int bytes; /* For the return value from 'read' */
@ -519,11 +519,11 @@ feed_subshell (int how, int fail_on_error)
FD_ZERO (&read_set);
FD_SET (mc_global.tty.subshell_pty, &read_set);
FD_SET (subshell_pipe[READ], &read_set);
maxfdp = max (mc_global.tty.subshell_pty, subshell_pipe[READ]);
maxfdp = MAX (mc_global.tty.subshell_pty, subshell_pipe[READ]);
if (how == VISIBLY)
{
FD_SET (STDIN_FILENO, &read_set);
maxfdp = max (maxfdp, STDIN_FILENO);
maxfdp = MAX (maxfdp, STDIN_FILENO);
}
if (select (maxfdp + 1, &read_set, NULL, NULL, wptr) == -1)

View File

@ -64,7 +64,7 @@ What to do with this?
int f = !strcmp( remote_path, "/~" );
if (f || !strncmp( remote_path, "/~/", 3 )) {
char *s;
s = mc_build_filename ( qhome (*bucket), remote_path +3-f, NULL );
s = mc_build_filename ( qhome (*bucket), remote_path +3-f, (char *) NULL );
g_free (remote_path);
remote_path = s;
}
@ -1695,7 +1695,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
char *path;
/* Trailing "/." is necessary if remote_path is a symlink */
path = mc_build_filename (remote_path, ".", NULL);
path = mc_build_filename (remote_path, ".", (char *) NULL);
sock = ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII, 0);
g_free (path);
}

View File

@ -1371,7 +1371,7 @@ smbfs_get_path (smbfs_connection ** sc, const vfs_path_t * vpath)
{
char *s;
s = mc_build_filename ((*sc)->home, remote_path + 3 - f, NULL);
s = mc_build_filename ((*sc)->home, remote_path + 3 - f, (char *) NULL);
g_free (remote_path);
remote_path = s;
}

View File

@ -354,11 +354,9 @@ mcview_get_next_char (WView * view, mcview_state_machine_t * state, int *c)
#ifdef HAVE_CHARSET
if (view->utf8)
{
gboolean result;
int char_length;
int char_length = 0;
*c = mcview_get_utf (view, state->offset, &char_length, &result);
if (!result)
if (!mcview_get_utf (view, state->offset, c, &char_length))
return FALSE;
/* Pretend EOF if we crossed force_max */
if (view->force_max >= 0 && state->offset + char_length > view->force_max)

View File

@ -81,7 +81,7 @@ mcview_ccache_add_entry (coord_cache_t * cache, size_t pos, const coord_cache_en
if ((cache == NULL) || (entry == NULL))
return;
pos = min (pos, cache->size);
pos = MIN (pos, cache->size);
/* increase cache capacity if needed */
if (cache->size == cache->capacity)

View File

@ -151,18 +151,13 @@ mcview_get_ptr_file (WView * view, off_t byte_index)
/* --------------------------------------------------------------------------------------------- */
int
mcview_get_utf (WView * view, off_t byte_index, int *char_length, gboolean * result)
gboolean
mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
{
gchar *str = NULL;
int res = -1;
gunichar ch;
gchar *next_ch = NULL;
int res;
gchar utf8buf[UTF8_CHAR_LEN + 1];
*char_length = 0;
*result = FALSE;
switch (view->datasource)
{
case DS_STDIO_PIPE:
@ -180,8 +175,10 @@ mcview_get_utf (WView * view, off_t byte_index, int *char_length, gboolean * res
break;
}
*ch = 0;
if (str == NULL)
return 0;
return FALSE;
res = g_utf8_get_char_validated (str, -1);
@ -189,6 +186,7 @@ mcview_get_utf (WView * view, off_t byte_index, int *char_length, gboolean * res
{
/* Retry with explicit bytes to make sure it's not a buffer boundary */
int i;
for (i = 0; i < UTF8_CHAR_LEN; i++)
{
if (mcview_get_byte (view, byte_index + i, &res))
@ -206,18 +204,20 @@ mcview_get_utf (WView * view, off_t byte_index, int *char_length, gboolean * res
if (res < 0)
{
ch = *str;
*char_length = 1;
*ch = (unsigned char) (*str);
*ch_len = 1;
}
else
{
ch = res;
gchar *next_ch = NULL;
*ch = res;
/* Calculate UTF-8 char length */
next_ch = g_utf8_next_char (str);
*char_length = next_ch - str;
*ch_len = next_ch - str;
}
*result = TRUE;
return ch;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -284,12 +284,12 @@ mcview_compute_areas (WView * view)
/* Compute the heights of the areas */
rest = view_area.height;
height = min (rest, 1);
height = MIN (rest, 1);
view->status_area.height = height;
rest -= height;
height = (ruler == RULER_NONE || view->hex_mode) ? 0 : 2;
height = min (rest, height);
height = MIN (rest, height);
view->ruler_area.height = height;
rest -= height;

View File

@ -264,7 +264,7 @@ off_t mcview_get_filesize (WView *);
void mcview_update_filesize (WView * view);
char *mcview_get_ptr_file (WView *, off_t);
char *mcview_get_ptr_string (WView *, off_t);
int mcview_get_utf (WView *, off_t, int *, gboolean *);
gboolean mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len);
gboolean mcview_get_byte_string (WView *, off_t, int *);
gboolean mcview_get_byte_none (WView *, off_t, int *);
void mcview_set_byte (WView *, off_t, byte);

View File

@ -424,7 +424,7 @@ mcview_load (WView * view, const char *command, const char *file, int start_line
if (max_offset < 0)
new_offset = 0;
else
new_offset = min (new_offset, max_offset);
new_offset = MIN (new_offset, max_offset);
if (!view->hex_mode)
{
view->dpy_start = mcview_bol (view, new_offset, 0);

View File

@ -60,13 +60,12 @@
static gboolean
mcview_nroff_get_char (mcview_nroff_t * nroff, int *ret_val, off_t nroff_index)
{
int c;
int c = 0;
#ifdef HAVE_CHARSET
if (nroff->view->utf8)
{
gboolean utf_result;
c = mcview_get_utf (nroff->view, nroff_index, &nroff->char_length, &utf_result);
if (!utf_result)
if (!mcview_get_utf (nroff->view, nroff_index, &c, &nroff->char_length))
{
/* we need got symbol in any case */
nroff->char_length = 1;

View File

@ -89,7 +89,7 @@ mcview_search_status_update_cb (status_msg_t * sm)
int wd_width;
Widget *lw = WIDGET (ssm->label);
wd_width = max (wd->cols, lw->cols + 6);
wd_width = MAX (wd->cols, lw->cols + 6);
widget_set_size (wd, wd->y, wd->x, wd->lines, wd_width);
widget_set_size (lw, lw->y, wd->x + (wd->cols - lw->cols) / 2, lw->lines, lw->cols);
vsm->first = FALSE;

View File

@ -56,31 +56,31 @@ run_mc_build_filename (int iteration)
switch (iteration)
{
case 0:
return mc_build_filename ("test", "path", NULL);
return mc_build_filename ("test", "path", (char *) NULL);
case 1:
return mc_build_filename ("/test", "path/", NULL);
return mc_build_filename ("/test", "path/", (char *) NULL);
case 2:
return mc_build_filename ("/test", "pa/th", NULL);
return mc_build_filename ("/test", "pa/th", (char *) NULL);
case 3:
return mc_build_filename ("/test", "#vfsprefix:", "path ", NULL);
return mc_build_filename ("/test", "#vfsprefix:", "path ", (char *) NULL);
case 4:
return mc_build_filename ("/test", "vfsprefix://", "path ", NULL);
return mc_build_filename ("/test", "vfsprefix://", "path ", (char *) NULL);
case 5:
return mc_build_filename ("/test", "vfs/../prefix:///", "p\\///ath", NULL);
return mc_build_filename ("/test", "vfs/../prefix:///", "p\\///ath", (char *) NULL);
case 6:
return mc_build_filename ("/test", "path", "..", "/test", "path/", NULL);
return mc_build_filename ("/test", "path", "..", "/test", "path/", (char *) NULL);
case 7:
return mc_build_filename ("", "path", NULL);
return mc_build_filename ("", "path", (char *) NULL);
case 8:
return mc_build_filename ("", "/path", NULL);
return mc_build_filename ("", "/path", (char *) NULL);
case 9:
return mc_build_filename ("path", "", NULL);
return mc_build_filename ("path", "", (char *) NULL);
case 10:
return mc_build_filename ("/path", "", NULL);
return mc_build_filename ("/path", "", (char *) NULL);
case 11:
return mc_build_filename ("pa", "", "th", NULL);
return mc_build_filename ("pa", "", "th", (char *) NULL);
case 12:
return mc_build_filename ("/pa", "", "/th", NULL);
return mc_build_filename ("/pa", "", "/th", (char *) NULL);
default:
return NULL;
}

View File

@ -41,7 +41,7 @@ static char *ini_filename;
static void
config_object__init (void)
{
ini_filename = g_build_filename (WORKDIR, "config_string.ini", NULL);
ini_filename = g_build_filename (WORKDIR, "config_string.ini", (char *) NULL);
unlink (ini_filename);
mc_config = mc_config_init (ini_filename, FALSE);

Some files were not shown because too many files have changed in this diff Show More