Merge branch '2888_cleanup'

* 2888_cleanup: (34 commits)
  (exec_get_export_variables_ext): use g_new0() for stable test results.
  Implement quick and easy disable of xdg-open usage.
  Sync with gnulib 40f82767840187c20051ca99385f75a42f92de99.
  Add extra checks in macro engine.
  Ticket #2935: update uc1541 extfs plug-in up to version 2.5.
  (del_widget): fix memory leak.
  (editcmd_dialog_replace_prompt_show): fix string truncations.
  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.
  Keep some edit window parameters during file reloading.
  Fix editor crash in "Save as..." command.
  Ticket #2841: adjust i18n label sizes in learn key dialog.
  Disable the localized output of utilities such as - ls, git, etc..
  (add_widget_autopos): don't access to NULL widget.
  Parenthesis around some -1.
  src/filemanager/mountlist.c: use GLib functions to allocate/free memory.
  Sync with gnulib 613bcb6205cf2b64d835c19074c5a7e7c6cb99eb
  ...
This commit is contained in:
Andrew Borodin 2012-12-20 15:37:24 +04:00
commit d8f970c503
54 changed files with 504 additions and 380 deletions

View File

@ -226,7 +226,6 @@ dnl Check for functions
dnl ############################################################################
AC_CHECK_FUNCS([\
atoll \
isascii \
statfs sysconf \
tcgetattr tcsetattr \

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

@ -117,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"

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

@ -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

@ -1148,7 +1148,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) \

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

@ -858,12 +858,14 @@ unsigned long
add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const void *before)
{
Widget *wh = WIDGET (h);
Widget *widget = WIDGET (w);
Widget *widget;
/* Don't accept 0 widgets */
if (w == NULL)
abort ();
widget = WIDGET (w);
if ((pos_flags & WPOS_CENTER_HORZ) != 0)
widget->x = (wh->cols - widget->cols) / 2;
widget->x += wh->x;
@ -934,19 +936,22 @@ add_widget_before (WDialog * h, void *w, void *before)
void
del_widget (void *w)
{
WDialog *h = WIDGET (w)->owner;
WDialog *h;
GList *d;
/* Don't accept NULL widget. This shouldn't happen */
if (w == NULL)
abort ();
h = WIDGET (w)->owner;
d = g_list_find (h->widgets, w);
if (d == h->current)
h->current = dlg_widget_next (h, d);
h->widgets = g_list_remove_link (h->widgets, d);
send_message (d->data, NULL, MSG_DESTROY, 0, NULL);
g_free (d->data);
g_list_free_1 (d);
/* widget has been deleted in runtime */

View File

@ -8,12 +8,12 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
g_module_supported=""
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
@ -80,9 +80,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

@ -8,6 +8,8 @@ action=$1
filetype=$2
pager=$3
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -141,7 +143,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}" "${pager}"
;;
*)

View File

@ -6,6 +6,7 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$'
@ -186,7 +187,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -6,6 +6,8 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -52,7 +54,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -6,6 +6,8 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -86,7 +88,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -6,6 +6,7 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -50,7 +51,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -6,6 +6,8 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -82,7 +84,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -8,6 +8,8 @@ action=$1
filetype=$2
pager=$3
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
get_unpacker() {
filetype=$1
case "${filetype}" in
@ -131,7 +133,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}" "${pager}"
;;
*)

View File

@ -6,6 +6,7 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -42,7 +43,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -6,6 +6,8 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
do_view_action() {
filetype=$1
@ -44,7 +46,7 @@ view)
do_view_action "${filetype}"
;;
open)
xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
do_open_action "${filetype}"
;;
*)

View File

@ -411,10 +411,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

@ -2200,13 +2200,28 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
long line)
{
gboolean to_free = FALSE;
Widget *w;
option_auto_syntax = 1; /* Resetting to auto on every invokation */
option_line_state_width = option_line_state ? LINE_STATE_WIDTH : 0;
if (edit != NULL)
{
/* save some widget parameters */
gboolean fullscreen = edit->fullscreen;
int y_prev = edit->y_prev;
int x_prev = edit->x_prev;
int lines_prev = edit->lines_prev;
int cols_prev = edit->cols_prev;
edit_purge_widget (edit);
/* restore saved parameters */
edit->fullscreen = fullscreen;
edit->y_prev = y_prev;
edit->x_prev = x_prev;
edit->lines_prev = lines_prev;
edit->cols_prev = cols_prev;
}
else
{
#ifdef ENABLE_NLS
@ -2238,12 +2253,12 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
#endif /* ENABLE_NLS */
edit = g_malloc0 (sizeof (WEdit));
to_free = TRUE;
init_widget (WIDGET (edit), y, x, lines, cols, NULL, NULL);
edit->fullscreen = TRUE;
edit_save_size (edit);
}
w = WIDGET (edit);
init_widget (w, y, x, lines, cols, NULL, NULL);
edit_save_size (edit);
edit->fullscreen = TRUE;
edit->drag_state = MCEDIT_DRAG_NORMAL;
edit->stat1.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
@ -2367,15 +2382,16 @@ edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
Widget *w = WIDGET (edit);
WEdit *e;
int y = w->y;
int x = w->x;
int lines = w->lines;
int columns = w->cols;
e = g_malloc0 (sizeof (WEdit));
*WIDGET (e) = *w;
/* save some widget parameters */
e->fullscreen = edit->fullscreen;
e->y_prev = edit->y_prev;
e->x_prev = edit->x_prev;
e->lines_prev = edit->lines_prev;
e->cols_prev = edit->cols_prev;
if (edit_init (e, y, x, lines, columns, filename_vpath, line) == NULL)
if (edit_init (e, w->y, w->x, w->lines, w->cols, filename_vpath, line) == NULL)
{
g_free (e);
return FALSE;

View File

@ -876,7 +876,7 @@ editcmd_find (WEdit * edit, gsize * len)
search_start =
edit_calculate_start_of_current_line (edit, search_start, end_string_symbol);
while ((int) search_start >= start_mark)
while (search_start >= start_mark)
{
if (search_end > (off_t) (search_start + edit->search->original_len)
&& mc_search_is_fixed_search_str (edit->search))
@ -1127,7 +1127,7 @@ static gboolean
edit_find_word_start (WEdit * edit, off_t * word_start, gsize * word_len)
{
int c, last;
gsize i;
off_t i;
/* return if at begin of file */
if (edit->curs1 <= 0)
@ -1142,7 +1142,7 @@ edit_find_word_start (WEdit * edit, off_t * word_start, gsize * word_len)
for (i = 2;; i++)
{
/* return if at begin of file */
if ((gsize) edit->curs1 < i)
if (edit->curs1 < i)
return FALSE;
last = c;
@ -1155,7 +1155,7 @@ edit_find_word_start (WEdit * edit, off_t * word_start, gsize * word_len)
return FALSE;
*word_start = edit->curs1 - (i - 1); /* start found */
*word_len = i - 1;
*word_len = (gsize) (i - 1);
break;
}
}
@ -1944,7 +1944,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);

View File

@ -241,6 +241,7 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
/* dialog size */
int dlg_height = 10;
int dlg_width;
char tmp[BUF_MEDIUM];
char *repl_from, *repl_to;
@ -254,11 +255,13 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
if ((edit->curs_row >= ypos - 1) && (edit->curs_row <= ypos + dlg_height - 1))
ypos -= dlg_height;
dlg_width = WIDGET (w->owner)->cols - xpos - 1;
g_snprintf (tmp, sizeof (tmp), "\"%s\"", from_text);
repl_from = g_strdup (str_trunc (tmp, -7));
repl_from = g_strdup (str_trunc (tmp, dlg_width - 7));
g_snprintf (tmp, sizeof (tmp), "\"%s\"", to_text);
repl_to = g_strdup (str_trunc (tmp, -7));
repl_to = g_strdup (str_trunc (tmp, dlg_width - 7));
{
quick_widget_t quick_widgets[] = {

View File

@ -778,8 +778,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);
@ -802,8 +802,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));
@ -872,8 +872,8 @@ chown_advanced_cmd (void)
fname, unix_error_string (errno));
/* call mc_chown only, if mc_chmod didn't fail */
else if (mc_chown
(vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) - 1,
(ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) - 1) == -1)
(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));
break;

View File

@ -2766,26 +2766,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? */
@ -2812,17 +2792,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

@ -632,10 +632,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;
@ -658,10 +658,11 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
dlg_width = max (58, buttons_width + 6);
dlg_height = 17; /* will be adjusted later */
ui = g_new0 (FileOpContextUI, 1);
ctx->ui = ui;
ctx->dialog_type = dialog_type;
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;
@ -725,21 +726,6 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
dlg_set_size (ui->op_dlg, y + 3, dlg_width);
dlg_select_widget (skip_button);
}
/* --------------------------------------------------------------------------------------------- */
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

@ -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

@ -296,10 +296,17 @@ init_learn (void)
for (i = 0; i < learn_total; i++)
{
char buffer[BUF_TINY];
char *label;
int padding;
learnkeys[i].ok = FALSE;
learnkeys[i].sequence = NULL;
g_snprintf (buffer, sizeof (buffer), "%-16s", _(key_name_conv_tab[i].longname));
label = _(key_name_conv_tab[i].longname);
padding = 16 - str_term_width1 (label);
padding = max (0, padding);
g_snprintf (buffer, sizeof (buffer), "%s%*s", label, padding, "");
learnkeys[i].button =
WIDGET (button_new (y, x, B_USER + i, NARROW_BUTTON, buffer, learn_button));
learnkeys[i].label = WIDGET (label_new (y, x + 19, ""));

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

@ -2,6 +2,8 @@
LANG=C
export LANG
LC_TIME=C
export LC_TIME
# --- GIT -----------------------------------------------------------------------

View File

@ -148,7 +148,7 @@ sub list
if ( open(PIPEIN, "LANG=C ls -l /var/lib/dpkg/info/$qarchive.* |") ) {
if ( open(PIPEIN, "LC_TIME=C LANG=C ls -l /var/lib/dpkg/info/$qarchive.* |") ) {
while(<PIPEIN>) {
chop;
next if /\.list$/;

View File

@ -2,6 +2,8 @@
LANG=C
export LANG
LC_TIME=C
export LC_TIME
umask 077
prefix='[git]'

View File

@ -2,6 +2,8 @@
LANG=C
export LANG
LC_TIME=C
export LC_TIME
# --- GIT -----------------------------------------------------------------------

View File

@ -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

@ -778,11 +778,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':
{
@ -1016,7 +1012,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);
@ -1056,14 +1052,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

@ -1895,7 +1895,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

@ -225,7 +225,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset)
off_t addr;
char *error;
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

@ -58,7 +58,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)

View File

@ -54,7 +54,7 @@ setup (void)
mc_global.mc_run_mode = MC_RUN_FULL;
current_panel = g_new0(struct WPanel, 1);
current_panel->cwd_vpath = vfs_path_from_str("/home");
current_panel->dir.list = g_new (file_entry, MIN_FILES);
current_panel->dir.list = g_new0 (file_entry, MIN_FILES);
current_panel->dir.size = MIN_FILES;
}