mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 04:22:34 +03:00
Add IS_PATH_SEP macro and use it.
Also massive use of PATH_SEP and PATH_SEP_STR macros. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
990e3053b3
commit
42e7e39bd8
@ -128,6 +128,7 @@
|
||||
/* OS specific defines */
|
||||
#define PATH_SEP '/'
|
||||
#define PATH_SEP_STR "/"
|
||||
#define IS_PATH_SEP(c) ((c) == PATH_SEP)
|
||||
#define PATH_ENV_SEP ':'
|
||||
#define TMPDIR_DEFAULT "/tmp"
|
||||
#define SCRIPT_SUFFIX ""
|
||||
|
29
lib/util.c
29
lib/util.c
@ -152,28 +152,28 @@ resolve_symlinks (const vfs_path_t * vpath)
|
||||
goto ret;
|
||||
}
|
||||
buf2[len] = 0;
|
||||
if (*buf2 == PATH_SEP)
|
||||
if (IS_PATH_SEP (*buf2))
|
||||
strcpy (buf, buf2);
|
||||
else
|
||||
strcpy (r, buf2);
|
||||
}
|
||||
canonicalize_pathname (buf);
|
||||
r = strchr (buf, 0);
|
||||
if (!*r || *(r - 1) != PATH_SEP)
|
||||
if (*r == '\0' || !IS_PATH_SEP (r[-1]))
|
||||
/* FIXME: this condition is always true because r points to the EOL */
|
||||
{
|
||||
*r++ = PATH_SEP;
|
||||
*r = 0;
|
||||
*r = '\0';
|
||||
}
|
||||
*q = c;
|
||||
p = q;
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
if (!*buf)
|
||||
if (*buf == '\0')
|
||||
strcpy (buf, PATH_SEP_STR);
|
||||
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
||||
*(r - 1) = 0;
|
||||
else if (IS_PATH_SEP (r[-1]) && r != buf + 1)
|
||||
r[-1] = '\0';
|
||||
|
||||
ret:
|
||||
g_free (buf2);
|
||||
@ -653,17 +653,18 @@ x_basename (const char *s)
|
||||
|| url_delim - s + strlen (VFS_PATH_URL_DELIMITER) < strlen (s))
|
||||
{
|
||||
/* avoid trailing PATH_SEP, if present */
|
||||
if (s[strlen (s) - 1] == PATH_SEP)
|
||||
{
|
||||
while (--path_sep > s && *path_sep != PATH_SEP);
|
||||
return (path_sep != s) ? path_sep + 1 : s;
|
||||
}
|
||||
else
|
||||
if (!IS_PATH_SEP (s[strlen (s) - 1]))
|
||||
return (path_sep != NULL) ? path_sep + 1 : s;
|
||||
|
||||
while (--path_sep > s && !IS_PATH_SEP (*path_sep))
|
||||
;
|
||||
return (path_sep != s) ? path_sep + 1 : s;
|
||||
}
|
||||
|
||||
while (--url_delim > s && *url_delim != PATH_SEP);
|
||||
while (--url_delim > s && *url_delim != PATH_SEP);
|
||||
while (--url_delim > s && !IS_PATH_SEP (*url_delim))
|
||||
;
|
||||
while (--url_delim > s && !IS_PATH_SEP (*url_delim))
|
||||
;
|
||||
|
||||
return (url_delim == s) ? s : url_delim + 1;
|
||||
}
|
||||
|
@ -684,10 +684,10 @@ tilde_expand (const char *directory)
|
||||
p = directory + 1;
|
||||
|
||||
/* d = "~" or d = "~/" */
|
||||
if (!(*p) || (*p == PATH_SEP))
|
||||
if (*p == '\0' || IS_PATH_SEP (*p))
|
||||
{
|
||||
passwd = getpwuid (geteuid ());
|
||||
q = (*p == PATH_SEP) ? p + 1 : "";
|
||||
q = IS_PATH_SEP (*p) ? p + 1 : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -843,12 +843,12 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
const size_t url_delim_len = strlen (VFS_PATH_URL_DELIMITER);
|
||||
|
||||
/* Detect and preserve UNC paths: //server/... */
|
||||
if ((flags & CANON_PATH_GUARDUNC) && path[0] == PATH_SEP && path[1] == PATH_SEP)
|
||||
if ((flags & CANON_PATH_GUARDUNC) != 0 && IS_PATH_SEP (path[0]) && IS_PATH_SEP (path[1]))
|
||||
{
|
||||
p = path + 2;
|
||||
while (p[0] && p[0] != '/')
|
||||
while (p[0] != '\0' && !IS_PATH_SEP (p[0]))
|
||||
p++;
|
||||
if (p[0] == '/' && p > path + 2)
|
||||
if (IS_PATH_SEP (p[0]) && p > path + 2)
|
||||
lpath = p;
|
||||
}
|
||||
|
||||
@ -861,10 +861,11 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
p = lpath;
|
||||
while (*p)
|
||||
{
|
||||
if (p[0] == PATH_SEP && p[1] == PATH_SEP && (p == lpath || *(p - 1) != ':'))
|
||||
if (IS_PATH_SEP (p[0]) && IS_PATH_SEP (p[1]) && (p == lpath || *(p - 1) != ':'))
|
||||
{
|
||||
s = p + 1;
|
||||
while (*(++s) == PATH_SEP);
|
||||
while (IS_PATH_SEP (*(++s)))
|
||||
;
|
||||
str_move (p + 1, s);
|
||||
}
|
||||
p++;
|
||||
@ -877,7 +878,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
p = lpath;
|
||||
while (*p)
|
||||
{
|
||||
if (p[0] == PATH_SEP && p[1] == '.' && p[2] == PATH_SEP)
|
||||
if (IS_PATH_SEP (p[0]) && p[1] == '.' && IS_PATH_SEP (p[2]))
|
||||
str_move (p, p + 2);
|
||||
else
|
||||
p++;
|
||||
@ -890,7 +891,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
|
||||
/* Remove trailing slashes */
|
||||
p = lpath + strlen (lpath) - 1;
|
||||
while (p > lpath && *p == PATH_SEP)
|
||||
while (p > lpath && IS_PATH_SEP (*p))
|
||||
{
|
||||
if (p >= lpath - (url_delim_len + 1)
|
||||
&& strncmp (p - url_delim_len + 1, VFS_PATH_URL_DELIMITER, url_delim_len) == 0)
|
||||
@ -899,7 +900,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
}
|
||||
|
||||
/* Remove leading "./" */
|
||||
if (lpath[0] == '.' && lpath[1] == PATH_SEP)
|
||||
if (lpath[0] == '.' && IS_PATH_SEP (lpath[1]))
|
||||
{
|
||||
if (lpath[2] == 0)
|
||||
{
|
||||
@ -916,7 +917,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
len = strlen (lpath);
|
||||
if (len < 2)
|
||||
return;
|
||||
if (lpath[len - 1] == PATH_SEP
|
||||
if (IS_PATH_SEP (lpath[len - 1])
|
||||
&& (len < url_delim_len
|
||||
|| strncmp (lpath + len - url_delim_len, VFS_PATH_URL_DELIMITER,
|
||||
url_delim_len) != 0))
|
||||
@ -925,7 +926,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lpath[len - 1] == '.' && lpath[len - 2] == PATH_SEP)
|
||||
if (lpath[len - 1] == '.' && IS_PATH_SEP (lpath[len - 2]))
|
||||
{
|
||||
if (len == 2)
|
||||
{
|
||||
@ -950,7 +951,8 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
p = lpath;
|
||||
while (p[0] && p[1] && p[2])
|
||||
{
|
||||
if ((p[0] != PATH_SEP || p[1] != '.' || p[2] != '.') || (p[3] != PATH_SEP && p[3] != 0))
|
||||
if (!IS_PATH_SEP (p[0]) || p[1] != '.' || p[2] != '.'
|
||||
|| (!IS_PATH_SEP (p[3]) && p[3] != '\0'))
|
||||
{
|
||||
p++;
|
||||
continue;
|
||||
@ -962,7 +964,8 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
&& strncmp (s - url_delim_len + 2, VFS_PATH_URL_DELIMITER, url_delim_len) == 0)
|
||||
{
|
||||
s -= (url_delim_len - 2);
|
||||
while (s >= lpath && *s-- != PATH_SEP);
|
||||
while (s >= lpath && !IS_PATH_SEP (*s--))
|
||||
;
|
||||
}
|
||||
|
||||
while (s >= lpath)
|
||||
@ -973,8 +976,9 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
char *vfs_prefix = s - url_delim_len;
|
||||
struct vfs_class *vclass;
|
||||
|
||||
while (vfs_prefix > lpath && *--vfs_prefix != PATH_SEP);
|
||||
if (*vfs_prefix == PATH_SEP)
|
||||
while (vfs_prefix > lpath && !IS_PATH_SEP (*--vfs_prefix))
|
||||
;
|
||||
if (IS_PATH_SEP (*vfs_prefix))
|
||||
vfs_prefix++;
|
||||
*(s - url_delim_len) = '\0';
|
||||
|
||||
@ -992,7 +996,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (*s == PATH_SEP)
|
||||
if (IS_PATH_SEP (*s))
|
||||
break;
|
||||
|
||||
s--;
|
||||
@ -1009,7 +1013,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
|
||||
if (p[3] != 0)
|
||||
{
|
||||
if (s == lpath && *s == PATH_SEP)
|
||||
if (s == lpath && IS_PATH_SEP (*s))
|
||||
{
|
||||
/* "/../foo" -> "/foo" */
|
||||
str_move (s + 1, p + 4);
|
||||
@ -1034,17 +1038,15 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
if (s == lpath)
|
||||
{
|
||||
/* "token/.." -> "." */
|
||||
if (lpath[0] != PATH_SEP)
|
||||
{
|
||||
if (!IS_PATH_SEP (lpath[0]))
|
||||
lpath[0] = '.';
|
||||
}
|
||||
lpath[1] = 0;
|
||||
lpath[1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* "foo/token/.." -> "foo" */
|
||||
if (s == lpath + 1)
|
||||
s[0] = 0;
|
||||
s[0] = '\0';
|
||||
#ifdef HAVE_CHARSET
|
||||
else if ((strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
|
||||
&& (is_supported_encoding (s + enc_prefix_len)))
|
||||
@ -1055,9 +1057,9 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
s[2] = '\0';
|
||||
|
||||
/* search for the previous token */
|
||||
/* s[-1] == PATH_SEP */
|
||||
/* IS_PATH_SEP (s[-1]) */
|
||||
p = s - 1;
|
||||
while (p >= lpath && *p != PATH_SEP)
|
||||
while (p >= lpath && !IS_PATH_SEP (*p))
|
||||
p--;
|
||||
|
||||
if (p >= lpath)
|
||||
@ -1121,9 +1123,8 @@ mc_realpath (const char *path, char *resolved_path)
|
||||
path = copy_path;
|
||||
max_path = copy_path + PATH_MAX - 2;
|
||||
/* If it's a relative pathname use getwd for starters. */
|
||||
if (*path != '/')
|
||||
if (!IS_PATH_SEP (*path))
|
||||
{
|
||||
|
||||
new_path = g_get_current_dir ();
|
||||
if (new_path == NULL)
|
||||
{
|
||||
@ -1137,19 +1138,19 @@ mc_realpath (const char *path, char *resolved_path)
|
||||
}
|
||||
|
||||
new_path += strlen (got_path);
|
||||
if (new_path[-1] != '/')
|
||||
*new_path++ = '/';
|
||||
if (!IS_PATH_SEP (new_path[-1]))
|
||||
*new_path++ = PATH_SEP;
|
||||
}
|
||||
else
|
||||
{
|
||||
*new_path++ = '/';
|
||||
*new_path++ = PATH_SEP;
|
||||
path++;
|
||||
}
|
||||
/* Expand each slash-separated pathname component. */
|
||||
while (*path != '\0')
|
||||
{
|
||||
/* Ignore stray "/". */
|
||||
if (*path == '/')
|
||||
if (IS_PATH_SEP (*path))
|
||||
{
|
||||
path++;
|
||||
continue;
|
||||
@ -1157,27 +1158,28 @@ mc_realpath (const char *path, char *resolved_path)
|
||||
if (*path == '.')
|
||||
{
|
||||
/* Ignore ".". */
|
||||
if (path[1] == '\0' || path[1] == '/')
|
||||
if (path[1] == '\0' || IS_PATH_SEP (path[1]))
|
||||
{
|
||||
path++;
|
||||
continue;
|
||||
}
|
||||
if (path[1] == '.')
|
||||
{
|
||||
if (path[2] == '\0' || path[2] == '/')
|
||||
if (path[2] == '\0' || IS_PATH_SEP (path[2]))
|
||||
{
|
||||
path += 2;
|
||||
/* Ignore ".." at root. */
|
||||
if (new_path == got_path + 1)
|
||||
continue;
|
||||
/* Handle ".." by backing up. */
|
||||
while ((--new_path)[-1] != '/');
|
||||
while (!IS_PATH_SEP ((--new_path)[-1]))
|
||||
;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Safely copy the next pathname component. */
|
||||
while (*path != '\0' && *path != '/')
|
||||
while (*path != '\0' && !IS_PATH_SEP (*path))
|
||||
{
|
||||
if (path > max_path)
|
||||
{
|
||||
@ -1211,12 +1213,13 @@ mc_realpath (const char *path, char *resolved_path)
|
||||
{
|
||||
/* Note: readlink doesn't add the null byte. */
|
||||
link_path[n] = '\0';
|
||||
if (*link_path == '/')
|
||||
if (IS_PATH_SEP (*link_path))
|
||||
/* Start over for an absolute symlink. */
|
||||
new_path = got_path;
|
||||
else
|
||||
/* Otherwise back up over this component. */
|
||||
while (*(--new_path) != '/');
|
||||
while (!IS_PATH_SEP (*(--new_path)))
|
||||
;
|
||||
/* Safe sex check. */
|
||||
if (strlen (path) + n >= PATH_MAX - 2)
|
||||
{
|
||||
@ -1229,10 +1232,10 @@ mc_realpath (const char *path, char *resolved_path)
|
||||
path = copy_path;
|
||||
}
|
||||
#endif /* S_IFLNK */
|
||||
*new_path++ = '/';
|
||||
*new_path++ = PATH_SEP;
|
||||
}
|
||||
/* Delete trailing slash but don't whomp a lone slash. */
|
||||
if (new_path != got_path + 1 && new_path[-1] == '/')
|
||||
if (new_path != got_path + 1 && IS_PATH_SEP (new_path[-1]))
|
||||
new_path--;
|
||||
/* Make sure it's null terminated. */
|
||||
*new_path = '\0';
|
||||
@ -1313,7 +1316,7 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||
|
||||
path = g_string_new ("");
|
||||
|
||||
absolute = (*first_element != '\0' && *first_element == PATH_SEP);
|
||||
absolute = IS_PATH_SEP (*first_element);
|
||||
|
||||
do
|
||||
{
|
||||
@ -1331,10 +1334,10 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||
|
||||
canonicalize_pathname (tmp_element);
|
||||
len = strlen (tmp_element);
|
||||
start = (tmp_element[0] == PATH_SEP) ? tmp_element + 1 : tmp_element;
|
||||
start = IS_PATH_SEP (tmp_element[0]) ? tmp_element + 1 : tmp_element;
|
||||
|
||||
g_string_append (path, start);
|
||||
if (tmp_element[len - 1] != PATH_SEP && element != NULL)
|
||||
if (!IS_PATH_SEP (tmp_element[len - 1]) && element != NULL)
|
||||
g_string_append_c (path, PATH_SEP);
|
||||
|
||||
g_free (tmp_element);
|
||||
|
@ -155,12 +155,14 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry, int foll
|
||||
ERRNOR (EFAULT, NULL);
|
||||
|
||||
/* make full path from relative */
|
||||
if (*linkname != PATH_SEP)
|
||||
if (!IS_PATH_SEP (*linkname))
|
||||
{
|
||||
char *fullpath = vfs_s_fullpath (me, entry->dir);
|
||||
if (fullpath)
|
||||
char *fullpath;
|
||||
|
||||
fullpath = vfs_s_fullpath (me, entry->dir);
|
||||
if (fullpath != NULL)
|
||||
{
|
||||
fullname = g_strconcat (fullpath, "/", linkname, (char *) NULL);
|
||||
fullname = g_strconcat (fullpath, PATH_SEP_STR, linkname, (char *) NULL);
|
||||
linkname = fullname;
|
||||
g_free (fullpath);
|
||||
}
|
||||
@ -193,7 +195,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
while (*path == PATH_SEP) /* Strip leading '/' */
|
||||
while (IS_PATH_SEP (*path)) /* Strip leading '/' */
|
||||
path++;
|
||||
|
||||
if (path[0] == '\0')
|
||||
@ -202,7 +204,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
return ent;
|
||||
}
|
||||
|
||||
for (pseg = 0; path[pseg] != '\0' && path[pseg] != PATH_SEP; pseg++)
|
||||
for (pseg = 0; path[pseg] != '\0' && !IS_PATH_SEP (path[pseg]); pseg++)
|
||||
;
|
||||
|
||||
for (iter = root->subdir; iter != NULL; iter = g_list_next (iter))
|
||||
@ -726,7 +728,7 @@ vfs_s_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
|
||||
char *name;
|
||||
|
||||
name = g_strconcat (super->name, "/", me->prefix, VFS_PATH_URL_DELIMITER,
|
||||
name = g_strconcat (super->name, PATH_SEP_STR, me->prefix, VFS_PATH_URL_DELIMITER,
|
||||
/* super->current_dir->name, */ (char *) NULL);
|
||||
func (name);
|
||||
g_free (name);
|
||||
@ -1196,7 +1198,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
ino = ino->ent->dir;
|
||||
if (ino == ino->super->root)
|
||||
break;
|
||||
newpath = g_strconcat (ino->ent->name, "/", path, (char *) NULL);
|
||||
newpath = g_strconcat (ino->ent->name, PATH_SEP_STR, path, (char *) NULL);
|
||||
g_free (path);
|
||||
path = newpath;
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ mc_chdir (const vfs_path_t * vpath)
|
||||
char *p;
|
||||
|
||||
p = strchr (path_element->path, 0) - 1;
|
||||
if (*p == PATH_SEP && p > path_element->path)
|
||||
if (IS_PATH_SEP (*p) && p > path_element->path)
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
@ -826,10 +826,8 @@ mc_tmpdir (void)
|
||||
return tmpdir;
|
||||
|
||||
sys_tmp = getenv ("TMPDIR");
|
||||
if (!sys_tmp || sys_tmp[0] != '/')
|
||||
{
|
||||
if (sys_tmp == NULL || !IS_PATH_SEP (sys_tmp[0]))
|
||||
sys_tmp = TMPDIR_DEFAULT;
|
||||
}
|
||||
|
||||
pwd = getpwuid (getuid ());
|
||||
|
||||
|
@ -139,7 +139,7 @@ vfs_canon (const char *path)
|
||||
vfs_die ("Cannot canonicalize NULL");
|
||||
|
||||
/* Relative to current directory */
|
||||
if (*path != PATH_SEP)
|
||||
if (!IS_PATH_SEP (*path))
|
||||
{
|
||||
char *result, *local;
|
||||
|
||||
@ -198,7 +198,7 @@ vfs_get_encoding (const char *path, ssize_t len)
|
||||
if (semi == NULL)
|
||||
return NULL;
|
||||
|
||||
if (semi == path || *(semi - 1) == PATH_SEP)
|
||||
if (semi == path || IS_PATH_SEP (semi[-1]))
|
||||
{
|
||||
char *slash;
|
||||
|
||||
@ -448,11 +448,11 @@ vfs_path_from_str_uri_parser (char *path, vfs_path_flag_t flags)
|
||||
char *real_vfs_prefix_start = url_delimiter;
|
||||
struct vfs_s_subclass *sub = NULL;
|
||||
|
||||
while (real_vfs_prefix_start > path && *(real_vfs_prefix_start) != PATH_SEP)
|
||||
while (real_vfs_prefix_start > path && !IS_PATH_SEP (*real_vfs_prefix_start))
|
||||
real_vfs_prefix_start--;
|
||||
vfs_prefix_start = real_vfs_prefix_start;
|
||||
|
||||
if (*(vfs_prefix_start) == PATH_SEP)
|
||||
if (IS_PATH_SEP (*vfs_prefix_start))
|
||||
vfs_prefix_start += 1;
|
||||
|
||||
*url_delimiter = '\0';
|
||||
@ -495,8 +495,8 @@ vfs_path_from_str_uri_parser (char *path, vfs_path_flag_t flags)
|
||||
#endif
|
||||
g_array_prepend_val (vpath->path, element);
|
||||
|
||||
if ((real_vfs_prefix_start > path && *(real_vfs_prefix_start) == PATH_SEP) ||
|
||||
(real_vfs_prefix_start == path && *(real_vfs_prefix_start) != PATH_SEP))
|
||||
if ((real_vfs_prefix_start > path && IS_PATH_SEP (*real_vfs_prefix_start)) ||
|
||||
(real_vfs_prefix_start == path && !IS_PATH_SEP (*real_vfs_prefix_start)))
|
||||
*real_vfs_prefix_start = '\0';
|
||||
else
|
||||
*(real_vfs_prefix_start + 1) = '\0';
|
||||
@ -537,7 +537,7 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
{
|
||||
char *url_str;
|
||||
|
||||
if (ret_tokens->len > 0 && ret_tokens->str[ret_tokens->len - 1] != PATH_SEP)
|
||||
if (ret_tokens->len > 0 && !IS_PATH_SEP (ret_tokens->str[ret_tokens->len - 1]))
|
||||
g_string_append_c (ret_tokens, PATH_SEP);
|
||||
|
||||
g_string_append (ret_tokens, element->vfs_prefix);
|
||||
@ -556,7 +556,7 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
#ifdef HAVE_CHARSET
|
||||
if (element->encoding != NULL)
|
||||
{
|
||||
if (ret_tokens->len > 0 && ret_tokens->str[ret_tokens->len - 1] != PATH_SEP)
|
||||
if (ret_tokens->len > 0 && !IS_PATH_SEP (ret_tokens->str[ret_tokens->len - 1]))
|
||||
g_string_append (ret_tokens, PATH_SEP_STR);
|
||||
g_string_append (ret_tokens, VFS_ENCODING_PREFIX);
|
||||
g_string_append (ret_tokens, element->encoding);
|
||||
@ -584,7 +584,7 @@ vfs_path_strip_home (const char *dir)
|
||||
|
||||
len = strlen (home_dir);
|
||||
|
||||
if (strncmp (dir, home_dir, len) == 0 && (dir[len] == PATH_SEP || dir[len] == '\0'))
|
||||
if (strncmp (dir, home_dir, len) == 0 && (IS_PATH_SEP (dir[len]) || dir[len] == '\0'))
|
||||
return g_strdup_printf ("~%s", dir + len);
|
||||
}
|
||||
|
||||
@ -606,8 +606,8 @@ vfs_path_strip_home (const char *dir)
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if ((!is_relative) && (*appendfrom != PATH_SEP) && (*appendfrom != '\0') \
|
||||
&& (buffer->len == 0 || buffer->str[buffer->len - 1] != PATH_SEP)) \
|
||||
if (!is_relative && !IS_PATH_SEP (*appendfrom) && *appendfrom != '\0' \
|
||||
&& (buffer->len == 0 || !IS_PATH_SEP (buffer->str[buffer->len - 1]))) \
|
||||
g_string_append_c (buffer, PATH_SEP); \
|
||||
g_string_append (buffer, appendfrom); \
|
||||
} \
|
||||
@ -651,7 +651,7 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
if (element->vfs_prefix != NULL)
|
||||
{
|
||||
char *url_str;
|
||||
if ((!is_relative) && (buffer->len == 0 || buffer->str[buffer->len - 1] != PATH_SEP))
|
||||
if (!is_relative && (buffer->len == 0 || !IS_PATH_SEP (buffer->str[buffer->len - 1])))
|
||||
g_string_append_c (buffer, PATH_SEP);
|
||||
|
||||
g_string_append (buffer, element->vfs_prefix);
|
||||
@ -674,7 +674,7 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
if ((flags & VPF_HIDE_CHARSET) == 0)
|
||||
{
|
||||
if ((!is_relative)
|
||||
&& (buffer->len == 0 || buffer->str[buffer->len - 1] != PATH_SEP))
|
||||
&& (buffer->len == 0 || !IS_PATH_SEP (buffer->str[buffer->len - 1])))
|
||||
g_string_append (buffer, PATH_SEP_STR);
|
||||
g_string_append (buffer, VFS_ENCODING_PREFIX);
|
||||
g_string_append (buffer, element->encoding);
|
||||
@ -1547,7 +1547,7 @@ vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element)
|
||||
g_string_append (pretty_path, url_params);
|
||||
g_free (url_params);
|
||||
|
||||
if (*element->path != PATH_SEP)
|
||||
if (!IS_PATH_SEP (*element->path))
|
||||
g_string_append_c (pretty_path, PATH_SEP);
|
||||
|
||||
g_string_append (pretty_path, element->path);
|
||||
|
@ -253,7 +253,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
if ((flags & URL_NOSLASH) == 0)
|
||||
{
|
||||
/* locate path component */
|
||||
while (*dir != PATH_SEP && *dir != '\0')
|
||||
while (!IS_PATH_SEP (*dir) && *dir != '\0')
|
||||
dir++;
|
||||
if (*dir == '\0')
|
||||
path_element->path = g_strdup (PATH_SEP_STR);
|
||||
|
@ -76,7 +76,7 @@ struct vfs_class *current_vfs = NULL;
|
||||
|
||||
#define VFS_FIRST_HANDLE 100
|
||||
|
||||
#define ISSLASH(a) (!a || (a == '/'))
|
||||
#define ISSLASH(a) (a == '\0' || IS_PATH_SEP (a))
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
@ -121,7 +121,7 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
||||
|
||||
/* try found /#enc: */
|
||||
semi = g_strrstr_len (path, size, VFS_ENCODING_PREFIX);
|
||||
if (semi != NULL && (semi == path || *(semi - 1) == PATH_SEP))
|
||||
if (semi != NULL && (semi == path || IS_PATH_SEP (semi[-1])))
|
||||
{
|
||||
char encoding[16];
|
||||
const char *slash;
|
||||
|
@ -288,7 +288,7 @@ filename_completion_function (const char *text, int state, input_complete_t flag
|
||||
g_string_append (temp, users_dirname);
|
||||
|
||||
/* We need a '/' at the end. */
|
||||
if (temp->str[temp->len - 1] != PATH_SEP)
|
||||
if (!IS_PATH_SEP (temp->str[temp->len - 1]))
|
||||
g_string_append_c (temp, PATH_SEP);
|
||||
}
|
||||
g_string_append (temp, entry->d_name);
|
||||
@ -909,7 +909,7 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,
|
||||
SHOW_C_CTX ("try_complete:filename_subst_1");
|
||||
matches = completion_matches (state->word, filename_completion_function, state->flags);
|
||||
|
||||
if (matches == NULL && state->is_cd && *state->word != PATH_SEP && *state->word != '~')
|
||||
if (matches == NULL && state->is_cd && !IS_PATH_SEP (*state->word) && *state->word != '~')
|
||||
{
|
||||
state->q = text + *lc_start;
|
||||
for (state->p = text;
|
||||
|
@ -211,14 +211,10 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
if (*start_filename == '\0')
|
||||
return 0;
|
||||
|
||||
if (*start_filename != PATH_SEP && edit->dir_vpath != NULL)
|
||||
{
|
||||
if (!IS_PATH_SEP (*start_filename) && edit->dir_vpath != NULL)
|
||||
real_filename_vpath = vfs_path_append_vpath_new (edit->dir_vpath, filename_vpath, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
real_filename_vpath = vfs_path_clone (filename_vpath);
|
||||
}
|
||||
|
||||
this_save_mode = option_save_mode;
|
||||
if (this_save_mode != EDIT_QUICK_SAVE)
|
||||
@ -284,7 +280,7 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
savedir = g_strdup (".");
|
||||
|
||||
/* Token-related function never return leading slash, so we need add it manually */
|
||||
saveprefix = mc_build_filename ("/", savedir, "cooledit", NULL);
|
||||
saveprefix = mc_build_filename (PATH_SEP_STR, savedir, "cooledit", NULL);
|
||||
g_free (savedir);
|
||||
fd = mc_mkstemps (&savename_vpath, saveprefix, NULL);
|
||||
g_free (saveprefix);
|
||||
|
@ -444,7 +444,7 @@ nice_cd (const char *text, const char *xtext, const char *help,
|
||||
|
||||
g_free (machine);
|
||||
|
||||
if (*cd_path != PATH_SEP)
|
||||
if (!IS_PATH_SEP (*cd_path))
|
||||
{
|
||||
char *tmp = cd_path;
|
||||
|
||||
@ -863,7 +863,7 @@ mkdir_cmd (void)
|
||||
{
|
||||
vfs_path_t *absdir;
|
||||
|
||||
if (dir[0] == '/' || dir[0] == '~')
|
||||
if (IS_PATH_SEP (dir[0]) || dir[0] == '~')
|
||||
absdir = vfs_path_from_str (dir);
|
||||
else
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ handle_cdpath (const char *path)
|
||||
gboolean result = FALSE;
|
||||
|
||||
/* CDPATH handling */
|
||||
if (*path != PATH_SEP)
|
||||
if (!IS_PATH_SEP (*path))
|
||||
{
|
||||
char *cdpath, *p;
|
||||
char c;
|
||||
@ -416,10 +416,8 @@ do_cd_command (char *orig_cmd)
|
||||
}
|
||||
sync_tree (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
}
|
||||
else if (cmd[operand_pos] == PATH_SEP)
|
||||
{
|
||||
else if (IS_PATH_SEP (cmd[operand_pos]))
|
||||
sync_tree (cmd + operand_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
vfs_path_t *new_vpath;
|
||||
|
@ -652,7 +652,7 @@ dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
|
||||
vpath_str = vfs_path_as_str (vpath);
|
||||
/* Do not add a ".." entry to the root directory */
|
||||
if ((vpath_str[0] == PATH_SEP) && (vpath_str[1] == '\0'))
|
||||
if (IS_PATH_SEP (vpath_str[0]) && vpath_str[1] == '\0')
|
||||
list->len--;
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
/* Add ".." except to the root directory. The ".." entry
|
||||
(if any) must be the first in the list. */
|
||||
tmp_path = vfs_path_get_by_index (vpath, 0)->path;
|
||||
if (vfs_path_elements_count (vpath) == 1 && tmp_path[0] == PATH_SEP && tmp_path[1] == '\0')
|
||||
if (vfs_path_elements_count (vpath) == 1 && IS_PATH_SEP (tmp_path[0]) && tmp_path[1] == '\0')
|
||||
{
|
||||
/* root directory */
|
||||
dir_list_clean (list);
|
||||
|
@ -2689,7 +2689,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
* dir is deleted)
|
||||
*/
|
||||
if (!force_single && tmp_dest_dir[0] != '\0'
|
||||
&& tmp_dest_dir[strlen (tmp_dest_dir) - 1] != PATH_SEP)
|
||||
&& !IS_PATH_SEP (tmp_dest_dir[strlen (tmp_dest_dir) - 1]))
|
||||
{
|
||||
/* add trailing separator */
|
||||
dest_dir = g_strconcat (tmp_dest_dir, PATH_SEP_STR, (char *) NULL);
|
||||
|
@ -63,7 +63,7 @@ get_absolute_name (const vfs_path_t * vpath)
|
||||
if (vpath == NULL)
|
||||
return NULL;
|
||||
|
||||
if (*(vfs_path_get_by_index (vpath, 0)->path) == PATH_SEP)
|
||||
if (IS_PATH_SEP (*vfs_path_get_by_index (vpath, 0)->path))
|
||||
return vfs_path_clone (vpath);
|
||||
|
||||
return vfs_path_append_vpath_new (vfs_get_raw_current_dir (), vpath, NULL);
|
||||
|
@ -887,7 +887,7 @@ insert_file (const char *dir, const char *file)
|
||||
char *tmp_name = NULL;
|
||||
static char *dirname = NULL;
|
||||
|
||||
while (dir[0] == PATH_SEP && dir[1] == PATH_SEP)
|
||||
while (IS_PATH_SEP (dir[0]) && IS_PATH_SEP (dir[1]))
|
||||
dir++;
|
||||
|
||||
if (old_dir)
|
||||
@ -1181,7 +1181,7 @@ find_ignore_dir_search (const char *dir)
|
||||
{
|
||||
/* be sure that ignore dir is not a part of dir like:
|
||||
ignore dir is "h", dir is "home" */
|
||||
if (dir[ilen] == '\0' || dir[ilen] == PATH_SEP)
|
||||
if (dir[ilen] == '\0' || IS_PATH_SEP (dir[ilen]))
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
@ -1190,7 +1190,8 @@ find_ignore_dir_search (const char *dir)
|
||||
char *d;
|
||||
|
||||
d = strstr (dir, *ignore_dir);
|
||||
if (d != NULL && d[-1] == PATH_SEP && (d[ilen] == '\0' || d[ilen] == PATH_SEP))
|
||||
if (d != NULL && IS_PATH_SEP (d[-1])
|
||||
&& (d[ilen] == '\0' || IS_PATH_SEP (d[ilen])))
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
@ -1743,7 +1744,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||
else
|
||||
{
|
||||
p = name + (size_t) start_dir_len;
|
||||
if (*p == PATH_SEP)
|
||||
if (IS_PATH_SEP (*p))
|
||||
p++;
|
||||
}
|
||||
|
||||
|
@ -736,7 +736,7 @@ midnight_put_panel_path (WPanel * panel)
|
||||
|
||||
command_insert (cmdline, cwd_vpath_str, FALSE);
|
||||
|
||||
if (cwd_vpath_str[strlen (cwd_vpath_str) - 1] != PATH_SEP)
|
||||
if (!IS_PATH_SEP (cwd_vpath_str[strlen (cwd_vpath_str) - 1]))
|
||||
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
||||
|
||||
vfs_path_free (cwd_vpath);
|
||||
|
@ -848,7 +848,7 @@ read_file_system_list (int need_fs_type)
|
||||
/* All volumes are mounted in the rootfs, directly under /. */
|
||||
rootdir_list = NULL;
|
||||
rootdir_tail = &rootdir_list;
|
||||
dirp = opendir ("/");
|
||||
dirp = opendir (PATH_SEP_STR);
|
||||
if (dirp)
|
||||
{
|
||||
struct dirent *d;
|
||||
@ -862,9 +862,9 @@ read_file_system_list (int need_fs_type)
|
||||
continue;
|
||||
|
||||
if (DIR_IS_DOTDOT (d->d_name))
|
||||
name = g_strdup ("/");
|
||||
name = g_strdup (PATH_SEP_STR);
|
||||
else
|
||||
name = g_strconcat ("/", d->d_name, (char *) NULL);
|
||||
name = g_strconcat (PATH_SEP_STR, d->d_name, (char *) NULL);
|
||||
|
||||
if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
|
||||
{
|
||||
@ -1661,7 +1661,7 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
|
||||
|
||||
i = strlen (temp->me_mountdir);
|
||||
if (i > len && (strncmp (path, temp->me_mountdir, i) == 0))
|
||||
if (!entry || (path[i] == PATH_SEP || path[i] == '\0'))
|
||||
if (entry == NULL || IS_PATH_SEP (path[i]) || path[i] == '\0')
|
||||
{
|
||||
len = i;
|
||||
entry = temp;
|
||||
|
@ -2900,7 +2900,7 @@ chdir_to_readlink (WPanel * panel)
|
||||
return;
|
||||
p[1] = 0;
|
||||
}
|
||||
if (*buffer == PATH_SEP)
|
||||
if (IS_PATH_SEP (*buffer))
|
||||
new_dir_vpath = vfs_path_from_str (buffer);
|
||||
else
|
||||
new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, buffer, NULL);
|
||||
@ -3167,22 +3167,21 @@ get_parent_dir_name (const vfs_path_t * cwd_vpath, const vfs_path_t * lwd_vpath)
|
||||
|
||||
if ((p != NULL)
|
||||
&& (strncmp (cwd, lwd, (size_t) (p - lwd)) == 0)
|
||||
&& (clen == (size_t) (p - lwd)
|
||||
|| ((p == lwd) && (cwd[0] == PATH_SEP) && (cwd[1] == '\0'))))
|
||||
&& (clen == (size_t) (p - lwd) || (p == lwd && IS_PATH_SEP (cwd[0]) && cwd[1] == '\0')))
|
||||
return (p + 1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* skip VFS prefix */
|
||||
while (--p > lwd && *p != PATH_SEP)
|
||||
while (--p > lwd && !IS_PATH_SEP (*p))
|
||||
;
|
||||
/* get last component */
|
||||
while (--p > lwd && *p != PATH_SEP)
|
||||
while (--p > lwd && !IS_PATH_SEP (*p))
|
||||
;
|
||||
|
||||
/* return last component */
|
||||
return (p != lwd || *p == PATH_SEP) ? p + 1 : p;
|
||||
return (p != lwd || IS_PATH_SEP (*p)) ? p + 1 : p;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -4115,7 +4114,7 @@ panel_recursive_cd_to_parent (const vfs_path_t * vpath)
|
||||
|
||||
/* check if path contains only '/' */
|
||||
panel_cwd_path = vfs_path_as_str (cwd_vpath);
|
||||
if (panel_cwd_path[0] == PATH_SEP && panel_cwd_path[1] == '\0')
|
||||
if (IS_PATH_SEP (panel_cwd_path[0]) && panel_cwd_path[1] == '\0')
|
||||
return NULL;
|
||||
|
||||
tmp_vpath = vfs_path_vtokens_get (cwd_vpath, 0, -1);
|
||||
|
@ -340,7 +340,7 @@ do_external_panelize (char *command)
|
||||
line[strlen (line) - 1] = 0;
|
||||
if (strlen (line) < 1)
|
||||
continue;
|
||||
if (line[0] == '.' && line[1] == PATH_SEP)
|
||||
if (line[0] == '.' && IS_PATH_SEP (line[1]))
|
||||
name = line + 2;
|
||||
else
|
||||
name = line;
|
||||
@ -361,7 +361,7 @@ do_external_panelize (char *command)
|
||||
|
||||
if (list->len == 0)
|
||||
dir_list_init (list);
|
||||
else if (list->list[0].fname[0] == PATH_SEP)
|
||||
else if (IS_PATH_SEP (list->list[0].fname[0]))
|
||||
{
|
||||
vfs_path_t *vpath_root;
|
||||
int ret;
|
||||
|
@ -318,7 +318,7 @@ show_tree (WTree * tree)
|
||||
const char *cname;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
|
||||
for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--)
|
||||
;
|
||||
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
|
||||
i++;
|
||||
@ -405,7 +405,7 @@ show_tree (WTree * tree)
|
||||
const char *cname;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
for (j = strlen (cname) - 1; cname[j] != PATH_SEP; j--)
|
||||
for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--)
|
||||
;
|
||||
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
|
||||
break;
|
||||
|
@ -150,9 +150,9 @@ pathcmp (const vfs_path_t * p1_vpath, const vfs_path_t * p2_vpath)
|
||||
ret_val = -1;
|
||||
else if (*p2 == '\0')
|
||||
ret_val = 1;
|
||||
else if (*p1 == PATH_SEP)
|
||||
else if (IS_PATH_SEP (*p1))
|
||||
ret_val = -1;
|
||||
else if (*p2 == PATH_SEP)
|
||||
else if (IS_PATH_SEP (*p2))
|
||||
ret_val = 1;
|
||||
else
|
||||
ret_val = (*p1 - *p2);
|
||||
@ -258,7 +258,7 @@ tree_store_load_from (char *name)
|
||||
scanned = buffer[0] == '1';
|
||||
|
||||
lc_name = decode (buffer + 2);
|
||||
if (lc_name[0] != PATH_SEP)
|
||||
if (!IS_PATH_SEP (lc_name[0]))
|
||||
{
|
||||
/* Clear-text decompression */
|
||||
char *s = strtok (lc_name, " ");
|
||||
@ -451,7 +451,7 @@ tree_store_add_entry (const vfs_path_t * name)
|
||||
const char *new_name;
|
||||
|
||||
new_name = vfs_path_get_last_path_str (new->name);
|
||||
new->subname = strrchr (new_name, '/');
|
||||
new->subname = strrchr (new_name, PATH_SEP);
|
||||
if (new->subname == NULL)
|
||||
new->subname = new_name;
|
||||
else
|
||||
@ -703,7 +703,7 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
|
||||
const char *name_vpath_str;
|
||||
|
||||
name_vpath_str = vfs_path_as_str (name_vpath);
|
||||
is_root = (name_vpath_str[0] == PATH_SEP && name_vpath_str[1] == '\0');
|
||||
is_root = (IS_PATH_SEP (name_vpath_str[0]) && name_vpath_str[1] == '\0');
|
||||
if (is_root)
|
||||
return;
|
||||
}
|
||||
@ -722,7 +722,7 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
|
||||
const char *cname;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
ok = (cname[len] == '\0' || cname[len] == PATH_SEP);
|
||||
ok = (cname[len] == '\0' || IS_PATH_SEP (cname[len]));
|
||||
if (!ok)
|
||||
break;
|
||||
|
||||
@ -756,7 +756,7 @@ tree_store_mark_checked (const char *subname)
|
||||
return;
|
||||
|
||||
cname = vfs_path_as_str (ts.check_name);
|
||||
if (cname[0] == PATH_SEP && cname[1] == '\0')
|
||||
if (IS_PATH_SEP (cname[0]) && cname[1] == '\0')
|
||||
name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL);
|
||||
else
|
||||
name = vfs_path_append_new (ts.check_name, subname, NULL);
|
||||
@ -788,7 +788,7 @@ tree_store_mark_checked (const char *subname)
|
||||
gboolean ok;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
|
||||
ok = (cname[len] == '\0' || IS_PATH_SEP (cname[len]) || len == 1);
|
||||
if (!ok)
|
||||
break;
|
||||
|
||||
@ -846,7 +846,7 @@ tree_store_start_check (const vfs_path_t * vpath)
|
||||
const char *cname;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
|
||||
ok = (cname[len] == '\0' || IS_PATH_SEP (cname[len]) || len == 1);
|
||||
if (!ok)
|
||||
break;
|
||||
|
||||
@ -883,7 +883,7 @@ tree_store_end_check (void)
|
||||
const char *cname;
|
||||
|
||||
cname = vfs_path_as_str (current->name);
|
||||
ok = (cname[len] == '\0' || cname[len] == PATH_SEP || len == 1);
|
||||
ok = (cname[len] == '\0' || IS_PATH_SEP (cname[len]) || len == 1);
|
||||
if (!ok)
|
||||
break;
|
||||
|
||||
|
@ -86,7 +86,7 @@ strip_ext (char *ss)
|
||||
{
|
||||
if (*s == '.')
|
||||
e = s;
|
||||
if (*s == PATH_SEP && e)
|
||||
if (IS_PATH_SEP (*s) && e != NULL)
|
||||
e = NULL; /* '.' in *directory* name */
|
||||
s++;
|
||||
}
|
||||
|
@ -193,10 +193,10 @@ show_datadirs_extended (void)
|
||||
#if defined ENABLE_VFS_EXTFS || defined ENABLE_VFS_FISH
|
||||
PRINTF_SECTION (_("VFS plugins and scripts:"), LIBEXECDIR);
|
||||
#ifdef ENABLE_VFS_EXTFS
|
||||
PRINTF2 ("extfs.d:", LIBEXECDIR, MC_EXTFS_DIR "/");
|
||||
PRINTF2 ("extfs.d:", LIBEXECDIR, MC_EXTFS_DIR PATH_SEP_STR);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
PRINTF2 ("fish:", LIBEXECDIR, FISH_PREFIX "/");
|
||||
PRINTF2 ("fish:", LIBEXECDIR, FISH_PREFIX PATH_SEP_STR);
|
||||
#endif
|
||||
#endif /* ENABLE_VFS_EXTFS || defiined ENABLE_VFS_FISH */
|
||||
(void) puts ("");
|
||||
@ -205,12 +205,12 @@ show_datadirs_extended (void)
|
||||
|
||||
PRINTF_SECTION2 (_("Config directory:"), mc_config_get_path ());
|
||||
PRINTF_SECTION2 (_("Data directory:"), mc_config_get_data_path ());
|
||||
PRINTF ("skins:", mc_config_get_data_path (), MC_SKINS_SUBDIR "/");
|
||||
PRINTF ("skins:", mc_config_get_data_path (), MC_SKINS_SUBDIR PATH_SEP_STR);
|
||||
#ifdef ENABLE_VFS_EXTFS
|
||||
PRINTF ("extfs.d:", mc_config_get_data_path (), MC_EXTFS_DIR "/");
|
||||
PRINTF ("extfs.d:", mc_config_get_data_path (), MC_EXTFS_DIR PATH_SEP_STR);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
PRINTF ("fish:", mc_config_get_data_path (), FISH_PREFIX "/");
|
||||
PRINTF ("fish:", mc_config_get_data_path (), FISH_PREFIX PATH_SEP_STR);
|
||||
#endif
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
PRINTF ("mcedit macros:", mc_config_get_data_path (), MC_MACRO_FILE);
|
||||
|
@ -421,7 +421,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat
|
||||
}
|
||||
|
||||
/* remove trailing slashes */
|
||||
for (tn = name + strlen (name) - 1; tn >= name && *tn == PATH_SEP; tn--)
|
||||
for (tn = name + strlen (name) - 1; tn >= name && IS_PATH_SEP (*tn); tn--)
|
||||
*tn = '\0';
|
||||
|
||||
tn = strrchr (name, PATH_SEP);
|
||||
|
@ -356,7 +356,7 @@ extfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
|
||||
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, a->fstype);
|
||||
name =
|
||||
g_strconcat (a->name ? a->name : "", "/", info->prefix, VFS_PATH_URL_DELIMITER,
|
||||
g_strconcat (a->name ? a->name : "", PATH_SEP_STR, info->prefix, VFS_PATH_URL_DELIMITER,
|
||||
(char *) NULL);
|
||||
func (name);
|
||||
g_free (name);
|
||||
@ -523,11 +523,11 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
|
||||
|
||||
if (*cfn != '\0')
|
||||
{
|
||||
if (*cfn == PATH_SEP)
|
||||
if (IS_PATH_SEP (*cfn))
|
||||
cfn++;
|
||||
p = strchr (cfn, '\0');
|
||||
if (p != cfn && *(p - 1) == PATH_SEP)
|
||||
*(p - 1) = '\0';
|
||||
if (p != cfn && IS_PATH_SEP (p[-1]))
|
||||
p[-1] = '\0';
|
||||
p = strrchr (cfn, PATH_SEP);
|
||||
if (p == NULL)
|
||||
{
|
||||
|
@ -546,8 +546,8 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
#if 0
|
||||
super->name =
|
||||
g_strconcat ("sh://", super->path_element->user, "@", super->path_element->host, "/",
|
||||
(char *) NULL);
|
||||
g_strconcat ("sh://", super->path_element->user, "@", super->path_element->host,
|
||||
PATH_SEP_STR, (char *) NULL);
|
||||
#else
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
#endif
|
||||
@ -1573,8 +1573,8 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
|
||||
name =
|
||||
g_strconcat (vfs_fish_ops.prefix, VFS_PATH_URL_DELIMITER,
|
||||
super->path_element->user, "@", super->path_element->host, flags, "/",
|
||||
super->path_element->path, (char *) NULL);
|
||||
super->path_element->user, "@", super->path_element->host, flags,
|
||||
PATH_SEP_STR, super->path_element->path, (char *) NULL);
|
||||
func (name);
|
||||
g_free (name);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
}
|
||||
|
||||
/* strip leading slash(es) */
|
||||
while (*remote_path == '/')
|
||||
while (IS_PATH_SEP (*remote_path))
|
||||
remote_path++;
|
||||
|
||||
/*
|
||||
@ -304,11 +304,11 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
|
||||
/* replace first occurrence of ":/" with ":" */
|
||||
p = strchr (ret, ':');
|
||||
if ((p != NULL) && (*(p + 1) == '/'))
|
||||
if (p != NULL && IS_PATH_SEP (p[1]))
|
||||
memmove (p + 1, p + 2, strlen (p + 2) + 1);
|
||||
|
||||
/* strip trailing "/." */
|
||||
p = strrchr (ret, '/');
|
||||
p = strrchr (ret, PATH_SEP);
|
||||
if ((p != NULL) && (*(p + 1) == '.') && (*(p + 2) == '\0'))
|
||||
*p = '\0';
|
||||
|
||||
@ -990,7 +990,7 @@ ftpfs_open_archive (struct vfs_s_super *super,
|
||||
SUP->isbinary = TYPE_UNKNOWN;
|
||||
SUP->remote_is_amiga = 0;
|
||||
SUP->ctl_connection_busy = 0;
|
||||
super->name = g_strdup ("/");
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
super->root =
|
||||
vfs_s_new_inode (vpath_element->class, super,
|
||||
vfs_s_default_stat (vpath_element->class, S_IFDIR | 0755));
|
||||
@ -1045,19 +1045,19 @@ ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
if (*bufp != '\0')
|
||||
{
|
||||
if (*(bufq - 1) != '/')
|
||||
if (!IS_PATH_SEP (bufq[-1]))
|
||||
{
|
||||
*bufq++ = '/';
|
||||
*bufq++ = PATH_SEP;
|
||||
*bufq = '\0';
|
||||
}
|
||||
|
||||
if (*bufp == '/')
|
||||
if (IS_PATH_SEP (*bufp))
|
||||
return g_strdup (bufp);
|
||||
|
||||
/* If the remote server is an Amiga a leading slash
|
||||
might be missing. MC needs it because it is used
|
||||
as separator between hostname and path internally. */
|
||||
return g_strconcat ("/", bufp, (char *) NULL);
|
||||
return g_strconcat (PATH_SEP_STR, bufp, (char *) NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1381,7 +1381,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
|
||||
char *remote_path = ftpfs_translate_path (me, super, remote);
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd,
|
||||
/* WarFtpD can't STORE //filename */
|
||||
(*remote_path == '/') ? remote_path + 1 : remote_path);
|
||||
IS_PATH_SEP (*remote_path) ? remote_path + 1 : remote_path);
|
||||
g_free (remote_path);
|
||||
}
|
||||
else
|
||||
@ -1484,7 +1484,7 @@ resolve_symlink_without_ls_options (struct vfs_class *me, struct vfs_s_super *su
|
||||
fel = flist->data;
|
||||
if (S_ISLNK (fel->s.st_mode) && fel->linkname)
|
||||
{
|
||||
if (fel->linkname[0] == '/')
|
||||
if (IS_PATH_SEP (fel->linkname[0]))
|
||||
{
|
||||
if (strlen (fel->linkname) >= MC_MAXPATHLEN)
|
||||
continue;
|
||||
@ -1496,7 +1496,7 @@ resolve_symlink_without_ls_options (struct vfs_class *me, struct vfs_s_super *su
|
||||
continue;
|
||||
strcpy (tmp, dir->remote_path);
|
||||
if (tmp[1] != '\0')
|
||||
strcat (tmp, "/");
|
||||
strcat (tmp, PATH_SEP_STR);
|
||||
strcat (tmp + 1, fel->linkname);
|
||||
}
|
||||
for (depth = 0; depth < 100; depth++)
|
||||
@ -1508,7 +1508,7 @@ resolve_symlink_without_ls_options (struct vfs_class *me, struct vfs_s_super *su
|
||||
if (S_ISLNK (fe->s.st_mode) && fe->l_stat == 0)
|
||||
{
|
||||
/* Symlink points to link which isn't resolved, yet. */
|
||||
if (fe->linkname[0] == '/')
|
||||
if (IS_PATH_SEP (fe->linkname[0]))
|
||||
{
|
||||
if (strlen (fe->linkname) >= MC_MAXPATHLEN)
|
||||
break;
|
||||
@ -1519,7 +1519,7 @@ resolve_symlink_without_ls_options (struct vfs_class *me, struct vfs_s_super *su
|
||||
/* at this point tmp looks always like this
|
||||
/directory/filename, i.e. no need to check
|
||||
strrchr's return value */
|
||||
*(strrchr (tmp, '/') + 1) = '\0'; /* dirname */
|
||||
*(strrchr (tmp, PATH_SEP) + 1) = '\0'; /* dirname */
|
||||
if ((strlen (tmp) + strlen (fe->linkname)) >= MC_MAXPATHLEN)
|
||||
break;
|
||||
strcat (tmp, fe->linkname);
|
||||
|
@ -439,12 +439,12 @@ sfs_init (struct vfs_class *me)
|
||||
continue;
|
||||
|
||||
for (c = key; *c; c++)
|
||||
if ((*c == ':') || (*c == '/'))
|
||||
if (*c == ':' || IS_PATH_SEP (*c))
|
||||
{
|
||||
semi = c;
|
||||
if (*c == '/')
|
||||
if (IS_PATH_SEP (*c))
|
||||
{
|
||||
*c = 0;
|
||||
*c = '\0';
|
||||
flags |= F_FULLMATCH;
|
||||
}
|
||||
break;
|
||||
|
@ -524,7 +524,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
|
||||
else
|
||||
len = strlen (header->header.arch_name);
|
||||
|
||||
if (len != 0 && header->header.arch_name[len - 1] == '/')
|
||||
if (len != 0 && IS_PATH_SEP (header->header.arch_name[len - 1]))
|
||||
header->header.linkflag = LF_DIR;
|
||||
}
|
||||
|
||||
@ -618,8 +618,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
|
||||
current_link_name =
|
||||
(next_long_link ? next_long_link : g_strndup (header->header.arch_linkname, NAMSIZ));
|
||||
len = strlen (current_link_name);
|
||||
if (len > 1 && current_link_name[len - 1] == '/')
|
||||
current_link_name[len - 1] = 0;
|
||||
if (len > 1 && IS_PATH_SEP (current_link_name[len - 1]))
|
||||
current_link_name[len - 1] = '\0';
|
||||
|
||||
current_file_name = NULL;
|
||||
switch (arch->type)
|
||||
@ -669,7 +669,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
|
||||
|
||||
data_position = current_tar_position;
|
||||
|
||||
p = strrchr (current_file_name, '/');
|
||||
p = strrchr (current_file_name, PATH_SEP);
|
||||
if (p == NULL)
|
||||
{
|
||||
p = current_file_name;
|
||||
|
@ -179,13 +179,13 @@ undelfs_get_path (const vfs_path_t * vpath, char **fsname, char **file)
|
||||
#if 0
|
||||
/* Strip trailing ./
|
||||
*/
|
||||
if (p - dirname > 2 && *(p - 1) == '/' && *(p - 2) == '.')
|
||||
if (p - dirname > 2 && IS_PATH_SEP (p[-1]) && p[-2] == '.')
|
||||
*(p = p - 2) = 0;
|
||||
#endif
|
||||
|
||||
while (p > dirname)
|
||||
{
|
||||
if (*p == '/')
|
||||
if (IS_PATH_SEP (*p))
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user