From: Jaakko Heinonen Date: Tue, 2 Aug 2005 18:41:01 +0000 (+0000) Subject: - code re-organization X-Git-Tag: upstream/0.6.1~2^2~183 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=1ce000762e496959ea5afa3830b171c73f0409c8;p=pkg%2Fabook.git - code re-organization --- diff --git a/edit.c b/edit.c index a32121e..4502e10 100644 --- a/edit.c +++ b/edit.c @@ -110,17 +110,46 @@ init_editor() refresh_statusline(); } -/* - * we have to introduce edit_undo here - */ -static void edit_undo(int item, int mode); - enum { BACKUP_ITEM, RESTORE_ITEM, CLEAR_UNDO }; +static void +edit_undo(int item, int mode) +{ + int i; + static list_item *backup = NULL; + + switch(mode) { + case CLEAR_UNDO: + if(backup) { + free_list_item(backup[0]); + xfree(backup); + } + break; + case BACKUP_ITEM: + if(backup) { + free_list_item(backup[0]); + xfree(backup); + } + backup = xmalloc(sizeof(list_item)); + for(i = 0; i < ITEM_FIELDS; i++) + backup[0][i] = safe_strdup(database[item][i]); + break; + case RESTORE_ITEM: + if(backup) { + free_list_item(database[item]); + itemcpy(database[item], backup[0]); + xfree(backup); + } + break; + default: + assert(0); + } +} + static void close_editor() @@ -345,40 +374,6 @@ edit_field(int tab, char c, int item) return 1; } -static void -edit_undo(int item, int mode) -{ - int i; - static list_item *backup = NULL; - - switch(mode) { - case CLEAR_UNDO: - if(backup) { - free_list_item(backup[0]); - xfree(backup); - } - break; - case BACKUP_ITEM: - if(backup) { - free_list_item(backup[0]); - xfree(backup); - } - backup = xmalloc(sizeof(list_item)); - for(i = 0; i < ITEM_FIELDS; i++) - backup[0][i] = safe_strdup(database[item][i]); - break; - case RESTORE_ITEM: - if(backup) { - free_list_item(database[item]); - itemcpy(database[item], backup[0]); - xfree(backup); - } - break; - default: - assert(0); - } -} - static int edit_loop(int item) {