mc/mc-cvs-fixes.patch

228 lines
6.2 KiB
Diff

--- src/achown.c
+++ src/achown.c
@@ -265,7 +265,7 @@
/* get and put user names in the listbox */
setpwent ();
while ((chl_pass = getpwent ())) {
- listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0,
+ listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0,
chl_pass->pw_name, NULL);
}
endpwent ();
@@ -275,7 +275,7 @@
/* get and put group names in the listbox */
setgrent ();
while ((chl_grp = getgrent ())) {
- listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0,
+ listbox_add_item (chl_list, LISTBOX_APPEND_SORTED, 0,
chl_grp->gr_name, NULL);
}
endgrent ();
--- src/chown.c
+++ src/chown.c
@@ -180,14 +180,14 @@
/* get and put user names in the listbox */
setpwent ();
while ((l_pass = getpwent ())) {
- listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
+ listbox_add_item (l_user, LISTBOX_APPEND_SORTED, 0, l_pass->pw_name, NULL);
}
endpwent ();
/* get and put group names in the listbox */
setgrent ();
while ((l_grp = getgrent ())) {
- listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
+ listbox_add_item (l_group, LISTBOX_APPEND_SORTED, 0, l_grp->gr_name, NULL);
}
endgrent ();
--- src/widget.c
+++ src/widget.c
@@ -2402,8 +2402,6 @@
else
l->height = height;
l->count = 0;
- l->top = 0;
- l->current = 0;
l->cback = callback;
l->allow_duplicates = 1;
l->scrollbar = slow_terminal ? 0 : 1;
@@ -2443,6 +2441,22 @@
e->next = l->current->next;
l->current->next->prev = e;
l->current->next = e;
+ } else if (pos == LISTBOX_APPEND_SORTED) {
+ WLEntry *w = l->list;
+
+ while (w->next != l->list && strcmp (e->text, w->text) > 0)
+ w = w->next;
+ if (w->next == l->list) {
+ e->prev = w;
+ e->next = l->list;
+ w->next = e;
+ l->list->prev = e;
+ } else {
+ e->next = w;
+ e->prev = w->prev;
+ w->prev->next = e;
+ w->prev = e;
+ }
}
l->count++;
}
--- src/widget.h
+++ src/widget.h
@@ -181,7 +181,8 @@
enum append_pos {
LISTBOX_APPEND_AT_END, /* append at the end */
LISTBOX_APPEND_BEFORE, /* insert before current */
- LISTBOX_APPEND_AFTER /* insert after current */
+ LISTBOX_APPEND_AFTER, /* insert after current */
+ LISTBOX_APPEND_SORTED /* insert alphabetically */
};
char *listbox_add_item (WListbox *l, enum append_pos pos, int
--- vfs/direntry.c
+++ vfs/direntry.c
@@ -447,7 +447,6 @@
CALL (free_archive) (me, super);
g_free (super->name);
- super->name = NULL;
g_free(super);
}
--- vfs/fish.c
+++ vfs/fish.c
@@ -355,6 +355,7 @@
struct vfs_s_entry *ent = NULL;
FILE *logfile;
char *quoted_path;
+ int reply_code;
logfile = MEDATA->logfile;
@@ -365,6 +366,8 @@
quoted_path = name_quote (remote_path, 0);
fish_command (me, super, NONE,
"#LIST /%s\n"
+ "if ls -1 /%s >/dev/null 2>&1 ;\n"
+ "then\n"
"ls -lLan /%s 2>/dev/null | grep '^[^cbt]' | (\n"
"while read p l u g s m d y n; do\n"
"echo \"P$p $u.$g\nS$s\nd$m $d $y\n:$n\n\"\n"
@@ -375,8 +378,11 @@
"echo \"P$p $u.$g\nE$a$i\nd$m $d $y\n:$n\n\"\n"
"done\n"
")\n"
- "echo '### 200'\n",
- remote_path, quoted_path, quoted_path);
+ "echo '### 200'\n"
+ "else\n"
+ "echo '### 500'\n"
+ "fi\n",
+ remote_path, quoted_path, quoted_path, quoted_path);
g_free (quoted_path);
ent = vfs_s_generate_entry(me, NULL, dir, 0);
while (1) {
@@ -455,17 +461,21 @@
}
vfs_s_free_entry (me, ent);
- me->verrno = E_REMOTE;
- if (fish_decode_reply(buffer+4, 0) == COMPLETE) {
+ reply_code = fish_decode_reply(buffer + 4, 0);
+ if (reply_code == COMPLETE) {
g_free (SUP.cwdir);
SUP.cwdir = g_strdup (remote_path);
print_vfs_message (_("%s: done."), me->name);
return 0;
+ } else if (reply_code == ERROR) {
+ me->verrno = EACCES;
+ } else {
+ me->verrno = E_REMOTE;
}
error:
print_vfs_message (_("%s: failure"), me->name);
- return 1;
+ return -1;
}
static int
@@ -618,25 +628,39 @@
g_free (name);
name = quoted_name;
fh->u.fish.append = 0;
+
+ /*
+ * Check whether the remote file is readable by using `dd' to copy
+ * a single byte from the remote file to /dev/null. If `dd' completes
+ * with exit status of 0 use `cat' to send the file contents to the
+ * standard output (i.e. over the network).
+ */
offset = fish_command (me, FH_SUPER, WANT_STRING,
"#RETR /%s\n"
+ "if dd if=/%s of=/dev/null bs=1 count=1 2>/dev/null ;\n"
+ "then\n"
"ls -ln /%s 2>/dev/null | (\n"
"read p l u g s r\n"
"echo \"$s\"\n"
")\n"
"echo '### 100'\n"
"cat /%s\n"
- "echo '### 200'\n",
- name, name, name );
+ "echo '### 200'\n"
+ "else\n"
+ "echo '### 500'\n"
+ "fi\n",
+ name, name, name, name );
g_free (name);
if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
fh->linear = LS_LINEAR_OPEN;
fh->u.fish.got = 0;
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 || (defined _LARGE_FILES && _LARGE_FILES)
- if (sscanf( reply_str, "%llu", &fh->u.fish.total )!=1)
+ errno = 0;
+#if SIZEOF_OFF_T == SIZEOF_LONG
+ fh->u.fish.total = strtol (reply_str, NULL, 10);
#else
- if (sscanf( reply_str, "%u", &fh->u.fish.total )!=1)
+ fh->u.fish.total = strtoll (reply_str, NULL, 10);
#endif
+ if (errno != 0)
ERRNOR (E_REMOTE, 0);
return 1;
}
@@ -760,7 +784,7 @@
POSTFIX(OPT_FLUSH);
}
-#define FISH_OP(name, chk, string) \
+#define FISH_OP(name, string) \
static int fish_##name (struct vfs_class *me, const char *path1, const char *path2) \
{ \
char buf[BUF_LARGE]; \
@@ -786,13 +810,12 @@
return fish_send_command(me, super2, buf, OPT_FLUSH); \
}
-#define XTEST if (bucket1 != bucket2) { ERRNOR (EXDEV, -1); }
-FISH_OP(rename, XTEST, "#RENAME /%s /%s\n"
- "mv /%s /%s 2>/dev/null\n"
- "echo '### 000'" )
-FISH_OP(link, XTEST, "#LINK /%s /%s\n"
- "ln /%s /%s 2>/dev/null\n"
- "echo '### 000'" )
+FISH_OP(rename, "#RENAME /%s /%s\n"
+ "mv /%s /%s 2>/dev/null\n"
+ "echo '### 000'" )
+FISH_OP(link, "#LINK /%s /%s\n"
+ "ln /%s /%s 2>/dev/null\n"
+ "echo '### 000'" )
static int fish_symlink (struct vfs_class *me, const char *setto, const char *path)
{