/*=============================================+ * disp_seq -- Display sequence contents * used for drilldown in variable debugger * seq: sequence to display *============================================*/ static void disp_seq (INDISEQ seq) { struct dbgsymtab_s sdata; INT nels = length_indiseq(seq); INT i=0; if (!nels) { msg_info(_("sequence is empty")); return; } init_dbgsymtab_arrays(&sdata, nels); /* loop thru seq building display array */ for (i=0; i<nels; ++i) { STRING key=0, name=0; PVALUE val = NULL; element_indiseq(seq, i, &key, &name); format_dbgsymtab_str(key, name, val, &sdata); } disp_dbgsymtab(_("SEQ contents"), &sdata); free_dbgsymtab_arrays(&sdata); }
/*================================================= * add_children -- add children to tree recursively *===============================================*/ static DISPNODE add_children (NODE indi, INT gen, INT maxgen, INT * count) { DISPNODE tn = alloc_displaynode(); DISPNODE tn0, tn1; int i; tn->keynum = indi_to_keynum(indi); tn->firstchild = 0; tn->nextsib = 0; (*count)++; if (gen < maxgen) { INDISEQ childseq = indi_to_children(indi); if (childseq) { tn0=0; for (i=0; i<length_indiseq(childseq); i++) { NODE child; STRING childkey, childname; element_indiseq(childseq, i, &childkey, &childname); child = key_to_indi(childkey); tn1 = add_children(child, gen+1, maxgen, count); /* link new displaynode into tree we're building */ if (tn0) tn0 = tn0->nextsib = tn1; else /* first child - first time thru loop */ tn0 = tn->firstchild = tn1; } remove_indiseq(childseq); } } return tn; }
/*=============================================================== * choose_one_from_indiseq_if_needed -- handle ask1 cases * seq: [IN] sequence from which to choose * ask1: [IN] whether to prompt if only one element in sequence * titl1: [IN] title if sequence has one element * titln: [IN] title if sequence has multiple elements *=============================================================*/ static INT choose_one_from_indiseq_if_needed (INDISEQ seq, ASK1Q ask1, STRING titl1 , STRING titln) { if (length_indiseq(seq) > 1) return choose_one_from_indiseq(titln, seq); else if (ask1==DOASK1 && titl1) return choose_one_from_indiseq(titl1, seq); return 0; }