1
0
mirror of https://github.com/golang/go synced 2024-11-24 22:37:56 -07:00

gc: better windows detection

R=ken2
CC=golang-dev
https://golang.org/cl/944043
This commit is contained in:
Russ Cox 2010-04-27 17:19:15 -07:00
parent 8553b9c68f
commit 69a2e1dc52
2 changed files with 8 additions and 20 deletions

View File

@ -1241,10 +1241,3 @@ int duintptr(Sym *s, int off, uint64 v);
int duintxx(Sym *s, int off, uint64 v, int wid); int duintxx(Sym *s, int off, uint64 v, int wid);
void genembedtramp(Type*, Type*, Sym*); void genembedtramp(Type*, Type*, Sym*);
int gen_as_init(Node*); int gen_as_init(Node*);
enum {
SysUnix = 1<<1,
SysWindows = 1<<2,
};
int systemtype(int);

View File

@ -8,6 +8,8 @@
#include <ar.h> #include <ar.h>
extern int yychar; extern int yychar;
int windows;
void lexfini(void); void lexfini(void);
void yytinit(void); void yytinit(void);
@ -81,7 +83,10 @@ main(int argc, char *argv[])
if(getwd(pathname, 999) == 0) if(getwd(pathname, 999) == 0)
strcpy(pathname, "/???"); strcpy(pathname, "/???");
if(systemtype(SysWindows)) { if(isalpha(pathname[0]) && pathname[1] == ':') {
// On Windows.
windows = 1;
// Canonicalize path by converting \ to / (Windows accepts both). // Canonicalize path by converting \ to / (Windows accepts both).
for(p=pathname; *p; p++) for(p=pathname; *p; p++)
if(*p == '\\') if(*p == '\\')
@ -247,9 +252,9 @@ addidir(char* dir)
int int
islocalname(Strlit *name) islocalname(Strlit *name)
{ {
if(systemtype(SysUnix) && name->len >= 1 && name->s[0] == '/') if(!windows && name->len >= 1 && name->s[0] == '/')
return 1; return 1;
if(systemtype(SysWindows) && name->len >= 3 && if(windows && name->len >= 3 &&
isalpha(name->s[0]) && name->s[1] == ':' && name->s[2] == '/') isalpha(name->s[0]) && name->s[1] == ':' && name->s[2] == '/')
return 1; return 1;
if(name->len >= 2 && strncmp(name->s, "./", 2) == 0) if(name->len >= 2 && strncmp(name->s, "./", 2) == 0)
@ -1673,13 +1678,3 @@ mkpackage(char* pkgname)
outfile = smprint("%s.%c", namebuf, thechar); outfile = smprint("%s.%c", namebuf, thechar);
} }
} }
int
systemtype(int sys)
{
#ifdef __MINGW32__
return sys&SysWindows;
#else
return sys&SysUnix;
#endif
}