mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 16:26:12 +08:00
Use isdirsep rather than SLASH_P throughout.
* path.cc (iscygdrive): Disallow /cygdrive\x. (normalize_posix_path): "Normalize" a windows path, if detected, rather than converting to posix. * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support and capability checking for B230400 bitrate. (fhandler_serial::tcgetattr): Add support for B230400 bitrate. * include/sys/termios.h: Add B230400 definition for Posix support of 230.4Kbps.
This commit is contained in:
parent
9f05d3a44a
commit
85ba109de7
@ -1,3 +1,18 @@
|
|||||||
|
2003-01-09 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
Use isdirsep rather than SLASH_P throughout.
|
||||||
|
* path.cc (iscygdrive): Disallow /cygdrive\x.
|
||||||
|
(normalize_posix_path): "Normalize" a windows path, if detected, rather
|
||||||
|
than converting to posix.
|
||||||
|
|
||||||
|
2003-01-06 Troy Curtiss <troyc@usa.net>
|
||||||
|
|
||||||
|
* fhandler_serial.cc (fhandler_serial::tcsetattr): Add support and
|
||||||
|
capability checking for B230400 bitrate.
|
||||||
|
(fhandler_serial::tcgetattr): Add support for B230400 bitrate.
|
||||||
|
* include/sys/termios.h: Add B230400 definition for Posix support of
|
||||||
|
230.4Kbps.
|
||||||
|
|
||||||
2003-01-05 Christopher Faylor <cgf@redhat.com>
|
2003-01-05 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* pinfo.cc (_pinfo::commune_send): Use myself->lock rather than just
|
* pinfo.cc (_pinfo::commune_send): Use myself->lock rather than just
|
||||||
|
@ -598,7 +598,7 @@ fhandler_disk_file::opendir (path_conv& real_name)
|
|||||||
dir->__d_u.__d_data.__fh = this;
|
dir->__d_u.__d_data.__fh = this;
|
||||||
/* FindFirstFile doesn't seem to like duplicate /'s. */
|
/* FindFirstFile doesn't seem to like duplicate /'s. */
|
||||||
len = strlen (dir->__d_dirname);
|
len = strlen (dir->__d_dirname);
|
||||||
if (len == 0 || SLASH_P (dir->__d_dirname[len - 1]))
|
if (len == 0 || isdirsep (dir->__d_dirname[len - 1]))
|
||||||
strcat (dir->__d_dirname, "*");
|
strcat (dir->__d_dirname, "*");
|
||||||
else
|
else
|
||||||
strcat (dir->__d_dirname, "\\*"); /**/
|
strcat (dir->__d_dirname, "\\*"); /**/
|
||||||
|
@ -87,7 +87,7 @@ fhandler_proc::get_proc_fhandler (const char *path)
|
|||||||
* it being normalised and therefore the path may have runs of slashes
|
* it being normalised and therefore the path may have runs of slashes
|
||||||
* in it.
|
* in it.
|
||||||
*/
|
*/
|
||||||
while (SLASH_P (*path))
|
while (isdirsep (*path))
|
||||||
path++;
|
path++;
|
||||||
|
|
||||||
/* Check if this is the root of the virtual filesystem (i.e. /proc). */
|
/* Check if this is the root of the virtual filesystem (i.e. /proc). */
|
||||||
@ -105,7 +105,7 @@ fhandler_proc::get_proc_fhandler (const char *path)
|
|||||||
|
|
||||||
bool has_subdir = false;
|
bool has_subdir = false;
|
||||||
while (*path)
|
while (*path)
|
||||||
if (SLASH_P (*path++))
|
if (isdirsep (*path++))
|
||||||
{
|
{
|
||||||
has_subdir = true;
|
has_subdir = true;
|
||||||
break;
|
break;
|
||||||
|
@ -85,7 +85,7 @@ fhandler_process::exists ()
|
|||||||
const char *path = get_name ();
|
const char *path = get_name ();
|
||||||
debug_printf ("exists (%s)", path);
|
debug_printf ("exists (%s)", path);
|
||||||
path += proc_len + 1;
|
path += proc_len + 1;
|
||||||
while (*path != 0 && !SLASH_P (*path))
|
while (*path != 0 && !isdirsep (*path))
|
||||||
path++;
|
path++;
|
||||||
if (*path == 0)
|
if (*path == 0)
|
||||||
return 2;
|
return 2;
|
||||||
@ -172,7 +172,7 @@ fhandler_process::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
const char *path;
|
const char *path;
|
||||||
path = get_name () + proc_len + 1;
|
path = get_name () + proc_len + 1;
|
||||||
pid = atoi (path);
|
pid = atoi (path);
|
||||||
while (*path != 0 && !SLASH_P (*path))
|
while (*path != 0 && !isdirsep (*path))
|
||||||
path++;
|
path++;
|
||||||
|
|
||||||
if (*path == 0)
|
if (*path == 0)
|
||||||
|
@ -114,9 +114,9 @@ fhandler_registry::exists ()
|
|||||||
}
|
}
|
||||||
pathlen = strlen (path);
|
pathlen = strlen (path);
|
||||||
file = path + pathlen - 1;
|
file = path + pathlen - 1;
|
||||||
if (SLASH_P (*file) && pathlen > 1)
|
if (isdirsep (*file) && pathlen > 1)
|
||||||
file--;
|
file--;
|
||||||
while (!SLASH_P (*file))
|
while (!isdirsep (*file))
|
||||||
file--;
|
file--;
|
||||||
file++;
|
file++;
|
||||||
|
|
||||||
@ -240,9 +240,9 @@ fhandler_registry::fstat (struct __stat64 *buf, path_conv *pc)
|
|||||||
{
|
{
|
||||||
int pathlen = strlen (path);
|
int pathlen = strlen (path);
|
||||||
const char *value_name = path + pathlen - 1;
|
const char *value_name = path + pathlen - 1;
|
||||||
if (SLASH_P (*value_name) && pathlen > 1)
|
if (isdirsep (*value_name) && pathlen > 1)
|
||||||
value_name--;
|
value_name--;
|
||||||
while (!SLASH_P (*value_name))
|
while (!isdirsep (*value_name))
|
||||||
value_name--;
|
value_name--;
|
||||||
value_name++;
|
value_name++;
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
@ -429,9 +429,9 @@ fhandler_registry::open (path_conv * pc, int flags, mode_t mode)
|
|||||||
path++;
|
path++;
|
||||||
pathlen = strlen (path);
|
pathlen = strlen (path);
|
||||||
file = path + pathlen - 1;
|
file = path + pathlen - 1;
|
||||||
if (SLASH_P (*file) && pathlen > 1)
|
if (isdirsep (*file) && pathlen > 1)
|
||||||
file--;
|
file--;
|
||||||
while (!SLASH_P (*file))
|
while (!isdirsep (*file))
|
||||||
file--;
|
file--;
|
||||||
file++;
|
file++;
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ open_key (const char *name, REGSAM access, bool isValue)
|
|||||||
while (*name)
|
while (*name)
|
||||||
{
|
{
|
||||||
const char *anchor = name;
|
const char *anchor = name;
|
||||||
while (*name && !SLASH_P (*name))
|
while (*name && !isdirsep (*name))
|
||||||
name++;
|
name++;
|
||||||
strncpy (component, anchor, name - anchor);
|
strncpy (component, anchor, name - anchor);
|
||||||
component[name - anchor] = '\0';
|
component[name - anchor] = '\0';
|
||||||
|
@ -591,6 +591,9 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
|
|||||||
case B115200:
|
case B115200:
|
||||||
state.BaudRate = CBR_115200;
|
state.BaudRate = CBR_115200;
|
||||||
break;
|
break;
|
||||||
|
case B230400:
|
||||||
|
state.BaudRate = 230400 /* CBR_230400 - not defined */;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* Unsupported baud rate! */
|
/* Unsupported baud rate! */
|
||||||
termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed);
|
termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed);
|
||||||
@ -722,7 +725,6 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
|
|||||||
|
|
||||||
state.fAbortOnError = TRUE;
|
state.fAbortOnError = TRUE;
|
||||||
|
|
||||||
/* -------------- Set state and exit ------------------ */
|
|
||||||
if (memcmp (&ostate, &state, sizeof (state)) != 0)
|
if (memcmp (&ostate, &state, sizeof (state)) != 0)
|
||||||
SetCommState (get_handle (), &state);
|
SetCommState (get_handle (), &state);
|
||||||
|
|
||||||
@ -891,6 +893,9 @@ fhandler_serial::tcgetattr (struct termios *t)
|
|||||||
case CBR_115200:
|
case CBR_115200:
|
||||||
t->c_cflag = t->c_ospeed = t->c_ispeed = B115200;
|
t->c_cflag = t->c_ospeed = t->c_ispeed = B115200;
|
||||||
break;
|
break;
|
||||||
|
case 230400: /* CBR_230400 - not defined */
|
||||||
|
t->c_cflag = t->c_ospeed = t->c_ispeed = B230400;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* Unsupported baud rate! */
|
/* Unsupported baud rate! */
|
||||||
termios_printf ("Invalid baud rate %d", state.BaudRate);
|
termios_printf ("Invalid baud rate %d", state.BaudRate);
|
||||||
|
@ -177,7 +177,8 @@ POSIX commands */
|
|||||||
#define B57600 0x01001
|
#define B57600 0x01001
|
||||||
#define B115200 0x01002
|
#define B115200 0x01002
|
||||||
#define B128000 0x01003
|
#define B128000 0x01003
|
||||||
#define B256000 0x01003
|
#define B230400 0x01004
|
||||||
|
#define B256000 0x01005
|
||||||
#define CRTSXOFF 0x04000
|
#define CRTSXOFF 0x04000
|
||||||
#define CRTSCTS 0x08000
|
#define CRTSCTS 0x08000
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ create_shortcut_header (void)
|
|||||||
|
|
||||||
#define iscygdrive_device(path) \
|
#define iscygdrive_device(path) \
|
||||||
(isalpha (path[mount_table->cygdrive_len]) && \
|
(isalpha (path[mount_table->cygdrive_len]) && \
|
||||||
(isdirsep (path[mount_table->cygdrive_len + 1]) || \
|
(path[mount_table->cygdrive_len + 1] == '/' || \
|
||||||
!path[mount_table->cygdrive_len + 1]))
|
!path[mount_table->cygdrive_len + 1]))
|
||||||
|
|
||||||
#define isproc(path) \
|
#define isproc(path) \
|
||||||
@ -159,16 +159,16 @@ int
|
|||||||
path_prefix_p (const char *path1, const char *path2, int len1)
|
path_prefix_p (const char *path1, const char *path2, int len1)
|
||||||
{
|
{
|
||||||
/* Handle case where PATH1 has trailing '/' and when it doesn't. */
|
/* Handle case where PATH1 has trailing '/' and when it doesn't. */
|
||||||
if (len1 > 0 && SLASH_P (path1[len1 - 1]))
|
if (len1 > 0 && isdirsep (path1[len1 - 1]))
|
||||||
len1--;
|
len1--;
|
||||||
|
|
||||||
if (len1 == 0)
|
if (len1 == 0)
|
||||||
return SLASH_P (path2[0]) && !SLASH_P (path2[1]);
|
return isdirsep (path2[0]) && !isdirsep (path2[1]);
|
||||||
|
|
||||||
if (!pathnmatch (path1, path2, len1))
|
if (!pathnmatch (path1, path2, len1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return SLASH_P (path2[len1]) || path2[len1] == 0 || path1[len1 - 1] == ':';
|
return isdirsep (path2[len1]) || path2[len1] == 0 || path1[len1 - 1] == ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return non-zero if paths match in first len chars.
|
/* Return non-zero if paths match in first len chars.
|
||||||
@ -203,11 +203,10 @@ normalize_posix_path (const char *src, char *dst)
|
|||||||
char *dst_start = dst;
|
char *dst_start = dst;
|
||||||
|
|
||||||
syscall_printf ("src %s", src);
|
syscall_printf ("src %s", src);
|
||||||
|
|
||||||
if (isdrive (src) || strpbrk (src, "\\:"))
|
if (isdrive (src) || strpbrk (src, "\\:"))
|
||||||
{
|
return normalize_win32_path (src, dst);
|
||||||
cygwin_conv_to_full_posix_path (src, dst);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!isslash (src[0]))
|
if (!isslash (src[0]))
|
||||||
{
|
{
|
||||||
if (!cygheap->cwd.get (dst))
|
if (!cygheap->cwd.get (dst))
|
||||||
@ -1190,18 +1189,18 @@ normalize_win32_path (const char *src, char *dst)
|
|||||||
while (*src)
|
while (*src)
|
||||||
{
|
{
|
||||||
/* Strip duplicate /'s. */
|
/* Strip duplicate /'s. */
|
||||||
if (SLASH_P (src[0]) && SLASH_P (src[1]))
|
if (isdirsep (src[0]) && isdirsep (src[1]))
|
||||||
src++;
|
src++;
|
||||||
/* Ignore "./". */
|
/* Ignore "./". */
|
||||||
else if (src[0] == '.' && SLASH_P (src[1])
|
else if (src[0] == '.' && isdirsep (src[1])
|
||||||
&& (src == src_start || SLASH_P (src[-1])))
|
&& (src == src_start || isdirsep (src[-1])))
|
||||||
src += 2;
|
src += 2;
|
||||||
|
|
||||||
/* Backup if "..". */
|
/* Backup if "..". */
|
||||||
else if (src[0] == '.' && src[1] == '.'
|
else if (src[0] == '.' && src[1] == '.'
|
||||||
/* dst must be greater than dst_start */
|
/* dst must be greater than dst_start */
|
||||||
&& dst[-1] == '\\'
|
&& dst[-1] == '\\'
|
||||||
&& (SLASH_P (src[2]) || src[2] == 0))
|
&& (isdirsep (src[2]) || src[2] == 0))
|
||||||
{
|
{
|
||||||
/* Back up over /, but not if it's the first one. */
|
/* Back up over /, but not if it's the first one. */
|
||||||
if (dst > dst_root_start + 1)
|
if (dst > dst_root_start + 1)
|
||||||
@ -1210,7 +1209,7 @@ normalize_win32_path (const char *src, char *dst)
|
|||||||
while (dst > dst_root_start + 1 && dst[-1] != '\\' && dst[-2] != ':')
|
while (dst > dst_root_start + 1 && dst[-1] != '\\' && dst[-2] != ':')
|
||||||
dst--;
|
dst--;
|
||||||
src += 2;
|
src += 2;
|
||||||
if (SLASH_P (*src))
|
if (isdirsep (*src))
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
/* Otherwise, add char to result. */
|
/* Otherwise, add char to result. */
|
||||||
@ -1289,7 +1288,7 @@ nofinalslash (const char *src, char *dst)
|
|||||||
int len = strlen (src);
|
int len = strlen (src);
|
||||||
if (src != dst)
|
if (src != dst)
|
||||||
memcpy (dst, src, len + 1);
|
memcpy (dst, src, len + 1);
|
||||||
while (len > 1 && SLASH_P (dst[--len]))
|
while (len > 1 && isdirsep (dst[--len]))
|
||||||
dst[len] = '\0';
|
dst[len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1599,13 +1598,13 @@ mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_
|
|||||||
The cygdrive prefix always ends with a trailing slash so
|
The cygdrive prefix always ends with a trailing slash so
|
||||||
the drive letter is added after the path. */
|
the drive letter is added after the path. */
|
||||||
dst[len++] = cyg_tolower (src[0]);
|
dst[len++] = cyg_tolower (src[0]);
|
||||||
if (!src[2] || (SLASH_P (src[2]) && !src[3]))
|
if (!src[2] || (isdirsep (src[2]) && !src[3]))
|
||||||
dst[len++] = '\000';
|
dst[len++] = '\000';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
dst[len++] = '/';
|
dst[len++] = '/';
|
||||||
if (SLASH_P (src[2]))
|
if (isdirsep (src[2]))
|
||||||
n = 3;
|
n = 3;
|
||||||
else
|
else
|
||||||
n = 2;
|
n = 2;
|
||||||
@ -1657,7 +1656,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *lastchar = src_path + src_path_len - 1;
|
const char *lastchar = src_path + src_path_len - 1;
|
||||||
trailing_slash_p = SLASH_P (*lastchar) && lastchar[-1] != ':';
|
trailing_slash_p = isdirsep (*lastchar) && lastchar[-1] != ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_printf ("conv_to_posix_path (%s, %s, %s)", src_path,
|
debug_printf ("conv_to_posix_path (%s, %s, %s)", src_path,
|
||||||
@ -1705,7 +1704,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
|||||||
|
|
||||||
if (!*p || !p[1])
|
if (!*p || !p[1])
|
||||||
nextchar = 0;
|
nextchar = 0;
|
||||||
else if (isdirsep (*p))
|
else if (*p == '/')
|
||||||
nextchar = -1;
|
nextchar = -1;
|
||||||
else
|
else
|
||||||
nextchar = 1;
|
nextchar = 1;
|
||||||
@ -1756,7 +1755,8 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
|||||||
{
|
{
|
||||||
/* The use of src_path and not pathbuf here is intentional.
|
/* The use of src_path and not pathbuf here is intentional.
|
||||||
We couldn't translate the path, so just ensure no \'s are present. */
|
We couldn't translate the path, so just ensure no \'s are present. */
|
||||||
slashify (src_path, posix_path, trailing_slash_p);
|
strcpy (posix_path, src_path);
|
||||||
|
// slashify (src_path, posix_path, trailing_slash_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
@ -3573,7 +3573,7 @@ cygwin_split_path (const char *path, char *dir, char *file)
|
|||||||
*file = 0;
|
*file = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SLASH_P (*path))
|
if (isdirsep (*path))
|
||||||
++path;
|
++path;
|
||||||
dir_started_p = 1;
|
dir_started_p = 1;
|
||||||
}
|
}
|
||||||
@ -3582,7 +3582,7 @@ cygwin_split_path (const char *path, char *dir, char *file)
|
|||||||
We pretend as if they don't exist. */
|
We pretend as if they don't exist. */
|
||||||
const char *end = path + strlen (path);
|
const char *end = path + strlen (path);
|
||||||
/* path + 1: keep leading slash. */
|
/* path + 1: keep leading slash. */
|
||||||
while (end > path + 1 && SLASH_P (end[-1]))
|
while (end > path + 1 && isdirsep (end[-1]))
|
||||||
--end;
|
--end;
|
||||||
|
|
||||||
/* At this point, END points to one beyond the last character
|
/* At this point, END points to one beyond the last character
|
||||||
@ -3591,7 +3591,7 @@ cygwin_split_path (const char *path, char *dir, char *file)
|
|||||||
/* Point LAST_SLASH at the last slash (duh...). */
|
/* Point LAST_SLASH at the last slash (duh...). */
|
||||||
const char *last_slash;
|
const char *last_slash;
|
||||||
for (last_slash = end - 1; last_slash >= path; --last_slash)
|
for (last_slash = end - 1; last_slash >= path; --last_slash)
|
||||||
if (SLASH_P (*last_slash))
|
if (isdirsep (*last_slash))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (last_slash == path)
|
if (last_slash == path)
|
||||||
|
@ -105,7 +105,7 @@ extern HANDLE title_mutex;
|
|||||||
/**************************** Convenience ******************************/
|
/**************************** Convenience ******************************/
|
||||||
|
|
||||||
/* Used when treating / and \ as equivalent. */
|
/* Used when treating / and \ as equivalent. */
|
||||||
#define SLASH_P(ch) \
|
#define isdirsep(ch) \
|
||||||
({ \
|
({ \
|
||||||
char __c = (ch); \
|
char __c = (ch); \
|
||||||
((__c) == '/' || (__c) == '\\'); \
|
((__c) == '/' || (__c) == '\\'); \
|
||||||
@ -124,7 +124,6 @@ extern unsigned int signal_shift_subtract;
|
|||||||
#undef issep
|
#undef issep
|
||||||
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
||||||
|
|
||||||
#define isdirsep SLASH_P
|
|
||||||
#define isabspath(p) \
|
#define isabspath(p) \
|
||||||
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user