]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pack: also recognize '\\' as path separator in filenames
authorShenghou Ma <minux.ma@gmail.com>
Fri, 16 Mar 2012 17:34:44 +0000 (01:34 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Fri, 16 Mar 2012 17:34:44 +0000 (01:34 +0800)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5841051

src/cmd/pack/ar.c

index 8d881f876aa7e1d8b062dda670077cdd182dffe4..7e07fbc895c6b435f1525966d71436d3c7ae1eea 100644 (file)
@@ -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 */
        }
 }