]> Cypherpunks repositories - gostls13.git/commitdiff
5a, 5c, 6a, 6c, 8a, 8c: fix Windows file paths
authorHector Chu <hectorchu@gmail.com>
Wed, 7 Sep 2011 19:49:56 +0000 (15:49 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 7 Sep 2011 19:49:56 +0000 (15:49 -0400)
Verified with objdump -W.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4974061

include/libc.h
src/cmd/5a/lex.c
src/cmd/5c/swt.c
src/cmd/6a/lex.c
src/cmd/6c/swt.c
src/cmd/8a/lex.c
src/cmd/8c/swt.c

index 0817d77b81393017ebbb75024e51a8777a592b7b..f9ad963345a577b98cfe6fb789e0ec1af1bdaebc 100644 (file)
@@ -307,6 +307,8 @@ extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
 extern int fork(void);
 extern int pread(int fd, void *buf, int n, int off);
 extern int pwrite(int fd, void *buf, int n, int off);
+#undef  getwd
+#define getwd(s, ns) getcwd(s, ns)
 #undef  lseek
 #define lseek(fd, n, base) _lseeki64(fd, n, base)
 #define mkdir(path, perm) mkdir(path)
index ad7ed05ddd90f2a1ddf47c82552a1d2b00cc21ee..4bef0219a2c5726caeb1f640eedba257a5e4142b 100644 (file)
@@ -44,7 +44,11 @@ enum
 int
 systemtype(int sys)
 {
+#ifdef _WIN32
+       return sys&Windows;
+#else
        return sys&Plan9;
+#endif
 }
 
 void
@@ -643,17 +647,13 @@ outhist(void)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;
index 7cbaadba962602d30e9ae63f6dd92ea0751f2efa..32032532f20f6e30902cba75ac3568a78906a41a 100644 (file)
@@ -460,17 +460,13 @@ outhist(Biobuf *b)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;
index 1cc89a37a03b5b9244ae460d69c11645c7c73967..1a8e5ad619d76cffdc4038a2d3e57f51525ceb1a 100644 (file)
@@ -44,7 +44,11 @@ enum
 int
 systemtype(int sys)
 {
+#ifdef _WIN32
+       return sys&Windows;
+#else
        return sys&Plan9;
+#endif
 }
 
 int
@@ -1251,17 +1255,13 @@ outhist(void)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;
index d7a917043eb0f6767a1112a92be149a648375a02..3de86306d3b57acd1deacbade55f8052cef55c46 100644 (file)
@@ -331,17 +331,13 @@ outhist(Biobuf *b)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;
index 44cfa41f87e83885be274d6f126c1e80fcb7868b..ca2e2c138d0fd6303c78b225d903d9d524ac76d9 100644 (file)
@@ -44,7 +44,11 @@ enum
 int
 systemtype(int sys)
 {
+#ifdef _WIN32
+       return sys&Windows;
+#else
        return sys&Plan9;
+#endif
 }
 
 int
@@ -912,17 +916,13 @@ outhist(void)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;
index 769ef2c66ef8f94cfb15825ee21ba9db003fcef8..006bfdfe23fafab11745dce5392a4b0fb8b3e5dd 100644 (file)
@@ -330,17 +330,13 @@ outhist(Biobuf *b)
        for(h = hist; h != H; h = h->link) {
                p = h->name;
                op = 0;
-               /* on windows skip drive specifier in pathname */
                if(systemtype(Windows) && p && p[1] == ':'){
-                       p += 2;
-                       c = *p;
-               }
-               if(p && p[0] != c && h->offset == 0 && pathname){
-                       /* on windows skip drive specifier in pathname */
+                       c = p[2];
+               } else if(p && p[0] != c && h->offset == 0 && pathname){
                        if(systemtype(Windows) && pathname[1] == ':') {
                                op = p;
-                               p = pathname+2;
-                               c = *p;
+                               p = pathname;
+                               c = p[2];
                        } else if(pathname[0] == c){
                                op = p;
                                p = pathname;