Пример #1
0
/*============================================
 * llrpt_detachnode -- Remove node from GEDCOM tree
 * usage: detachnode(NODE) -> VOID
 * (This is the historic deletenode)
 *==========================================*/
PVALUE
llrpt_detachnode (PNODE node, SYMTAB stab, BOOLEAN *eflg)
{
	PNODE arg = iargs(node);
	NODE dead, prnt;
	PVALUE val = eval_and_coerce(PGNODE, arg, stab, eflg);
	if (*eflg) {
		prog_var_error(node, stab, arg, val, nonnod1, "detachnode");
		delete_pvalue(val);
		return NULL;
	}
	dead = pvalue_to_node(val);
	if ((prnt = nparent(dead))) {
		NODE prev = NULL, next;
		NODE curs = nchild(prnt);
		while (curs && curs != dead) {
			prev = curs;
			curs = nsibling(curs);
		}
		ASSERT(curs); /* else broken tree: dead was not child of its parent */
		next = nsibling(dead);
		if (prev == NULL) 
			nchild(prnt) = next;
		else
			nsibling(prev) = next;
	}
	/* unparent node, but ensure its locking is only releative to new parent */
	dolock_node_in_cache(dead, FALSE);
	nparent(dead) = NULL;
	dolock_node_in_cache(dead, TRUE);
	nsibling(dead) = NULL;
	/* we don't actually delete the node, garbage collection must get it */
	return NULL;
}
Пример #2
0
/*====================================================
 * disp_pvalue -- Display details of specified pvalue
 *  Drilldown in variable debugger
 *  This is primarily to display contents of container values
 *  val:   [IN]  value to display
 *==================================================*/
static void
disp_pvalue (PVALUE val)
{
	switch (which_pvalue_type(val)) {
		case PGNODE:
			{
				NODE node = pvalue_to_node(val);
				char buffer[256] = "";
				size_t len = sizeof(buffer);
				STRING str = buffer;
				if (ntag(node)) {
					llstrappf(str, len, uu8, "%s: ", ntag(node));
				}
				if (nval(node)) {
					llstrapps(str, len, uu8, nval(node));
				}
				msg_info(str);
			}
			return;
		case PINDI:
		case PFAM:
		case PSOUR:
		case PEVEN:
		case POTHR:
			{
				RECORD rec = pvalue_to_record(val);
				NODE node = nztop(rec);
				size_t len = 128;
				STRING txt = generic_to_list_string(node, NULL, len, " ", NULL, TRUE);
				msg_info(txt);
			}
			return;
		case PLIST:
			{
				LIST list = pvalue_to_list(val);
				disp_list(list);
			}
			return;
		case PTABLE:
			{
				TABLE tab = pvalue_to_table(val);
				disp_table(tab);
			}
			return;
		case PSET:
			{
				INDISEQ seq = pvalue_to_seq(val);
				disp_seq(seq);
			}
			return;
	}
}