From: Rob Pike Date: Thu, 16 Apr 2009 04:57:55 +0000 (-0700) Subject: fix gotest by fixing nm -s to print in file order by storing a sequence number X-Git-Tag: weekly.2009-11-06~1818 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=57bff962d97b712fbbd2c81af46b770684114fbd;p=gostls13.git fix gotest by fixing nm -s to print in file order by storing a sequence number as the .6 file is read. now tests will be run in file order. R=rsc DELTA=9 (6 added, 1 deleted, 2 changed) OCL=27542 CL=27544 --- diff --git a/include/mach_amd64.h b/include/mach_amd64.h index 3ad0efcbb8..30cd4dcd0e 100644 --- a/include/mach_amd64.h +++ b/include/mach_amd64.h @@ -85,6 +85,7 @@ struct Sym char type; char *name; char *gotype; + int sequence; // order in file }; /* * End of Plan 9 a.out.h diff --git a/src/cmd/nm/nm.c b/src/cmd/nm/nm.c index 63c77bd921..66748eef7c 100644 --- a/src/cmd/nm/nm.c +++ b/src/cmd/nm/nm.c @@ -185,11 +185,13 @@ cmp(void *vs, void *vt) s = vs; t = vt; - if(nflag) + if(nflag) // sort on address (numeric) order if((*s)->value < (*t)->value) return -1; else return (*s)->value > (*t)->value; + if(sflag) // sort on file order (sequence) + return (*s)->sequence - (*t)->sequence; return strcmp((*s)->name, (*t)->name); } /* @@ -298,8 +300,7 @@ printsyms(Sym **symptr, long nsym) char *cp; char path[512]; - if(!sflag) - qsort(symptr, nsym, sizeof(*symptr), (void*)cmp); + qsort(symptr, nsym, sizeof(*symptr), (void*)cmp); wid = 0; for (i=0; is.type = type; sp->s.sig = sig; sp->s.value = islocal(type) ? MAXOFF : 0; + sp->s.sequence = sequence++; names[id] = &sp->s; sp->next = hash[h]; hash[h] = sp;