[libgsf] 2013-03-08 Morten Welinder <terra gnome org>



commit 23e9d702934c1c9ab941b4bf71cdde2bee14cfff
Author: Morten Welinder <terra gnome org>
Date:   Fri Mar 8 13:21:23 2013 -0500

    2013-03-08  Morten Welinder  <terra gnome org>
    
        * gsf/gsf-input.c (gsf_input_set_modtime): Change to transfer-none
        semantics.  All callers changed.
        * gsf/gsf-output.c (gsf_output_set_modtime): Change to
        transfer-none semantics.  All callers changed.

 ChangeLog              |    5 +++++
 gsf/gsf-infile-msole.c |   13 ++-----------
 gsf/gsf-infile-tar.c   |    6 +-----
 gsf/gsf-infile-zip.c   |    9 ++++++---
 gsf/gsf-input-gzip.c   |   13 +++++++------
 gsf/gsf-input-stdio.c  |    6 ++++--
 gsf/gsf-input.c        |    5 ++++-
 gsf/gsf-outfile-zip.c  |    8 +++++---
 gsf/gsf-output.c       |   13 ++++++-------
 9 files changed, 40 insertions(+), 38 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 32b9b97..60f8cd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-03-08  Morten Welinder  <terra gnome org>
 
+       * gsf/gsf-input.c (gsf_input_set_modtime): Change to transfer-none
+       semantics.  All callers changed.
+       * gsf/gsf-output.c (gsf_output_set_modtime): Change to
+       transfer-none semantics.  All callers changed.
+
        * gsf/gsf-outfile-msole.c (gsf_outfile_msole_close_root): Set
        modtime when available.
 
diff --git a/gsf/gsf-infile-msole.c b/gsf/gsf-infile-msole.c
index 0a55230..c945f32 100644
--- a/gsf/gsf-infile-msole.c
+++ b/gsf/gsf-infile-msole.c
@@ -647,12 +647,7 @@ ole_init_info (GsfInfileMSOle *ole, GError **err)
         * The spec says to ignore modtime for root object.  That doesn't
         * keep files from actually have a modtime there.
         */
-       if (ole->dirent->modtime) {
-               /* Copy */
-               gsf_input_set_modtime (GSF_INPUT (ole),
-                                      g_date_time_add (ole->dirent->modtime, 0));
-       }
-
+       gsf_input_set_modtime (GSF_INPUT (ole), ole->dirent->modtime);
 
        return FALSE;
 }
@@ -778,11 +773,7 @@ gsf_infile_msole_new_child (GsfInfileMSOle *parent,
 
        child->dirent = dirent;
        gsf_input_set_size (GSF_INPUT (child), (gsf_off_t) dirent->size);
-       if (dirent->modtime) {
-               /* Copy */
-               gsf_input_set_modtime (GSF_INPUT (child),
-                                      g_date_time_add (dirent->modtime, 0));
-       }
+       gsf_input_set_modtime (GSF_INPUT (child), dirent->modtime);
 
        /* The root dirent defines the small block file */
        if (dirent->index != 0) {
diff --git a/gsf/gsf-infile-tar.c b/gsf/gsf-infile-tar.c
index 99cdc9f..e0051d5 100644
--- a/gsf/gsf-infile-tar.c
+++ b/gsf/gsf-infile-tar.c
@@ -378,11 +378,7 @@ gsf_infile_tar_child_by_index (GsfInfile *infile, int target, GError **err)
                GsfInput *input = gsf_input_proxy_new_section (tar->source,
                                                               c->offset,
                                                               c->length);
-               if (c->modtime) {
-                       /* Copy */
-                       gsf_input_set_modtime (input,
-                                              g_date_time_add (c->modtime, 0));
-               }
+               gsf_input_set_modtime (input, c->modtime);
                gsf_input_set_name (input, c->name);
                return input;
        }
diff --git a/gsf/gsf-infile-zip.c b/gsf/gsf-infile-zip.c
index d987d89..0e7b5f7 100644
--- a/gsf/gsf-infile-zip.c
+++ b/gsf/gsf-infile-zip.c
@@ -636,9 +636,12 @@ gsf_infile_zip_new_child (GsfInfileZip *parent, GsfZipVDir *vdir, GError **err)
        if (dirent) {
                gsf_input_set_size (GSF_INPUT (child),
                                    (gsf_off_t) dirent->usize);
-               if (dirent->dostime)
-                       gsf_input_set_modtime (GSF_INPUT (child),
-                                              zip_make_modtime (dirent->dostime));
+
+               if (dirent->dostime) {
+                       GDateTime *modtime = zip_make_modtime (dirent->dostime);
+                       gsf_input_set_modtime (GSF_INPUT (child), modtime);
+                       g_date_time_unref (modtime);
+               }
 
                if (zip_child_init (child, err) != FALSE) {
                        g_object_unref (child);
diff --git a/gsf/gsf-input-gzip.c b/gsf/gsf-input-gzip.c
index 403be96..f66399b 100644
--- a/gsf/gsf-input-gzip.c
+++ b/gsf/gsf-input-gzip.c
@@ -81,7 +81,7 @@ check_header (GsfInputGZip *input)
                static guint8 const signature[2] = {0x1f, 0x8b};
                guint8 const *data;
                unsigned flags, len;
-               guint32 modtime;
+               guint32 modutime;
 
                /* Check signature */
                if (NULL == (data = gsf_input_read (input->source, 2 + 1 + 1 + 6, NULL)) ||
@@ -93,11 +93,12 @@ check_header (GsfInputGZip *input)
                if (data[2] != Z_DEFLATED || (flags & ~GZIP_HEADER_FLAGS) != 0)
                        return TRUE;
 
-               modtime = GSF_LE_GET_GUINT32 (data + 4);
-               if (modtime != 0)
-                       gsf_input_set_modtime
-                               (GSF_INPUT (input),
-                                g_date_time_new_from_unix_utc (modtime));
+               modutime = GSF_LE_GET_GUINT32 (data + 4);
+               if (modutime != 0) {
+                       GDateTime *modtime = g_date_time_new_from_unix_utc (modutime);
+                       gsf_input_set_modtime (GSF_INPUT (input), modtime);
+                       g_date_time_unref (modtime);
+               }
 
                /* If we have the size, don't bother seeking to the end.  */
                if (input->uncompressed_size < 0) {
diff --git a/gsf/gsf-input-stdio.c b/gsf/gsf-input-stdio.c
index c20be0e..783fe75 100644
--- a/gsf/gsf-input-stdio.c
+++ b/gsf/gsf-input-stdio.c
@@ -149,6 +149,7 @@ gsf_input_stdio_new (char const *filename, GError **err)
        gsf_input_set_size (GSF_INPUT (input), size);
        gsf_input_set_name_from_filename (GSF_INPUT (input), filename);
        if (st.st_mtime != (time_t)-1) {
+               GDateTime *modtime;
                GTimeVal tv;
 
                tv.tv_sec = st.st_mtime;
@@ -160,8 +161,9 @@ gsf_input_stdio_new (char const *filename, GError **err)
                tv.tv_usec = 0;
 #endif
 
-               gsf_input_set_modtime (GSF_INPUT (input),
-                                      g_date_time_new_from_timeval_utc (&tv));
+               modtime = g_date_time_new_from_timeval_utc (&tv);
+               gsf_input_set_modtime (GSF_INPUT (input), modtime);
+               g_date_time_unref (modtime);
        }
 
        return GSF_INPUT (input);
diff --git a/gsf/gsf-input.c b/gsf/gsf-input.c
index 62deb93..39cb695 100644
--- a/gsf/gsf-input.c
+++ b/gsf/gsf-input.c
@@ -607,7 +607,7 @@ gsf_input_get_modtime (GsfInput *input)
 /**
  * gsf_input_set_modtime:
  * @input: the input stream
- * @modtime: (transfer full) (allow-none): the new modification time.
+ * @modtime: (transfer none) (allow-none): the new modification time.
  *
  * protected.
  *
@@ -618,6 +618,9 @@ gsf_input_set_modtime (GsfInput *input, GDateTime *modtime)
 {
        g_return_val_if_fail (GSF_IS_INPUT (input), FALSE);
 
+       if (modtime)
+               modtime = g_date_time_add (modtime, 0); /* Copy */
+
        /* This actually also works for null modtime.  */
        g_object_set_data_full (G_OBJECT (input),
                                MODTIME_ATTR, modtime,
diff --git a/gsf/gsf-outfile-zip.c b/gsf/gsf-outfile-zip.c
index 0892ffd..a511717 100644
--- a/gsf/gsf-outfile-zip.c
+++ b/gsf/gsf-outfile-zip.c
@@ -132,9 +132,11 @@ gsf_outfile_zip_constructor (GType                  type,
                gsf_output_set_container (GSF_OUTPUT (zip), NULL);
        }
 
-       if (!gsf_output_get_modtime (GSF_OUTPUT (zip)))
-               gsf_output_set_modtime (GSF_OUTPUT (zip),
-                                       g_date_time_new_now_utc ());
+       if (!gsf_output_get_modtime (GSF_OUTPUT (zip))) {
+               GDateTime *modtime = g_date_time_new_now_utc ();
+               gsf_output_set_modtime (GSF_OUTPUT (zip), modtime);
+               g_date_time_unref (modtime);
+       }
 
        return (GObject *)zip;
 }
diff --git a/gsf/gsf-output.c b/gsf/gsf-output.c
index b0cc2cd..6d116c2 100644
--- a/gsf/gsf-output.c
+++ b/gsf/gsf-output.c
@@ -64,13 +64,9 @@ gsf_output_set_property (GObject      *object,
        case PROP_NAME:
                gsf_output_set_name (output, g_value_get_string (value));
                break;
-       case PROP_MODTIME: {
-               GDateTime *modtime = g_value_get_boxed (value);
-               if (modtime)
-                       modtime = g_date_time_add (modtime, 0); /* Copy */
-               gsf_output_set_modtime (output, modtime);
+       case PROP_MODTIME:
+               gsf_output_set_modtime (output, g_value_get_boxed (value));
                break;
-       }
        case PROP_CONTAINER:
                gsf_output_set_container (output, g_value_get_object (value));
                break;
@@ -643,7 +639,7 @@ gsf_output_get_modtime (GsfOutput *output)
 /**
  * gsf_output_set_modtime:
  * @output: the output stream
- * @modtime: (transfer full) (allow-none): the new modification time.
+ * @modtime: (transfer none) (allow-none): the new modification time.
  *
  * Returns: %TRUE if the assignment was ok.
  */
@@ -652,6 +648,9 @@ gsf_output_set_modtime (GsfOutput *output, GDateTime *modtime)
 {
        g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE);
 
+       if (modtime)
+               modtime = g_date_time_add (modtime, 0); /* Copy */
+
        /* This actually also works for null modtime.  */
        g_object_set_data_full (G_OBJECT (output),
                                MODTIME_ATTR, modtime,


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