X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fir.c;h=63556545b04c6494fb53ae974372fd8b1aa7ecd1;hp=ab9730515916ad012a2162cedf8dfdf36f6d056c;hb=2d355679ac2a1e225f158ab8064566174e9e1402;hpb=44b15998f0b17d98b4714e77a89fc90b2a2dc29e diff --git a/src/ir.c b/src/ir.c index ab97305..6355654 100644 --- a/src/ir.c +++ b/src/ir.c @@ -101,7 +101,7 @@ struct ir_class_t uint8_t* name; }; struct ir_set_t -{ struct ir_set_t* nextchild, * nextsib, * p; +{ struct ir_set_t* nextchild, * nextsib; uint32_t ref; uint8_t* name; struct ir_framebox_t* frameboxes; @@ -666,51 +666,47 @@ static void crawl_set(struct ir_set_t*,int); void ir_test(void) { uprintf("IR From Directory: %s\n",getcwd(NULL,255)); crawl_class(&root_class); + if (root_class.root_set != NULL) + crawl_set(root_class.root_set, 0); } -#define pspace(num) for (i = 0; i < (num); i++) putchar('.') static void crawl_class ( struct ir_class_t* class ) -{ wprintf("%U/\n", class->name); - if(chdir((char*)class->name)) - eprintf("CHDIR %U from %s\n",class->name,getcwd(NULL,255)); - if (class->nextchild != NULL) - crawl_class(class->nextchild); - if (class->root_set != NULL) - crawl_set(class->root_set, 0); - if (class->nextsib != NULL) - { if (chdir("..")) +{ struct ir_class_t* iter; + for (iter = class->nextchild; iter != NULL; iter = iter->nextsib) + { wprintf("%U/\n", iter->name); + if(chdir((char*)iter->name)) + eprintf("CHDIR %U from %s\n",iter->name,getcwd(NULL,255)); + crawl_class(iter); + if (iter->root_set != NULL) + crawl_set(iter->root_set, 0); + uprintf("%U\\\n",iter->name); + if (chdir("..")) eprintf("CHDIR ..\n"); - crawl_class(class->nextsib); - if(chdir((char*)class->name)) - eprintf("CHDIR %U from %s\n",class->name,getcwd(NULL,255)); } - uprintf("%U\\\n",class->name); - if (chdir("..")) - eprintf("CHDIR ..\n"); } +#define push_setp(setp) (*(struct ir_set_t**)stack_alloc(sizeof(struct ir_set_t*)) = setp) +#define pop_setp() (*(struct ir_set_t**)pagelist_pop(&datapages, sizeof(struct ir_set_t*))) static void crawl_set ( struct ir_set_t* set, int depth ) -{ struct ir_set_t* iter, * last; +{ struct ir_set_t* iter; int i; - pspace(depth * 12); - last = NULL; + i = depth * 12; + while (i--) + putchar('.'); i = depth; for(iter = set; iter != NULL; iter = iter->nextchild) { uprintf("[%10U]", iter->name); - if (last != NULL) - iter->p = last; - last = iter; + push_setp(iter); i++; } - --i; putchar('\n'); - for(iter = last; iter != NULL; iter = iter->p, --i) - if (iter->nextsib != NULL) + while (--i >= depth) + if (((iter = pop_setp())->nextsib) != NULL) crawl_set(iter->nextsib,i); }