Fixes for bugs in midnight commander
Midnight commander (mc) is a useful text-mode file manager for linux. However, it has a few long-standing bugs that detract from its usability as an administration tool. Unfortunately, the only way to report bugs is by sending a report to their mailing list. Below is a list of problems I have encountered, along with their solutions.
Getting it to compile. mc no longer compiles on some linux
systems. The latest version, mc-4.6.1-pre1, bombs out with
undelfs.c:237: macro `g_try_realloc' used with too many (2) args make[3]: *** [undelfs.o] Error 1
Solution
in vfs/unfelfs.c, substitute this
if (lsd.free_blocks && !lsd.bad_blocks) { if (num_delarray >= max_delarray) { struct deleted_info *delarray_new = g_try_realloc (delarray, sizeof (struct deleted_info) * (max_delarray + 50)); if (!delarray_new) { message (1, undelfserr, _ (" no more memory while reallocating array ")); goto error_out; } delarray = delarray_new; max_delarray += 50; }
with this
if (lsd.free_blocks && !lsd.bad_blocks) { if (num_delarray >= max_delarray) { max_delarray += 50; delarray = g_renew (struct deleted_info, delarray, max_delarray); if (!delarray) { message (1, undelfserr, _(" no more memory while reallocating array ")); goto error_out; } }
In ftp mode (ftpfs), files with leading spaces cannot be copied. mc says "Cannot read source file, permission denied". The real problem is that mc strips leading spaces from the directory list and therefore can't see the real filename.
In vfs/utilvfs.c, in function vfs_split_text line 252 change
for (numcols = 0; *p && numcols < MAXCOLS; numcols++) { while (*p == ' ' || *p == '\r' || *p == '\n') { *p = 0; p++; }
to
for (numcols = 0; *p && numcols < MAXCOLS; numcols++) { while ( *p == '\r' || *p == '\n') { *p = 0; p++; }
and remove this to get rid of the meaningless error messages
if (++errorcount < 5) { message (1, _("Cannot parse:"), (p_copy && *p_copy) ? p_copy : line); } else if (errorcount == 5) message (1, _("Error"), _("More parsing errors will be ignored."));
mc doesn't change to new directory on exiting. Newer versions are supposed to do this. However, this feature does not work yet. For old versions, people used to use a shell hack called "mcset". I put this file in /etc and appended "source /etc/mcset" to /etc/profile.
Contents of mcset:
#!/bin/sh # Shell program to use Midnight Commander # to chdir to last directory mc() { echo Starting... MC=/tmp/mc$$-"$RANDOM" /usr/bin/mc -P "$@" > "$MC" cd `cat "$MC"` rm "$MC" unset MC; echo Ending... }
Back