From fa5c9dddc25aeea5f3b42d82b40f13c8aa1137b9 Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Wed, 3 Apr 2002 17:52:44 +0000 Subject: [PATCH] various updates --- options.c | 67 ++++++++++++++++++++++++++++---------------------- sample.abookrc | 27 +++++++++----------- ui.c | 1 - 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/options.c b/options.c index 2f6d0bb..4e65f5a 100644 --- a/options.c +++ b/options.c @@ -168,6 +168,10 @@ free_opts() * file parsing */ +typedef struct { + char *data, *ptr; +} buffer; + static void opt_line_remove_comments(char *p) { @@ -198,28 +202,24 @@ opt_line_remove_comments(char *p) } } -static char * -get_token_start(char *p) +void +find_token_start(buffer *b) { - assert(p); + assert(b); - for(; ISSPACE(*p); p++); - - return p; + for(; ISSPACE(*b -> ptr); b -> ptr ++); } -static char * -get_token_end(char *p) +void +find_token_end(buffer *b) { - assert(p); + assert(b); - for(p = get_token_start(p); *p; p++) { - if(ISSPACE(*p)) { + for(find_token_start(b); *(b -> ptr); b -> ptr ++) { + if(ISSPACE(*(b -> ptr))) { break; } } - - return p; } static char * @@ -260,22 +260,22 @@ opt_set_set_option(char *var, char *p, struct option *opt) } static char * -opt_parse_set(char *p) +opt_parse_set(buffer *b) { - char *var; int i; + char *p; - var = get_token_start(p); - if((p = strchr(var, '='))) + find_token_start(b); + if((p = strchr(b -> ptr, '='))) *p++ = 0; else return "invalid value assignment"; - strtrim(var); + strtrim(b -> ptr); for(i = 0;abook_vars[i].option; i++) - if(!strcmp(abook_vars[i].option, var)) - return opt_set_set_option(var, p, &abook_vars[i]); + if(!strcmp(abook_vars[i].option, b -> ptr)) + return opt_set_set_option(b -> ptr, p, &abook_vars[i]); return "unknown option"; } @@ -283,7 +283,7 @@ opt_parse_set(char *p) static struct { char *token; - char * (*func) (char *line); + char * (*func) (buffer *line); } opt_parsers[] = { { "set", opt_parse_set }, { NULL } @@ -293,24 +293,31 @@ static bool opt_parse_line(char *line, int n, char *fn) { int i; - char *p; char *err = NULL; + char *token; + buffer b; assert(line && fn); - line = get_token_start(line); - p = get_token_end(line); - *p++ = 0; + b.ptr = line; + + find_token_start(&b); + b.data = b.ptr; + find_token_end(&b); + *b.ptr++ = 0; if(!*line) return FALSE; - strtrim(line); - strtrim(p); + strtrim(b.data); + strtrim(b.ptr); + + token = b.data; + b.data = b.ptr = b.ptr; for(i = 0; opt_parsers[i].token; i++) - if(!strcmp(opt_parsers[i].token, line)) { - if(!(err = opt_parsers[i].func(p))) + if(!strcmp(opt_parsers[i].token, token)) { + if(!(err = opt_parsers[i].func(&b))) return FALSE; break; } @@ -319,7 +326,7 @@ opt_parse_line(char *line, int n, char *fn) if(err) fprintf(stderr, "%s\n", err); else - fprintf(stderr, "unknown token %s\n", line); + fprintf(stderr, "unknown token %s\n", token); return TRUE; } diff --git a/sample.abookrc b/sample.abookrc index 847e4ff..9809767 100644 --- a/sample.abookrc +++ b/sample.abookrc @@ -2,16 +2,16 @@ # see abookrc(5) for detailed explanation # Automatically save database on exit -autosave=true +set autosave=true # Show all email addresses in list -show_all_emails=true +set show_all_emails=true # Screen column for email field to start -emailpos=25 +set emailpos=25 # Field to be used in the extra column -extra_column=phone +set extra_column=phone # frequently used values: # -1 disabled # phone Home Phone @@ -24,29 +24,26 @@ extra_column=phone # Specify an alternative field to be displayed in the extra # column if there is no data for the field specified in # extra_column for a particular item. -extra_alternative=-1 +set extra_alternative=-1 # Screen column for the extra field to start -extrapos=65 +set extrapos=65 # Command used to start mutt -mutt_command=mutt +set mutt_command=mutt # Return all email addresses to a mutt query -mutt_return_all_emails=true +set mutt_return_all_emails=true # Command used to print -print_command=lpr - -# Sort files in fileselector (alphabetic order) -filesel_sort=false +set print_command=lpr # Command used to start the web browser -www_command=lynx +set www_command=lynx # address style [eu|us|uk] -address_style=eu +set address_style=eu # use ASCII characters only -use_ascii_only=false +set use_ascii_only=false diff --git a/ui.c b/ui.c index ceb61db..4d4150e 100644 --- a/ui.c +++ b/ui.c @@ -59,7 +59,6 @@ bool can_resize = FALSE; WINDOW *top = NULL, *bottom = NULL; - static void init_windows() { -- 2.39.2