From: Francois Fleuret Date: Thu, 2 May 2013 12:12:00 +0000 (+0200) Subject: Cosmetics + now alias replaces the full search request, not just the key. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=d2d42bbbc5910878fd44cea75beff781255162b6;p=mymail.git Cosmetics + now alias replaces the full search request, not just the key. --- diff --git a/mymail.c b/mymail.c index ff0bd45..80864d2 100644 --- a/mymail.c +++ b/mymail.c @@ -57,12 +57,19 @@ #define LEADING_FROM_LINE_REGEXP_STRING "^From .*\\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\) \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\) [ 0123][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]\n$" +/********************************************************************/ + +struct alias_node { + char *alias, *value; + struct alias_node *next; +}; + /* Global variables! */ int global_quiet; int global_use_leading_time; - regex_t global_leading_from_line_regexp; +struct alias_node *global_alias_list; /********************************************************************/ @@ -102,15 +109,6 @@ struct search_condition { /********************************************************************/ -struct alias_node { - char *alias, *value; - struct alias_node *next; -}; - -struct alias_node *global_alias_list; - -/********************************************************************/ - struct parsable_field { int id; int cflags; @@ -829,6 +827,13 @@ void init_condition(struct search_condition *condition, const char *full_string, const char *string; struct alias_node *a; + for(a = global_alias_list; a; a = a->next) { + if(strcmp(full_string, a->alias) == 0) { + full_string = a->value; + break; + } + } + string = parse_token(full_search_field, TOKEN_BUFFER_SIZE, ' ', full_string); search_field = full_search_field; @@ -839,13 +844,6 @@ void init_condition(struct search_condition *condition, const char *full_string, condition->negation = 0; } - for(a = global_alias_list; a; a = a->next) { - if(strcmp(search_field, a->alias) == 0) { - search_field = a->value; - break; - } - } - condition->db_key = -1; /* Time condition */ @@ -946,6 +944,7 @@ void read_rc_file(const char *rc_filename) { if(*s && *s != '#') { s = parse_token(command, TOKEN_BUFFER_SIZE, ' ', s); + if(strcmp(command, "alias") == 0) { struct alias_node *a = safe_malloc(sizeof(struct alias_node)); a->next = global_alias_list;