Free regexp only for non ID_INTERVAL conditions.
authorFrancois Fleuret <francois@fleuret.org>
Mon, 4 Feb 2013 21:49:22 +0000 (22:49 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Mon, 4 Feb 2013 21:49:22 +0000 (22:49 +0100)
mymail.c

index 24b2aa0..b0c1216 100644 (file)
--- a/mymail.c
+++ b/mymail.c
@@ -376,7 +376,7 @@ void search_in_db(FILE *db_file,
             fseek(mail_file, current_position_in_mail, SEEK_SET);
 
             if(fgets(raw_mbox_line, BUFFER_SIZE, mail_file)) {
-              last_mbox_line_was_empty = 1;
+              last_mbox_line_was_empty = 0;
               fprintf(output_file, "%s", raw_mbox_line);
               while(1) {
                 if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) ||
@@ -865,7 +865,14 @@ int main(int argc, char **argv) {
           search_conditions[n].negation = 0;
         }
 
-        if(strcmp(search_field, "today") == 0) {
+        if(strcmp(search_field, "6h") == 0) {
+          search_conditions[n].field_id = ID_INTERVAL;
+          search_conditions[n].interval_start = time(0) - 3600 * 6;
+          search_conditions[n].interval_stop = 0;
+        }
+
+        else if(strcmp(search_field, "24h") == 0 ||
+                strcmp(search_field, "today") == 0) {
           search_conditions[n].field_id = ID_INTERVAL;
           search_conditions[n].interval_start = time(0) - 3600 * 24;
           search_conditions[n].interval_stop = 0;
@@ -980,7 +987,9 @@ int main(int argc, char **argv) {
       }
 
       for(n = 0; n < nb_search_conditions; n++) {
-        regfree(&search_conditions[n].regexp);
+        if(search_conditions[n].field_id != ID_INTERVAL) {
+          regfree(&search_conditions[n].regexp);
+        }
         free(search_condition_strings[n]);
       }
     }