]> git.deb.at Git - pkg/abook.git/commitdiff
- make it compile with tcc
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Wed, 10 Aug 2005 05:45:37 +0000 (05:45 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Wed, 10 Aug 2005 05:45:37 +0000 (05:45 +0000)
- whitespace cleanups
- minor cleanups in parse_database

BUGS
ChangeLog
database.c
database.h
filter.c
ui.c

diff --git a/BUGS b/BUGS
index b2a8a9fe1609e77e2669f338ae23d99ffaea6b49..ec3e6d0816af2ebd74baa22f38fb0932b28a62ed 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -25,4 +25,8 @@ Filters:
 
 * fseek in ldif import filter should be eliminated
 
+Misc:
+* crashes if compiled with tinycc bound checking. It's still unclear
+  if this is a bug in abook. (Valgrind doesn't show up anything.)
+
 $Id$
index 60d654ad04196216ce5944f553d944f5a3fcc01e..1a1752ad02b4c6f1448479f45816f67385c1ea02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
  - autoconf/automake update
  - replace abook_malloc, abook_realloc and my_free with new xmalloc routines
  - update for abook_rl (abook_readline)
+ - make it compile with tcc (Tiny C Compiler)
  - code cleanups and minor fixes
 
 0.5.3
index 259c63c6414cf359aa8867f06d209ddaa1412347..0b9b58e6b1c18e750fa508469727f8f73b364569 100644 (file)
@@ -100,39 +100,38 @@ parse_database(FILE *in)
 
        for(;;) {
                line = getaline(in);
-               if( feof(in) ) {
-                       if( item[NAME] && sec )
+               if(feof(in)) {
+                       if(item[NAME] && sec)
                                add_item2database(item);
                        else
                                free_list_item(item);
                        break;
                }
 
-               if( !*line || *line == '\n' || *line == '#' ) {
-                       free(line);
-                       continue;
-               } else if( *line == '[' ) {
+               if(!*line || *line == '\n' || *line == '#') {
+                       goto next;
+               } else if(*line == '[') {
                        if( item[NAME] && sec )
                                add_item2database(item);
                        else
                                free_list_item(item);
                        memset(&item, 0, sizeof(item));
                        sec = 1;
-                       if ( !(tmp = strchr(line, ']')))
+                       if(!(tmp = strchr(line, ']')))
                                sec = 0; /*incorrect section lines are skipped*/
-               } else if((tmp = strchr(line, '=') ) && sec ) {
+               } else if((tmp = strchr(line, '=') ) && sec) {
                        *tmp++ = '\0';
-                       for(i=0; i<ITEM_FIELDS; i++)
-                               if( !strcmp(abook_fields[i].key, line) ) {
+                       for(i = 0; i < ITEM_FIELDS; i++)
+                               if(!strcmp(abook_fields[i].key, line)) {
                                        item[i] = strdup(tmp);
                                        goto next;
                                }
                }
 next:
-               free(line);
+               xfree(line);
        }
 
-       free(line);
+       xfree(line);
        return 0;
 }
 
@@ -143,10 +142,10 @@ load_database(char *filename)
 {
        FILE *in;
 
-       if( database != NULL )
+       if(database != NULL)
                close_database();
 
-       if ( (in = abook_fopen(filename, "r")) == NULL )
+       if ((in = abook_fopen(filename, "r")) == NULL)
                return -1;
 
        parse_database(in);
index 3bfeb4e385a342fed6cd77ad0a0c7793646c5ecd..87228851df824051ad20fe6ea8bc1e37f67e2324 100644 (file)
@@ -36,7 +36,7 @@ enum {
 #define CUSTOM_MIN             CUSTOM1
 #define CUSTOM_MAX             CUSTOM5
 
-typedef char * list_item[ITEM_FIELDS];
+typedef char *list_item[ITEM_FIELDS];
 
 #define        MAX_FIELDNAME_LEN       21
 
index 9eb96192243f41461432d21bbc3ed63ae55a28c2..03ad954a73cf3ab8c0d44460ce54339ae3d1e060 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -431,7 +431,7 @@ static void ldif_fix_string(char *str);
 
 #define        LDIF_ITEM_FIELDS        16
 
-typedef char*  ldif_item[LDIF_ITEM_FIELDS];
+typedef char *ldif_item[LDIF_ITEM_FIELDS];
 
 static ldif_item ldif_field_names = {
        "cn",
@@ -519,27 +519,27 @@ ldif_read_line(FILE *in)
 }
 
 static void
-ldif_add_item(ldif_item ldif_item)
+ldif_add_item(ldif_item li)
 {
        list_item abook_item;
        int i;
 
        memset(abook_item, 0, sizeof(abook_item));
 
-       if( !ldif_item[LDIF_ITEM_FIELDS -1] )
+       if(!li[LDIF_ITEM_FIELDS -1] )
                goto bail_out;
 
 
        for(i=0; i < LDIF_ITEM_FIELDS; i++) {
-               if(ldif_conv_table[i] >= 0 && ldif_item[i] && *ldif_item[i] )
-                       abook_item[ldif_conv_table[i]] = strdup(ldif_item[i]);
+               if(ldif_conv_table[i] >= 0 && li[i] && *li[i] )
+                       abook_item[ldif_conv_table[i]] = strdup(li[i]);
        }
 
        add_item2database(abook_item);
 
 bail_out:
        for(i=0; i < LDIF_ITEM_FIELDS; i++)
-               xfree(ldif_item[i]);
+               xfree(li[i]);
 
 }
 
diff --git a/ui.c b/ui.c
index 27aa91f12f35edc1cc828c92188b1a83446d312b..bde07e4fde9e45288580e6bd00cea188160df046 100644 (file)
--- a/ui.c
+++ b/ui.c
@@ -63,7 +63,6 @@ static void
 init_windows()
 {
        top = newwin(LIST_TOP - 1, COLS, 0, 0);
-
        bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0);
 }
 
@@ -112,7 +111,7 @@ resize_abook()
 static void
 win_changed(int i)
 {
-       if( can_resize )
+       if(can_resize)
                resize_abook();
        else
                should_resize = TRUE;
@@ -155,15 +154,15 @@ init_ui()
                return 1;
        }
 
-#ifdef SIGWINCH
-       signal(SIGWINCH, win_changed);
-#endif
-
        init_list();
        init_windows();
 
        ui_initialized = TRUE;
 
+#ifdef SIGWINCH
+       signal(SIGWINCH, win_changed);
+#endif
+
        return 0;
 }
 
@@ -198,7 +197,7 @@ void
 refresh_screen()
 {
 #ifdef SIGWINCH
-       if( should_resize ) {
+       if(should_resize) {
                resize_abook();
                return;
        }
@@ -284,7 +283,6 @@ statusline_ask_boolean(char *msg, int def)
        return ret;
 }
 
-
 void
 refresh_statusline()
 {
@@ -296,7 +294,6 @@ refresh_statusline()
        wrefresh(bottom);
 }
 
-
 char *
 ask_filename(char *prompt)
 {
@@ -347,8 +344,8 @@ display_help(int help)
 
        for(i = 0; tbl[i] != NULL; i++) {
                waddstr(helpw, tbl[i]);
-               if( ( !( (i+1) % (LINES-8) ) ) ||
-                       (tbl[i+1] == NULL) ) {
+               if( (!((i + 1) % (LINES - 8))) ||
+                       (tbl[i + 1] == NULL) ) {
                        refresh();
                        wrefresh(helpw);
                        refresh_statusline();
@@ -467,7 +464,6 @@ get_commands()
        }
 }
 
-
 void
 ui_remove_items()
 {