]> git.deb.at Git - pkg/abook.git/blobdiff - database.c
- whitespace changes
[pkg/abook.git] / database.c
index f7bb7459373391db14a95a9f39a71886efcddc26..259c63c6414cf359aa8867f06d209ddaa1412347 100644 (file)
 #      include "config.h"
 #endif
 
-static void    free_item(int i);
-
-
 list_item *database = NULL;
 
 int items = 0;
 
 #define INITIAL_LIST_CAPACITY  30
 
-int list_capacity = 0;
+static int list_capacity = 0;
 
 extern int first_list_item;
 extern int curitem;
 extern char *selected;
 
 extern char *datafile;
-extern char *rcfile;
 
 /*
  * field definitions
@@ -198,7 +194,7 @@ save_database()
        if( (out = abook_fopen(datafile, "w")) == NULL )
                return -1;
 
-       if( list_is_empty() ) {
+       if(list_is_empty()) {
                fclose(out);
                unlink(datafile);
                return 1;
@@ -286,12 +282,12 @@ adjust_list_capacity()
 int
 add_item2database(list_item item)
 {
-       if( item[NAME] == NULL || ! *item[NAME] ) {
+       if(item[NAME] == NULL || ! *item[NAME]) {
                free_list_item(item);
                return 1;
        }
 
-       if( ++items > list_capacity)
+       if(++items > list_capacity)
                adjust_list_capacity();
 
        validate_item(item);
@@ -307,27 +303,26 @@ remove_selected_items()
 {
        int i, j;
 
-       if( list_is_empty() )
+       if(list_is_empty())
                return;
 
-       if( ! selected_items() )
-               selected[ curitem ] = 1;
+       if(!selected_items())
+               selected[curitem] = 1;
 
-       for( j = LAST_ITEM; j >= 0; j-- ) {
-               if( selected[j] ) {
+       for(j = LAST_ITEM; j >= 0; j--) {
+               if(selected[j]) {
                        free_item(j); /* added for .4 data_s_ */
-                       for( i = j; i < LAST_ITEM; i++ ) {
-                               itemcpy(database[ i ], database[ i + 1 ]);
-                               selected[ i ] = selected[ i + 1 ];
+                       for(i = j; i < LAST_ITEM; i++) {
+                               itemcpy(database[i], database[i + 1]);
+                               selected[i] = selected[i + 1];
                        }
                        items--;
                }
        }
 
-       if( curitem > LAST_ITEM && items > 0 )
+       if(curitem > LAST_ITEM && items > 0)
                curitem = LAST_ITEM;
 
-
        adjust_list_capacity();
 
        select_none();
@@ -380,7 +375,7 @@ namecmp(const void *i1, const void *i2)
        itemcpy(a, i1);
        itemcpy(b, i2);
 
-       return safe_strcoll( a[sort_field], b[sort_field] );
+       return safe_strcoll(a[sort_field], b[sort_field]);
 }
 
 static int