* 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$
- 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
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;
}
{
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);
#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
#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",
}
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]);
}
init_windows()
{
top = newwin(LIST_TOP - 1, COLS, 0, 0);
-
bottom = newwin(LINES - LIST_BOTTOM, COLS, LIST_BOTTOM, 0);
}
static void
win_changed(int i)
{
- if( can_resize )
+ if(can_resize)
resize_abook();
else
should_resize = TRUE;
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;
}
refresh_screen()
{
#ifdef SIGWINCH
- if( should_resize ) {
+ if(should_resize) {
resize_abook();
return;
}
return ret;
}
-
void
refresh_statusline()
{
wrefresh(bottom);
}
-
char *
ask_filename(char *prompt)
{
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();
}
}
-
void
ui_remove_items()
{