2009-06-29 [colin] 3.7.1cvs83
authorColin Leroy <colin@colino.net>
Mon, 29 Jun 2009 20:11:38 +0000 (20:11 +0000)
committerColin Leroy <colin@colino.net>
Mon, 29 Jun 2009 20:11:38 +0000 (20:11 +0000)
* src/filtering.c
* src/filtering.h
* src/prefs_filtering_action.c
Fix bug 1935, 'problems with very long filtering actions':
Use a dynamic buffer in action to string, and a bigger
buffer in string to action

ChangeLog
PATCHSETS
configure.ac
src/filtering.c
src/filtering.h
src/prefs_filtering_action.c

index 665b4a4f14b568d3e2154f517f48df877db6e60c..d771192e5e7abe30da6cfabb300ea82d13dc1e3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-29 [colin]     3.7.1cvs83
+
+       * src/filtering.c
+       * src/filtering.h
+       * src/prefs_filtering_action.c
+               Fix bug 1935, 'problems with very long filtering actions':
+               Use a dynamic buffer in action to string, and a bigger
+               buffer in string to action
+
 2009-06-29 [colin]     3.7.1cvs82
 
        * src/matcher_parser_lex.l
index 922d80b461bd11d9bb1c701b31082ac5add1e188..d0a7df51ce7152610776ddd7a4e0ba4509ff7350 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.22 -r 1.1.2.23 src/ldapupdate.c;  cvs diff -u -r 1.12.2.20 -r 1.12.2.21 src/ldif.c;  ) > 3.7.1cvs80.patchset
 ( cvs diff -u -r 1.60.2.133 -r 1.60.2.134 src/addressbook.c;  cvs diff -u -r 1.11.2.22 -r 1.11.2.23 src/editgroup.c;  cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/gtk/gtkcmctree.c;  cvs diff -u -r 1.1.4.56 -r 1.1.4.57 src/gtk/gtksctree.c;  ) > 3.7.1cvs81.patchset
 ( cvs diff -u -r 1.16.2.13 -r 1.16.2.14 src/matcher_parser_lex.l;  ) > 3.7.1cvs82.patchset
+( cvs diff -u -r 1.60.2.52 -r 1.60.2.53 src/filtering.c;  cvs diff -u -r 1.21.2.17 -r 1.21.2.18 src/filtering.h;  cvs diff -u -r 1.1.4.60 -r 1.1.4.61 src/prefs_filtering_action.c;  ) > 3.7.1cvs83.patchset
index 433a009c35f7af5820b145f7eea8b77896bab617..235a60e745e0cda289cd33a87172ee9a4debcd96 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=82
+EXTRA_VERSION=83
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 6e9d76eb81c6b47a064f5577ea970b0a536297e5..d0690bb8fe3bd909b873ee01a9783cfa016b9678 100644 (file)
@@ -719,7 +719,7 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
     gboolean * final)
 {
        gboolean result = TRUE;
-       gchar    buf[256];
+       gchar    *buf;
         GSList * tmp;
         
         * final = FALSE;
@@ -727,9 +727,9 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
                 FilteringAction * action;
 
                 action = tmp->data;
-                               filteringaction_to_string(buf, sizeof buf, action);
-                               if (debug_filtering_session)
-                                       log_print(LOG_DEBUG_FILTERING, _("applying action [ %s ]\n"), buf);
+               buf = filteringaction_to_string(action);
+               if (debug_filtering_session)
+                       log_print(LOG_DEBUG_FILTERING, _("applying action [ %s ]\n"), buf);
 
                 if (FALSE == (result = filteringaction_apply(action, info))) {
                                        if (debug_filtering_session) {
@@ -740,11 +740,12 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
                                        } else
                                                g_warning("No further processing after rule %s\n", buf);
                 }
-                
+                g_free(buf);
                 if (filtering_is_final_action(action)) {
                         * final = TRUE;
                         break;
                 }
+               
         }
        return result;
 }
@@ -911,12 +912,14 @@ gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* a
        return ret;
 }
 
-gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action)
+gchar *filteringaction_to_string(FilteringAction *action)
 {
        const gchar *command_str;
        gchar * quoted_dest;
        gchar * quoted_header;
-       
+       GString *dest = g_string_new("");
+       gchar *deststr = NULL;
+
        command_str = get_matchparser_tab_str(action->type);
 
        if (command_str == NULL)
@@ -929,9 +932,9 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_SET_TAG:
        case MATCHACTION_UNSET_TAG:
                quoted_dest = matcher_quote_str(action->destination);
-               g_snprintf(dest, destlen, "%s \"%s\"", command_str, quoted_dest);
+               g_string_append_printf(dest, "%s \"%s\"", command_str, quoted_dest);
                g_free(quoted_dest);
-               return dest;
+               break;
 
        case MATCHACTION_DELETE:
        case MATCHACTION_MARK:
@@ -947,43 +950,45 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_IGNORE:
        case MATCHACTION_WATCH:
        case MATCHACTION_CLEAR_TAGS:
-               g_snprintf(dest, destlen, "%s", command_str);
-               return dest;
+               g_string_append_printf(dest, "%s", command_str);
+               break;
 
        case MATCHACTION_REDIRECT:
        case MATCHACTION_FORWARD:
        case MATCHACTION_FORWARD_AS_ATTACHMENT:
                quoted_dest = matcher_quote_str(action->destination);
-               g_snprintf(dest, destlen, "%s %d \"%s\"", command_str, action->account_id, quoted_dest);
+               g_string_append_printf(dest, "%s %d \"%s\"", command_str, action->account_id, quoted_dest);
                g_free(quoted_dest);
-               return dest; 
+               break;
 
        case MATCHACTION_COLOR:
-               g_snprintf(dest, destlen, "%s %d", command_str, action->labelcolor);
-               return dest;  
+               g_string_append_printf(dest, "%s %d", command_str, action->labelcolor);
+               break;
 
        case MATCHACTION_CHANGE_SCORE:
        case MATCHACTION_SET_SCORE:
-               g_snprintf(dest, destlen, "%s %d", command_str, action->score);
-               return dest;  
+               g_string_append_printf(dest, "%s %d", command_str, action->score);
+               break;
 
        case MATCHACTION_ADD_TO_ADDRESSBOOK:
                quoted_header = matcher_quote_str(action->header);
                quoted_dest = matcher_quote_str(action->destination);
-               g_snprintf(dest, destlen, "%s \"%s\" \"%s\"", command_str, quoted_header, quoted_dest);
+               g_string_append_printf(dest, "%s \"%s\" \"%s\"", command_str, quoted_header, quoted_dest);
                g_free(quoted_dest);
                g_free(quoted_header);
-               return dest;
+               break;
 
        default:
                return NULL;
        }
+       deststr = dest->str;
+       g_string_free(dest, FALSE);
+       return deststr;
 }
 
 gchar * filteringaction_list_to_string(GSList * action_list)
 {
        gchar *action_list_str;
-       gchar  buf[256];
         GSList * tmp;
        gchar *list_str;
 
@@ -994,8 +999,7 @@ gchar * filteringaction_list_to_string(GSList * action_list)
                 
                 action = tmp->data;
                 
-                action_str = filteringaction_to_string(buf,
-                    sizeof buf, action);
+                action_str = filteringaction_to_string(action);
                 
                 if (action_list_str != NULL) {
                         list_str = g_strconcat(action_list_str, " ", action_str, NULL);
@@ -1004,6 +1008,7 @@ gchar * filteringaction_list_to_string(GSList * action_list)
                 else {
                         list_str = g_strdup(action_str);
                 }
+               g_free(action_str);
                 action_list_str = list_str;
         }
 
index 7bce81ccdffe8f219bcf7d6d9e9912f780eee390..3cb65a9e25d23d7cdef7f35640f63168f52ce192 100644 (file)
@@ -89,7 +89,7 @@ void filter_msginfo_move_or_delete(GSList *filtering_list, MsgInfo *info);
 gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount *ac_prefs,
                                                                   FilteringInvocationType context, gchar *extra_info);
 
-gchar * filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action);
+gchar * filteringaction_to_string(FilteringAction *action);
 void prefs_filtering_write_config(void);
 void prefs_filtering_read_config(void);
 gchar * filteringaction_list_to_string(GSList * action_list);
index a4b87135e8ea3bb3cc27a4a00c7ed90220bfd465..abae26fbb2c822e276d2fdbce0559d44ce500820 100644 (file)
@@ -652,7 +652,7 @@ static void prefs_filtering_action_create(void)
 static void prefs_filtering_action_list_view_set_row(GtkTreeIter *row, 
                                                     FilteringAction *action)
 {
-        gchar buf[256];
+        gchar *buf;
 
        if (row == NULL && action == NULL) {
                prefs_filtering_action_list_view_insert_action
@@ -661,11 +661,12 @@ static void prefs_filtering_action_list_view_set_row(GtkTreeIter *row,
                return;
        }                        
 
-        filteringaction_to_string(buf, sizeof buf, action);
+        buf = filteringaction_to_string(action);
 
        prefs_filtering_action_list_view_insert_action
                        (filtering_action.action_list_view,
                         row, buf, TRUE);
+       g_free(buf);
 }
 
 /*!