[gimp/gimp-2-8] app: revert xcf_write_int8() to work like in 2.8.10, and fix its return value



commit b2ef624e2645b6cb90974d36a7a5df5a7a45258f
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 9 22:45:58 2014 +0200

    app: revert xcf_write_int8() to work like in 2.8.10, and fix its return value
    
    This reverts one line of commit 0657a68d2ef18f9f8c67e9fad938406b1ff6f38f
    which is supposed to only add docs. Also, actually return the number of
    byzes written, not always the number of bytes we intended to write.

 app/xcf/xcf-write.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/app/xcf/xcf-write.c b/app/xcf/xcf-write.c
index bd90191..c451370 100644
--- a/app/xcf/xcf-write.c
+++ b/app/xcf/xcf-write.c
@@ -108,21 +108,21 @@ xcf_write_float (FILE           *fp,
  *
  * Returns: @count
  */
-
-/* TODO: shouldn't the return value (i.e. local variable total) mean the number of written bytes? */
 guint
 xcf_write_int8 (FILE           *fp,
                 const guint8   *data,
                 gint            count,
                 GError        **error)
 {
-  guint total = count;
+  guint total = 0;
 
   while (count > 0)
     {
       gint bytes = fwrite ((const gchar*) data, sizeof (gchar), count, fp);
 
-      if (bytes != count)
+      total += bytes;
+
+      if (bytes == 0)
         {
           g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
                        _("Error writing XCF: %s"), g_strerror (errno));


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