[gmime: 7/27] Properly fall back to using default_options when warning about parser errors



commit d9fb41a962e7e81c134261a72b79f5d1c6a29638
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Wed Nov 8 16:02:00 2017 -0500

    Properly fall back to using default_options when warning about parser errors

 gmime/gmime-parser-options.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gmime/gmime-parser-options.c b/gmime/gmime-parser-options.c
index 79c4ebc..d11e00c 100644
--- a/gmime/gmime-parser-options.c
+++ b/gmime/gmime-parser-options.c
@@ -77,9 +77,19 @@ g_mime_parser_options_shutdown (void)
 void
 _g_mime_parser_options_warn (GMimeParserOptions *options, gint64 offset, guint errcode, const gchar *item)
 {
-       if ((options != NULL) && (options->warning_cb != NULL)) {
-               options->warning_cb(offset, errcode, item, options->warning_user_data);
+       GMimeWarningFunc warn;
+       gpointer user_data;
+       
+       if (options == NULL) {
+               user_data = default_options->warning_user_data;
+               warn = default_options->warning_cb;
+       } else {
+               user_data = options->warning_user_data;
+               warn = options->warning_cb;
        }
+       
+       if (warn != NULL)
+               warn (offset, errcode, item, user_data);
 }
 
 /**
@@ -421,7 +431,7 @@ g_mime_parser_options_set_fallback_charsets (GMimeParserOptions *options, const
 GMimeParserWarningFunc
 g_mime_parser_options_get_warning_callback (GMimeParserOptions *options)
 {
-       return (options != NULL) ? options->warning_cb : default_options->warning_cb;
+       return options ? options->warning_cb : default_options->warning_cb;
 }
 
 
@@ -437,7 +447,7 @@ void
 g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, 
gpointer user_data)
 {
        g_return_if_fail (options != NULL);
-
+       
        options->warning_cb = warning_cb;
        options->warning_user_data = user_data;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]