[gimp] plug-ins: use the same compat loading code in file-gih and file-gbr



commit cecd3fb057513a277b7aa4d31e228c25238d6166
Author: Michael Natterer <mitch gimp org>
Date:   Sun Nov 17 14:52:27 2013 +0100

    plug-ins: use the same compat loading code in file-gih and file-gbr
    
    It was the same before, but now it's even more consistent.

 plug-ins/common/file-gbr.c |    7 ++++---
 plug-ins/common/file-gih.c |   23 ++++++++++++++---------
 2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/plug-ins/common/file-gbr.c b/plug-ins/common/file-gbr.c
index 2acfb42..0c3f8aa 100644
--- a/plug-ins/common/file-gbr.c
+++ b/plug-ins/common/file-gbr.c
@@ -481,12 +481,13 @@ load_image (GFile   *file,
       {
         PatternHeader ph;
 
-        /*  For backwards-compatibility, check if a pattern follows.
-            The obsolete .gpb format did it this way.  */
+        /* For backwards-compatibility, check if a pattern follows.
+         * The obsolete .gpb format did it this way.
+         */
 
         if (g_input_stream_read_all (input, &ph, sizeof (PatternHeader),
                                      &bytes_read, NULL, NULL) &&
-            bytes_read == sizeof(PatternHeader))
+            bytes_read == sizeof (PatternHeader))
           {
             /*  rearrange the bytes in each unsigned int  */
             ph.header_size  = g_ntohl (ph.header_size);
diff --git a/plug-ins/common/file-gih.c b/plug-ins/common/file-gih.c
index 505317c..b3840a8 100644
--- a/plug-ins/common/file-gih.c
+++ b/plug-ins/common/file-gih.c
@@ -518,9 +518,9 @@ gih_load_one_brush (GInputStream  *input,
        * The obsolete .gpb format did it this way.
        */
 
-      if (g_input_stream_read_all (input, &ph, sizeof (ph),
+      if (g_input_stream_read_all (input, &ph, sizeof (PatternHeader),
                                    &bytes_read, NULL, error) &&
-          bytes_read == sizeof (ph))
+          bytes_read == sizeof (PatternHeader))
         {
           /*  rearrange the bytes in each unsigned int  */
           ph.header_size  = g_ntohl (ph.header_size);
@@ -530,12 +530,16 @@ gih_load_one_brush (GInputStream  *input,
           ph.bytes        = g_ntohl (ph.bytes);
           ph.magic_number = g_ntohl (ph.magic_number);
 
-          if (ph.magic_number == GPATTERN_MAGIC && ph.version == 1 &&
-              ph.header_size > sizeof (ph) &&
-              ph.bytes == 3 && ph.width == bh.width && ph.height == bh.height &&
-              g_seekable_seek (G_SEEKABLE (input),
-                               ph.header_size - sizeof (ph), G_SEEK_CUR,
-                               NULL, NULL))
+          if (ph.magic_number == GPATTERN_MAGIC        &&
+              ph.version      == 1                     &&
+              ph.header_size  > sizeof (PatternHeader) &&
+              ph.bytes        == 3                     &&
+              ph.width        == bh.width              &&
+              ph.height       == bh.height             &&
+              g_input_stream_skip (input,
+                                   ph.header_size - sizeof (PatternHeader),
+                                   NULL, NULL) ==
+              ph.header_size - sizeof (PatternHeader))
             {
               guchar *plain_brush = brush_buf;
               gint    i;
@@ -545,7 +549,8 @@ gih_load_one_brush (GInputStream  *input,
 
               for (i = 0; i < ph.width * ph.height; i++)
                 {
-                  if (! g_input_stream_read_all (input, brush_buf + i * 4, 3,
+                  if (! g_input_stream_read_all (input,
+                                                 brush_buf + i * 4, 3,
                                                  &bytes_read, NULL, error) ||
                       bytes_read != 3)
                     {


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