Skip to content

Commit

Permalink
tiff: declare var at begin of block
Browse files Browse the repository at this point in the history
  • Loading branch information
olt committed Jun 3, 2019
1 parent 58df7dd commit 39b1e55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/encode.c
Expand Up @@ -734,10 +734,11 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
}

if (PyTuple_Check(value)) {
is_var_length = 1;

Py_ssize_t len;
len = PyTuple_Size(value);

is_var_length = 1;

if (!len) {
continue;
}
Expand Down
24 changes: 13 additions & 11 deletions src/libImaging/TiffDecode.c
Expand Up @@ -525,23 +525,25 @@ int ImagingLibTiffMergeFieldInfo(ImagingCodecState state, TIFFDataType field_typ
int status = 0;

// custom fields added with ImagingLibTiffMergeFieldInfo are only used for
// decoding, ignore read_count;
int read_count = 0;

// decoding, ignore readcount;
int readcount = 0;
// we support writing single value, or a variable number of values
int write_count = 1;
int writecount = 1;
// whether the first value should encode the number of values.
int passcount = 0;

TIFFFieldInfo info[] = {
{ key, readcount, writecount, field_type, FIELD_CUSTOM, 1, passcount, field_name }
};

if (is_var_length) {
write_count = -1;
info[0].field_writecount = -1;
}

// whether the first value should encode the number of values.
int passcount = 0;
if (is_var_length && field_type != TIFF_ASCII) {
passcount = 1;
info[0].field_passcount = 1;
}
const TIFFFieldInfo info[] = {
{ key, read_count, write_count, field_type, FIELD_CUSTOM, 1, passcount, field_name }
};

n = sizeof(info) / sizeof(info[0]);

// Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7
Expand Down

0 comments on commit 39b1e55

Please sign in to comment.