2014.12.29 20:26 "[Tiff] [PATCH][cosmetics] Fix indentation for few last commits", by Yuriy M. Kaminskiy
Only cosmetic changes to improve consistency with surrounding code (esp. tab size), no semantic change.
Index: tiff-4.0.x-20141227/libtiff/tif_dir.c
===================================================================
--- tiff-4.0.x-20141227.orig/libtiff/tif_dir.c 2014-12-28 17:19:40.708097136 +0300
+++ tiff-4.0.x-20141227/libtiff/tif_dir.c 2014-12-28 17:20:26.004098115 +0300
@@ -160,7 +160,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va
TIFFDirectory* td = &tif->tif_dir;
int status = 1;
uint32 v32, i, v;
- double dblval;
+ double dblval;
char* s;
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
uint32 standard_tag = tag;
@@ -285,15 +285,15 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va
setDoubleArrayOneValue(&td->td_smaxsamplevalue,
va_arg(ap, double), td->td_samplesperpixel);
break;
case TIFFTAG_XRESOLUTION:
dblval = va_arg(ap, double);
if( dblval < 0 )
badvaluedouble;goto
+ dblval = va_arg(ap, double);
+ if (dblval < 0)
+ goto badvaluedouble;
td->td_xresolution = (float) dblval;
break;
case TIFFTAG_YRESOLUTION:
dblval = va_arg(ap, double);
if( dblval < 0 )
badvaluedouble;goto
+ dblval = va_arg(ap, double);
+ if (dblval < 0)
+ goto badvaluedouble;
td->td_yresolution = (float) dblval;
break;
case TIFFTAG_PLANARCONFIG:
@@ -702,15 +702,15 @@ badvalue32:
}
return (0);
badvaluedouble:
- {
const TIFFField* fip=TIFFFieldWithTag(tif,tag);
module, TIFFErrorExt(tif->tif_clientdata,
Bad value %f for \"%s\" tag", "%s:
dblval, tif->tif_name,
? fip->field_name : "Unknown");fip
va_end(ap);
- }
- return (0);
+ {
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "%s: Bad value %f for \"%s\" tag",
+ tif->tif_name, dblval,
+ fip ? fip->field_name : "Unknown");
+ va_end(ap);
+ }
+ return (0);
}
/*
Index: tiff-4.0.x-20141227/libtiff/tif_dirread.c
===================================================================
--- tiff-4.0.x-20141227.orig/libtiff/tif_dirread.c 2014-12-28 17:19:40.688097304 +0300
+++ tiff-4.0.x-20141227/libtiff/tif_dirread.c 2014-12-28 17:20:26.008099548 +0300
@@ -3430,7 +3430,7 @@ TIFFReadDirectory(TIFF* tif)
const TIFFField* fip;
uint32 fii=FAILED_FII;
toff_t nextdiroff;
int bitspersample_read = FALSE;
+ int bitspersample_read = FALSE;
tif->tif_diroff=tif->tif_nextdiroff;
if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
@@ -3708,8 +3708,8 @@ TIFFReadDirectory(TIFF* tif)
}
if
(!TIFFSetField(tif,dp->tdir_tag,value))
goto
bad;
if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE )
= TRUE; bitspersample_read
+ if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE)
+ bitspersample_read = TRUE;
}
break;
case TIFFTAG_SMINSAMPLEVALUE:
@@ -3767,19 +3767,20 @@ TIFFReadDirectory(TIFF* tif)
uint32
countrequired;
uint32
incrementpersample;
uint16*
value=NULL;
/* It would be dangerous to instanciate those tag values
*/
since if td_bitspersample has not yet been read (due /*
to */
unordered tags), it could be read afterwards with a /*
*/
values greater than the default one (1), which may /*
cause *//* crashes in user code */
!bitspersample_read )if(
- {
fip = TIFFFieldWithTag(tif,dp->tdir_tag);
TIFFWarningExt(tif->tif_clientdata,module,"Ignoring %s since BitsPerSample tag
not found",
? fip->field_name: "unknown fip
tagname");
- continue;
- }
+ /*
+ * It would be dangerous to instanciate those tag values
+ * since if td_bitspersample has not yet been read (due to
+ * unordered tags), it could be read afterwards with a
+ * values greater than the default one (1), which may cause
+ * crashes in user code
+ */
+ if (!bitspersample_read) {
+ fip = TIFFFieldWithTag(tif,dp->tdir_tag);
+ TIFFWarningExt(tif->tif_clientdata,module,
+ "Ignoring %s since BitsPerSample tag not found",
+ fip ? fip->field_name : "unknown tagname");
+ continue;
+ }
countpersample=(1L<<tif->tif_dir.td_bitspersample);
if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample))
{
@@ -4295,8 +4296,8 @@ EstimateStripByteCounts(TIFF* tif, TIFFD
TIFFDirectory *td = &tif->tif_dir;
uint32 strip;
- if( !_TIFFFillStriles( tif ) )
- return -1;
+ if (!_TIFFFillStriles(tif))
+ return -1;
if (td->td_stripbytecount)
_TIFFfree(td->td_stripbytecount);
Index: tiff-4.0.x-20141227/libtiff/tif_getimage.c
===================================================================
--- tiff-4.0.x-20141227.orig/libtiff/tif_getimage.c 2014-12-28 17:19:40.672098904 +0300
+++ tiff-4.0.x-20141227/libtiff/tif_getimage.c 2014-12-28 17:20:26.012096581 +0300 @@ -182,23 +182,21 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[102
"Planarconfiguration",
td->td_planarconfig);
return
(0);
}
- if( td->td_samplesperpixel != 3 )
- {
sprintf(emsg,
can not handle image with %s=%d", "Sorry,
td->td_samplesperpixel);"Samples/pixel",
- return 0;
- }
+ if (td->td_samplesperpixel != 3) {
+ sprintf(emsg,
+ "Sorry, can not handle image with %s=%d",
+ "Samples/pixel", td->td_samplesperpixel);
+ return 0;
+ }
break;
case PHOTOMETRIC_CIELAB:
if( td->td_samplesperpixel != 3 || td->td_bitspersample != 8 )
- {
sprintf(emsg,
can not handle image with %s=%d and %s=%d", "Sorry,
td->td_samplesperpixel, "Samples/pixel",
td->td_bitspersample);"Bits/sample",
- return 0;
- }
+ if (td->td_samplesperpixel != 3 || td->td_bitspersample != 8) {
+ sprintf(emsg,
+ "Sorry, can not handle image with %s=%d and %s=%d",
+ "Samples/pixel", td->td_samplesperpixel,
+ "Bits/sample", td->td_bitspersample);
+ return 0;
+ }
break;
default:
sprintf(emsg, "Sorry, can not handle image with
%s=%d",
Index: tiff-4.0.x-20141227/libtiff/tif_next.c
===================================================================
--- tiff-4.0.x-20141227.orig/libtiff/tif_next.c 2014-12-28 17:19:40.656098549 +0300
+++ tiff-4.0.x-20141227/libtiff/tif_next.c 2014-12-28 17:20:26.012096581 +0300
@@ -101,9 +101,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize
}
default: {
uint32 npixels = 0, grey;
- uint32 imagewidth = tif->tif_dir.td_imagewidth;
if( isTiled(tif) )
= tif->tif_dir.td_tilewidth;imagewidth
+ uint32 imagewidth = isTiled(tif) ? tif->tif_dir.td_tilewidth : tif->tif_dir.td_imagewidth;
/*
* The scanline is composed of a sequence
of constant
@@ -148,8 +146,7 @@ NeXTPreDecode(TIFF* tif, uint16 s)
TIFFDirectory *td = &tif->tif_dir;
(void)s;
- if( td->td_bitspersample != 2 )
- {
+ if (td->td_bitspersample != 2) {
TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d",
td->td_bitspersample);
return (0);
Index: tiff-4.0.x-20141227/tools/bmp2tiff.c
===================================================================
--- tiff-4.0.x-20141227.orig/tools/bmp2tiff.c 2014-12-28 17:19:40.640097706 +0300
+++ tiff-4.0.x-20141227/tools/bmp2tiff.c 2014-12-28 17:20:26.012096581 +0300
@@ -403,13 +403,12 @@ main(int argc, char* argv[])
width = info_hdr.iWidth;
length = (info_hdr.iHeight > 0)? info_hdr.iHeight: -info_hdr.iHeight;
if( width <= 0 || length <= 0 )
{
TIFFError(infilename,
dimensions of BMP file" );"Invalid
- close(fd);
- return -1;
- }
+ if (width <= 0 || length <= 0) {
+ TIFFError(infilename,
+ "Invalid dimensions of BMP file" );
+ close(fd);
+ return -1;
+ }
switch (info_hdr.iBitCount)
{
@@ -600,14 +599,13 @@ main(int argc, char* argv[])
compr_size = file_hdr.iSize -
file_hdr.iOffBits;
uncompr_size = width * length;
/* Detect int overflow */
uncompr_size / width != length )if(
{
TIFFError(infilename,
dimensions of BMP file" );"Invalid
- close(fd);
- return -1;
- }
+ /* Detect int overflow */
+ if (uncompr_size / width != length) {
+ TIFFError(infilename,
+ "Invalid dimensions of BMP file" );
+ close(fd);
+ return -1;
+ }
comprbuf = (unsigned char *) _TIFFmalloc( compr_size );
if (!comprbuf) {
TIFFError(infilename,
Index: tiff-4.0.x-20141227/tools/thumbnail.c
===================================================================
--- tiff-4.0.x-20141227.orig/tools/thumbnail.c 2014-12-28 17:19:40.624099306 +0300
+++ tiff-4.0.x-20141227/tools/thumbnail.c 2014-12-28 17:20:26.012096581 +0300
@@ -273,27 +273,26 @@ static void
cpTags(TIFF* in, TIFF* out)
{
struct cpTag *p;
- for (p = tags; p < &tags[NTAGS]; p++)
- {
- /* Horrible: but TIFFGetField() expects 2 arguments to be passed */
- /* if we request a tag that is defined in a codec, but that codec */
- /* isn't used */
- if( p->tag == TIFFTAG_GROUP3OPTIONS )
- {
- uint16 compression;
- if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
- compression != COMPRESSION_CCITTFAX3 )
- continue;
- }
- if( p->tag == TIFFTAG_GROUP4OPTIONS )
- {
- uint16 compression;
- if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
- compression != COMPRESSION_CCITTFAX4 )
- continue;
- }
- cpTag(in, out, p->tag, p->count, p->type);
+ for (p = tags; p < &tags[NTAGS]; p++) {
+ /*
+ * Horrible: but TIFFGetField() expects 2 arguments to be passed
+ * if we request a tag that is defined in a codec, but that codec
+ * isn't used
+ */
+ if (p->tag == TIFFTAG_GROUP3OPTIONS) {
+ uint16 compression;
+ if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
+ compression != COMPRESSION_CCITTFAX3 )
+ continue;
}
+ if (p->tag == TIFFTAG_GROUP4OPTIONS) {
+ uint16 compression;
+ if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
+ compression != COMPRESSION_CCITTFAX4 )
+ continue;
+ }
+ cpTag(in, out, p->tag, p->count, p->type);
+ }
}
#undef NTAGS
@@ -567,14 +566,15 @@ setImage1(const uint8* br, uint32 rw, ui
while (err >= limit) {
err -= limit;
sy++;
- if (err >= limit)
- {
- /* We should perhaps error loudly, but I can't make sense of that */
- /* code... */
- if( nrows == 256 )
- break;
- rows[nrows++] = br + bpr*sy;
- }
+ if (err >= limit) {
+ /*
+ * We should perhaps error loudly, but I can't make sense of that
+ * code...
+ */
+ if( nrows == 256 )
+ break;
+ rows[nrows++] = br + bpr*sy;
+ }
}
setrow(row, nrows, rows);
row += tnw;
Index: tiff-4.0.x-20141227/tools/tiff2pdf.c
===================================================================
--- tiff-4.0.x-20141227.orig/tools/tiff2pdf.c 2014-12-28 17:19:40.612098918 +0300
+++ tiff-4.0.x-20141227/tools/tiff2pdf.c 2014-12-28 17:20:26.016097525 +0300
@@ -1176,27 +1176,25 @@ void t2p_read_tiff_init(T2P* t2p, TIFF*
}
t2p->tiff_tiles[i].tiles_tilecount=
t2p->tiff_pages[i].page_tilecount;
- if( (TIFFGetField(input, TIFFTAG_PLANARCONFIG, &xuint16) != 0)
- && (xuint16 == PLANARCONFIG_SEPARATE ) ){
- if( !TIFFGetField(input, TIFFTAG_SAMPLESPERPIXEL, &xuint16) )
- {
- TIFFError(
- TIFF2PDF_MODULE,
- "Missing SamplesPerPixel, %s",
- TIFFFileName(input));
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
- if( (t2p->tiff_tiles[i].tiles_tilecount % xuint16) != 0 )
- {
- TIFFError(
- TIFF2PDF_MODULE,
- "Invalid tile count, %s",
- TIFFFileName(input));
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
- t2p->tiff_tiles[i].tiles_tilecount/= xuint16;
+ if ((TIFFGetField(input, TIFFTAG_PLANARCONFIG, &xuint16) != 0)
+ && (xuint16 == PLANARCONFIG_SEPARATE)) {
+ if (!TIFFGetField(input, TIFFTAG_SAMPLESPERPIXEL, &xuint16)) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Missing SamplesPerPixel, %s",
+ TIFFFileName(input));
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
+ if ((t2p->tiff_tiles[i].tiles_tilecount % xuint16) != 0) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Invalid tile count, %s",
+ TIFFFileName(input));
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
+ t2p->tiff_tiles[i].tiles_tilecount/= xuint16;
}
if( t2p->tiff_tiles[i].tiles_tilecount > 0){
t2p->pdf_xrefcount +=
@@ -1608,22 +1606,22 @@ void t2p_read_tiff_data(T2P* t2p, TIFF*
#endif
break;
case PHOTOMETRIC_CIELAB:
- if( t2p->tiff_samplesperpixel != 3){
- TIFFError(
- TIFF2PDF_MODULE,
- "Unsupported samplesperpixel = %d for CIELAB",
- t2p->tiff_samplesperpixel);
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
- if( t2p->tiff_bitspersample != 8){
- TIFFError(
- TIFF2PDF_MODULE,
- "Invalid bitspersample = %d for CIELAB",
- t2p->tiff_bitspersample);
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
+ if (t2p->tiff_samplesperpixel != 3) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Unsupported samplesperpixel = %d for CIELAB",
+ t2p->tiff_samplesperpixel);
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
+ if (t2p->tiff_bitspersample != 8) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Invalid bitspersample = %d for CIELAB",
+ t2p->tiff_bitspersample);
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
t2p->pdf_labrange[0]= -127;
t2p->pdf_labrange[1]= 127;
t2p->pdf_labrange[2]= -127;
@@ -1639,22 +1637,22 @@ void t2p_read_tiff_data(T2P* t2p, TIFF*
t2p->pdf_colorspace=T2P_CS_LAB;
break;
case PHOTOMETRIC_ITULAB:
- if( t2p->tiff_samplesperpixel != 3){
- TIFFError(
- TIFF2PDF_MODULE,
- "Unsupported samplesperpixel = %d for ITULAB",
- t2p->tiff_samplesperpixel);
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
- if( t2p->tiff_bitspersample != 8){
- TIFFError(
- TIFF2PDF_MODULE,
- "Invalid bitspersample = %d for ITULAB",
- t2p->tiff_bitspersample);
- t2p->t2p_error = T2P_ERR_ERROR;
- return;
- }
+ if (t2p->tiff_samplesperpixel != 3) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Unsupported samplesperpixel = %d for ITULAB",
+ t2p->tiff_samplesperpixel);
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
+ if (t2p->tiff_bitspersample != 8) {
+ TIFFError(
+ TIFF2PDF_MODULE,
+ "Invalid bitspersample = %d for ITULAB",
+ t2p->tiff_bitspersample);
+ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
t2p->pdf_labrange[0]=-85;
t2p->pdf_labrange[1]=85;
t2p->pdf_labrange[2]=-75;
Index: tiff-4.0.x-20141227/tools/tiffdump.c
===================================================================
--- tiff-4.0.x-20141227.orig/tools/tiffdump.c 2014-12-28 17:19:40.596098563 +0300
+++ tiff-4.0.x-20141227/tools/tiffdump.c 2014-12-28 17:20:26.020097981 +0300
@@ -389,7 +389,7 @@ ReadDirectory(int fd, unsigned int ix, u
void* datamem;
uint64 dataoffset;
int datatruncated;
- int datasizeoverflow;
+ int datasizeoverflow;
tag = *(uint16*)dp;
if (swabflag)
@@ -429,7 +429,7 @@ ReadDirectory(int fd, unsigned int ix, u
else
typewidth = datawidth[type];
datasize = count*typewidth;
- datasizeoverflow = (typewidth > 0 && datasize / typewidth != count);
+ datasizeoverflow = (typewidth > 0 && datasize / typewidth != count);
datafits = 1;
datamem = dp;
dataoffset = 0;
Index: tiff-4.0.x-20141227/tools/tiffset.c
===================================================================
--- tiff-4.0.x-20141227.orig/tools/tiffset.c 2014-12-28 17:25:45.908097678 +0300
+++ tiff-4.0.x-20141227/tools/tiffset.c 2014-12-28 17:30:00.348095870 +0300
@@ -106,22 +106,22 @@ main(int argc, char* argv[])
}
arg_index++;
}
- /* Add unset option to tiffset -- Zach Baker (niquil@niquil.net) 11/14/2012 */
- if (strcmp(argv[arg_index],"-u") == 0 && arg_index < argc-2) {
+ /* Add unset option to tiffset -- Zach Baker (niquil@niquil.net) 11/14/2012 */
+ if (strcmp(argv[arg_index],"-u") == 0 && arg_index < argc-2) {
const TIFFField *fip;
const char *tagname;
+
arg_index++;
tagname = argv[arg_index];
fip = GetField(tiff, tagname);
+
if (!fip)
return 3;
if (TIFFUnsetField(tiff, TIFFFieldTag(fip)) != 1)
- {
- fprintf(stderr, "Failed to unset %s\n", TIFFFieldName(fip));
- }
+ fprintf(stderr, "Failed to unset %s\n", TIFFFieldName(fip));
arg_index++;
- } else if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) {
+ } else if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) {
const TIFFField *fip;
const char *tagname;