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); } }
void outhist(Biobuf *b) { Hist *h; 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) { q = utfrune(p, '/'); if(q) { n = q-p; if(n == 0) n = 1; // leading "/" q++; } else { n = strlen(p); q = 0; } if(n) zfile(b, p, n); p = q; if(p == 0 && op) { p = op; op = 0; } } zhist(b, h->line, h->offset); } }
static void outhist(Biobuf *b) { Hist *h; char *p, ds[] = {'c', ':', '/', 0}; char *tofree; int n; 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; for(h = hist; h != H; h = h->link) { p = h->name; if(p) { if(goroot != nil) { n = strlen(goroot); if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') { tofree = smprint("%s%s", goroot_final, p+n); p = tofree; } } 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); if(tofree) { free(tofree); tofree = nil; } } }