1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Centralise stripslashes() and make it OS-sensitive.

I noticed that Unix PSCP was unwantedly renaming downloaded files
which had a backslash in their names, because pscp.c's stripslashes()
treated \ as a path component separator, since it hadn't been modified
since PSCP ran on Windows only.

It also turns out that pscp.c, psftp.c and winsftp.c all had a
stripslashes(), and they didn't all have quite the same prototype. So
now there's one in winsftp.c and one in uxsftp.c, with appropriate
OS-dependent behaviour, and the ones in pscp.c and psftp.c are gone.
This commit is contained in:
Simon Tatham
2015-09-24 17:47:10 +01:00
parent 13edf90e0a
commit 5c5ca116db
5 changed files with 37 additions and 64 deletions

View File

@ -340,14 +340,14 @@ struct WildcardMatcher {
char *srcpath;
};
/*
* Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE).
*/
static char *stripslashes(char *str, int local)
char *stripslashes(const char *str, int local)
{
char *p;
/*
* On Windows, \ / : are all path component separators.
*/
if (local) {
p = strchr(str, ':');
if (p) str = p+1;
@ -361,7 +361,7 @@ static char *stripslashes(char *str, int local)
if (p) str = p+1;
}
return str;
return (char *)str;
}
WildcardMatcher *begin_wildcard_matching(const char *name)