src/liflines/edit.c
/*=====================================
 * edit_indi -- Edit person in database
 * (with user interaction)
 * returns TRUE if user makes changes (& saves them)
 *===================================*/
- Edit person in database
(with user interaction)
returns TRUE if user makes changes (& saves them)
- Edit person in database ( with user interaction ) returns TRUE if user makes changes ( & saves them )
BOOLEAN
edit_indi (RECORD irec1, RFMT rfmt)  
{
	NODE indi1, indi2=0;
	XLAT ttmi = transl_get_predefined_xlat(MEDIN);
	if (!irec1 && !(irec1 = ask_for_indi(_(qSidpedt), NOASK1)))
		return FALSE;
	indi1 = nztop(irec1);
	nodechk(indi1, "edit_indi");
	write_indi_to_file_for_edit(indi1, editfile, rfmt);
	do_edit();
	if (readonly) {
		STRING msg;
		BOOLEAN emp;
		indi2 = file_to_node(editfile, ttmi, &msg, &emp);
		if (!equal_tree(indi1, indi2))
			message("%s", _(qSronlye));
		free_nodes(indi2);
		return FALSE;
	}
	while (TRUE) {
		INT cnt;
		STRING msg;
		BOOLEAN emp;
		indi2 = file_to_node(editfile, ttmi, &msg, &emp);
		if (!indi2) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			} 
			break;
		}
		cnt = resolve_refn_links(indi2);
		if (!valid_indi_tree(indi2, &msg, indi1)) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			}
			free_nodes(indi2);
			indi2 = NULL;
			break;
		}
		if (cnt > 0) {
			char msgb[120];
			snprintf(msgb, sizeof(msgb)
				, get_unresolved_ref_error_string(cnt), cnt);
			if (ask_yes_or_no_msg(msgb, _(qSireditopt))) {
				write_indi_to_file_for_edit(indi2, editfile, rfmt);
				do_edit();
				continue;
			}
		}
		break;
	}
	if (!indi2) return FALSE;
	if (equal_tree(indi1, indi2) || !ask_yes_or_no(_(qScfpupt))) {
		free_nodes(indi2);
		return FALSE;
	}
	replace_indi(indi1, indi2);
	history_record_change(irec1);
	msg_status(_(qSgdpmod), indi_to_name(indi1, 35));
	return TRUE;
}
BOOLEAN edit_indi ( RECORD irec1 , RFMT rfmt ) { NODE indi1 , indi2 = 0 ; XLAT ttmi = transl_get_predefined_xlat ( MEDIN ) ; if ( ! irec1 && ! ( irec1 = ask_for_indi ( _ ( qSidpedt ) , NOASK1 ) ) ) return FALSE ; indi1 = nztop ( irec1 ) ; nodechk ( indi1 , " " ) ; write_indi_to_file_for_edit ( indi1 , editfile , rfmt ) ; do_edit ( ) ; if ( readonly ) { STRING msg ; BOOLEAN emp ; indi2 = file_to_node ( editfile , ttmi , & msg , & emp ) ; if ( ! equal_tree ( indi1 , indi2 ) ) message ( " " , _ ( qSronlye ) ) ; free_nodes ( indi2 ) ; return FALSE ; } while ( TRUE ) { INT cnt ; STRING msg ; BOOLEAN emp ; indi2 = file_to_node ( editfile , ttmi , & msg , & emp ) ; if ( ! indi2 ) { if ( ask_yes_or_no_msg ( msg , _ ( qSiredit ) ) ) { do_edit ( ) ; continue ; } break ; } cnt = resolve_refn_links ( indi2 ) ; if ( ! valid_indi_tree ( indi2 , & msg , indi1 ) ) { if ( ask_yes_or_no_msg ( msg , _ ( qSiredit ) ) ) { do_edit ( ) ; continue ; } free_nodes ( indi2 ) ; indi2 = NULL ; break ; } if ( cnt > 0 ) { char msgb [ 120 ] ; snprintf ( msgb , sizeof ( msgb ) , get_unresolved_ref_error_string ( cnt ) , cnt ) ; if ( ask_yes_or_no_msg ( msgb , _ ( qSireditopt ) ) ) { write_indi_to_file_for_edit ( indi2 , editfile , rfmt ) ; do_edit ( ) ; continue ; } } break ; } if ( ! indi2 ) return FALSE ; if ( equal_tree ( indi1 , indi2 ) || ! ask_yes_or_no ( _ ( qScfpupt ) ) ) { free_nodes ( indi2 ) ; return FALSE ; } replace_indi ( indi1 , indi2 ) ; history_record_change ( irec1 ) ; msg_status ( _ ( qSgdpmod ) , indi_to_name ( indi1 , 35 ) ) ; return TRUE ; }
edit_indi -- Edit person in database
 (with user interaction)
 returns TRUE if user makes changes (& saves them)
edit_indi -- Edit person in database ( with user interaction ) returns TRUE if user makes changes ( & saves them )
/* may be NULL */ /* Identify indi if necessary */ /* Prepare file for user to edit */ /* Have user edit file */ /* validate for showstopper errors */ /* if fail a showstopper error, must reedit or abort */ /* Allow user to reedit if desired if any refn links unresolved */ /* this is not a showstopper, so alternative is to continue */ /* Editing done; see if database changes */ /* Move new data (in indi2 children) into existing indi1 tree */ /* Note in change history */