]> git.deb.at Git - pkg/abook.git/commitdiff
- code re-organization
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Tue, 2 Aug 2005 18:41:01 +0000 (18:41 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Tue, 2 Aug 2005 18:41:01 +0000 (18:41 +0000)
edit.c

diff --git a/edit.c b/edit.c
index a32121ed9f058c5a8af9ce710b79999caae22827..4502e106191571b1a1cd3d5946d2a11b371cb967 100644 (file)
--- 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)
 {