]> git.deb.at Git - pkg/abook.git/blobdiff - options.c
- replace abook_malloc, abook_realloc and my_free with new xmalloc routines
[pkg/abook.git] / options.c
index fb5c7a635d61e10c8340e774bf280e1766bdb555..d43f0e725793683162fcbd0b5ce31595afeda445 100644 (file)
--- a/options.c
+++ b/options.c
@@ -66,6 +66,7 @@ static struct option abook_vars[] = {
 
        { "add_email_prevent_duplicates", OT_BOOL, BOOL_ADD_EMAIL_PREVENT_DUPLICATES, FALSE },
        { "sort_field", OT_STR, STR_SORT_FIELD, UL "nick" },
+       { "show_cursor", OT_BOOL, BOOL_SHOW_CURSOR, FALSE },
 
        { NULL }
 };
@@ -257,6 +258,8 @@ opt_set_set_option(char *var, char *p, struct option *opt)
                        else
                                return "invalid value";
                        break;
+               default:
+                       assert(0);
        }
        
        return NULL;
@@ -283,6 +286,8 @@ opt_parse_set(buffer *b)
        return "unknown option";
 }
 
+#include "database.h" /* needed for change_custom_field_name */
+
 static char *
 opt_parse_customfield(buffer *b)
 {
@@ -291,18 +296,14 @@ opt_parse_customfield(buffer *b)
        size_t len;
 
        find_token_start(b);
-
        p = b -> ptr;
-
        find_token_end(b);
 
        memset(num, 0, sizeof(num));
 
-       if((len = (b -> ptr - p)) > sizeof(num))
-               return "invalid custom field number";
-
-       strncpy(num, p, min(sizeof(num), len));
-       n = atoi(num);
+       len = (b -> ptr - p);
+       strncpy(num, p, min(sizeof(num) - 1, len));
+       n = safe_atoi(num);
 
        find_token_start(b);
 
@@ -387,7 +388,8 @@ load_opts(char *filename)
                                err += opt_parse_line(line, n, filename) ? 1:0;
                }
 
-               my_free(line);
+               free(line);
+               line = NULL;
        }
 
        free(line);