From baf1c7616dd0a5fa1bafde2045ac2af22d95122a Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Wed, 10 Aug 2005 05:45:37 +0000 Subject: [PATCH] - make it compile with tcc - whitespace cleanups - minor cleanups in parse_database --- BUGS | 4 ++++ ChangeLog | 1 + database.c | 27 +++++++++++++-------------- database.h | 2 +- filter.c | 12 ++++++------ ui.c | 20 ++++++++------------ 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/BUGS b/BUGS index b2a8a9f..ec3e6d0 100644 --- 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$ diff --git a/ChangeLog b/ChangeLog index 60d654a..1a1752a 100644 --- 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 diff --git a/database.c b/database.c index 259c63c..0b9b58e 100644 --- a/database.c +++ b/database.c @@ -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= 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 27aa91f..bde07e4 100644 --- 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() { -- 2.39.2