- for(i = 0; i < LABELTABSIZE; i++){
- for(np = labels[i]; np != NULL; np = np->next){
- fprintf(stdout, "%s ---> #%04X\n", np->name, np->adr);
+ LABELARRAY *ar[labelcnt];
+
+ for(i = 0; i < LABELTABSIZE; i++) {
+ for(np = labels[i]; np != NULL; np = np->next) {
+ assert(np->label != NULL);
+ ar[asize] = malloc_chk(sizeof(LABELARRAY), "ar[]");
+ if(np->prog == NULL) {
+ ar[asize]->prog = NULL;
+ } else {
+ ar[asize]->prog = strdup_chk(np->prog, "ar[].prog");
+ }
+ ar[asize]->label = strdup_chk(np->label, "ar[].label");
+ ar[asize++]->adr = np->adr;
+ }
+ }
+ qsort(ar, asize, sizeof(*ar), compare_adr);
+ for(i = 0; i < asize; i++) {
+ if(ar[i]->prog != NULL) {
+ fprintf(stdout, "%s.", ar[i]->prog);