]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Remove use of SEEK_CUR in the image reader.
authorNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2014 03:32:28 +0000 (22:32 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2014 05:40:50 +0000 (00:40 -0500)
Other than this one seek, all other seeks used by the library are of the
SEEK_SET type.  Only requiring SEEK_SET will simplify implementations of
lbx_file_ops quite a lot, so let's get rid of this one.

The whole point of this seek is to skip just one byte — a normal read
works just as well.

src/image.c

index adc6a43427289a20b581255abd70be6c1b3c908f..bd207e7d3dbc124dd82278db5bc96694665b31e9 100644 (file)
@@ -313,11 +313,14 @@ long lbx_img_read_row_data(struct lbx_image *pub, void *buf)
                return -1;
        }
 
-       if (!(img->flags & FLAG_RAW)) {
-               /* Skip padding byte, if any */
-               if (img->currentn % 2) {
-                       if (img->fops->seek(img->f, 1, SEEK_CUR))
-                               return -1;
+       if (!(img->flags & FLAG_RAW) && img->currentn % 2) {
+               unsigned char c;
+
+               /* Skip padding byte */
+               if (img->fops->read(&c, 1, img->f) != 1) {
+                       if (img->fops->eof(img->f))
+                               lbx_error_raise(LBX_EEOF);
+                       return -1;
                }
        }