X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fir.c;h=4ef2e5a9fa328be6fd935f8624dfc922a36239a3;hp=e61d388f466c782efeae8be5dbbd7b2745d612f8;hb=32084db924eb07c8a5e44748aaf12883189b37d2;hpb=03bec8cb89af10a1bac8f7bd90484f6cb32fbad5 diff --git a/src/ir.c b/src/ir.c index e61d388..4ef2e5a 100644 --- a/src/ir.c +++ b/src/ir.c @@ -631,15 +631,18 @@ uint32_t ir_linkdata_ref return linkdata->link.setld->ref; } -/* Resolve and return the link's target set */ +/* Resolve and return the link's target set + Fails on error, cannot return NULL +*/ struct ir_set_t* ir_linkdata_set ( union ir_setdata_t* linkdata ) { struct ir_class_t* class_iter; - struct ir_namelist_t* namelist_iter; + struct ir_namelist_t* namelist_iter,* namelist_iter_last; struct ir_setld_t* setld; struct ir_classld_t* classld; struct ir_set_t* set; set = NULL; + class_iter = NULL; if (linkdata->header.type != LDAT) eprintf("Data %s is not a link\n", linkdata->header.data_name); setld = linkdata->link.setld; @@ -651,34 +654,56 @@ struct ir_set_t* ir_linkdata_set if (classld->root_class == NULL) eprintf("No root class for classld\n"); class_iter = classld->root_class->nextchild; + namelist_iter_last = NULL; while (class_iter != NULL) { if (classnames_identical(class_iter->name, namelist_iter->name)) { if (namelist_iter == classld->namelist_head) break; class_iter = class_iter->nextchild; + namelist_iter_last = namelist_iter; namelist_iter = namelist_iter->nextsib; } else class_iter = class_iter->nextsib; } if (class_iter == NULL) - eprintf("Class resolution failed\n"); + { if (namelist_iter_last) + eprintf("No such subclass \"%s\" of class \"%s\"\n", + namelist_iter->name, + namelist_iter_last->name); + else + eprintf("No such class \"%s\"\n", namelist_iter->name); + } set = class_iter->root_set; } - else if (setld->ref) + else set = ir_set_from_ref(setld->ref); if (set == NULL) eprintf("Initial set resolution failed\n"); namelist_iter = setld->namelist; - while (set != NULL) - { if (bytes_identical(set->name, namelist_iter->name)) - { if (namelist_iter == setld->namelist_head) - break; - set = set->nextchild; - namelist_iter = namelist_iter->nextsib; - } - else - set = set->nextsib; + namelist_iter_last = NULL; + if (setld->namelist != NULL) + { while (set != NULL) + { if (bytes_identical(set->name, namelist_iter->name)) + { if (namelist_iter == setld->namelist_head) + break; + set = set->nextchild; + namelist_iter_last = namelist_iter; + namelist_iter = namelist_iter->nextsib; + } + else + set = set->nextsib; + } + if (set == NULL) + { if (namelist_iter_last) + eprintf("No such subset \"%s\" of set \"%s\"\n", + namelist_iter->name, + namelist_iter_last->name); + else + eprintf("No such set \"%s\" in class \"%s\"\n", + namelist_iter->name, + class_iter->name); + } } return set; }