diff options
author | Christopher Faylor <me@cgf.cx> | 2000-05-30 00:38:51 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-05-30 00:38:51 +0000 |
commit | 75858e8a036c3746af4c93121823bfb2294a976b (patch) | |
tree | 0f517221f3b8d89f6563409e088ac5484c70a38e /winsup/cygwin/path.cc | |
parent | fc1df4b6c6d1b04a865474564ed28ff099f07c90 (diff) | |
download | newlib-75858e8a036c3746af4c93121823bfb2294a976b.zip newlib-75858e8a036c3746af4c93121823bfb2294a976b.tar.gz newlib-75858e8a036c3746af4c93121823bfb2294a976b.tar.bz2 |
* Makefile.in: Remove libadvapi32.a.
* autoload.h: Add additional field to autoload block for handling unimplemented
functions.
(LoadDLLfuncEx): New function which accepts additional parameter for
controlling unimplemented function behavior.
(LoadDLLfunc): Use LoadDLLfuncEx.
* dcrt0.cc: Use new arguments for LoadDLLfunc. Add advapi32 routines.
(noload): Rewrite in assembler. Handle new unimplemented function type.
* exceptions.cc: Eliminate another vestige of StackWalk stuff.
* net.cc: Use new arguments for LoadDLLfunc.
* uinfo.cc: Ditto.
* config.h.in: Remove obsolete define.
* path.h (isdrive): New macro.
* dcrt0.cc (globify): Use new macro to determine if a string refers to an
MS-DOS drive.
* environ.cc (winenv): Ditto.
* spawn.cc (find_exec): Ditto.
* path.cc (get_raw_device_number): Ditto.
(mount_info::conv_to_posix_path): Ditto.
(chdir): Ditto.
(cygwin_posix_path_list_p): Ditto.
(cygwin_split_path): Ditto.
(path_conv::check): Move tmp_buf to beginning of function since it can be used
earlier in the loop. Use tmp_buf rather than 'root' to hold root information.
(mount_info::conv_to_win32_path): Add trailing slash to end of mount path when
it translates to a drive. Add defensive code to avoid writing beyond the end
of 'dst'.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index dd52d18..4cb2636 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -189,6 +189,7 @@ path_conv::check (const char *src, symlink_follow follow_mode, trailer. */ char path_buf[MAX_PATH]; char path_copy[MAX_PATH]; + char tmp_buf[MAX_PATH]; symlink_info sym; char *rel_path, *full_path; @@ -353,7 +354,6 @@ path_conv::check (const char *src, symlink_follow follow_mode, system_printf ("problem parsing %s - '%s'", src, full_path); else { - char tmp_buf[MAX_PATH]; int headlen = 1 + tail - path_copy; p = sym.contents - headlen; memcpy (p, path_copy, headlen); @@ -378,19 +378,18 @@ fillin: out: DWORD serial, volflags; - char root[strlen(full_path) + 10]; - strcpy (root, full_path); - if (!rootdir (root) || - !GetVolumeInformation (root, NULL, 0, &serial, NULL, &volflags, NULL, 0)) + strcpy (tmp_buf, full_path); + if (!rootdir (tmp_buf) || + !GetVolumeInformation (tmp_buf, NULL, 0, &serial, NULL, &volflags, NULL, 0)) { debug_printf ("GetVolumeInformation(%s) = ERR, full_path(%s), set_has_acls(FALSE)", - root, full_path, GetLastError ()); + tmp_buf, full_path, GetLastError ()); set_has_acls (FALSE); } else { debug_printf ("GetVolumeInformation(%s) = OK, full_path(%s), set_has_acls(%d)", - root, full_path, volflags & FS_PERSISTENT_ACLS); + tmp_buf, full_path, volflags & FS_PERSISTENT_ACLS); set_has_acls (volflags & FS_PERSISTENT_ACLS); } } @@ -446,7 +445,7 @@ get_raw_device_number (const char *uxname, const char *w32path, int &unit) if (! strncasecmp (uxname, "/dev/n", 6)) unit += 128; } - else if (isalpha (w32path[4]) && w32path[5] == ':') + else if (isdrive (w32path + 4)) { devn = FH_FLOPPY; unit = tolower (w32path[4]) - 'a'; @@ -1023,6 +1022,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path, int n = mi->native_pathlen; memcpy (dst, mi->native_path, n); char *p = pathbuf + mi->posix_pathlen; + if (!trailing_slash_p && isdrive (mi->native_path) && !mi->native_path[2]) + trailing_slash_p = 1; if (!trailing_slash_p && !*p) dst[n] = '\0'; else @@ -1048,17 +1049,23 @@ fillin: path_prefix_p (current_directory_name, dst, cwdlen = strlen (current_directory_name))) { - if (strlen (dst) == cwdlen) - dst += cwdlen; + size_t n = strlen (dst); + if (n < cwdlen) + strcpy (win32_path, dst); else - dst += isdirsep (current_directory_name[cwdlen - 1]) ? cwdlen : cwdlen + 1; - - memmove (win32_path, dst, strlen (dst) + 1); - if (!*win32_path) { - strcpy (win32_path, "."); - if (trailing_slash_p) - strcat (win32_path, "\\"); + if (n == cwdlen) + dst += cwdlen; + else + dst += isdirsep (current_directory_name[cwdlen - 1]) ? cwdlen : cwdlen + 1; + + memmove (win32_path, dst, strlen (dst) + 1); + if (!*win32_path) + { + strcpy (win32_path, "."); + if (trailing_slash_p) + strcat (win32_path, "\\"); + } } } else if (win32_path != dst) @@ -1220,7 +1227,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path, letter not covered by the mount table. If it's a relative path then the caller must want an absolute path (otherwise we would have returned above). So we always return an absolute path at this point. */ - if ((isalpha (pathbuf[0])) && (pathbuf[1] == ':')) + if (isdrive (pathbuf)) cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p); else { @@ -2500,13 +2507,13 @@ chdir (const char *dir) If it does, append a \ to the native directory specification to defeat the Windows 95 (i.e. MS-DOS) tendency of returning to the last directory visited on the given drive. */ - if (isalpha (native_dir[0]) && native_dir[1] == ':' && !native_dir[2]) + if (isdrive (native_dir) && !native_dir[2]) { native_dir[2] = '\\'; native_dir[3] = '\0'; } - int res = SetCurrentDirectoryA (native_dir); - if (!res) + int res = SetCurrentDirectoryA (native_dir) ? 0 : -1; + if (res == -1) __seterrno (); /* Clear the cache until we need to retrieve the directory again. */ @@ -2521,8 +2528,8 @@ chdir (const char *dir) current_directory_posix_name = NULL; } - syscall_printf ("%d = chdir (%s) (dos %s)", res ? 0 : -1, dir, native_dir); - return res ? 0 : -1; + syscall_printf ("%d = chdir (%s) (dos %s)", res, dir, native_dir); + return res; } /******************** Exported Path Routines *********************/ @@ -2629,8 +2636,7 @@ extern "C" int cygwin_posix_path_list_p (const char *path) { - int posix_p = ! (strchr (path, ';') - || (isalpha (path[0]) && path[1] == ':')); + int posix_p = ! (strchr (path, ';') || isdrive (path)); return posix_p; } @@ -2725,7 +2731,7 @@ cygwin_split_path (const char *path, char *dir, char *file) /* Deal with drives. Remember that c:foo <==> c:/foo. */ - if (isalpha (path[0]) && path[1] == ':') + if (isdrive (path)) { *dir++ = *path++; *dir++ = *path++; |