This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
[PATCH]: Still stripping
- From: "Pierre A. Humblet" <pierre at phumblet dot no-ip dot org>
- To: cygwin-patches at cygwin dot com
- Date: Thu, 23 Dec 2004 11:42:15 -0500
- Subject: [PATCH]: Still stripping
- Reply-to: pierre dot humblet at ieee dot org
In a case such as "abc..exe", the posix_path "abc." should not be
stripped. The patch below only strips the posix path if the win32
path was stripped. I don't think that the posix path can be empty
in that case.
Pierre
2004-12-23 Pierre Humblet <pierre.humblet@ieee.org>
* path.h (path_conv::set_normalized_path): Add second argument.
* path.cc (path_conv::check): Declare, set and use "strip_tail".
(path_conv::set_normalized_path): Add and use second argument,
replacing all tail stripping tests.
Index: path.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.h,v
retrieving revision 1.67
diff -u -p -r1.67 path.h
--- path.h 2 Oct 2004 02:20:20 -0000 1.67
+++ path.h 23 Dec 2004 16:07:45 -0000
@@ -214,7 +214,7 @@ class path_conv
unsigned __stdcall ndisk_links (DWORD);
char *normalized_path;
size_t normalized_path_size;
- void set_normalized_path (const char *) __attribute__ ((regparm (2)));
+ void set_normalized_path (const char *, bool strip=false) __attribute__ ((regparm (2)));
DWORD get_symlink_length () { return symlink_length; };
private:
DWORD symlink_length;
Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.333
diff -u -p -r1.333 path.cc
--- path.cc 22 Dec 2004 11:31:30 -0000 1.333
+++ path.cc 23 Dec 2004 16:24:52 -0000
@@ -424,21 +424,18 @@ path_conv::fillin (HANDLE h)
}
void
-path_conv::set_normalized_path (const char *path_copy)
+path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
{
char *eopath = strchr (path, '\0');
- size_t n;
+ char *p = strchr (path_copy, '\0');
- if (dev.devn != FH_FS || !*path_copy || strncmp (path_copy, "//./", 4) == 0)
- n = strlen (path_copy) + 1;
- else
+ if (strip_tail)
{
- char *p = strchr (path_copy, '\0');
- while (*--p == '.' || *p == ' ')
- continue;
- p[1] = '\0';
- n = 2 + p - path_copy;
+ while (p[-1] == '.' || p[-1] == ' ')
+ p--;
+ *p = '\0';
}
+ size_t n = p + 1 - path_copy;
normalized_path = path + sizeof (path) - n;
if (normalized_path > eopath)
@@ -804,6 +801,7 @@ path_conv::check (const char *src, unsig
add_ext_from_sym (sym);
out:
+ bool strip_tail = false;
/* If the user wants a directory, do not return a symlink */
if (!need_directory || error)
/* nothing to do */;
@@ -836,7 +834,10 @@ out:
if (!tail)
/* nothing */;
else if (tail[-1] != '\\')
- *tail = '\0';
+ {
+ *tail = '\0';
+ strip_tail = true;
+ }
else
{
error = ENOENT;
@@ -901,7 +902,7 @@ out:
{
if (tail < path_end && tail > path_copy + 1)
*tail = '/';
- set_normalized_path (path_copy);
+ set_normalized_path (path_copy, strip_tail);
}
#if 0