From 367557cd79ffb5ff82d9d21c2e8098d95083b3c0 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Sat, 17 Mar 2012 01:34:44 +0800 Subject: [PATCH] cmd/pack: also recognize '\\' as path separator in filenames R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5841051 --- src/cmd/pack/ar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmd/pack/ar.c b/src/cmd/pack/ar.c index 8d881f876aa..7e07fbc895c 100644 --- a/src/cmd/pack/ar.c +++ b/src/cmd/pack/ar.c @@ -1382,11 +1382,14 @@ mesg(int c, char *file) void trim(char *s, char *buf, int n) { - char *p; + char *p, *q; for(;;) { 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); return; } @@ -1394,7 +1397,7 @@ trim(char *s, char *buf, int n) strncpy(buf, p+1, n); return; } - *p = 0; /* strip trailing slash */ + *p = 0; /* strip trailing (back)slash */ } }