From: ken Date: Fri, 17 Feb 2017 06:07:33 +0000 (-0800) Subject: linkdata_set comments and debug statements X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=commitdiff_plain;h=32084db924eb07c8a5e44748aaf12883189b37d2 linkdata_set comments and debug statements --- diff --git a/src/ir.c b/src/ir.c index 527f472..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,18 +654,26 @@ 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 @@ -670,15 +681,29 @@ struct ir_set_t* ir_linkdata_set 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; }