Commit 367557cd authored by Shenghou Ma's avatar Shenghou Ma

cmd/pack: also recognize '\\' as path separator in filenames

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5841051
parent cb4ed897
...@@ -1382,11 +1382,14 @@ mesg(int c, char *file) ...@@ -1382,11 +1382,14 @@ mesg(int c, char *file)
void void
trim(char *s, char *buf, int n) trim(char *s, char *buf, int n)
{ {
char *p; char *p, *q;
for(;;) { for(;;) {
p = strrchr(s, '/'); p = strrchr(s, '/');
if (!p) { /* no slash in name */ q = strrchr(s, '\\');
if (q > p)
p = q;
if (!p) { /* no (back)slash in name */
strncpy(buf, s, n); strncpy(buf, s, n);
return; return;
} }
...@@ -1394,7 +1397,7 @@ trim(char *s, char *buf, int n) ...@@ -1394,7 +1397,7 @@ trim(char *s, char *buf, int n)
strncpy(buf, p+1, n); strncpy(buf, p+1, n);
return; return;
} }
*p = 0; /* strip trailing slash */ *p = 0; /* strip trailing (back)slash */
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment