Fixed cursor positioning so that it does not call any vfs code, few

statics added to vfs layer, no longer use '0' in place of NULL.
This commit is contained in:
Pavel Machek 1998-09-29 16:01:16 +00:00
parent 27c7250201
commit 136006707c
9 changed files with 66 additions and 41 deletions

View File

@ -1,3 +1,11 @@
Tue Sep 29 17:53:56 1998 Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>
* main.c: removed stupid reference to {sfs,extfs}_which
* screen.c: fixed higlighting to go for longest match if it does
not find exact match. This is so that it works well with vfs (and
needs _NO_ knowledge about vfs layer).
Tue Sep 29 14:02:56 1998 Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>
* layout.c (print_vfs_message): fixed buffer overrun by

View File

@ -922,6 +922,8 @@ translate_url_to_new_syntax (const char *p)
* If we moved to the parent directory move the selection pointer to
* the old directory name; If we leave VFS dir, remove FS specificator.
* Warn: This code spoils lwd string.
*
* You do _NOT_ want to add any vfs aware code here. <pavel@ucw.cz>
*/
char*
get_parent_dir_name (char *cwd, char *lwd)
@ -929,15 +931,7 @@ get_parent_dir_name (char *cwd, char *lwd)
char *p;
if (strlen (lwd) > strlen (cwd))
if((p=strrchr(lwd, PATH_SEP)) && !strncmp(cwd, lwd, p-lwd)){
#ifdef USE_VFS
char *q;
if((q=strrchr(p, '#')) != 0){
/* Here we need proper VFS function */
if(!strcmp((q+1), "utar") || extfs_which(q+1) >= 0 || sfs_which(q+1) >= 0)
*q = '\0';
}
#endif /* USE_VFS */
return (p+1);
return (p+1);
}
return NULL;
}

View File

@ -814,16 +814,26 @@ paint_panel (WPanel *panel)
mini_info_separator (panel);
}
static void
do_select (WPanel *panel, int i)
{
if (i != panel->selected){
panel->selected = i;
panel->top_file = panel->selected - (panel->widget.lines-2)/2;
if (panel->top_file < 0)
panel->top_file = 0;
x_adjust_top_file (panel);
}
}
void
Xtry_to_select (WPanel *panel, char *name)
{
int i;
int i, best = -1, bestl = -1;
char *subdir;
if (!name){
panel->selected = 0;
panel->top_file = 0;
x_adjust_top_file (panel);
if (!name) {
do_select(panel, 0);
return;
}
@ -835,28 +845,31 @@ Xtry_to_select (WPanel *panel, char *name)
/* Search that subdirectory, if found select it */
for (i = 0; i < panel->count; i++){
if (strcmp (subdir, panel->dir.list [i].fname))
char *s = panel->dir.list [i].fname;
int l = strlen (s);
if (strncmp (subdir, s, l))
continue;
if (i != panel->selected){
panel->selected = i;
panel->top_file = panel->selected - (panel->widget.lines-2)/2;
if (panel->top_file < 0)
panel->top_file = 0;
x_adjust_top_file (panel);
if (l == strlen(subdir)){
/* Complete match, hilight */
do_select (panel, i);
return;
}
return;
if (bestl > l)
continue;
bestl = l;
best = i;
}
if (best != -1) {
/* Try to select longest inclusive match - good for vfs */
do_select (panel, best);
return;
}
/* Try to select a file near the file that is missing */
if (panel->selected >= panel->count){
panel->selected = panel->count-1;
panel->top_file = panel->selected - (panel->widget.lines)/2;
if (panel->top_file < 0)
panel->top_file = 0;
x_adjust_top_file (panel);
} else
return;
if (panel->selected >= panel->count)
do_select (panel, panel->count-1);
}
#ifndef PORT_HAS_PANEL_UPDATE_COLS

View File

@ -1,3 +1,8 @@
Tue Sep 29 17:23:03 1998 Pavel Machek <pavel@atrey.karlin.mff.cuni.cz>
* extfs.c, sfs.c: added few static's to prevent people from doing
stupid things
Mon Sep 28 21:43:16 1998 Norbert Warmuth <nwarmuth@privat.circular.de>
* vfs.h (struct vfs): renamed errno to verrno because glibc2

View File

@ -48,6 +48,7 @@
static struct entry *
find_entry (struct entry *dir, char *name, int make_dirs, int make_file);
static int extfs_which (vfs *me, char *path);
static struct archive *first_archive = NULL;
static int my_errno = 0;
@ -394,7 +395,9 @@ static char *get_path_mangle (char *inname, struct archive **archive, int is_dir
archive_name = inname;
vfs_split( inname, &local, &op );
fstype = extfs_which( op );
fstype = extfs_which( NULL, op ); /* FIXME: we really should pass
self pointer. But as we know that extfs_which does not touch vfs
*me, it does not matter for now */
if (!local)
local = "";
if (fstype == -1)
@ -873,7 +876,7 @@ static void extfs_ungetlocalcopy (vfs *me, char *path, char *local, int has_chan
#include "../src/profile.h"
int extfs_init (vfs *me)
static int extfs_init (vfs *me)
{
FILE *cfg;
char *mc_extfsini;
@ -925,7 +928,8 @@ int extfs_init (vfs *me)
return 1;
}
int extfs_which (vfs *me, char *path)
/* Do NOT use me argument in this function */
static int extfs_which (vfs *me, char *path)
{
int i;
@ -935,12 +939,12 @@ int extfs_which (vfs *me, char *path)
return -1;
}
char *extfs_get_prefix (int idx)
static char *extfs_get_prefix (int idx)
{
return extfs_prefixes [idx];
}
void extfs_done (vfs *me)
static void extfs_done (vfs *me)
{
int i;

View File

@ -157,7 +157,7 @@ static int command (struct connection *bucket, int wait_reply,
int n, status;
va_start (ap, fmt);
vsprintf (buf, fmt, ap);
vsnprintf (buf, 2046, fmt, ap);
va_end (ap);
n = strlen(buf);
buf[n] = 0;
@ -492,6 +492,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
fe->bucket = bucket;
fe->s.st_ino = bucket->__inode_counter++;
fe->s.st_nlink = 1;
fe->local_filename = NULL;
}
switch(buffer[0]) {

View File

@ -219,7 +219,7 @@ static int command (struct connection *bucket, int wait_reply,
int sock = qsock (bucket);
va_start (ap, fmt);
vsprintf (buf, fmt, ap);
vsnprintf (buf, 2046, fmt, ap);
va_end (ap);
n = strlen(buf);
buf[n++] = '\r';

View File

@ -288,7 +288,7 @@ extern int local_fstat (void *data, struct stat *buf);
extern int local_errno (vfs *me);
extern int local_lseek (void *data, off_t offset, int whence);
int sfs_init (vfs *me)
static int sfs_init (vfs *me)
{
FILE *cfg = fopen( LIBDIR "extfs/sfs.ini", "r" );
if (!cfg) {
@ -342,7 +342,7 @@ int sfs_init (vfs *me)
return 1;
}
void sfs_done (vfs *me)
static void sfs_done (vfs *me)
{
int i;
for (i=0; i<sfs_no; i++) {
@ -353,7 +353,7 @@ void sfs_done (vfs *me)
sfs_no = 0;
}
int sfs_which (vfs *me, char *path)
static int sfs_which (vfs *me, char *path)
{
int i;

View File

@ -426,7 +426,7 @@ remove_temp_file (char *file_name)
if (ent->local_filename) {
unlink (ent->local_filename);
free (ent->local_filename);
ent->local_filename = 0;
ent->local_filename = NULL;
return 0;
}
}