1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

5a, 6a, 8a: take GOROOT_FINAL into consideration

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5940052
This commit is contained in:
Shenghou Ma 2012-04-04 00:03:42 +08:00
parent 96da953d86
commit 6af069f3e1
3 changed files with 96 additions and 1 deletions

View File

@ -641,11 +641,37 @@ outhist(void)
Hist *h;
char *p, *q, *op, c;
int n;
char *tofree;
static int first = 1;
static char *goroot, *goroot_final;
if(first) {
// Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL.
first = 0;
goroot = getenv("GOROOT");
goroot_final = getenv("GOROOT_FINAL");
if(goroot == nil)
goroot = "";
if(goroot_final == nil)
goroot_final = goroot;
if(strcmp(goroot, goroot_final) == 0) {
goroot = nil;
goroot_final = nil;
}
}
tofree = nil;
g = nullgen;
c = '/';
for(h = hist; h != H; h = h->link) {
p = h->name;
if(p != nil && goroot != nil) {
n = strlen(goroot);
if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') {
tofree = smprint("%s%s", goroot_final, p+n);
p = tofree;
}
}
op = 0;
if(systemtype(Windows) && p && p[1] == ':'){
c = p[2];
@ -697,6 +723,11 @@ outhist(void)
Bputc(&obuf, h->line>>24);
zaddr(&nullgen, 0);
zaddr(&g, 0);
if(tofree) {
free(tofree);
tofree = nil;
}
}
}

View File

@ -1250,11 +1250,38 @@ outhist(void)
Hist *h;
char *p, *q, *op, c;
int n;
char *tofree;
static int first = 1;
static char *goroot, *goroot_final;
if(first) {
// Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL.
first = 0;
goroot = getenv("GOROOT");
goroot_final = getenv("GOROOT_FINAL");
if(goroot == nil)
goroot = "";
if(goroot_final == nil)
goroot_final = goroot;
if(strcmp(goroot, goroot_final) == 0) {
goroot = nil;
goroot_final = nil;
}
}
tofree = nil;
g = nullgen;
c = pathchar();
for(h = hist; h != H; h = h->link) {
p = h->name;
if(p != nil && goroot != nil) {
n = strlen(goroot);
if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') {
tofree = smprint("%s%s", goroot_final, p+n);
p = tofree;
}
}
op = 0;
if(systemtype(Windows) && p && p[1] == ':'){
c = p[2];
@ -1306,6 +1333,11 @@ outhist(void)
Bputc(&obuf, h->line>>24);
zaddr(&nullgen, 0);
zaddr(&g, 0);
if(tofree) {
free(tofree);
tofree = nil;
}
}
}

View File

@ -915,11 +915,38 @@ outhist(void)
Hist *h;
char *p, *q, *op, c;
int n;
char *tofree;
static int first = 1;
static char *goroot, *goroot_final;
if(first) {
// Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL.
first = 0;
goroot = getenv("GOROOT");
goroot_final = getenv("GOROOT_FINAL");
if(goroot == nil)
goroot = "";
if(goroot_final == nil)
goroot_final = goroot;
if(strcmp(goroot, goroot_final) == 0) {
goroot = nil;
goroot_final = nil;
}
}
tofree = nil;
g = nullgen;
c = pathchar();
for(h = hist; h != H; h = h->link) {
p = h->name;
if(p != nil && goroot != nil) {
n = strlen(goroot);
if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') {
tofree = smprint("%s%s", goroot_final, p+n);
p = tofree;
}
}
op = 0;
if(systemtype(Windows) && p && p[1] == ':'){
c = p[2];
@ -971,6 +998,11 @@ outhist(void)
Bputc(&obuf, h->line>>24);
zaddr(&nullgen, 0);
zaddr(&g, 0);
if(tofree) {
free(tofree);
tofree = nil;
}
}
}