* path.cc: Change 'to_posix_p' to 'to_posix' throughout.
(conv_path_list_buf_size): Accommodate relative paths.
This commit is contained in:
parent
110363c8a2
commit
d238c1b453
|
@ -1,3 +1,8 @@
|
||||||
|
2003-02-05 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* path.cc: Change 'to_posix_p' to 'to_posix' throughout.
|
||||||
|
(conv_path_list_buf_size): Accommodate relative paths.
|
||||||
|
|
||||||
2003-02-05 Christopher Faylor <cgf@redhat.com>
|
2003-02-05 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* path.cc (etc::dir_changed): Fix debug printf.
|
* path.cc (etc::dir_changed): Fix debug printf.
|
||||||
|
@ -99,7 +104,7 @@
|
||||||
* pwdgrp.h: Change arguments of internal_getpwsid,
|
* pwdgrp.h: Change arguments of internal_getpwsid,
|
||||||
internal_getgrsid and internal_getgroups to cygpsid.
|
internal_getgrsid and internal_getgroups to cygpsid.
|
||||||
* passwd.cc (internal_getpwsid): Change argument from cygsid to cygpsid.
|
* passwd.cc (internal_getpwsid): Change argument from cygsid to cygpsid.
|
||||||
* grp.cc (internal_getgrsid): Ditto.
|
* grp.cc (internal_getgrsid): Ditto.
|
||||||
(internal_getgroups): Ditto.
|
(internal_getgroups): Ditto.
|
||||||
|
|
||||||
2003-02-03 Christopher Faylor <cgf@redhat.com>
|
2003-02-03 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
|
@ -1318,13 +1318,13 @@ slash_unc_prefix_p (const char *path)
|
||||||
/* conv_path_list: Convert a list of path names to/from Win32/POSIX. */
|
/* conv_path_list: Convert a list of path names to/from Win32/POSIX. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
conv_path_list (const char *src, char *dst, int to_posix_p)
|
conv_path_list (const char *src, char *dst, int to_posix)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
char *d = dst;
|
char *d = dst;
|
||||||
char src_delim = to_posix_p ? ';' : ':';
|
char src_delim = to_posix ? ';' : ':';
|
||||||
char dst_delim = to_posix_p ? ':' : ';';
|
char dst_delim = to_posix ? ':' : ';';
|
||||||
int (*conv_fn) (const char *, char *) = (to_posix_p
|
int (*conv_fn) (const char *, char *) = (to_posix
|
||||||
? cygwin_conv_to_posix_path
|
? cygwin_conv_to_posix_path
|
||||||
: cygwin_conv_to_win32_path);
|
: cygwin_conv_to_win32_path);
|
||||||
|
|
||||||
|
@ -3487,23 +3487,29 @@ cygwin_posix_path_list_p (const char *path)
|
||||||
allows the caller to use alloca if it wants. */
|
allows the caller to use alloca if it wants. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
conv_path_list_buf_size (const char *path_list, int to_posix_p)
|
conv_path_list_buf_size (const char *path_list, bool to_posix)
|
||||||
{
|
{
|
||||||
int i, num_elms, max_mount_path_len, size;
|
int i, num_elms, max_mount_path_len, size;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
|
path_conv pc(".", PC_FULL | PC_POSIX);
|
||||||
/* The theory is that an upper bound is
|
/* The theory is that an upper bound is
|
||||||
current_size + (num_elms * max_mount_path_len) */
|
current_size + (num_elms * max_mount_path_len) */
|
||||||
|
|
||||||
char delim = to_posix_p ? ';' : ':';
|
unsigned nrel;
|
||||||
p = path_list;
|
char delim = to_posix ? ';' : ':';
|
||||||
for (num_elms = 1; (p = strchr (p, delim)) != NULL; ++num_elms)
|
for (p = path_list, num_elms = nrel = 0; p; num_elms++)
|
||||||
++p;
|
{
|
||||||
|
if (!isabspath (p))
|
||||||
|
nrel++;
|
||||||
|
p = strchr (++p, delim);
|
||||||
|
}
|
||||||
|
|
||||||
/* 7: strlen ("//c") + slop, a conservative initial value */
|
/* 7: strlen ("//c") + slop, a conservative initial value */
|
||||||
for (max_mount_path_len = 7, i = 0; i < mount_table->nmounts; ++i)
|
for (max_mount_path_len = sizeof ("/cygdrive/X"), i = 0;
|
||||||
|
i < mount_table->nmounts; i++)
|
||||||
{
|
{
|
||||||
int mount_len = (to_posix_p
|
int mount_len = (to_posix
|
||||||
? mount_table->mount[i].posix_pathlen
|
? mount_table->mount[i].posix_pathlen
|
||||||
: mount_table->mount[i].native_pathlen);
|
: mount_table->mount[i].native_pathlen);
|
||||||
if (max_mount_path_len < mount_len)
|
if (max_mount_path_len < mount_len)
|
||||||
|
@ -3511,20 +3517,23 @@ conv_path_list_buf_size (const char *path_list, int to_posix_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 100: slop */
|
/* 100: slop */
|
||||||
size = strlen (path_list) + (num_elms * max_mount_path_len) + 100;
|
size = strlen (path_list)
|
||||||
|
+ (num_elms * max_mount_path_len)
|
||||||
|
+ (nrel * strlen (to_posix ? pc.get_win32 () : pc.normalized_path))
|
||||||
|
+ 100;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_win32_to_posix_path_list_buf_size (const char *path_list)
|
cygwin_win32_to_posix_path_list_buf_size (const char *path_list)
|
||||||
{
|
{
|
||||||
return conv_path_list_buf_size (path_list, 1);
|
return conv_path_list_buf_size (path_list, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_posix_to_win32_path_list_buf_size (const char *path_list)
|
cygwin_posix_to_win32_path_list_buf_size (const char *path_list)
|
||||||
{
|
{
|
||||||
return conv_path_list_buf_size (path_list, 0);
|
return conv_path_list_buf_size (path_list, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
|
Loading…
Reference in New Issue