From b5eb3d0f15ffbac20e9f755ddc542669bbac4201 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 29 Mar 2001 00:30:39 +0000 Subject: [PATCH] * path.cc (chdir): Eat trailing whitespace on input path. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/path.cc | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7f053fb29..451bc76ae 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +Wed Mar 28 19:28:50 2001 Christopher Faylor + + * path.cc (chdir): Eat trailing whitespace on input path. + Tue Mar 27 22:38:42 2001 Christopher Faylor * lib/_cygwin_S_IEXEC.c: Remove "const" from globals or they never seem diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index b95182d66..ff89eb4ff 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2742,6 +2742,14 @@ chdir (const char *dir) syscall_printf ("dir %s", dir); path_conv path (dir, PC_FULL | PC_SYM_FOLLOW); + char *s; + /* Incredibly. Windows allows you to specify a path with trailing + whitespace to SetCurrentDirectory. This doesn't work too well + with other parts of the API, though, apparently. So nuke trailing + white space. */ + for (s = strchr (dir, '\0'); --s >= dir && isspace (*s); ) + *s = '\0'; + if (path.error) { set_errno (path.error);