mirror of
https://github.com/golang/go
synced 2024-11-25 08:27:57 -07:00
gc: fix symbol table generation on windows
gc records full, '/' delimited, filenames now. R=rsc CC=golang-dev https://golang.org/cl/1962042
This commit is contained in:
parent
acb695f421
commit
77a70ddb7b
@ -918,6 +918,7 @@ char* lexname(int lex);
|
|||||||
void mkpackage(char* pkgname);
|
void mkpackage(char* pkgname);
|
||||||
void unimportfile(void);
|
void unimportfile(void);
|
||||||
int32 yylex(void);
|
int32 yylex(void);
|
||||||
|
extern int windows;
|
||||||
extern int yylast;
|
extern int yylast;
|
||||||
extern int yyprev;
|
extern int yyprev;
|
||||||
|
|
||||||
|
109
src/cmd/gc/obj.c
109
src/cmd/gc/obj.c
@ -74,41 +74,96 @@ Bputname(Biobuf *b, Sym *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
outhist(Biobuf *b)
|
outzfile(Biobuf *b, char *p)
|
||||||
{
|
{
|
||||||
Hist *h;
|
char *q, *q2;
|
||||||
char *p, *q, *op;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
for(h = hist; h != H; h = h->link) {
|
|
||||||
p = h->name;
|
|
||||||
op = 0;
|
|
||||||
|
|
||||||
if(p && p[0] != '/' && h->offset == 0 && pathname && pathname[0] == '/') {
|
|
||||||
op = p;
|
|
||||||
p = pathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(p) {
|
while(p) {
|
||||||
q = utfrune(p, '/');
|
q = utfrune(p, '/');
|
||||||
if(q) {
|
if(windows) {
|
||||||
n = q-p;
|
q2 = utfrune(p, '\\');
|
||||||
if(n == 0)
|
if(q2 && (!q || q2 < q))
|
||||||
n = 1; // leading "/"
|
q = q2;
|
||||||
q++;
|
|
||||||
} else {
|
|
||||||
n = strlen(p);
|
|
||||||
q = 0;
|
|
||||||
}
|
}
|
||||||
if(n)
|
if(!q) {
|
||||||
zfile(b, p, n);
|
zfile(b, p, strlen(p));
|
||||||
p = q;
|
return;
|
||||||
if(p == 0 && op) {
|
|
||||||
p = op;
|
|
||||||
op = 0;
|
|
||||||
}
|
}
|
||||||
|
if(q > p)
|
||||||
|
zfile(b, p, q-p);
|
||||||
|
p = q + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define isdelim(c) (c == '/' || c == '\\')
|
||||||
|
|
||||||
|
static void
|
||||||
|
outwinname(Biobuf *b, Hist *h, char *ds, char *p)
|
||||||
|
{
|
||||||
|
if(isdelim(p[0])) {
|
||||||
|
// full rooted name
|
||||||
|
zfile(b, ds, 3); // leading "c:/"
|
||||||
|
outzfile(b, p+1);
|
||||||
|
} else {
|
||||||
|
// relative name
|
||||||
|
if(h->offset == 0 && pathname && pathname[1] == ':') {
|
||||||
|
if(tolowerrune(ds[0]) == tolowerrune(pathname[0])) {
|
||||||
|
// using current drive
|
||||||
|
zfile(b, pathname, 3); // leading "c:/"
|
||||||
|
outzfile(b, pathname+3);
|
||||||
|
} else {
|
||||||
|
// using drive other then current,
|
||||||
|
// we don't have any simple way to
|
||||||
|
// determine current working directory
|
||||||
|
// there, therefore will output name as is
|
||||||
|
zfile(b, ds, 2); // leading "c:"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outzfile(b, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
outhist(Biobuf *b)
|
||||||
|
{
|
||||||
|
Hist *h;
|
||||||
|
char *p, ds[] = {'c', ':', '/', 0};
|
||||||
|
|
||||||
|
for(h = hist; h != H; h = h->link) {
|
||||||
|
p = h->name;
|
||||||
|
if(p) {
|
||||||
|
if(windows) {
|
||||||
|
// if windows variable is set, then, we know already,
|
||||||
|
// pathname is started with windows drive specifier
|
||||||
|
// and all '\' were replaced with '/' (see lex.c)
|
||||||
|
if(isdelim(p[0]) && isdelim(p[1])) {
|
||||||
|
// file name has network name in it,
|
||||||
|
// like \\server\share\dir\file.go
|
||||||
|
zfile(b, "//", 2); // leading "//"
|
||||||
|
outzfile(b, p+2);
|
||||||
|
} else if(p[1] == ':') {
|
||||||
|
// file name has drive letter in it
|
||||||
|
ds[0] = p[0];
|
||||||
|
outwinname(b, h, ds, p+2);
|
||||||
|
} else {
|
||||||
|
// no drive letter in file name
|
||||||
|
outwinname(b, h, pathname, p);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(p[0] == '/') {
|
||||||
|
// full rooted name, like /home/rsc/dir/file.go
|
||||||
|
zfile(b, "/", 1); // leading "/"
|
||||||
|
outzfile(b, p+1);
|
||||||
|
} else {
|
||||||
|
// relative name, like dir/file.go
|
||||||
|
if(h->offset == 0 && pathname && pathname[0] == '/') {
|
||||||
|
zfile(b, "/", 1); // leading "/"
|
||||||
|
outzfile(b, pathname+1);
|
||||||
|
}
|
||||||
|
outzfile(b, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
zhist(b, h->line, h->offset);
|
zhist(b, h->line, h->offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,6 @@ endif
|
|||||||
# Disable tests that windows cannot run yet.
|
# Disable tests that windows cannot run yet.
|
||||||
ifeq ($(GOOS),windows)
|
ifeq ($(GOOS),windows)
|
||||||
NOTEST+=exec # no pipe
|
NOTEST+=exec # no pipe
|
||||||
NOTEST+=log # no runtime.Caller
|
|
||||||
NOTEST+=os # many things unimplemented
|
NOTEST+=os # many things unimplemented
|
||||||
NOTEST+=os/signal # no signals
|
NOTEST+=os/signal # no signals
|
||||||
NOTEST+=path # tree walking does not work
|
NOTEST+=path # tree walking does not work
|
||||||
|
Loading…
Reference in New Issue
Block a user