mirror of https://github.com/MidnightCommander/mc
* ftpfs.c (ftpfs_find_machine): Added const qualifier.
* mcserv.c (do_auth): Likewise. * utilvfs.c (is_month): Likewise. (is_time): Likewise. (is_week): Likewise. * vfs.c (_vfs_get_class): Added const qualifier. (vfs_prefix_to_class): Added a string length parameter to reduce the use of g_strdup. (vfs_split): Changes due to the new string length parameter.
This commit is contained in:
parent
8b1e87523a
commit
6f34e18e3e
|
@ -1,3 +1,14 @@
|
|||
2004-09-25 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* ftpfs.c (ftpfs_find_machine): Added const qualifier.
|
||||
* mcserv.c (do_auth): Likewise.
|
||||
* utilvfs.c (is_month): Likewise. (is_time): Likewise.
|
||||
(is_week): Likewise.
|
||||
* vfs.c (_vfs_get_class): Added const qualifier.
|
||||
(vfs_prefix_to_class): Added a string length parameter to
|
||||
reduce the use of g_strdup. (vfs_split): Changes due to the
|
||||
new string length parameter.
|
||||
|
||||
2004-09-25 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* direntry.c (vfs_s_free_entry): g_free handles NULL argument too,
|
||||
|
|
|
@ -1781,7 +1781,7 @@ static int ftpfs_find_machine (const char *host, const char *domain)
|
|||
|
||||
if (g_strcasecmp (host, buffer)) {
|
||||
/* Try adding our domain to short names in .netrc */
|
||||
char *host_domain = strchr (host, '.');
|
||||
const char *host_domain = strchr (host, '.');
|
||||
if (!host_domain)
|
||||
continue;
|
||||
|
||||
|
|
11
vfs/mcserv.c
11
vfs/mcserv.c
|
@ -126,7 +126,7 @@ static int clnt_version;
|
|||
int logged_in = 0;
|
||||
|
||||
/* Home directory */
|
||||
char *home_dir = NULL;
|
||||
const char *home_dir = NULL;
|
||||
|
||||
char *up_dir = NULL;
|
||||
|
||||
|
@ -972,10 +972,11 @@ do_auth (const char *username, const char *password)
|
|||
if (this->pw_dir[strlen (this->pw_dir) - 1] == '/')
|
||||
home_dir = strdup (this->pw_dir);
|
||||
else {
|
||||
home_dir = malloc (strlen (this->pw_dir) + 2);
|
||||
if (home_dir) {
|
||||
strcpy (home_dir, this->pw_dir);
|
||||
strcat (home_dir, "/");
|
||||
char *new_home_dir = malloc (strlen (this->pw_dir) + 2);
|
||||
if (new_home_dir) {
|
||||
strcpy (new_home_dir, this->pw_dir);
|
||||
strcat (new_home_dir, "/");
|
||||
home_dir = new_home_dir;
|
||||
} else
|
||||
home_dir = "/";
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
|
|||
struct passwd *passwd_info;
|
||||
char *dir, *colon, *inner_colon, *at, *rest;
|
||||
char *retval;
|
||||
char *pcopy = g_strdup (path);
|
||||
char *pend = pcopy + strlen (pcopy);
|
||||
char * const pcopy = g_strdup (path);
|
||||
const char *pend = pcopy + strlen (pcopy);
|
||||
|
||||
if (pass)
|
||||
*pass = NULL;
|
||||
|
@ -299,7 +299,7 @@ static int
|
|||
is_week (const char *str, struct tm *tim)
|
||||
{
|
||||
static const char *week = "SunMonTueWedThuFriSat";
|
||||
char *pos;
|
||||
const char *pos;
|
||||
|
||||
if (!str)
|
||||
return 0;
|
||||
|
@ -316,7 +316,7 @@ static int
|
|||
is_month (const char *str, struct tm *tim)
|
||||
{
|
||||
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
char *pos;
|
||||
const char *pos;
|
||||
|
||||
if (!str)
|
||||
return 0;
|
||||
|
@ -351,7 +351,7 @@ is_localized_month (const unsigned char *month)
|
|||
static int
|
||||
is_time (const char *str, struct tm *tim)
|
||||
{
|
||||
char *p, *p2;
|
||||
const char *p, *p2;
|
||||
|
||||
if (!str)
|
||||
return 0;
|
||||
|
|
20
vfs/vfs.c
20
vfs/vfs.c
|
@ -150,7 +150,7 @@ vfs_register_class (struct vfs_class *vfs)
|
|||
|
||||
/* Return VFS class for the given prefix */
|
||||
static struct vfs_class *
|
||||
vfs_prefix_to_class (char *prefix)
|
||||
vfs_prefix_to_class (const char *prefix, size_t prefix_len)
|
||||
{
|
||||
struct vfs_class *vfs;
|
||||
|
||||
|
@ -161,7 +161,7 @@ vfs_prefix_to_class (char *prefix)
|
|||
return vfs;
|
||||
}
|
||||
if (vfs->prefix
|
||||
&& !strncmp (prefix, vfs->prefix, strlen (vfs->prefix)))
|
||||
&& !strncmp (prefix, vfs->prefix, prefix_len))
|
||||
return vfs;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -243,7 +243,7 @@ vfs_split (char *path, char **inpath, char **op)
|
|||
if (slash)
|
||||
*slash = 0;
|
||||
|
||||
if ((ret = vfs_prefix_to_class (semi+1))){
|
||||
if ((ret = vfs_prefix_to_class (semi+1, strlen (semi+1)))){
|
||||
if (op)
|
||||
*op = semi + 1;
|
||||
if (inpath)
|
||||
|
@ -262,8 +262,8 @@ vfs_split (char *path, char **inpath, char **op)
|
|||
static struct vfs_class *
|
||||
_vfs_get_class (const char *path)
|
||||
{
|
||||
char *semi;
|
||||
char *slash;
|
||||
const char *semi;
|
||||
const char *slash;
|
||||
struct vfs_class *ret;
|
||||
|
||||
g_return_val_if_fail(path, NULL);
|
||||
|
@ -273,18 +273,14 @@ _vfs_get_class (const char *path)
|
|||
return NULL;
|
||||
|
||||
slash = strchr (semi, PATH_SEP);
|
||||
*semi = 0;
|
||||
if (slash)
|
||||
*slash = 0;
|
||||
if (slash == NULL)
|
||||
slash += strlen (slash);
|
||||
|
||||
ret = vfs_prefix_to_class (semi+1);
|
||||
ret = vfs_prefix_to_class (semi+1, slash - (semi + 1));
|
||||
|
||||
if (slash)
|
||||
*slash = PATH_SEP;
|
||||
if (!ret)
|
||||
ret = _vfs_get_class (path);
|
||||
|
||||
*semi = '#';
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue