Merge branch '2889_cleanup' into 4.8.1-stable

* 2889_cleanup: (47 commits)
  Sync with gnulib 40f82767840187c20051ca99385f75a42f92de99.
  Add extra checks in macro engine.
  Ticket #2935: update uc1541 extfs plug-in up to version 2.5.
  Portability: rename some str_class members
  Portability: ESC_CHAR is defined in /usr/include/langinfo.h in some systems
  Cleanup code related to GLib < 2.12.
  Portability: use g_ascii_strtoll instead of strtoll, atoll and atof.
  Fix crash when user menu is called in editor with no filename.
  Optimization of SIGWINCH handling.
  Parenthesis around some -1.
  src/filemanager/mountlist.c: use GLib functions to allocate/free memory.
  Sync with gnulib 613bcb6205cf2b64d835c19074c5a7e7c6cb99eb
  FileOpContext::preserve: make gboolean.
  FileOpContext::dive_into_subdirs: make gboolean.
  Don't create copy/move progress dialog for background operations.
  src/vfs/tar/tar.c: types accuracy.
  src/vfs/cpio/cpio.c: types accuracy.
  vfs_s_subclass::linear_read: return ssize_t instead of int.
  lib/vfs/direntry.c: types accuracy.
  lib/vfs/vfs.h: indentation.
  ...
This commit is contained in:
Andrew Borodin 2012-12-21 12:51:23 +04:00
commit 60c9abfd0e
71 changed files with 783 additions and 676 deletions

View File

@ -30,6 +30,8 @@ AC_DEFINE_UNQUOTED([MC_CONFIGURE_ARGS],["$ac_configure_args"],[MC configure argu
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
AC_PATH_PROG([PYTHON], [python], [/usr/bin/python])
AC_PATH_PROG([RUBY], [ruby], [/usr/bin/ruby])
AC_ISC_POSIX
@ -160,7 +162,6 @@ dnl Check availability of some functions
dnl
AC_CHECK_FUNCS([\
atoll \
isascii \
statfs sysconf \
tcgetattr tcsetattr \
@ -206,6 +207,40 @@ AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AH_TEMPLATE([sig_atomic_t],
[/* Define to `int' if <signal.h> doesn't define.])
AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
[Some systems declare sig_atomic_t as volatile, some others -- no.
This define will have value `sig_atomic_t' or
`volatile sig_atomic_t' accordingly.])
AC_MSG_CHECKING(for sig_atomic_t in signal.h)
AC_EGREP_HEADER(sig_atomic_t,signal.h,
[
ac_cv_type_sig_atomic_t=yes;
AC_EGREP_HEADER(volatile.*sig_atomic_t,
signal.h,
[
is_sig_atomic_t_volatile=yes;
AC_MSG_RESULT([yes, volatile])
],
[
is_sig_atomic_t_volatile=no;
AC_MSG_RESULT([yes, non volatile])
])
],
[
AC_MSG_RESULT(no)
AC_CHECK_TYPE(sig_atomic_t, int)
is_sig_atomic_t_volatile=no
])
if test $is_sig_atomic_t_volatile = 'yes'
then
AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
else
AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
fi
AC_FUNC_STRCOLL
mc_AC_GET_FS_INFO
@ -506,7 +541,6 @@ Makefile
contrib/Makefile
contrib/dist/Makefile
contrib/dist/debian/Makefile
contrib/dist/gentoo/Makefile
contrib/dist/redhat/Makefile
contrib/dist/redhat/mc.spec
@ -551,6 +585,7 @@ src/vfs/extfs/helpers/ualz
src/vfs/extfs/helpers/uar
src/vfs/extfs/helpers/uarc
src/vfs/extfs/helpers/uarj
src/vfs/extfs/helpers/uc1541
src/vfs/extfs/helpers/ucab
src/vfs/extfs/helpers/uha
src/vfs/extfs/helpers/ulha
@ -587,6 +622,7 @@ lib/vfs/Makefile
lib/widget/Makefile
misc/syntax/Makefile
misc/syntax/Syntax
doc/Makefile
doc/hints/Makefile
@ -623,10 +659,10 @@ tests/src/filemanager/Makefile
fi
AC_OUTPUT
echo "
AC_MSG_NOTICE([
Configuration:
Source code location: ${srcdir}
@ -643,4 +679,4 @@ Configuration:
Diff viewer: ${diff_msg}
Support for charset: ${charset_msg}
Search type: ${SEARCH_TYPE}
"
])

View File

@ -1,4 +1,4 @@
SUBDIRS = debian gentoo redhat
SUBDIRS = gentoo redhat
AUTOMAKE_OPTIONS = 1.5

View File

@ -1 +0,0 @@

View File

@ -5,7 +5,7 @@ SED_PARAMETERS = \
-e "s{%sysconfdir%{@sysconfdir@{g"
MAN_DATE_CMD = \
LC_ALL=$(DATE_LANG) perl -MPOSIX -e '\
LC_ALL=$(DATE_LANG) @PERL@ -MPOSIX -e '\
@fi=lstat("'$${MAN_FILE}'"); \
print POSIX::strftime("$(DATE_FORMAT)", localtime($$fi[9]));' 2>/dev/null

View File

@ -68,11 +68,3 @@ g_unichar_iszerowidth (gunichar c)
#endif /* ! GLIB_CHECK_VERSION (2, 13, 0) */
/* --------------------------------------------------------------------------------------------- */
#if ! GLIB_CHECK_VERSION (2, 7, 0)
gboolean
g_file_set_contents (const gchar * filename, const gchar * contents, gssize length, GError ** error)
{
return g_file_replace (filename, contents, length, error);
}
#endif /* ! GLIB_CHECK_VERSION (2, 7, 0) */

View File

@ -15,10 +15,6 @@
gboolean g_unichar_iszerowidth (gunichar);
#endif /* ! GLIB_CHECK_VERSION (2, 13, 0) */
#if ! GLIB_CHECK_VERSION (2, 7, 0)
gboolean g_file_set_contents (const gchar *, const gchar *, gssize, GError **);
#endif /* ! GLIB_CHECK_VERSION (2, 7, 0) */
/*** inline functions ****************************************************************************/
#endif /* MC_GLIBCOMPAT_H */

View File

@ -101,7 +101,7 @@ mc_global_t mc_global = {
.ugly_line_drawing = FALSE,
.old_mouse = FALSE,
.alternate_plus_minus = FALSE,
.winch_flag = FALSE
.winch_flag = 0
},
.vfs =

View File

@ -21,6 +21,9 @@
#include <sys/param.h>
#endif
/* for sig_atomic_t */
#include <signal.h>
/*** typedefs(not structures) and defined constants **********************************************/
/* The O_BINARY definition was taken from gettext */
@ -114,6 +117,10 @@
#define BUF_SMALL 128
#define BUF_TINY 64
/* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
#ifdef ESC_CHAR
#undef ESC_CHAR
#endif
/* AIX compiler doesn't understand '\e' */
#define ESC_CHAR '\033'
#define ESC_STR "\033"
@ -258,7 +265,7 @@ typedef struct
gboolean alternate_plus_minus;
/* Set if the window has changed it's size */
gboolean winch_flag;
SIG_ATOMIC_VOLATILE_T winch_flag;
} tty;
struct

View File

@ -100,9 +100,7 @@ void mc_config_init_config_paths (GError ** error);
void mc_config_deinit_config_paths (void);
gboolean mc_config_deprecated_dir_present (void);
void mc_config_migrate_from_old_place (GError ** error);
gboolean mc_config_migrate_from_old_place (GError ** error, char **msg);
const char *mc_config_get_data_path (void);

View File

@ -266,6 +266,21 @@ mc_config_fix_migrated_rules (void)
}
#endif /* MC_HOMEDIR_XDG */
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_config_deprecated_dir_present (void)
{
char *old_dir;
gboolean is_present;
old_dir = mc_config_get_deprecated_path ();
is_present = g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
g_free (old_dir);
return is_present && !config_dir_present;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -423,12 +438,15 @@ mc_config_get_path (void)
/* --------------------------------------------------------------------------------------------- */
void
mc_config_migrate_from_old_place (GError ** error)
gboolean
mc_config_migrate_from_old_place (GError ** error, char **msg)
{
char *old_dir;
size_t rule_index;
if (!mc_config_deprecated_dir_present ())
return FALSE;
old_dir = mc_config_get_deprecated_path ();
g_free (mc_config_init_one_config_path (mc_config_str, EDIT_DIR, error));
@ -437,6 +455,9 @@ mc_config_migrate_from_old_place (GError ** error)
g_free (mc_config_init_one_config_path (mc_data_str, EDIT_DIR, error));
#endif /* MC_HOMEDIR_XDG */
if (*error != NULL)
return FALSE;
for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
{
char *old_name;
@ -460,38 +481,19 @@ mc_config_migrate_from_old_place (GError ** error)
}
#ifdef MC_HOMEDIR_XDG
g_propagate_error (error,
g_error_new (MC_ERROR, 0,
_
("Your old settings were migrated from %s\n"
"to Freedesktop recommended dirs.\n"
"To get more info, please visit\n"
"http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html"),
old_dir));
*msg = g_strdup_printf (_("Your old settings were migrated from %s\n"
"to Freedesktop recommended dirs.\n"
"To get more info, please visit\n"
"http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html"),
old_dir);
#else /* MC_HOMEDIR_XDG */
g_propagate_error (error,
g_error_new (MC_ERROR, 0,
_
("Your old settings were migrated from %s\n"
"to %s\n"), old_dir, mc_config_str));
*msg = g_strdup_printf (_("Your old settings were migrated from %s\n"
"to %s\n"), old_dir, mc_config_str);
#endif /* MC_HOMEDIR_XDG */
g_free (old_dir);
}
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_config_deprecated_dir_present (void)
{
char *old_dir;
gboolean is_present;
old_dir = mc_config_get_deprecated_path ();
is_present = g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
g_free (old_dir);
return is_present && !config_dir_present;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -553,7 +553,7 @@ mc_search_regex__process_append_str (GString * dest_str, const char *from, gsize
char *tmp_str;
GString *tmp_string;
if (len == (gsize) - 1)
if (len == (gsize) (-1))
len = strlen (from);
if (*replace_flags == REPLACE_T_NO_TRANSFORM)

View File

@ -238,7 +238,7 @@ mc_search_run (mc_search_t * lc_mc_search, const void *user_data,
{
gboolean ret = FALSE;
if (!lc_mc_search)
if (lc_mc_search == NULL || user_data == NULL)
return FALSE;
if (!mc_search_is_type_avail (lc_mc_search->search_type))
{
@ -382,9 +382,15 @@ gboolean
mc_search (const gchar * pattern, const gchar * str, mc_search_type_t type)
{
gboolean ret;
mc_search_t *search = mc_search_new (pattern, -1);
if (search == NULL)
mc_search_t *search;
if (str == NULL)
return FALSE;
search = mc_search_new (pattern, -1);
if (search == NULL )
return FALSE;
search->search_type = type;
search->is_case_sensitive = TRUE;

View File

@ -102,17 +102,17 @@ struct str_class
/*I*/ void (*cprev_char_safe) (const char **);
/*I*/ int (*cnext_noncomb_char) (const char **text);
/*I*/ int (*cprev_noncomb_char) (const char **text, const char *begin);
/*I*/ int (*isspace) (const char *);
/*I*/ int (*ispunct) (const char *);
/*I*/ int (*isalnum) (const char *);
/*I*/ int (*isdigit) (const char *);
/*I*/ int (*isprint) (const char *);
/*I*/ int (*iscombiningmark) (const char *);
/*I*/ int (*char_isspace) (const char *);
/*I*/ int (*char_ispunct) (const char *);
/*I*/ int (*char_isalnum) (const char *);
/*I*/ int (*char_isdigit) (const char *);
/*I*/ int (*char_isprint) (const char *);
/*I*/ gboolean (*char_iscombiningmark) (const char *);
/*I*/ int (*length) (const char *);
/*I*/ int (*length2) (const char *, int);
/*I*/ int (*length_noncomb) (const char *);
/*I*/ int (*toupper) (const char *, char **, size_t *);
int (*tolower) (const char *, char **, size_t *);
/*I*/ int (*char_toupper) (const char *, char **, size_t *);
int (*char_tolower) (const char *, char **, size_t *);
void (*fix_string) (char *);
/*I*/ const char *(*term_form) (const char *);
/*I*/ const char *(*fit_to_term) (const char *, int, align_crt_t);
@ -334,7 +334,7 @@ int str_isprint (const char *ch);
* combining makrs are assumed to be zero width
* I
*/
int str_iscombiningmark (const char *ch);
gboolean str_iscombiningmark (const char *ch);
/* write lower from of fisrt characters in ch into out
* decrase remain by size of returned characters

View File

@ -59,7 +59,7 @@ strutils_escape (const char *src, gsize src_len, const char *escaped_chars,
ret = g_string_new ("");
if (src_len == (gsize) - 1)
if (src_len == (gsize) (-1))
src_len = strlen (src);
for (curr_index = 0; curr_index < src_len; curr_index++)

View File

@ -629,49 +629,49 @@ str_column_to_pos (const char *text, size_t pos)
int
str_isspace (const char *ch)
{
return used_class.isspace (ch);
return used_class.char_isspace (ch);
}
int
str_ispunct (const char *ch)
{
return used_class.ispunct (ch);
return used_class.char_ispunct (ch);
}
int
str_isalnum (const char *ch)
{
return used_class.isalnum (ch);
return used_class.char_isalnum (ch);
}
int
str_isdigit (const char *ch)
{
return used_class.isdigit (ch);
return used_class.char_isdigit (ch);
}
int
str_toupper (const char *ch, char **out, size_t * remain)
{
return used_class.toupper (ch, out, remain);
return used_class.char_toupper (ch, out, remain);
}
int
str_tolower (const char *ch, char **out, size_t * remain)
{
return used_class.tolower (ch, out, remain);
return used_class.char_tolower (ch, out, remain);
}
int
str_isprint (const char *ch)
{
return used_class.isprint (ch);
return used_class.char_isprint (ch);
}
int
gboolean
str_iscombiningmark (const char *ch)
{
return used_class.iscombiningmark (ch);
return used_class.char_iscombiningmark (ch);
}
const char *

View File

@ -161,11 +161,11 @@ str_8bit_isprint (const char *text)
return char_isprint (text[0]);
}
static int
static gboolean
str_8bit_iscombiningmark (const char *text)
{
(void) text;
return 0;
return FALSE;
}
static int
@ -758,14 +758,14 @@ str_8bit_init (void)
result.cprev_char_safe = str_8bit_cprev_char;
result.cnext_noncomb_char = str_8bit_cnext_noncomb_char;
result.cprev_noncomb_char = str_8bit_cprev_noncomb_char;
result.isspace = str_8bit_isspace;
result.ispunct = str_8bit_ispunct;
result.isalnum = str_8bit_isalnum;
result.isdigit = str_8bit_isdigit;
result.isprint = str_8bit_isprint;
result.iscombiningmark = str_8bit_iscombiningmark;
result.toupper = str_8bit_toupper;
result.tolower = str_8bit_tolower;
result.char_isspace = str_8bit_isspace;
result.char_ispunct = str_8bit_ispunct;
result.char_isalnum = str_8bit_isalnum;
result.char_isdigit = str_8bit_isdigit;
result.char_isprint = str_8bit_isprint;
result.char_iscombiningmark = str_8bit_iscombiningmark;
result.char_toupper = str_8bit_toupper;
result.char_tolower = str_8bit_tolower;
result.length = str_8bit_length;
result.length2 = str_8bit_length2;
result.length_noncomb = str_8bit_length;

View File

@ -127,11 +127,11 @@ str_ascii_isprint (const char *text)
return g_ascii_isprint ((gchar) text[0]);
}
static int
static gboolean
str_ascii_iscombiningmark (const char *text)
{
(void) text;
return 0;
return FALSE;
}
static int
@ -648,14 +648,14 @@ str_ascii_init (void)
result.cprev_char_safe = str_ascii_cprev_char;
result.cnext_noncomb_char = str_ascii_cnext_noncomb_char;
result.cprev_noncomb_char = str_ascii_cprev_noncomb_char;
result.isspace = str_ascii_isspace;
result.ispunct = str_ascii_ispunct;
result.isalnum = str_ascii_isalnum;
result.isdigit = str_ascii_isdigit;
result.isprint = str_ascii_isprint;
result.iscombiningmark = str_ascii_iscombiningmark;
result.toupper = str_ascii_toupper;
result.tolower = str_ascii_tolower;
result.char_isspace = str_ascii_isspace;
result.char_ispunct = str_ascii_ispunct;
result.char_isalnum = str_ascii_isalnum;
result.char_isdigit = str_ascii_isdigit;
result.char_isprint = str_ascii_isprint;
result.char_iscombiningmark = str_ascii_iscombiningmark;
result.char_toupper = str_ascii_toupper;
result.char_tolower = str_ascii_tolower;
result.length = str_ascii_length;
result.length2 = str_ascii_length2;
result.length_noncomb = str_ascii_length;

View File

@ -41,10 +41,12 @@
static const char replch[] = "\xEF\xBF\xBD";
static int
static gboolean
str_unichar_iscombiningmark (gunichar uni)
{
int type = g_unichar_type (uni);
GUnicodeType type;
type = g_unichar_type (uni);
return (type == G_UNICODE_COMBINING_MARK)
|| (type == G_UNICODE_ENCLOSING_MARK) || (type == G_UNICODE_NON_SPACING_MARK);
}
@ -163,7 +165,7 @@ str_utf8_isprint (const char *ch)
return g_unichar_isprint (uni);
}
static int
static gboolean
str_utf8_iscombiningmark (const char *ch)
{
gunichar uni = g_utf8_get_char_validated (ch, -1);
@ -363,7 +365,7 @@ struct term_form
{
char text[BUF_MEDIUM * 6];
size_t width;
int compose;
gboolean compose;
};
/* utiliti function, that make string valid in utf8 and all characters printable
@ -378,7 +380,7 @@ str_utf8_make_make_term_form (const char *text, size_t length)
result.text[0] = '\0';
result.width = 0;
result.compose = 0;
result.compose = FALSE;
actual = result.text;
/* check if text start with combining character,
@ -393,7 +395,7 @@ str_utf8_make_make_term_form (const char *text, size_t length)
actual[0] = ' ';
actual++;
result.width++;
result.compose = 1;
result.compose = TRUE;
}
}
}
@ -407,14 +409,14 @@ str_utf8_make_make_term_form (const char *text, size_t length)
{
left = g_unichar_to_utf8 (uni, actual);
actual += left;
if (!str_unichar_iscombiningmark (uni))
if (str_unichar_iscombiningmark (uni))
result.compose = TRUE;
else
{
result.width++;
if (g_unichar_iswide (uni))
result.width++;
}
else
result.compose = 1;
}
else
{
@ -467,43 +469,43 @@ struct utf8_tool
size_t remain;
const char *cheked;
int ident;
int compose;
gboolean compose;
};
/* utiliti function, that copy all characters from cheked to actual */
static int
static gboolean
utf8_tool_copy_chars_to_end (struct utf8_tool *tool)
{
size_t left;
gunichar uni;
tool->compose = 0;
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
{
uni = g_utf8_get_char (tool->cheked);
tool->compose |= str_unichar_iscombiningmark (uni);
tool->compose = tool->compose || str_unichar_iscombiningmark (uni);
left = g_unichar_to_utf8 (uni, NULL);
if (tool->remain <= left)
return 0;
return FALSE;
left = g_unichar_to_utf8 (uni, tool->actual);
tool->actual += left;
tool->remain -= left;
tool->cheked = g_utf8_next_char (tool->cheked);
}
return 1;
return TRUE;
}
/* utiliti function, that copy characters from cheked to actual until ident is
* smaller than to_ident */
static int
static gboolean
utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
{
size_t left;
gunichar uni;
int w;
tool->compose = 0;
tool->compose = FALSE;
while (tool->cheked[0] != '\0')
{
@ -514,24 +516,24 @@ utf8_tool_copy_chars_to (struct utf8_tool *tool, int to_ident)
if (g_unichar_iswide (uni))
w++;
if (tool->ident + w > to_ident)
return 1;
return TRUE;
}
else
{
w = 0;
tool->compose = 1;
tool->compose = TRUE;
}
left = g_unichar_to_utf8 (uni, NULL);
if (tool->remain <= left)
return 0;
return FALSE;
left = g_unichar_to_utf8 (uni, tool->actual);
tool->actual += left;
tool->remain -= left;
tool->cheked = g_utf8_next_char (tool->cheked);
tool->ident += w;
}
return 1;
return TRUE;
}
/* utiliti function, add count spaces to actual */
@ -562,7 +564,7 @@ utf8_tool_insert_char (struct utf8_tool *tool, char ch)
/* utiliti function, thah skip characters from cheked until ident is greater or
* equal to to_ident */
static int
static gboolean
utf8_tool_skip_chars_to (struct utf8_tool *tool, int to_ident)
{
gunichar uni;
@ -584,7 +586,7 @@ utf8_tool_skip_chars_to (struct utf8_tool *tool, int to_ident)
tool->cheked = g_utf8_next_char (tool->cheked);
uni = g_utf8_get_char (tool->cheked);
}
return 1;
return TRUE;
}
static void
@ -607,7 +609,7 @@ str_utf8_fit_to_term (const char *text, int width, align_crt_t just_mode)
tool.cheked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = 0;
tool.compose = FALSE;
if (pre_form->width <= (gsize) width)
{
@ -684,7 +686,7 @@ str_utf8_term_trim (const char *text, int width)
tool.cheked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = 0;
tool.compose = FALSE;
if ((gsize) width < pre_form->width)
{
@ -750,7 +752,7 @@ str_utf8_term_substring (const char *text, int start, int width)
tool.cheked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = 0;
tool.compose = FALSE;
tool.ident = -start;
utf8_tool_skip_chars_to (&tool, 0);
@ -779,7 +781,7 @@ str_utf8_trunc (const char *text, int width)
tool.cheked = pre_form->text;
tool.actual = result;
tool.remain = sizeof (result);
tool.compose = 0;
tool.compose = FALSE;
if (pre_form->width > (gsize) width)
{
@ -1321,14 +1323,14 @@ str_utf8_init (void)
result.cprev_char_safe = str_utf8_cprev_char_safe;
result.cnext_noncomb_char = str_utf8_cnext_noncomb_char;
result.cprev_noncomb_char = str_utf8_cprev_noncomb_char;
result.isspace = str_utf8_isspace;
result.ispunct = str_utf8_ispunct;
result.isalnum = str_utf8_isalnum;
result.isdigit = str_utf8_isdigit;
result.isprint = str_utf8_isprint;
result.iscombiningmark = str_utf8_iscombiningmark;
result.toupper = str_utf8_toupper;
result.tolower = str_utf8_tolower;
result.char_isspace = str_utf8_isspace;
result.char_ispunct = str_utf8_ispunct;
result.char_isalnum = str_utf8_isalnum;
result.char_isdigit = str_utf8_isdigit;
result.char_isprint = str_utf8_isprint;
result.char_iscombiningmark = str_utf8_iscombiningmark;
result.char_toupper = str_utf8_toupper;
result.char_tolower = str_utf8_tolower;
result.length = str_utf8_length;
result.length2 = str_utf8_length2;
result.length_noncomb = str_utf8_length_noncomb;

View File

@ -23,6 +23,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <ctype.h>
#ifdef HAVE_STRVERSCMP
#include <string.h>

View File

@ -83,7 +83,7 @@ static void
tty_color_free_all (gboolean is_temp_color)
{
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_condition_cb,
is_temp_color ? GINT_TO_POINTER (1) : NULL);
is_temp_color ? GSIZE_TO_POINTER (1) : NULL);
}
/* --------------------------------------------------------------------------------------------- */
@ -95,7 +95,7 @@ tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data)
tty_color_pair_t *mc_color_pair;
(void) key;
cp = GPOINTER_TO_INT (user_data);
cp = GPOINTER_TO_SIZE (user_data);
mc_color_pair = (tty_color_pair_t *) value;
return (cp == mc_color_pair->pair_index);
@ -106,12 +106,12 @@ tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data)
static size_t
tty_color_get_next__color_pair_number (void)
{
const size_t cp_count = g_hash_table_size (mc_tty_color__hashtable);
size_t cp;
size_t cp_count, cp;
cp_count = g_hash_table_size (mc_tty_color__hashtable);
for (cp = 0; cp < cp_count; cp++)
if (g_hash_table_find (mc_tty_color__hashtable, tty_color_get_next_cpn_cb,
GINT_TO_POINTER (cp)) == NULL)
GSIZE_TO_POINTER (cp)) == NULL)
break;
return cp;

View File

@ -63,12 +63,16 @@
#else
#include <termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#endif /* __linux__ */
#ifdef __CYGWIN__
#include <termios.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#endif /* __CYGWIN__ */
#ifdef __QNXNTO__
@ -2102,7 +2106,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
}
}
if (!block || mc_global.tty.winch_flag)
if (!block || mc_global.tty.winch_flag != 0)
{
time_addr = &time_out;
time_out.tv_sec = 0;
@ -2122,7 +2126,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
{
if (redo_event)
return EV_MOUSE;
if (!block || mc_global.tty.winch_flag)
if (!block || mc_global.tty.winch_flag != 0)
return EV_NONE;
vfs_timeout_handler ();
}

View File

@ -34,6 +34,10 @@
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <termios.h>
#include "lib/global.h"
#include "lib/strutil.h" /* str_term_form */
@ -98,7 +102,7 @@ sigwinch_handler (int dummy)
{
(void) dummy;
mc_global.tty.winch_flag = TRUE;
mc_global.tty.winch_flag = 1;
}
/* --------------------------------------------------------------------------------------------- */
@ -217,6 +221,41 @@ tty_shutdown (void)
/* --------------------------------------------------------------------------------------------- */
void
tty_change_screen_size (void)
{
#if defined(TIOCGWINSZ) && NCURSES_VERSION_MAJOR >= 4
struct winsize winsz;
winsz.ws_col = winsz.ws_row = 0;
#ifndef NCURSES_VERSION
tty_noraw_mode ();
tty_reset_screen ();
#endif
/* Ioctl on the STDIN_FILENO */
ioctl (fileno (stdout), TIOCGWINSZ, &winsz);
if (winsz.ws_col != 0 && winsz.ws_row != 0)
{
#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM)
resizeterm (winsz.ws_row, winsz.ws_col);
clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */
#else
COLS = winsz.ws_col;
LINES = winsz.ws_row;
#endif
}
#endif /* defined(TIOCGWINSZ) || NCURSES_VERSION_MAJOR >= 4 */
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
tty_resize (mc_global.tty.subshell_pty);
#endif
}
/* --------------------------------------------------------------------------------------------- */
void
tty_reset_prog_mode (void)
{

View File

@ -34,10 +34,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <sys/types.h> /* size_t */
#include <unistd.h>
#include <signal.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <termios.h>
#include "lib/global.h"
#include "lib/strutil.h" /* str_term_form */
@ -128,22 +130,14 @@ static const struct
/* *INDENT-ON* */
};
/* --------------------------------------------------------------------------------------------- */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static void
tty_setup_sigwinch (void (*handler) (int))
{
#ifdef SIGWINCH
struct sigaction act, oact;
act.sa_handler = handler;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
sigaction (SIGWINCH, &act, &oact);
#endif /* SIGWINCH */
(void) SLsignal (SIGWINCH, handler);
}
/* --------------------------------------------------------------------------------------------- */
@ -153,8 +147,8 @@ sigwinch_handler (int dummy)
{
(void) dummy;
tty_change_screen_size ();
mc_global.tty.winch_flag = TRUE;
mc_global.tty.winch_flag = 1;
(void) SLsignal (SIGWINCH, sigwinch_handler);
}
/* --------------------------------------------------------------------------------------------- */
@ -372,6 +366,20 @@ tty_shutdown (void)
}
}
/* --------------------------------------------------------------------------------------------- */
void
tty_change_screen_size (void)
{
SLtt_get_screen_size ();
SLsmg_reinit_smg ();
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
tty_resize (mc_global.tty.subshell_pty);
#endif
}
/* --------------------------------------------------------------------------------------------- */
/* Done each time we come back from done mode */

View File

@ -62,7 +62,7 @@ int mc_tty_frm[MC_TTY_FRM_MAX];
/*** file scope variables ************************************************************************/
static volatile sig_atomic_t got_interrupt = 0;
static SIG_ATOMIC_VOLATILE_T got_interrupt = 0;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -247,38 +247,6 @@ tty_resize (int fd)
/* --------------------------------------------------------------------------------------------- */
void
tty_change_screen_size (void)
{
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
#if defined TIOCGWINSZ
struct winsize winsz;
winsz.ws_col = winsz.ws_row = 0;
/* Ioctl on the STDIN_FILENO */
ioctl (0, TIOCGWINSZ, &winsz);
if (winsz.ws_col && winsz.ws_row)
{
#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM)
resizeterm (winsz.ws_row, winsz.ws_col);
clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */
#else
COLS = winsz.ws_col;
LINES = winsz.ws_row;
#endif
#ifdef HAVE_SUBSHELL_SUPPORT
if (!mc_global.tty.use_subshell)
return;
tty_resize (mc_global.tty.subshell_pty);
#endif
}
#endif /* TIOCGWINSZ */
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
}
/* --------------------------------------------------------------------------------------------- */
void
tty_init_xterm_support (gboolean is_xterm)
{

View File

@ -1145,7 +1145,7 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column,
{
size_t i;
*offset = strtoll (pos_tokens[2], NULL, 10);
*offset = (off_t) g_ascii_strtoll (pos_tokens[2], NULL, 10);
for (i = 0; i < MAX_SAVED_BOOKMARKS && pos_tokens[3 + i] != NULL; i++)
{

View File

@ -561,7 +561,6 @@ vfs_s_readlink (const vfs_path_t * vpath, char *buf, size_t size)
static ssize_t
vfs_s_read (void *fh, char *buffer, size_t count)
{
int n;
struct vfs_class *me = FH_SUPER->me;
if (FH->linear == LS_LINEAR_PREOPEN)
@ -578,6 +577,8 @@ vfs_s_read (void *fh, char *buffer, size_t count)
if (FH->handle != -1)
{
ssize_t n;
n = read (FH->handle, buffer, count);
if (n < 0)
me->verrno = errno;
@ -592,7 +593,6 @@ vfs_s_read (void *fh, char *buffer, size_t count)
static ssize_t
vfs_s_write (void *fh, const char *buffer, size_t count)
{
int n;
struct vfs_class *me = FH_SUPER->me;
if (FH->linear)
@ -601,6 +601,8 @@ vfs_s_write (void *fh, const char *buffer, size_t count)
FH->changed = 1;
if (FH->handle != -1)
{
ssize_t n;
n = write (FH->handle, buffer, count);
if (n < 0)
me->verrno = errno;
@ -1336,7 +1338,8 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
/* If you want reget, you'll have to open file with O_LINEAR */
off_t total = 0;
char buffer[8192];
int handle, n;
int handle;
ssize_t n;
off_t stat_size = ino->st.st_size;
vfs_file_handler_t fh;
vfs_path_t *tmp_vpath;

View File

@ -320,8 +320,8 @@ int mc_##name (const vfs_path_t *vpath1, const vfs_path_t *vpath2) \
if (vpath1 == NULL || vpath2 == NULL) \
return -1; \
\
path_element1 = vfs_path_get_by_index (vpath1, - 1); \
path_element2 = vfs_path_get_by_index (vpath2, - 1); \
path_element1 = vfs_path_get_by_index (vpath1, (-1)); \
path_element2 = vfs_path_get_by_index (vpath2, (-1)); \
\
if (!vfs_path_element_valid (path_element1) || !vfs_path_element_valid (path_element2) || \
path_element1->class != path_element2->class) \
@ -777,72 +777,32 @@ mc_lseek (int fd, off_t offset, int whence)
int
mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix)
{
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static unsigned long value;
struct timeval tv;
char *tmpbase;
char *tmpname;
char *XXXXXX;
char *ret_path;
int count;
char *p1, *p2;
int fd;
if (strchr (prefix, PATH_SEP) == NULL)
{
/* Add prefix first to find the position of XXXXXX */
tmpbase = g_build_filename (mc_tmpdir (), prefix, NULL);
}
if (strchr (prefix, PATH_SEP) != NULL)
p1 = g_strdup (prefix);
else
{
tmpbase = g_strdup (prefix);
/* Add prefix first to find the position of XXXXXX */
p1 = g_build_filename (mc_tmpdir (), prefix, (char *) NULL);
}
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL);
ret_path = tmpname;
XXXXXX = &tmpname[strlen (tmpbase)];
g_free (tmpbase);
p2 = g_strconcat (p1, "XXXXXX", suffix, (char *) NULL);
g_free (p1);
/* Get some more or less random data. */
gettimeofday (&tv, NULL);
value += (tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
for (count = 0; count < TMP_MAX; ++count)
fd = g_mkstemp (p2);
if (fd >= 0)
*pname_vpath = vfs_path_from_str (p2);
else
{
unsigned long v = value;
int fd;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];
v /= 62;
XXXXXX[1] = letters[v % 62];
v /= 62;
XXXXXX[2] = letters[v % 62];
v /= 62;
XXXXXX[3] = letters[v % 62];
v /= 62;
XXXXXX[4] = letters[v % 62];
v /= 62;
XXXXXX[5] = letters[v % 62];
fd = open (tmpname, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
if (fd >= 0)
{
/* Successfully created. */
*pname_vpath = vfs_path_from_str (ret_path);
g_free (ret_path);
return fd;
}
/* This is a random value. It is only necessary that the next
TMP_MAX values generated by adding 7777 to VALUE are different
with (module 2^32). */
value += 7777;
*pname_vpath = NULL;
fd = -1;
}
/* Unsuccessful. Free the filename. */
g_free (ret_path);
*pname_vpath = NULL;
g_free (p2);
return -1;
return fd;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -36,7 +36,7 @@
/*** global variables ****************************************************************************/
volatile sig_atomic_t got_sigpipe = 0;
SIG_ATOMIC_VOLATILE_T got_sigpipe = 0;
/*** file scope macro definitions ****************************************************************/

View File

@ -16,7 +16,7 @@
/*** global variables defined in .c file *********************************************************/
extern volatile sig_atomic_t got_sigpipe;
extern SIG_ATOMIC_VOLATILE_T got_sigpipe;
/*** declarations of public functions ************************************************************/

View File

@ -778,11 +778,7 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna
if (!is_num (idx2))
goto error;
#ifdef HAVE_ATOLL
s->st_size = (off_t) atoll (columns[idx2]);
#else
s->st_size = (off_t) atof (columns[idx2]);
#endif
s->st_size = (off_t) g_ascii_strtoll (columns[idx2], NULL, 10);
#ifdef HAVE_STRUCT_STAT_ST_RDEV
s->st_rdev = 0;
#endif

View File

@ -154,8 +154,8 @@ typedef struct vfs_class
void *(*open) (const vfs_path_t * vpath, int flags, mode_t mode);
int (*close) (void *vfs_info);
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
void *(*opendir) (const vfs_path_t * vpath);
void *(*readdir) (void *vfs_info);
@ -176,10 +176,10 @@ typedef struct vfs_class
int (*rename) (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
int (*chdir) (const vfs_path_t * vpath);
int (*ferrno) (struct vfs_class * me);
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
int (*mknod) (const vfs_path_t * vpath, mode_t mode, dev_t dev);
vfsid (*getid) (const vfs_path_t * vpath);
vfsid (*getid) (const vfs_path_t * vpath);
int (*nothingisopen) (vfsid id);
void (*free) (vfsid id);

View File

@ -147,7 +147,7 @@ struct vfs_s_subclass
int (*file_store) (struct vfs_class * me, vfs_file_handler_t * fh, char *path, char *localname);
int (*linear_start) (struct vfs_class * me, vfs_file_handler_t * fh, off_t from);
int (*linear_read) (struct vfs_class * me, vfs_file_handler_t * fh, void *buf, size_t len);
ssize_t (*linear_read) (struct vfs_class * me, vfs_file_handler_t * fh, void *buf, size_t len);
void (*linear_close) (struct vfs_class * me, vfs_file_handler_t * fh);
};

View File

@ -32,17 +32,12 @@
#include <config.h>
/* If TIOCGWINSZ supported, make it available here, because window resizing code
* depends on it... */
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <termios.h>
#include "lib/global.h"
#include "lib/tty/tty.h" /* LINES, COLS */
#include "lib/tty/win.h" /* do_enter_ca_mode() */
#include "lib/tty/color.h" /* tty_set_normal_attrs() */
#ifdef HAVE_SLANG
#include "lib/tty/win.h" /* do_enter_ca_mode() */
#endif
#include "lib/widget.h"
#include "lib/event.h"
@ -121,7 +116,6 @@ dialog_switch_goto (GList * dlg)
/* --------------------------------------------------------------------------------------------- */
#if defined TIOCGWINSZ
static void
dlg_resize_cb (void *data, void *user_data)
{
@ -133,7 +127,6 @@ dlg_resize_cb (void *data, void *user_data)
else
d->winch_pending = TRUE;
}
#endif
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
@ -358,7 +351,7 @@ mc_refresh (void)
if (mc_global.we_are_background)
return;
#endif /* ENABLE_BACKGROUND */
if (!mc_global.tty.winch_flag)
if (mc_global.tty.winch_flag == 0)
tty_refresh ();
else
{
@ -373,23 +366,11 @@ mc_refresh (void)
void
dialog_change_screen_size (void)
{
mc_global.tty.winch_flag = FALSE;
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
#if defined TIOCGWINSZ
mc_global.tty.winch_flag = 0;
#ifndef NCURSES_VERSION
tty_noraw_mode ();
tty_reset_screen ();
#endif
tty_change_screen_size ();
#ifdef HAVE_SLANG
/* XSI Curses spec states that portable applications shall not invoke
* initscr() more than once. This kludge could be done within the scope
* of the specification by using endwin followed by a refresh (in fact,
* more than one curses implementation does this); it is guaranteed to work
* only with slang.
*/
SLsmg_init_smg ();
do_enter_ca_mode ();
tty_keypad (TRUE);
tty_nodelay (FALSE);
@ -402,9 +383,6 @@ dialog_change_screen_size (void)
/* Now, force the redraw */
repaint_screen ();
#endif /* TIOCGWINSZ */
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -532,7 +532,7 @@ frontend_run_dlg (Dlg_head * h)
while (h->state == DLG_ACTIVE)
{
if (mc_global.tty.winch_flag)
if (mc_global.tty.winch_flag != 0)
dialog_change_screen_size ();
if (is_idle ())

View File

@ -10,12 +10,12 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
textmode_x11_support="no"
else
found_gmodule=no
PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.8], [found_gmodule=yes], [:])
PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-no-export-2.0"
else
dnl try fallback to the generic gmodule
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:])
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-2.0"
fi
@ -89,9 +89,9 @@ AC_DEFUN([AC_CHECK_GLIB], [
AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]))
glib_found=no
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [glib_found=yes], [:])
if test x"$glib_found" = xno; then
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.12)])
fi
])

View File

@ -1,5 +1,8 @@
SYNTAX_IN = Syntax.in
SYNTAX_OUT = Syntax
SYNTAXFILES = \
Syntax \
PKGBUILD.syntax \
ada95.syntax \
as.syntax \
@ -76,7 +79,9 @@ SYNTAXFILES = \
if USE_EDIT
syntaxdir = $(pkgdatadir)/syntax
syntax_DATA = $(SYNTAXFILES)
syntax_DATA = $(SYNTAX_OUT) \
$(SYNTAXFILES)
endif
EXTRA_DIST = $(SYNTAXFILES)
EXTRA_DIST = $(SYNTAX_IN) \
$(SYNTAXFILES)

View File

@ -171,7 +171,7 @@ include po.syntax
file ..\*\\.([Aa][Ss][Mm]|s|S)$ ASM\sProgram
include assembler.syntax
file ..\*\\.([Pp][Oo][Vv])$ POV\sScript
include povray.syntax

View File

@ -410,10 +410,8 @@ mc_args_add_extended_info_to_help (void)
"as tickets at www.midnight-commander.org\n"));
mc_args__loc__header_string = g_strdup_printf (_("GNU Midnight Commander %s\n"), VERSION);
#if GLIB_CHECK_VERSION(2,12,0)
g_option_context_set_description (context, mc_args__loc__footer_string);
g_option_context_set_summary (context, mc_args__loc__header_string);
#endif
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -35,8 +35,10 @@
#include <sys/types.h>
#ifdef __FreeBSD__
#include <sys/consio.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#endif
#include <unistd.h>
#include "lib/global.h"

View File

@ -290,7 +290,7 @@ void edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath);
void edit_load_syntax (WEdit * edit, char ***pnames, const char *type);
void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, off_t byte_index, int *color);
int edit_get_syntax_color (WEdit * edit, off_t byte_index);
void book_mark_insert (WEdit * edit, long line, int c);
int book_mark_query_color (WEdit * edit, long line, int c);

View File

@ -2341,10 +2341,7 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
edit->modified = 0;
edit->locked = 0;
edit_load_syntax (edit, NULL, NULL);
{
int color;
edit_get_syntax_color (edit, -1, &color);
}
edit_get_syntax_color (edit, -1);
/* load saved cursor position */
if ((line == 0) && option_save_position)

View File

@ -1571,9 +1571,7 @@ void
edit_refresh_cmd (WEdit * edit)
{
#ifdef HAVE_SLANG
int color;
edit_get_syntax_color (edit, -1, &color);
edit_get_syntax_color (edit, -1);
tty_touch_screen ();
mc_refresh ();
#else
@ -1982,7 +1980,7 @@ edit_load_macro_cmd (WEdit * edit)
macros_config = mc_config_init (macros_fname, TRUE);
g_free (macros_fname);
if (macros_config == NULL)
if (macros_config == NULL || macros_list == NULL || macros_list->len != 0)
return FALSE;
profile_keys = keys = mc_config_get_keys (macros_config, section_name, &len);
@ -2378,6 +2376,9 @@ edit_block_move_cmd (WEdit * edit)
if (eval_marks (edit, &start_mark, &end_mark))
return;
if (!edit->column_highlight && edit->curs1 > start_mark && edit->curs1 < end_mark)
return;
line = edit->curs_line;
if (edit->mark2 < 0)
edit_mark_cmd (edit, FALSE);
@ -2387,13 +2388,12 @@ edit_block_move_cmd (WEdit * edit)
{
off_t mark1, mark2;
int size;
int b_width = 0;
int c1, c2;
int c1, c2, b_width;
int x, x2;
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
b_width = (c2 - c1);
b_width = c2 - c1;
edit_update_curs_col (edit);
@ -2401,7 +2401,7 @@ edit_block_move_cmd (WEdit * edit)
x2 = x + edit->over_col;
/* do nothing when cursor inside first line of selected area */
if ((edit_eol (edit, edit->curs1) == edit_eol (edit, start_mark)) && (x2 > c1 && x2 <= c2))
if ((edit_eol (edit, edit->curs1) == edit_eol (edit, start_mark)) && x2 > c1 && x2 <= c2)
return;
if (edit->curs1 > start_mark && edit->curs1 < edit_eol (edit, end_mark))
@ -2438,12 +2438,10 @@ edit_block_move_cmd (WEdit * edit)
copy_buf = g_malloc0 (end_mark - start_mark);
edit_cursor_move (edit, start_mark - edit->curs1);
edit_scroll_screen_over_cursor (edit);
count = start_mark;
while (count < end_mark)
{
for (count = start_mark; count < end_mark; count++)
copy_buf[end_mark - count - 1] = edit_delete (edit, 1);
count++;
}
edit_scroll_screen_over_cursor (edit);
edit_cursor_move (edit,
current - edit->curs1 -

View File

@ -332,7 +332,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
end_col -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
edit_get_syntax_color (edit, b - 1, &color);
color = edit_get_syntax_color (edit, b - 1);
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
@ -412,7 +412,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
}
else
{
edit_get_syntax_color (edit, q, &color);
color = edit_get_syntax_color (edit, q);
p->style |= color << 16;
}
switch (c)

View File

@ -603,13 +603,12 @@ edit_get_rule (WEdit * edit, off_t byte_index)
/* --------------------------------------------------------------------------------------------- */
static inline void
translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int *color)
static inline int
translate_rule_to_color (WEdit * edit, struct syntax_rule rule)
{
*color = edit->rules[rule.context]->keyword[rule.keyword]->color;
return edit->rules[rule.context]->keyword[rule.keyword]->color;
}
/* --------------------------------------------------------------------------------------------- */
/**
Returns 0 on error/eof or a count of the number of bytes read
@ -1414,15 +1413,16 @@ get_first_editor_line (WEdit * edit)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
edit_get_syntax_color (WEdit * edit, off_t byte_index, int *color)
int
edit_get_syntax_color (WEdit * edit, off_t byte_index)
{
if (!tty_use_colors ())
*color = 0;
else if (edit->rules && byte_index < edit->last_byte && option_syntax_highlighting)
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color);
else
*color = EDITOR_NORMAL_COLOR;
return 0;
if (edit->rules != NULL && byte_index < edit->last_byte && option_syntax_highlighting)
return translate_rule_to_color (edit, edit_get_rule (edit, byte_index));
return EDITOR_NORMAL_COLOR;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -317,6 +317,8 @@ toggle_panels (void)
vfs_path_t **new_dir_p;
#endif /* HAVE_SUBSHELL_SUPPORT */
SIG_ATOMIC_VOLATILE_T was_sigwinch = 0;
channels_down ();
disable_mouse ();
if (clear_before_exec)
@ -386,6 +388,13 @@ toggle_panels (void)
if (mc_global.tty.alternate_plus_minus)
application_keypad_mode ();
/* HACK:
* Save sigwinch flag that will be reset in mc_refresh() called via update_panels().
* There is some problem with screen redraw in ncurses-based mc in this situation.
*/
was_sigwinch = mc_global.tty.winch_flag;
mc_global.tty.winch_flag = 0;
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
{
@ -406,7 +415,11 @@ toggle_panels (void)
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
update_xterm_title_path ();
}
repaint_screen ();
if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0)
dialog_change_screen_size ();
else
repaint_screen ();
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -18,8 +18,8 @@ libmcfilemanager_la_SOURCES = \
hotlist.c hotlist.h \
info.c info.h \
layout.c layout.h \
listmode.c listmode.h \
midnight.h midnight.c \
mountlist.c mountlist.h \
option.c option.h \
panelize.c panelize.h \
panel.c panel.h \
@ -27,9 +27,8 @@ libmcfilemanager_la_SOURCES = \
treestore.c treestore.h \
usermenu.c usermenu.h
#if USE_MOUNTLIST
libmcfilemanager_la_SOURCES += mountlist.c mountlist.h
#endif
# Unmaintained, unsupported, etc
# listmode.c listmode.h
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS)

View File

@ -737,8 +737,8 @@ apply_advanced_chowns (struct stat *sf)
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
/* call mc_chown only, if mc_chmod didn't fail */
else if (mc_chown (vpath, (ch_flags[9] == '+') ? sf->st_uid : (uid_t) - 1,
(ch_flags[10] == '+') ? sf->st_gid : (gid_t) - 1) == -1)
else if (mc_chown (vpath, (ch_flags[9] == '+') ? sf->st_uid : (uid_t) (-1),
(ch_flags[10] == '+') ? sf->st_gid : (gid_t) (-1)) == -1)
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
do_file_mark (current_panel, current_file, 0);
@ -759,8 +759,8 @@ apply_advanced_chowns (struct stat *sf)
message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
/* call mc_chown only, if mc_chmod didn't fail */
else if (mc_chown (vpath, (ch_flags[9] == '+') ? a_uid : (uid_t) - 1,
(ch_flags[10] == '+') ? a_gid : (gid_t) - 1) == -1)
else if (mc_chown (vpath, (ch_flags[9] == '+') ? a_uid : (uid_t) (-1),
(ch_flags[10] == '+') ? a_gid : (gid_t) (-1)) == -1)
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"),
lc_fname, unix_error_string (errno));
@ -822,8 +822,8 @@ chown_advanced_cmd (void)
fname, unix_error_string (errno));
/* call mc_chown only, if mc_chmod didn't fail */
else if (mc_chown
(fname_vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) - 1,
(ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) - 1) == -1)
(fname_vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) (-1),
(ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) (-1)) == -1)
message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname,
unix_error_string (errno));
vfs_path_free (fname_vpath);

View File

@ -256,8 +256,8 @@ enter (WInput * lc_cmdline)
}
else
{
char *command, *s;
size_t i, j, cmd_len;
GString *command;
size_t i;
if (!vfs_current_is_local ())
{
@ -273,30 +273,25 @@ enter (WInput * lc_cmdline)
return MSG_NOT_HANDLED;
}
#endif
cmd_len = strlen (cmd);
command = g_malloc (cmd_len + 1);
command[0] = 0;
for (i = j = 0; i < cmd_len; i++)
command = g_string_sized_new (32);
for (i = 0; cmd[i] != '\0'; i++)
{
if (cmd[i] == '%')
{
i++;
s = expand_format (NULL, cmd[i], TRUE);
command = g_realloc (command, j + strlen (s) + cmd_len - i + 1);
strcpy (command + j, s);
g_free (s);
j = strlen (command);
}
if (cmd[i] != '%')
g_string_append_c (command, cmd[i]);
else
{
command[j] = cmd[i];
j++;
char *s;
s = expand_format (NULL, cmd[++i], TRUE);
g_string_append (command, s);
g_free (s);
}
command[j] = 0;
}
input_clean (lc_cmdline);
shell_execute (command, 0);
g_free (command);
shell_execute (command->str, 0);
g_string_free (command, TRUE);
#ifdef HAVE_SUBSHELL_SUPPORT
if ((quit & SUBSHELL_EXIT) != 0)

View File

@ -115,7 +115,9 @@ key_collate (const char *t1, const char *t2)
}
/* --------------------------------------------------------------------------------------------- */
/** clear keys, should be call after sorting is finished */
/**
* clear keys, should be call after sorting is finished.
*/
static void
clean_sort_keys (dir_list * list, int start, int count)
@ -131,6 +133,30 @@ clean_sort_keys (dir_list * list, int start, int count)
}
}
/* --------------------------------------------------------------------------------------------- */
/**
* Increase directory list by RESIZE_STEPS
*
* @param list directory list
* @returns FALSE = failure, TRUE = success
*/
static gboolean
grow_list (dir_list * list)
{
if (list == NULL)
return FALSE;
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
if (list->list == NULL)
return FALSE;
list->size += RESIZE_STEPS;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
/**
* If you change handle_dirent then check also handle_path.
@ -183,13 +209,9 @@ handle_dirent (dir_list * list, const char *fltr, struct dirent *dp,
return 0;
/* Need to grow the *list? */
if (next_free == list->size)
{
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
if (list->list == NULL)
return -1;
list->size += RESIZE_STEPS;
}
if (next_free == list->size && !grow_list (list))
return -1;
return 1;
}
@ -456,14 +478,8 @@ gboolean
set_zero_dir (dir_list * list)
{
/* Need to grow the *list? */
if (list->size == 0)
{
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
if (list->list == NULL)
return FALSE;
list->size += RESIZE_STEPS;
}
if (list->size == 0 && !grow_list (list))
return FALSE;
memset (&(list->list)[0], 0, sizeof (file_entry));
list->list[0].fnamelen = 2;
@ -521,13 +537,9 @@ handle_path (dir_list * list, const char *path,
vfs_path_free (vpath);
/* Need to grow the *list? */
if (next_free == list->size)
{
list->list = g_try_realloc (list->list, sizeof (file_entry) * (list->size + RESIZE_STEPS));
if (list->list == NULL)
return -1;
list->size += RESIZE_STEPS;
}
if (next_free == list->size && !grow_list (list))
return -1;
return 1;
}

View File

@ -2615,7 +2615,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
static gboolean i18n_flag = FALSE;
if (!i18n_flag)
{
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
op_names[i] = Q_ (op_names[i]);
i18n_flag = TRUE;
}
@ -2753,26 +2753,6 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
tctx = file_op_total_context_new ();
gettimeofday (&tctx->transfer_start, (struct timezone *) NULL);
{
filegui_dialog_type_t dialog_type;
if (operation == OP_DELETE)
dialog_type = FILEGUI_DIALOG_DELETE_ITEM;
else
{
dialog_type = !((operation != OP_COPY) || (single_entry) || (force_single))
? FILEGUI_DIALOG_MULTI_ITEM : FILEGUI_DIALOG_ONE_ITEM;
if ((single_entry) && (operation == OP_COPY) && S_ISDIR (selection (panel)->st.st_mode))
dialog_type = FILEGUI_DIALOG_MULTI_ITEM;
}
/* Background also need ctx->ui, but not full */
if (do_bg)
file_op_context_create_ui_without_init (ctx, TRUE, dialog_type);
else
file_op_context_create_ui (ctx, TRUE, dialog_type);
}
#ifdef ENABLE_BACKGROUND
/* Did the user select to do a background operation? */
@ -2799,17 +2779,35 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
return FALSE;
}
}
else
#endif /* ENABLE_BACKGROUND */
{
filegui_dialog_type_t dialog_type;
if (operation == OP_DELETE)
dialog_type = FILEGUI_DIALOG_DELETE_ITEM;
else
{
dialog_type = ((operation != OP_COPY) || single_entry || force_single)
? FILEGUI_DIALOG_ONE_ITEM : FILEGUI_DIALOG_MULTI_ITEM;
if (single_entry && (operation == OP_COPY) && S_ISDIR (selection (panel)->st.st_mode))
dialog_type = FILEGUI_DIALOG_MULTI_ITEM;
}
file_op_context_create_ui (ctx, TRUE, dialog_type);
}
/* Initialize things */
/* We do not want to trash cache every time file is
created/touched. However, this will make our cache contain
invalid data. */
if ((dest != NULL) && (mc_setctl (dest_vpath, VFS_SETCTL_STALE_DATA, (void *) 1)))
if ((dest != NULL)
&& (mc_setctl (dest_vpath, VFS_SETCTL_STALE_DATA, GUINT_TO_POINTER (1)) != 0))
save_dest = g_strdup (dest);
if ((vfs_path_tokens_count (panel->cwd_vpath) != 0)
&& (mc_setctl (panel->cwd_vpath, VFS_SETCTL_STALE_DATA, (void *) 1)))
&& (mc_setctl (panel->cwd_vpath, VFS_SETCTL_STALE_DATA, GUINT_TO_POINTER (1)) != 0))
save_cwd = vfs_path_to_str (panel->cwd_vpath);
/* Now, let's do the job */

View File

@ -615,10 +615,10 @@ check_progress_buttons (FileOpContext * ctx)
/* {{{ File progress display routines */
void
file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
filegui_dialog_type_t dialog_type)
file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta, filegui_dialog_type_t dialog_type)
{
FileOpContextUI *ui;
const char *abort_button_label = N_("&Abort");
const char *skip_button_label = N_("&Skip");
int abort_button_width, skip_button_width, buttons_width;
@ -639,9 +639,6 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
dlg_width = max (58, buttons_width + 6);
dlg_height = 17; /* to make compiler happy :) */
ui = g_new0 (FileOpContextUI, 1);
ctx->ui = ui;
ctx->dialog_type = dialog_type;
switch (dialog_type)
@ -658,7 +655,9 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
}
ctx->recursive_result = RECURSIVE_YES;
ctx->ui = g_new0 (FileOpContextUI, 1);
ui = ctx->ui;
ui->replace_result = REPLACE_YES;
ui->showing_eta = with_eta && file_op_compute_totals;
ui->showing_bps = with_eta;
@ -706,21 +705,6 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
if (verbose && file_op_compute_totals && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
ui->progress_total_gauge->from_left_to_right = FALSE;
}
}
/* --------------------------------------------------------------------------------------------- */
void
file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
filegui_dialog_type_t dialog_type)
{
FileOpContextUI *ui;
g_return_if_fail (ctx != NULL);
g_return_if_fail (ctx->ui == NULL);
file_op_context_create_ui_without_init (ctx, with_eta, dialog_type);
ui = ctx->ui;
/* We will manage the dialog without any help, that's why
we have to call init_dlg */

View File

@ -20,8 +20,6 @@
void file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
filegui_dialog_type_t dialog_type);
void file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
filegui_dialog_type_t dialog_type);
void file_op_context_destroy_ui (FileOpContext * ctx);
char *file_mask_dialog (FileOpContext * ctx, FileOperation operation,

View File

@ -125,7 +125,7 @@ typedef struct FileOpContext
/* Preserve the original files' owner, group, permissions, and
* timestamps (owner, group only as root).
*/
int preserve;
gboolean preserve;
/* If running as root, preserve the original uid/gid (we don't want to
* try chown for non root) preserve_uidgid = preserve && uid == 0
@ -142,7 +142,7 @@ typedef struct FileOpContext
struct mc_search_struct *search_handle;
/* Whether to dive into subdirectories for recursive operations */
int dive_into_subdirs;
gboolean dive_into_subdirs;
/* When moving directories cross filesystem boundaries delete the
* successfully copied files when all files below the directory and its

View File

@ -1054,7 +1054,7 @@ quit_cmd_internal (int quiet)
#ifdef HAVE_SUBSHELL_SUPPORT
if (!mc_global.tty.use_subshell)
stop_dialogs ();
else if ((q = exit_subshell ()))
else if ((q = exit_subshell () ? 1 : 0) != 0)
#endif
stop_dialogs ();
}
@ -1707,17 +1707,19 @@ do_nc (void)
midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback,
"[main]", NULL, DLG_WANT_IDLE);
if (mc_global.mc_run_mode == MC_RUN_FULL)
setup_mc ();
else
setup_dummy_mc ();
/* Check if we were invoked as an editor or file viewer */
if (mc_global.mc_run_mode != MC_RUN_FULL)
{
setup_dummy_mc ();
ret = mc_maybe_editor_or_viewer ();
}
else
{
setup_mc ();
mc_filehighlight = mc_fhl_new (TRUE);
create_panels_and_run_mc ();
mc_fhl_free (&mc_filehighlight);
ret = TRUE;
/* destroy_dlg destroys even current_panel->cwd_vpath, so we have to save a copy :) */

View File

@ -201,16 +201,37 @@
#undef opendir
#undef closedir
#ifndef ME_DUMMY
#define ME_DUMMY(Fs_name, Fs_type) \
(strcmp (Fs_type, "autofs") == 0 \
|| strcmp (Fs_type, "none") == 0 \
|| strcmp (Fs_type, "proc") == 0 \
|| strcmp (Fs_type, "subfs") == 0 \
/* for NetBSD 3.0 */ \
|| strcmp (Fs_type, "kernfs") == 0 \
/* for Irix 6.5 */ \
|| strcmp (Fs_type, "ignore") == 0)
#define ME_DUMMY_0(Fs_name, Fs_type) \
(strcmp (Fs_type, "autofs") == 0 \
|| strcmp (Fs_type, "proc") == 0 \
|| strcmp (Fs_type, "subfs") == 0 \
/* for Linux 2.6/3.x */ \
|| strcmp (Fs_type, "debugfs") == 0 \
|| strcmp (Fs_type, "devpts") == 0 \
|| strcmp (Fs_type, "devtmpfs") == 0 \
|| strcmp (Fs_type, "fusectl") == 0 \
|| strcmp (Fs_type, "mqueue") == 0 \
|| strcmp (Fs_type, "rpc_pipefs") == 0 \
|| strcmp (Fs_type, "sysfs") == 0 \
/* FreeBSD, Linux 2.4 */ \
|| strcmp (Fs_type, "devfs") == 0 \
/* for NetBSD 3.0 */ \
|| strcmp (Fs_type, "kernfs") == 0 \
/* for Irix 6.5 */ \
|| strcmp (Fs_type, "ignore") == 0)
/* Historically, we have marked as "dummy" any file system of type "none",
but now that programs like du need to know about bind-mounted directories,
we grant an exception to any with "bind" in its list of mount options.
I.e., those are *not* dummy entries. */
#ifdef MOUNTED_GETMNTENT1
#define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \
(ME_DUMMY_0 (Fs_name, Fs_type) \
|| (strcmp (Fs_type, "none") == 0 \
&& !hasmntopt (Fs_ent, "bind")))
#else
#define ME_DUMMY(Fs_name, Fs_type) \
(ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
#endif
#ifdef __CYGWIN__
@ -354,13 +375,11 @@ free_mount_entry (struct mount_entry *me)
{
if (!me)
return;
if (me->me_devname)
free (me->me_devname);
if (me->me_mountdir)
free (me->me_mountdir);
if (me->me_type && me->me_type_malloced)
free (me->me_type);
free (me);
g_free (me->me_devname);
g_free (me->me_mountdir);
if (me->me_type_malloced)
g_free (me->me_type);
g_free (me);
}
/* --------------------------------------------------------------------------------------------- */
@ -590,10 +609,10 @@ read_file_system_list (int need_fs_type)
for (p = mntlist; p; p = p->next)
{
mnt = p->ment;
me = malloc (sizeof (*me));
me->me_devname = strdup (mnt->mnt_fsname);
me->me_mountdir = strdup (mnt->mnt_dir);
me->me_type = strdup (mnt->mnt_type);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (mnt->mnt_fsname);
me->me_mountdir = g_strdup (mnt->mnt_dir);
me->me_type = g_strdup (mnt->mnt_type);
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@ -617,12 +636,12 @@ read_file_system_list (int need_fs_type)
while ((mnt = getmntent (fp)))
{
me = malloc (sizeof (*me));
me->me_devname = strdup (mnt->mnt_fsname);
me->me_mountdir = strdup (mnt->mnt_dir);
me->me_type = strdup (mnt->mnt_type);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (mnt->mnt_fsname);
me->me_mountdir = g_strdup (mnt->mnt_dir);
me->me_type = g_strdup (mnt->mnt_type);
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, mnt);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = dev_from_mount_options (mnt->mnt_opts);
@ -648,14 +667,14 @@ read_file_system_list (int need_fs_type)
{
char *fs_type = fsp_to_string (fsp);
me = malloc (sizeof (*me));
me->me_devname = strdup (fsp->f_mntfromname);
me->me_mountdir = strdup (fsp->f_mntonname);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (fsp->f_mntfromname);
me->me_mountdir = g_strdup (fsp->f_mntonname);
me->me_type = fs_type;
me->me_type_malloced = 0;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
@ -674,14 +693,14 @@ read_file_system_list (int need_fs_type)
return NULL;
for (; entries-- > 0; fsp++)
{
me = malloc (sizeof (*me));
me->me_devname = strdup (fsp->f_mntfromname);
me->me_mountdir = strdup (fsp->f_mntonname);
me->me_type = strdup (fsp->f_fstypename);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (fsp->f_mntfromname);
me->me_mountdir = g_strdup (fsp->f_mntonname);
me->me_type = g_strdup (fsp->f_fstypename);
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
@ -698,9 +717,9 @@ read_file_system_list (int need_fs_type)
while (errno = 0, 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, (char *) 0)))
{
me = malloc (sizeof (*me));
me->me_devname = strdup (fsd.fd_req.devname);
me->me_mountdir = strdup (fsd.fd_req.path);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (fsd.fd_req.devname);
me->me_mountdir = g_strdup (fsd.fd_req.path);
me->me_type = gt_names[fsd.fd_req.fstype];
me->me_type_malloced = 0;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@ -759,17 +778,13 @@ read_file_system_list (int need_fs_type)
continue;
if (strcmp (d->d_name, ".") == 0)
name = strdup ("/");
name = g_strdup ("/");
else
{
name = malloc (1 + strlen (d->d_name) + 1);
name[0] = '/';
strcpy (name + 1, d->d_name);
}
name = g_strconcat ("/", d->d_name, (char *) NULL);
if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
{
struct rootdir_entry *re = malloc (sizeof (*re));
struct rootdir_entry *re = g_malloc (sizeof (*re));
re->name = name;
re->dev = statbuf.st_dev;
re->ino = statbuf.st_ino;
@ -779,7 +794,7 @@ read_file_system_list (int need_fs_type)
rootdir_tail = &re->next;
}
else
free (name);
g_free (name);
}
closedir (dirp);
}
@ -795,10 +810,10 @@ read_file_system_list (int need_fs_type)
if (re->dev == fi.dev && re->ino == fi.root)
break;
me = malloc (sizeof (*me));
me->me_devname = strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
me->me_mountdir = strdup (re != NULL ? re->name : fi.fsh_name);
me->me_type = strdup (fi.fsh_name);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
me->me_mountdir = g_strdup (re != NULL ? re->name : fi.fsh_name);
me->me_type = g_strdup (fi.fsh_name);
me->me_type_malloced = 1;
me->me_dev = fi.dev;
me->me_dummy = 0;
@ -814,8 +829,8 @@ read_file_system_list (int need_fs_type)
{
struct rootdir_entry *re = rootdir_list;
rootdir_list = re->next;
free (re->name);
free (re);
g_free (re->name);
g_free (re);
}
}
#endif /* MOUNTED_FS_STAT_DEV */
@ -836,32 +851,32 @@ read_file_system_list (int need_fs_type)
}
bufsize = (1 + numsys) * sizeof (*stats);
stats = malloc (bufsize);
stats = g_malloc (bufsize);
numsys = getfsstat (stats, bufsize, MNT_NOWAIT);
if (numsys < 0)
{
free (stats);
g_free (stats);
return NULL;
}
for (counter = 0; counter < numsys; counter++)
{
me = malloc (sizeof (*me));
me->me_devname = strdup (stats[counter].f_mntfromname);
me->me_mountdir = strdup (stats[counter].f_mntonname);
me->me_type = strdup (FS_TYPE (stats[counter]));
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (stats[counter].f_mntfromname);
me->me_mountdir = g_strdup (stats[counter].f_mntonname);
me->me_type = g_strdup (FS_TYPE (stats[counter]));
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
mtail = &me->me_next;
}
free (stats);
g_free (stats);
}
#endif /* MOUNTED_GETFSSTAT */
@ -877,16 +892,14 @@ read_file_system_list (int need_fs_type)
while (fread (&mnt, sizeof (mnt), 1, fp) > 0)
{
me = malloc (sizeof (*me));
me = g_malloc (sizeof (*me));
#ifdef GETFSTYP /* SVR3. */
me->me_devname = strdup (mnt.mt_dev);
me->me_devname = g_strdup (mnt.mt_dev);
#else
me->me_devname = malloc (strlen (mnt.mt_dev) + 6);
strcpy (me->me_devname, "/dev/");
strcpy (me->me_devname + 5, mnt.mt_dev);
me->me_devname = g_strconcat ("/dev/", mnt.mt_dev, (char *) NULL);
#endif
me->me_mountdir = strdup (mnt.mt_filsys);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_mountdir = g_strdup (mnt.mt_filsys);
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
me->me_type = "";
me->me_type_malloced = 0;
#ifdef GETFSTYP /* SVR3. */
@ -898,7 +911,7 @@ read_file_system_list (int need_fs_type)
if (statfs (me->me_mountdir, &fsd, sizeof (fsd), 0) != -1
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
{
me->me_type = strdup (typebuf);
me->me_type = g_strdup (typebuf);
me->me_type_malloced = 1;
}
}
@ -930,14 +943,14 @@ read_file_system_list (int need_fs_type)
struct mntent **mnttbl = getmnttbl (), **ent;
for (ent = mnttbl; *ent; ent++)
{
me = malloc (sizeof (*me));
me->me_devname = strdup ((*ent)->mt_resource);
me->me_mountdir = strdup ((*ent)->mt_directory);
me->me_type = strdup ((*ent)->mt_fstype);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup ((*ent)->mt_resource);
me->me_mountdir = g_strdup ((*ent)->mt_directory);
me->me_type = g_strdup ((*ent)->mt_fstype);
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
@ -992,10 +1005,10 @@ read_file_system_list (int need_fs_type)
{
while ((ret = getmntent (fp, &mnt)) == 0)
{
me = malloc (sizeof (*me));
me->me_devname = strdup (mnt.mnt_special);
me->me_mountdir = strdup (mnt.mnt_mountp);
me->me_type = strdup (mnt.mnt_fstype);
me = g_malloc (sizeof (*me));
me->me_devname = g_strdup (mnt.mnt_special);
me->me_mountdir = g_strdup (mnt.mnt_mountp);
me->me_type = g_strdup (mnt.mnt_fstype);
me->me_type_malloced = 1;
me->me_dummy = MNT_IGNORE (&mnt) != 0;
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@ -1031,14 +1044,14 @@ read_file_system_list (int need_fs_type)
/* Ask how many bytes to allocate for the mounted file system info. */
if (mntctl (MCTL_QUERY, sizeof (bufsize), (struct vmount *) &bufsize) != 0)
return NULL;
entries = malloc (bufsize);
entries = g_malloc (bufsize);
/* Get the list of mounted file systems. */
n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
if (n_entries < 0)
{
int saved_errno = errno;
free (entries);
g_free (entries);
errno = saved_errno;
return NULL;
}
@ -1048,7 +1061,7 @@ read_file_system_list (int need_fs_type)
char *options, *ignore;
vmp = (struct vmount *) thisent;
me = malloc (sizeof (*me));
me = g_malloc (sizeof (*me));
if (vmp->vmt_flags & MNT_REMOTE)
{
char *host, *dir;
@ -1057,18 +1070,15 @@ read_file_system_list (int need_fs_type)
/* Prepend the remote dirname. */
host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
me->me_devname = malloc (strlen (host) + strlen (dir) + 2);
strcpy (me->me_devname, host);
strcat (me->me_devname, ":");
strcat (me->me_devname, dir);
me->me_devname = g_strconcat (host, ":", dir, (char *) NULL);
}
else
{
me->me_remote = 0;
me->me_devname = strdup (thisent + vmp->vmt_data[VMT_OBJECT].vmt_off);
me->me_devname = g_strdup (thisent + vmp->vmt_data[VMT_OBJECT].vmt_off);
}
me->me_mountdir = strdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
me->me_type = strdup (fstype_to_string (vmp->vmt_gfstype));
me->me_mountdir = g_strdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
me->me_type = g_strdup (fstype_to_string (vmp->vmt_gfstype));
me->me_type_malloced = 1;
options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
ignore = strstr (options, "ignore");
@ -1082,7 +1092,7 @@ read_file_system_list (int need_fs_type)
*mtail = me;
mtail = &me->me_next;
}
free (entries);
g_free (entries);
}
#endif /* MOUNTED_VMOUNT. */
@ -1109,14 +1119,14 @@ read_file_system_list (int need_fs_type)
if (statvfs (node, &dev) == 0)
{
me = malloc (sizeof *me);
me->me_devname = strdup (dev.f_mntfromname);
me->me_mountdir = strdup (dev.f_mntonname);
me->me_type = strdup (dev.f_fstypename);
me = g_malloc (sizeof *me);
me->me_devname = g_strdup (dev.f_mntfromname);
me->me_mountdir = g_strdup (dev.f_mntonname);
me->me_type = g_strdup (dev.f_fstypename);
me->me_type_malloced = 1;
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = (dev_t) - 1; /* Magic; means not known yet. */
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
/* Add to the linked list. */
*mtail = me;
@ -1139,11 +1149,11 @@ read_file_system_list (int need_fs_type)
while (mount_list)
{
me = mount_list->me_next;
free (mount_list->me_devname);
free (mount_list->me_mountdir);
g_free (mount_list->me_devname);
g_free (mount_list->me_mountdir);
if (mount_list->me_type_malloced)
free (mount_list->me_type);
free (mount_list);
g_free (mount_list->me_type);
g_free (mount_list);
mount_list = me;
}
@ -1177,15 +1187,12 @@ read_file_system_list (int need_fs_type, int all_fs)
if (me)
{
if (me->me_devname)
free (me->me_devname);
if (me->me_mountdir)
free (me->me_mountdir);
if (me->me_type)
free (me->me_type);
g_free (me->me_devname);
g_free (me->me_mountdir);
g_free (me->me_type);
}
else
me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
me = (struct mount_entry *) g_malloc (sizeof (struct mount_entry));
if (!getcwd (dir, _POSIX_PATH_MAX))
return (NULL);
@ -1234,9 +1241,9 @@ read_file_system_list (int need_fs_type, int all_fs)
if (fsys_get_mount_pt (dev, &dir) == -1)
return (NULL);
me->me_devname = strdup (dev);
me->me_mountdir = strdup (dir);
me->me_type = strdup (tp);
me->me_devname = g_strdup (dev);
me->me_mountdir = g_strdup (dir);
me->me_type = g_strdup (tp);
me->me_dev = de.disk_type;
#ifdef DEBUG

View File

@ -44,7 +44,6 @@
#include "lib/tty/key.h" /* XCTRL and ALT macros */
#include "lib/skin.h"
#include "lib/strescape.h"
#include "lib/filehighlight.h"
#include "lib/mcconfig.h"
#include "lib/vfs/vfs.h"
#include "lib/unixcompat.h"
@ -306,6 +305,8 @@ panel_field_t panel_fields[] = {
};
/* *INDENT-ON* */
mc_fhl_t *mc_filehighlight = NULL;
extern int saving_setup;
/*** file scope macro definitions ****************************************************************/

View File

@ -11,6 +11,7 @@
#include "lib/fs.h" /* MC_MAXPATHLEN */
#include "lib/strutil.h"
#include "lib/widget.h" /* Widget */
#include "lib/filehighlight.h"
#include "src/main.h" /* cd_enum */
@ -138,6 +139,8 @@ extern panel_field_t panel_fields[];
extern hook_t *select_file_hook;
extern mc_fhl_t *mc_filehighlight;
/*** declarations of public functions ************************************************************/
WPanel *panel_new (const char *panel_name);

View File

@ -48,7 +48,6 @@
#include "lib/tty/tty.h"
#include "lib/tty/key.h" /* For init_key() */
#include "lib/skin.h"
#include "lib/filehighlight.h"
#include "lib/fileloc.h"
#include "lib/strutil.h"
#include "lib/util.h"
@ -79,8 +78,6 @@
/*** global variables ****************************************************************************/
mc_fhl_t *mc_filehighlight;
/* Set when main loop should be terminated */
int quit = 0;
@ -414,12 +411,16 @@ int
main (int argc, char *argv[])
{
GError *error = NULL;
gboolean config_migrated = FALSE;
char *config_migrate_msg;
int exit_code = EXIT_FAILURE;
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
#ifdef HAVE_SETLOCALE
(void) setlocale (LC_ALL, "");
(void) bindtextdomain ("mc", LOCALEDIR);
(void) textdomain ("mc");
#endif
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
/* do this before args parsing */
str_init_strings (NULL);
@ -456,8 +457,8 @@ main (int argc, char *argv[])
goto startup_exit_falure;
mc_config_init_config_paths (&error);
if (error == NULL && mc_config_deprecated_dir_present ())
mc_config_migrate_from_old_place (&error);
if (error == NULL)
config_migrated = mc_config_migrate_from_old_place (&error, &config_migrate_msg);
if (error != NULL)
{
mc_event_deinit (NULL);
@ -531,7 +532,6 @@ main (int argc, char *argv[])
error = NULL;
}
mc_filehighlight = mc_fhl_new (TRUE);
dlg_set_default_colors ();
#ifdef HAVE_SUBSHELL_SUPPORT
@ -560,11 +560,17 @@ main (int argc, char *argv[])
#endif /* HAVE_SUBSHELL_SUPPORT */
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
if (config_migrated)
{
message (D_ERROR, _("Warning"), "%s", config_migrate_msg);
g_free (config_migrate_msg);
}
/* Program main loop */
if (mc_global.midnight_shutdown)
exit_code = EXIT_SUCCESS;
else
exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE;
exit_code = do_nc () ? EXIT_SUCCESS : EXIT_FAILURE;
/* Save the tree store */
(void) tree_store_save ();
@ -576,7 +582,6 @@ main (int argc, char *argv[])
flush_extension_file (); /* does only free memory */
mc_fhl_free (&mc_filehighlight);
mc_skin_deinit ();
tty_colors_done ();

View File

@ -61,8 +61,6 @@ extern gboolean print_last_revert;
/* If set, then print to the given file the last directory we were at */
extern char *last_wd_string;
extern struct mc_fhl_struct *mc_filehighlight;
extern int use_internal_view;
extern int use_internal_edit;

View File

@ -195,12 +195,13 @@ write_all (int fd, const void *buf, size_t count)
{
if (errno == EINTR)
{
if (mc_global.tty.winch_flag)
tty_change_screen_size ();
continue;
}
else
{
return written > 0 ? written : ret;
}
return written > 0 ? written : ret;
}
count -= ret;
written += ret;
@ -502,10 +503,14 @@ feed_subshell (int how, int fail_on_error)
if (select (maxfdp + 1, &read_set, NULL, NULL, wptr) == -1)
{
/* Despite using SA_RESTART, we still have to check for this */
if (errno == EINTR)
{
if (mc_global.tty.winch_flag)
tty_change_screen_size ();
continue; /* try all over again */
}
tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
fprintf (stderr, "select (FD_SETSIZE, &read_set...): %s\r\n",
unix_error_string (errno));
@ -1002,12 +1007,15 @@ read_subshell_prompt (void)
if (rc == -1)
{
if (errno == EINTR)
continue;
else
{
fprintf (stderr, "select (FD_SETSIZE, &tmp...): %s\r\n", unix_error_string (errno));
exit (EXIT_FAILURE);
if (mc_global.tty.winch_flag)
tty_change_screen_size ();
continue;
}
fprintf (stderr, "select (FD_SETSIZE, &tmp...): %s\r\n", unix_error_string (errno));
exit (EXIT_FAILURE);
}
bytes = read (mc_global.tty.subshell_pty, pty_buffer, sizeof (pty_buffer));
@ -1051,16 +1059,16 @@ do_update_prompt (void)
/* --------------------------------------------------------------------------------------------- */
int
gboolean
exit_subshell (void)
{
int subshell_quit = TRUE;
gboolean subshell_quit = TRUE;
if (subshell_state != INACTIVE && subshell_alive)
subshell_quit =
!query_dialog (_("Warning"),
_("The shell is still active. Quit anyway?"),
D_NORMAL, 2, _("&Yes"), _("&No"));
query_dialog (_("Warning"),
_("The shell is still active. Quit anyway?"),
D_NORMAL, 2, _("&Yes"), _("&No")) == 0;
if (subshell_quit)
{

View File

@ -48,7 +48,7 @@ void init_subshell (void);
int invoke_subshell (const char *command, int how, vfs_path_t ** new_dir);
int read_subshell_prompt (void);
void do_update_prompt (void);
int exit_subshell (void);
gboolean exit_subshell (void);
void do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt);
void subshell_get_console_attributes (void);
void sigchld_handler (int sig);

View File

@ -130,7 +130,7 @@ struct new_cpio_header
typedef struct
{
unsigned long inumber;
unsigned short device;
dev_t device;
struct vfs_s_inode *inode;
} defer_inode;
@ -146,13 +146,12 @@ typedef struct
static struct vfs_class vfs_cpiofs_ops;
/* FIXME: should be off_t instead of int. */
static int cpio_position;
static off_t cpio_position;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static int cpio_find_head (struct vfs_class *me, struct vfs_s_super *super);
static ssize_t cpio_find_head (struct vfs_class *me, struct vfs_s_super *super);
static ssize_t cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super);
static ssize_t cpio_read_oldc_head (struct vfs_class *me, struct vfs_s_super *super);
static ssize_t cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super);
@ -171,7 +170,7 @@ cpio_defer_find (const void *a, const void *b)
/* --------------------------------------------------------------------------------------------- */
static int
static ssize_t
cpio_skip_padding (struct vfs_s_super *super)
{
switch (((cpio_super_data_t *) super->data)->type)
@ -306,12 +305,12 @@ cpio_read_head (struct vfs_class *me, struct vfs_s_super *super)
/* --------------------------------------------------------------------------------------------- */
static int
static ssize_t
cpio_find_head (struct vfs_class *me, struct vfs_s_super *super)
{
cpio_super_data_t *arch = (cpio_super_data_t *) super->data;
char buf[BUF_SMALL * 2];
int ptr = 0;
ssize_t ptr = 0;
ssize_t top;
ssize_t tmp;
@ -731,8 +730,6 @@ static int
cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
const vfs_path_element_t * vpath_element)
{
int status = STATUS_START;
(void) vpath_element;
if (cpio_open_cpio_file (vpath_element->class, super, vpath) == -1)
@ -740,6 +737,8 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
while (TRUE)
{
ssize_t status;
status = cpio_read_head (vpath_element->class, super);
switch (status)

View File

@ -6,7 +6,7 @@ EXTFSCONFFILES = sfs.ini
EXTFS_MISC = README README.extfs
# Scripts hat don't need adaptation to the local system
EXTFS_CONST = bpp changesetfs gitfs+ patchsetfs rpm trpm uc1541 u7z
EXTFS_CONST = bpp changesetfs gitfs+ patchsetfs rpm trpm u7z
# Scripts that need adaptation to the local system - source files
EXTFS_IN = \
@ -29,6 +29,7 @@ EXTFS_IN = \
uar.in \
uarc.in \
uarj.in \
uc1541.in \
ucab.in \
uha.in \
ulha.in \
@ -57,6 +58,7 @@ EXTFS_OUT = \
uar \
uarc \
uarj \
uc1541 \
ucab \
uha \
ulha \

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#! @PYTHON@
# -*- coding: utf-8 -*-
#

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! @PYTHON@
"""
UC1541 Virtual filesystem
@ -6,7 +6,58 @@ This extfs provides an access to disk image files for the Commodore
VIC20/C64/C128. It requires the utility c1541 that comes bundled with Vice,
the emulator for the VIC20, C64, C128 and other computers made by Commodore.
Remarks
-------
Due to different way of representing file entries on regular D64 disk images,
there could be issues with filenames that are transfered from/to the image.
Following rules was applied to represent a single file entry:
1. An extension is attached to the end of a filename depending on a file type.
Possible extensions are: prg, del, seq, usr and rel.
2. Every non-ASCII character (which could be some of characters specific to
PET-ASCII, or be a control character) will be replaced by dot (.), since
c1541 program will list them that way.
3. Every slash character (/) will be replaced by pipe character (|).
4. Leading space will be replaced by tilda (~).
While copying from D64 image to filesystem, filenames will be stored as they
are seen on a listing.
While copying from filesystem to D64 image, filename conversion will be done:
1. Every $ and * characters will be replaced by question mark (?)
2. Every pipe (|) and backslash (\) characters will be replaced by slash (/)
3. Every tilda (~) will be replaced by a space
4. 'prg' extension will be truncated
Representation of a directory can be sometimes confusing - in case when one
copied file without extension it stays there in such form, till next access
(after flushing VFS). Also file sizes are not accurate, since D64 directory
entries have sizes stored as 256 bytes blocks.
Configuration
-------------
Here are specific for this script variable, which while set, can influence
script behaviour:
UC1541_DEBUG - if set, uc1541 will produce log in /tmp/uc1541.log file
UC1541_VERBOSE - of set, script will be more verbose, i.e. error messages form
c1541 program will be passed to Midnight Commander, so that user will be aware
of error cause if any.
UC1541_HIDE_DEL - if set, no DEL entries will be shown
Changelog:
2.5 Fixed bug with filenames started with a '-' sign.
2.4 Fixed endless loop bug for reading directory in Python implemented
directory reader.
2.3 Re added and missing method _correct_fname used for writing files
into d64 image.
2.2 Fixed bug(?) with unusual sector end (marked as sector 0, not 255),
causing endless directory reading on random locations.
2.1 Fixed bug with filenames containing slash.
2.0 Added reading raw D64 image, and mapping for jokers. Now it is
possible to read files with PET-ASCII/control sequences in filenames.
Working with d64 images only. Added workaround for space at the
@ -20,8 +71,8 @@ Changelog:
1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2012-09-02
Version: 2.0
Date: 2012-10-15
Version: 2.5
Licence: BSD
"""
@ -70,15 +121,15 @@ class D64(object):
"""
Implement d64 directory reader
"""
CHAR_MAP = {32: ' ', 33: '!', 34: '"', 35: '#', 36: '$', 37: '%', 38: '&',
39: "'", 40: '(', 41: ')', 42: '*', 43: '+', 44: ',', 45: '-',
46: '.', 47: '/', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4',
53: '5', 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 60: '<',
61: '=', 62: '>', 63: '?', 64: '@', 65: 'a', 66: 'b', 67: 'c',
68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', 73: 'i', 74: 'j',
75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', 80: 'p', 81: 'q',
82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', 87: 'w', 88: 'x',
89: 'y', 90: 'z', 91: '[', 93: ']', 97: 'A', 98: 'B', 99: 'C',
CHAR_MAP = {32: ' ', 33: '!', 34: '"', 35: '#', 37: '%', 38: '&', 39: "'",
40: '(', 41: ')', 42: '*', 43: '+', 44: ',', 45: '-', 46: '.',
47: '/', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 60: '<', 61: '=',
62: '>', 63: '?', 64: '@', 65: 'a', 66: 'b', 67: 'c', 68: 'd',
69: 'e', 70: 'f', 71: 'g', 72: 'h', 73: 'i', 74: 'j', 75: 'k',
76: 'l', 77: 'm', 78: 'n', 79: 'o', 80: 'p', 81: 'q', 82: 'r',
83: 's', 84: 't', 85: 'u', 86: 'v', 87: 'w', 88: 'x', 89: 'y',
90: 'z', 91: '[', 93: ']', 97: 'A', 98: 'B', 99: 'C',
100: 'D', 101: 'E', 102: 'F', 103: 'G', 104: 'H', 105: 'I',
106: 'J', 107: 'K', 108: 'L', 109: 'M', 110: 'N', 111: 'O',
112: 'P', 113: 'Q', 114: 'R', 115: 'S', 116: 'T', 117: 'U',
@ -105,10 +156,10 @@ class D64(object):
dimage.close()
self.current_sector_data = None
self._sector_shift = 256
self.next_sector = 0
self.next_track = None
self._directory_contents = []
self._dir_contents = []
self._already_done = []
def _map_filename(self, string):
"""
@ -117,16 +168,17 @@ class D64(object):
"""
filename = list()
in_fname = True
for chr_ in string:
character = D64.CHAR_MAP.get(ord(chr_), '?')
if ord(chr_) == 160: # shift+space character; $a0
break
if in_fname:
if ord(chr_) == 160:
in_fname = False
else:
filename.append(character)
character = D64.CHAR_MAP.get(ord(chr_), '?')
filename.append(character)
# special cases
if filename[0] == "-":
filename[0] = "?"
LOG.debug("string: ``%s'' mapped to: ``%s''", string,
"".join(filename))
@ -138,7 +190,11 @@ class D64(object):
Return False if the chain ends, True otherwise
"""
if self.next_track == 0 and self.next_sector == 255:
# Well, self.next_sector _should_ have value $FF, but apparently there
# are the cases where it is not, therefore checking for that will not
# be performed and value of $00 on the next track will end the
# directory
if self.next_track == 0:
LOG.debug("End of directory")
return False
@ -150,10 +206,19 @@ class D64(object):
LOG.debug("Going to the track: %s,%s", self.next_track,
self.next_sector)
self.current_sector_data = self.raw[offset:offset + self._sector_shift]
self.current_sector_data = self.raw[offset:offset + 256]
self.next_track = ord(self.current_sector_data[0])
self.next_sector = ord(self.current_sector_data[1])
if (self.next_track, self.next_sector) in self._already_done:
# Just a failsafe. Endless loop is not what is expected.
LOG.debug("Loop in track/sector pointer at %d,%d",
self.next_track, self.next_sector)
self._already_done = []
return False
self._already_done.append((self.next_track, self.next_sector))
LOG.debug("Next track: %s,%s", self.next_track, self.next_sector)
return True
@ -192,7 +257,7 @@ class D64(object):
def _harvest_entries(self):
"""
Traverse through sectors and store entries in _directory_contents
Traverse through sectors and store entries in _dir_contents
"""
sector = self.current_sector_data
for x in range(8):
@ -212,10 +277,10 @@ class D64(object):
else:
size = ord(entry[30]) + ord(entry[31]) * 226
self._directory_contents.append({'fname': self._map_filename(fname),
'ftype': type_verbose,
'size': size,
'protect': protect})
self._dir_contents.append({'fname': self._map_filename(fname),
'ftype': type_verbose,
'size': size,
'protect': protect})
sector = sector[32:]
def list_dir(self):
@ -226,7 +291,7 @@ class D64(object):
while self._go_to_next_sector():
self._harvest_entries()
return self._directory_contents
return self._dir_contents
class Uc1541(object):
@ -249,7 +314,7 @@ class Uc1541(object):
def list(self):
"""
Output list contents of D64 image.
Convert filenames to be unix filesystem friendly
Convert filenames to be Unix filesystem friendly
Add suffix to show user what kind of file do he dealing with.
"""
LOG.info("List contents of %s", self.arch)
@ -295,11 +360,11 @@ class Uc1541(object):
def copyout(self, src, dst):
"""
Copy file form the D64 image. Source filename has to be corrected,
since it's representaion differ from the real one inside D64 image.
since it's representation differ from the real one inside D64 image.
"""
LOG.info("Copy form D64 %s as %s", src, dst)
if not src.endswith(".prg"):
return "canot read"
return "cannot read"
src = self._get_masked_fname(src)
@ -308,15 +373,38 @@ class Uc1541(object):
return 0
def _correct_fname(self, fname):
"""
Return filename with mapped characters, without .prg extension.
Characters like $, *, + in filenames are perfectly legal, but c1541
program seem to have issues with it while writing, so it will also be
replaced.
"""
char_map = {'|': "/",
"\\": "/",
"~": " ",
"$": "?",
"*": "?"}
if fname.lower().endswith(".prg"):
fname = fname[:-4]
new_fname = []
for char in fname:
trans = char_map.get(char)
new_fname.append(trans if trans else char)
return "".join(new_fname)
def _get_masked_fname(self, fname):
"""
Return masked filename with '?' jokers instead of non ASCII
characters, usefull for copying or deleting files with c1541. In case
characters, useful for copying or deleting files with c1541. In case
of several files with same name exists in directory, only first one
will be operative (first as appeared in directory).
Warning! If there are two different names but the only differenc is in
non-ASCII characters (some PET ASCII or controll characters) there is
Warning! If there are two different names but the only difference is in
non-ASCII characters (some PET ASCII or control characters) there is
a risk that one can remove both files.
"""
directory = self._get_dir()
@ -348,12 +436,16 @@ class Uc1541(object):
display_name = ".".join([fname, ext])
pattern_name = self.pyd64[idx]['fname']
if '/' in fname:
display_name = fname.replace('/', '|')
if '/' in display_name:
display_name = display_name.replace('/', '|')
# workaround for space at the beggining of the filename
if fname[0] == ' ':
display_name = '~' + display_name[1:]
# workaround for space and dash at the beggining of the
# filename
char_map = {' ': '~',
'-': '_'}
display_name = "".join([char_map.get(display_name[0],
display_name[0]),
display_name[1:]])
if ext == 'del':
perms = "----------"

View File

@ -779,11 +779,7 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
break;
}
case 'S':
#ifdef HAVE_ATOLL
ST.st_size = (off_t) atoll (buffer + 1);
#else
ST.st_size = (off_t) atof (buffer + 1);
#endif
ST.st_size = (off_t) g_ascii_strtoll (buffer + 1, NULL, 10);
break;
case 'P':
{
@ -853,10 +849,10 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
fish_fh_data_t *fish = (fish_fh_data_t *) fh->data;
gchar *shell_commands = NULL;
struct vfs_s_super *super = FH_SUPER;
int n, total;
char buffer[8192];
int code;
off_t total;
char buffer[BUF_8K];
struct stat s;
int was_error = 0;
int h;
char *quoted_name;
@ -908,8 +904,8 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
SUP->scr_append, (char *) NULL);
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
code = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
g_free (shell_commands);
}
else
@ -917,11 +913,11 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
shell_commands =
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
SUP->scr_send, (char *) NULL);
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
code = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
g_free (shell_commands);
}
if (n != PRELIM)
if (code != PRELIM)
{
close (h);
ERRNOR (E_REMOTE, -1);
@ -931,7 +927,8 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
while (TRUE)
{
int t;
ssize_t n, t;
while ((n = read (h, buffer, sizeof (buffer))) < 0)
{
if ((errno == EINTR) && tty_got_interrupt ())
@ -955,14 +952,13 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
}
tty_disable_interrupt_key ();
total += n;
vfs_print_message ("%s: %d/%" PRIuMAX,
was_error ? _("fish: storing zeros") : _("fish: storing file"),
total, (uintmax_t) s.st_size);
vfs_print_message ("%s: %" PRIuMAX "/%" PRIuMAX, _("fish: storing file"),
(uintmax_t) total, (uintmax_t) s.st_size);
}
close (h);
g_free (quoted_name);
if ((fish_get_reply (me, SUP->sockr, NULL, 0) != COMPLETE) || was_error)
if (fish_get_reply (me, SUP->sockr, NULL, 0) != COMPLETE)
ERRNOR (E_REMOTE, -1);
return 0;
@ -1017,7 +1013,7 @@ fish_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset)
#if SIZEOF_OFF_T == SIZEOF_LONG
fish->total = (off_t) strtol (reply_str, NULL, 10);
#else
fish->total = (off_t) strtoll (reply_str, NULL, 10);
fish->total = (off_t) g_ascii_strtoll (reply_str, NULL, 10);
#endif
if (errno != 0)
ERRNOR (E_REMOTE, 0);
@ -1032,13 +1028,13 @@ fish_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
fish_fh_data_t *fish = (fish_fh_data_t *) fh->data;
struct vfs_s_super *super = FH_SUPER;
char buffer[BUF_8K];
int n;
ssize_t n;
vfs_print_message (_("Aborting transfer..."));
do
{
n = MIN (sizeof (buffer), (size_t) (fish->total - fish->got));
n = MIN ((off_t) sizeof (buffer), (fish->total - fish->got));
if (n != 0)
{
n = read (SUP->sockr, buffer, n);
@ -1057,14 +1053,13 @@ fish_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
/* --------------------------------------------------------------------------------------------- */
static int
static ssize_t
fish_linear_read (struct vfs_class *me, vfs_file_handler_t * fh, void *buf, size_t len)
{
fish_fh_data_t *fish = (fish_fh_data_t *) fh->data;
struct vfs_s_super *super = FH_SUPER;
ssize_t n = 0;
len = MIN ((size_t) (fish->total - fish->got), len);
tty_disable_interrupt_key ();
while (len != 0 && ((n = read (SUP->sockr, buf, len)) < 0))

View File

@ -1786,7 +1786,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
static int
ftpfs_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char *localname)
{
int h, sock, n_read, n_written;
int h, sock;
off_t n_stored;
#ifdef HAVE_STRUCT_LINGER_L_LINGER
struct linger li;
@ -1822,20 +1822,20 @@ ftpfs_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, cha
tty_enable_interrupt_key ();
while (TRUE)
{
ssize_t n_read, n_written;
while ((n_read = read (h, lc_buffer, sizeof (lc_buffer))) == -1)
{
if (errno == EINTR)
if (errno != EINTR)
{
if (tty_got_interrupt ())
{
ftpfs_errno = EINTR;
goto error_return;
}
else
continue;
ftpfs_errno = errno;
goto error_return;
}
if (tty_got_interrupt ())
{
ftpfs_errno = EINTR;
goto error_return;
}
ftpfs_errno = errno;
goto error_return;
}
if (n_read == 0)
break;
@ -1846,9 +1846,8 @@ ftpfs_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, cha
if (n_written == -1)
{
if (errno == EINTR && !tty_got_interrupt ())
{
continue;
}
ftpfs_errno = errno;
goto error_return;
}
@ -1897,7 +1896,7 @@ ftpfs_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset)
/* --------------------------------------------------------------------------------------------- */
static int
static ssize_t
ftpfs_linear_read (struct vfs_class *me, vfs_file_handler_t * fh, void *buf, size_t len)
{
ssize_t n;

View File

@ -225,7 +225,7 @@ typedef struct
static struct vfs_class vfs_tarfs_ops;
/* As we open one archive at a time, it is safe to have this static */
static int current_tar_position = 0;
static off_t current_tar_position = 0;
static union record rec_buf;
@ -370,7 +370,7 @@ tar_get_next_record (struct vfs_s_super *archive, int tard)
/* --------------------------------------------------------------------------------------------- */
static void
tar_skip_n_records (struct vfs_s_super *archive, int tard, int n)
tar_skip_n_records (struct vfs_s_super *archive, int tard, size_t n)
{
(void) archive;
@ -566,7 +566,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
{
char **longp;
char *bp, *data;
int size, written;
off_t size;
size_t written;
if (arch->type == TAR_UNKNOWN)
arch->type = TAR_GNU;
@ -593,8 +594,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
return STATUS_BADCHECKSUM;
}
written = RECORDSIZE;
if (written > size)
written = size;
if ((off_t) written > size)
written = (size_t) size;
memcpy (bp, data, written);
bp += written;
@ -615,9 +616,9 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
struct stat st;
struct vfs_s_entry *entry;
struct vfs_s_inode *inode = NULL, *parent;
long data_position;
off_t data_position;
char *q;
int len;
size_t len;
char *current_file_name, *current_link_name;
current_link_name =

View File

@ -260,7 +260,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset)
res = TRUE;
addr = strtoll (exp, &error, base);
addr = (off_t) g_ascii_strtoll (exp, &error, base);
if ((*error == '\0') && (addr >= 0))
{
switch (current_goto_type)

View File

@ -59,7 +59,7 @@
/*** global variables ****************************************************************************/
#define OFF_T_BITWIDTH (unsigned int) (sizeof (off_t) * CHAR_BIT - 1)
const off_t INVALID_OFFSET = (off_t) - 1;
const off_t INVALID_OFFSET = (off_t) (-1);
const off_t OFFSETTYPE_MAX = ((off_t) 1 << (OFF_T_BITWIDTH - 1)) - 1;
/*** file scope macro definitions ****************************************************************/

View File

@ -75,9 +75,9 @@ mcview_search_update_steps (mcview_t * view)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mcview_find (mcview_t * view, gsize search_start, gsize * len)
mcview_find (mcview_t * view, off_t search_start, gsize * len)
{
gsize search_end;
off_t search_end;
view->search_numNeedSkipChar = 0;
search_cb_char_curr_index = -1;
@ -85,17 +85,17 @@ mcview_find (mcview_t * view, gsize search_start, gsize * len)
if (mcview_search_options.backwards)
{
search_end = mcview_get_filesize (view);
while ((int) search_start >= 0)
while (search_start >= 0)
{
view->search_nroff_seq->index = search_start;
mcview_nroff_seq_info (view->search_nroff_seq);
if (search_end > search_start + view->search->original_len
if (search_end > search_start + (off_t) view->search->original_len
&& mc_search_is_fixed_search_str (view->search))
search_end = search_start + view->search->original_len;
if (mc_search_run (view->search, (void *) view, search_start, search_end, len)
&& view->search->normal_offset == (off_t) search_start)
&& view->search->normal_offset == search_start)
{
if (view->text_nroff_mode)
view->search->normal_offset++;
@ -218,7 +218,7 @@ mcview_search_update_cmd_callback (const void *user_data, gsize char_offset)
{
mcview_t *view = (mcview_t *) user_data;
if (char_offset >= (gsize) view->update_activate)
if ((off_t) char_offset >= view->update_activate)
{
view->update_activate += view->update_steps;
if (verbose)