libtiff: Reformatting in test/ using 'pre-commit run'

From dee020782c17c1388ca5774f9904d318b51b288b Mon Sep 17 00:00:00 2001
From: pre-commit run by Even Rouault <[EMAIL REDACTED]>
Date: Thu, 8 Dec 2022 19:19:21 +0100
Subject: [PATCH] Reformatting in test/ using 'pre-commit run'

---
 test/ascii_tag.c                 |  277 +--
 test/check_tag.c                 |  102 +-
 test/custom_dir.c                |  437 ++--
 test/custom_dir_EXIF_231.c       | 3176 +++++++++++++++++-------------
 test/defer_strile_loading.c      |  146 +-
 test/defer_strile_writing.c      |  114 +-
 test/long_tag.c                  |  243 +--
 test/rational_precision2double.c | 2135 +++++++++++---------
 test/raw_decode.c                |  471 ++---
 test/rewrite_tag.c               |  284 +--
 test/short_tag.c                 |  345 ++--
 test/strip.c                     |  490 ++---
 test/strip_rw.c                  |  240 +--
 test/test_append_to_strip.c      |   49 +-
 test/test_arrays.c               | 1464 +++++++-------
 test/test_arrays.h               |   18 +-
 test/test_directory.c            |  279 ++-
 test/test_open_options.c         |  103 +-
 test/test_signed_tags.c          |  757 ++++---
 test/testtypes.c                 |   35 +-
 test/tifftest.h                  |   19 +-
 21 files changed, 6177 insertions(+), 5007 deletions(-)

diff --git a/test/ascii_tag.c b/test/ascii_tag.c
index b7cbf12b..df29045a 100644
--- a/test/ascii_tag.c
+++ b/test/ascii_tag.c
@@ -1,23 +1,23 @@
 /*
  * Copyright (c) 2004, Andrey Kiselev  <dron@ak4719.spb.edu>
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  */
 
@@ -32,142 +32,151 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_UNISTD_H 
-# include <unistd.h> 
-#endif 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include "tiffio.h"
 
 static const char filename[] = "ascii_test.tiff";
 
-static const struct {
-	ttag_t		tag;
-	const char	*value;
-} ascii_tags[] = {
-	{ TIFFTAG_DOCUMENTNAME, "Test TIFF image" },
-	{ TIFFTAG_IMAGEDESCRIPTION, "Temporary test image" },
-	{ TIFFTAG_MAKE, "This is not scanned image" },
-	{ TIFFTAG_MODEL, "No scanner" },
-	{ TIFFTAG_PAGENAME, "Test page" },
-	{ TIFFTAG_SOFTWARE, "Libtiff library" },
-	{ TIFFTAG_DATETIME, "2004:09:10 16:09:00" },
-	{ TIFFTAG_ARTIST, "Andrey V. Kiselev" },
-	{ TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)" },
-	{ TIFFTAG_TARGETPRINTER, "No printer" },
-	{ TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" },
-	{ TIFFTAG_FAXSUBADDRESS, "Fax subaddress" },
-	/* DGN tags */
-	{ TIFFTAG_UNIQUECAMERAMODEL, "No camera" },
-	{ TIFFTAG_CAMERASERIALNUMBER, "1234567890" }
-};
-#define NTAGS   (sizeof (ascii_tags) / sizeof (ascii_tags[0]))
+static const struct
+{
+    ttag_t tag;
+    const char *value;
+} ascii_tags[] = {{TIFFTAG_DOCUMENTNAME, "Test TIFF image"},
+                  {TIFFTAG_IMAGEDESCRIPTION, "Temporary test image"},
+                  {TIFFTAG_MAKE, "This is not scanned image"},
+                  {TIFFTAG_MODEL, "No scanner"},
+                  {TIFFTAG_PAGENAME, "Test page"},
+                  {TIFFTAG_SOFTWARE, "Libtiff library"},
+                  {TIFFTAG_DATETIME, "2004:09:10 16:09:00"},
+                  {TIFFTAG_ARTIST, "Andrey V. Kiselev"},
+                  {TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)"},
+                  {TIFFTAG_TARGETPRINTER, "No printer"},
+                  {TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev"},
+                  {TIFFTAG_FAXSUBADDRESS, "Fax subaddress"},
+                  /* DGN tags */
+                  {TIFFTAG_UNIQUECAMERAMODEL, "No camera"},
+                  {TIFFTAG_CAMERASERIALNUMBER, "1234567890"}};
+#define NTAGS (sizeof(ascii_tags) / sizeof(ascii_tags[0]))
 
 static const char ink_names[] = "Red\0Green\0Blue";
 const int ink_names_size = 15;
 
-int
-main()
+int main()
 {
-	TIFF		*tif;
-	size_t		i;
-	unsigned char	buf[] = { 0, 127, 255 };
-	char		*value;
-
-	/* Test whether we can write tags. */
-	tif = TIFFOpen(filename, "w");
-	if (!tif) {
-		fprintf (stderr, "Can't create test TIFF file %s.\n", filename);
-		return 1;
-	}
-
-	if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1)) {
-		fprintf (stderr, "Can't set ImageWidth tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1)) {
-		fprintf (stderr, "Can't set ImageLength tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) {
-		fprintf (stderr, "Can't set BitsPerSample tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) {
-		fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) {
-		fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) {
-		fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
-		goto failure;
-	}
-
-	for (i = 0; i < NTAGS; i++) {
-		if (!TIFFSetField(tif, ascii_tags[i].tag,
-				  ascii_tags[i].value)) {
-			fprintf(stderr, "Can't set tag %"PRIu32".\n",
-				ascii_tags[i].tag);
-			goto failure;
-		}
-	}
-
-	/* InkNames tag has special form, so we handle it separately. */
-	if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) {
-		fprintf (stderr, "Can't set tag %d (NUMBEROFINKS).\n",
-                         TIFFTAG_NUMBEROFINKS);
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) {
-		fprintf (stderr, "Can't set tag %d (INKNAMES).\n",
-			 TIFFTAG_INKNAMES);
-		goto failure;
-	}
-
-	/* Write dummy pixel data. */
-	if (TIFFWriteScanline(tif, buf, 0, 0) == -1) {
-		fprintf (stderr, "Can't write image data.\n");
-		goto failure;
-	}
-
-	TIFFClose(tif);
-	
-	/* Ok, now test whether we can read written values. */
-	tif = TIFFOpen(filename, "r");
-	if (!tif) {
-		fprintf (stderr, "Can't open test TIFF file %s.\n", filename);
-		return 1;
-	}
-
-	for (i = 0; i < NTAGS; i++) {
-		if (!TIFFGetField(tif, ascii_tags[i].tag, &value)
-		    || strcmp(value, ascii_tags[i].value)) {
-			fprintf(stderr, "Can't get tag %"PRIu32".\n",
-				ascii_tags[i].tag);
-			goto failure;
-		}
-	}
-
-	if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value)
-	    || memcmp(value, ink_names, ink_names_size)) {
-		fprintf (stderr, "Can't get tag %d (INKNAMES).\n",
-			 TIFFTAG_INKNAMES);
-		goto failure;
-	}
-
-	TIFFClose(tif);
-	
-	/* All tests passed; delete file and exit with success status. */
-	unlink(filename);
-	return 0;
+    TIFF *tif;
+    size_t i;
+    unsigned char buf[] = {0, 127, 255};
+    char *value;
+
+    /* Test whether we can write tags. */
+    tif = TIFFOpen(filename, "w");
+    if (!tif)
+    {
+        fprintf(stderr, "Can't create test TIFF file %s.\n", filename);
+        return 1;
+    }
+
+    if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1))
+    {
+        fprintf(stderr, "Can't set ImageWidth tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1))
+    {
+        fprintf(stderr, "Can't set ImageLength tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8))
+    {
+        fprintf(stderr, "Can't set BitsPerSample tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf)))
+    {
+        fprintf(stderr, "Can't set SamplesPerPixel tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG))
+    {
+        fprintf(stderr, "Can't set PlanarConfiguration tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB))
+    {
+        fprintf(stderr, "Can't set PhotometricInterpretation tag.\n");
+        goto failure;
+    }
+
+    for (i = 0; i < NTAGS; i++)
+    {
+        if (!TIFFSetField(tif, ascii_tags[i].tag, ascii_tags[i].value))
+        {
+            fprintf(stderr, "Can't set tag %" PRIu32 ".\n", ascii_tags[i].tag);
+            goto failure;
+        }
+    }
+
+    /* InkNames tag has special form, so we handle it separately. */
+    if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3))
+    {
+        fprintf(stderr, "Can't set tag %d (NUMBEROFINKS).\n",
+                TIFFTAG_NUMBEROFINKS);
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names))
+    {
+        fprintf(stderr, "Can't set tag %d (INKNAMES).\n", TIFFTAG_INKNAMES);
+        goto failure;
+    }
+
+    /* Write dummy pixel data. */
+    if (TIFFWriteScanline(tif, buf, 0, 0) == -1)
+    {
+        fprintf(stderr, "Can't write image data.\n");
+        goto failure;
+    }
+
+    TIFFClose(tif);
+
+    /* Ok, now test whether we can read written values. */
+    tif = TIFFOpen(filename, "r");
+    if (!tif)
+    {
+        fprintf(stderr, "Can't open test TIFF file %s.\n", filename);
+        return 1;
+    }
+
+    for (i = 0; i < NTAGS; i++)
+    {
+        if (!TIFFGetField(tif, ascii_tags[i].tag, &value) ||
+            strcmp(value, ascii_tags[i].value))
+        {
+            fprintf(stderr, "Can't get tag %" PRIu32 ".\n", ascii_tags[i].tag);
+            goto failure;
+        }
+    }
+
+    if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value) ||
+        memcmp(value, ink_names, ink_names_size))
+    {
+        fprintf(stderr, "Can't get tag %d (INKNAMES).\n", TIFFTAG_INKNAMES);
+        goto failure;
+    }
+
+    TIFFClose(tif);
+
+    /* All tests passed; delete file and exit with success status. */
+    unlink(filename);
+    return 0;
 
 failure:
-	/* 
-	 * Something goes wrong; close file and return unsuccessful status.
-	 * Do not remove the file for further manual investigation.
-	 */
-	TIFFClose(tif);
-	return 1;
+    /*
+     * Something goes wrong; close file and return unsuccessful status.
+     * Do not remove the file for further manual investigation.
+     */
+    TIFFClose(tif);
+    return 1;
 }
diff --git a/test/check_tag.c b/test/check_tag.c
index 63554866..66dcbb97 100644
--- a/test/check_tag.c
+++ b/test/check_tag.c
@@ -1,23 +1,23 @@
 /*
  * Copyright (c) 2004, Andrey Kiselev  <dron@ak4719.spb.edu>
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  */
 
@@ -29,61 +29,59 @@
 
 #include "tiffio.h"
 
-int
-CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value)
+int CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value)
 {
-	uint16_t tmp = 123;
+    uint16_t tmp = 123;
 
-	if (!TIFFGetField(tif, field, &tmp)) {
-		fprintf (stderr, "Problem fetching tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
-	if (tmp != value) {
-		fprintf (stderr, "Wrong SHORT value fetched for tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
+    if (!TIFFGetField(tif, field, &tmp))
+    {
+        fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field);
+        return -1;
+    }
+    if (tmp != value)
+    {
+        fprintf(stderr, "Wrong SHORT value fetched for tag %" PRIu32 ".\n",
+                field);
+        return -1;
+    }
 
-	return 0;
+    return 0;
 }
 
-int
-CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values)
+int CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values)
 {
-	uint16_t tmp[2] = {123, 456 };
+    uint16_t tmp[2] = {123, 456};
 
-	if (!TIFFGetField(tif, field, tmp, tmp + 1)) {
-		fprintf (stderr, "Problem fetching tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
-	if (tmp[0] != values[0] || tmp[1] != values[1]) {
-		fprintf (stderr, "Wrong SHORT PAIR fetched for tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
+    if (!TIFFGetField(tif, field, tmp, tmp + 1))
+    {
+        fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field);
+        return -1;
+    }
+    if (tmp[0] != values[0] || tmp[1] != values[1])
+    {
+        fprintf(stderr, "Wrong SHORT PAIR fetched for tag %" PRIu32 ".\n",
+                field);
+        return -1;
+    }
 
-	return 0;
+    return 0;
 }
 
-int
-CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value)
+int CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value)
 {
-	uint32_t tmp = 123;
+    uint32_t tmp = 123;
 
-	if (!TIFFGetField(tif, field, &tmp)) {
-		fprintf (stderr, "Problem fetching tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
-	if (tmp != value) {
-		fprintf (stderr, "Wrong LONG value fetched for tag %"PRIu32".\n",
-			 field);
-		return -1;
-	}
+    if (!TIFFGetField(tif, field, &tmp))
+    {
+        fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field);
+        return -1;
+    }
+    if (tmp != value)
+    {
+        fprintf(stderr, "Wrong LONG value fetched for tag %" PRIu32 ".\n",
+                field);
+        return -1;
+    }
 
-	return 0;
+    return 0;
 }
-
-
diff --git a/test/custom_dir.c b/test/custom_dir.c
index 3e93d25e..34c51276 100644
--- a/test/custom_dir.c
+++ b/test/custom_dir.c
@@ -1,23 +1,23 @@
 /*
  * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com>
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  */
 
@@ -31,213 +31,240 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_UNISTD_H 
-# include <unistd.h> 
-#endif 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
-#include "tiffio.h"
 #include "tif_dir.h"
+#include "tiffio.h"
 #include "tifftest.h"
 
 static const char filename[] = "custom_dir.tif";
 
-#define	SPP	3		/* Samples per pixel */
-const uint16_t	width = 1;
-const uint16_t	length = 1;
-const uint16_t	bps = 8;
-const uint16_t	photometric = PHOTOMETRIC_RGB;
-const uint16_t	rows_per_strip = 1;
-const uint16_t	planarconfig = PLANARCONFIG_CONTIG;
-
-static TIFFField
-customFields[] = {
-	{ TIFFTAG_IMAGEWIDTH, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom1", NULL },
-	{ TIFFTAG_DOTRANGE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom2", NULL },
+#define SPP 3 /* Samples per pixel */
+const uint16_t width = 1;
+const uint16_t length = 1;
+const uint16_t bps = 8;
+const uint16_t photometric = PHOTOMETRIC_RGB;
+const uint16_t rows_per_strip = 1;
+const uint16_t planarconfig = PLANARCONFIG_CONTIG;
+
+static TIFFField customFields[] = {
+    {TIFFTAG_IMAGEWIDTH, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII,
+     TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom1", NULL},
+    {TIFFTAG_DOTRANGE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII,
+     TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom2", NULL},
 };
 
-static TIFFFieldArray customFieldArray = { tfiatOther, 0, 2, customFields };
+static TIFFFieldArray customFieldArray = {tfiatOther, 0, 2, customFields};
 
-int
-main()
+int main()
 {
-	TIFF		*tif;
-	unsigned char	buf[SPP] = { 0, 127, 255 };
-	uint64_t          dir_offset = 0, dir_offset2 = 0;
-	uint64_t          read_dir_offset = 0, read_dir_offset2 = 0;
-	uint64_t          *dir_offset2_ptr = NULL;
-	char           *ascii_value;
-	uint16_t          count16 = 0;
-	
-
-	/* We write the main directory as a simple image. */
-	tif = TIFFOpen(filename, "w+");
-	if (!tif) {
-		fprintf (stderr, "Can't create test TIFF file %s.\n", filename);
-		return 1;
-	}
-
-	if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) {
-		fprintf (stderr, "Can't set ImageWidth tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) {
-		fprintf (stderr, "Can't set ImageLength tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) {
-		fprintf (stderr, "Can't set BitsPerSample tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) {
-		fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) {
-		fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) {
-		fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
-		goto failure;
-	}
-	if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) {
-		fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
-		goto failure;
-	}
-
-	/* Write dummy pixel data. */
-	if (TIFFWriteScanline(tif, buf, 0, 0) == -1) {
-		fprintf (stderr, "Can't write image data.\n");
-		goto failure;
-	}
-
-        if (!TIFFWriteDirectory( tif )) {
-		fprintf (stderr, "TIFFWriteDirectory() failed.\n");
-		goto failure;
-	}
-
-	/* 
-	 * Now create an EXIF directory. 
-	 */
-	if (TIFFCreateEXIFDirectory(tif) != 0) {
-		fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" );
-		goto failure;
-	}
-
-	if (!TIFFSetField( tif, EXIFTAG_SPECTRALSENSITIVITY, "EXIF Spectral Sensitivity")) {
-		fprintf (stderr, "Can't write SPECTRALSENSITIVITY\n" );
-		goto failure;
-	}		
-	
-        if (!TIFFWriteCustomDirectory( tif, &dir_offset )) {
-		fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
-		goto failure;
-	}
-
-	/*
-	 * Now create a custom directory with tags that conflict with mainline 
-	 * TIFF tags.
-	 */
-	
-	TIFFFreeDirectory( tif );
-	if (TIFFCreateCustomDirectory(tif, &customFieldArray) != 0) {
-		fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" );
-		goto failure;
-	}
-
-	if (!TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, "*Custom1")) { /* not really IMAGEWIDTH */
-		fprintf (stderr, "Can't write pseudo-IMAGEWIDTH.\n" );
-		goto failure;
-	}		
-	
-	if (!TIFFSetField( tif, TIFFTAG_DOTRANGE, "*Custom2")) { /* not really DOTWIDTH */
-		fprintf (stderr, "Can't write pseudo-DOTWIDTH.\n" );
-		goto failure;
-	}		
-	
-        if (!TIFFWriteCustomDirectory( tif, &dir_offset2 )) {
-		fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
-		goto failure;
-	}
-
-	/*
-	 * Go back to the first directory, and add the EXIFIFD pointer. 
-	 */
-	TIFFSetDirectory(tif, 0);
-	TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset );
-	TIFFSetField(tif, TIFFTAG_SUBIFD, 1, &dir_offset2 );
-
-	TIFFClose(tif);
-	
-	/* Ok, now test whether we can read written values in the EXIF directory. */
-	tif = TIFFOpen(filename, "r");
-	
-	TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset );
-	if( read_dir_offset != dir_offset ) {
-		fprintf (stderr, "Did not get expected EXIFIFD.\n" );
-		goto failure;
-	}
-
-	TIFFGetField(tif, TIFFTAG_SUBIFD, &count16, &dir_offset2_ptr );
-	read_dir_offset2 = dir_offset2_ptr[0];
-	if( read_dir_offset2 != dir_offset2 || count16 != 1) {
-		fprintf (stderr, "Did not get expected SUBIFD.\n" );
-		goto failure;
-	}
-
-	if( !TIFFReadEXIFDirectory(tif, read_dir_offset) ) {
-		fprintf (stderr, "TIFFReadEXIFDirectory() failed.\n" );
-		goto failure;
-	}
-	
-	if (!TIFFGetField( tif, EXIFTAG_SPECTRALSENSITIVITY, &ascii_value) ) {
-		fprintf (stderr, "reading SPECTRALSENSITIVITY failed.\n" );
-		goto failure;
-	}
-
-	if( strcmp(ascii_value,"EXIF Spectral Sensitivity") != 0) {
-		fprintf (stderr, "got wrong SPECTRALSENSITIVITY value.\n" );
-		goto failure;
-	}
-
-	/* Try reading the Custom directory */
-	
-	if( !TIFFReadCustomDirectory(tif, read_dir_offset2, &customFieldArray) ) {
-		fprintf (stderr, "TIFFReadCustomDirectory() failed.\n" );
-		goto failure;
-	}
-	
-	if (!TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &ascii_value) ) {
-		fprintf (stderr, "reading pseudo-IMAGEWIDTH failed.\n" );
-		goto failure;
-	}
-
-	if( strcmp(ascii_value,"*Custom1") != 0) {
-		fprintf (stderr, "got wrong pseudo-IMAGEWIDTH value.\n" );
-		goto failure;
-	}
-
-	if (!TIFFGetField( tif, TIFFTAG_DOTRANGE, &ascii_value) ) {
-		fprintf (stderr, "reading pseudo-DOTRANGE failed.\n" );
-		goto failure;
-	}
-
-	if( strcmp(ascii_value,"*Custom2") != 0) {
-		fprintf (stderr, "got wrong pseudo-DOTRANGE value.\n" );
-		goto failure;
-	}
-
-	TIFFClose(tif);
-	
-	/* All tests passed; delete file and exit with success status. */
-	unlink(filename);
-	return 0;
+    TIFF *tif;
+    unsigned char buf[SPP] = {0, 127, 255};
+    uint64_t dir_offset = 0, dir_offset2 = 0;
+    uint64_t read_dir_offset = 0, read_dir_offset2 = 0;
+    uint64_t *dir_offset2_ptr = NULL;
+    char *ascii_value;
+    uint16_t count16 = 0;
+
+    /* We write the main directory as a simple image. */
+    tif = TIFFOpen(filename, "w+");
+    if (!tif)
+    {
+        fprintf(stderr, "Can't create test TIFF file %s.\n", filename);
+        return 1;
+    }
+
+    if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width))
+    {
+        fprintf(stderr, "Can't set ImageWidth tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length))
+    {
+        fprintf(stderr, "Can't set ImageLength tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps))
+    {
+        fprintf(stderr, "Can't set BitsPerSample tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP))
+    {
+        fprintf(stderr, "Can't set SamplesPerPixel tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip))
+    {
+        fprintf(stderr, "Can't set SamplesPerPixel tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig))
+    {
+        fprintf(stderr, "Can't set PlanarConfiguration tag.\n");
+        goto failure;
+    }
+    if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric))
+    {
+        fprintf(stderr, "Can't set PhotometricInterpretation tag.\n");
+        goto failure;
+    }
+
+    /* Write dummy pixel data. */
+    if (TIFFWriteScanline(tif, buf, 0, 0) == -1)
+    {
+        fprintf(stderr, "Can't write image data.\n");
+        goto failure;
+    }
+
+    if (!TIFFWriteDirectory(tif))
+    {
+        fprintf(stderr, "TIFFWriteDirectory() failed.\n");
+        goto failure;
+    }
+
+    /*
+     * Now create an EXIF directory.
+     */
+    if (TIFFCreateEXIFDirectory(tif) != 0)
+    {
+        fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n");
+        goto failure;
+    }
+
+    if (!TIFFSetField(tif, EXIFTAG_SPECTRALSENSITIVITY,
+                      "EXIF Spectral Sensitivity"))
+    {
+        fprintf(stderr, "Can't write SPECTRALSENSITIVITY\n");
+        goto failure;
+    }
+
+    if (!TIFFWriteCustomDirectory(tif, &dir_offset))
+    {
+        fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
+        goto failure;
+    }
+
+    /*
+     * Now create a custom directory with tags that conflict with mainline
+     * TIFF tags.
+     */
+
+    TIFFFreeDirectory(tif);
+    if (TIFFCreateCustomDirectory(tif, &customFieldArray) != 0)
+    {
+        fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n");
+        goto failure;
+    }
+
+    if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, "*Custom1"))
+    { /* not really IMAGEWIDTH */
+        fprintf(stderr, "Can't write pseudo-IMAGEWIDTH.\n");
+        goto failure;
+    }
+
+    if (!TIFFSetField(tif, TIFFTAG_DOTRANGE, "*Custom2"))
+    { /* not really DOTWIDTH */
+        fprintf(stderr, "Can't write pseudo-DOTWIDTH.\n");
+        goto failure;
+    }
+
+    if (!TIFFWriteCustomDirectory(tif, &dir_offset2))
+    {
+        fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
+        goto failure;
+    }
+
+    /*
+     * Go back to the first directory, and add the EXIFIFD pointer.
+     */
+    TIFFSetDirectory(tif, 0);
+    TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset);
+    TIFFSetField(tif, TIFFTAG_SUBIFD, 1, &dir_offset2);
+
+    TIFFClose(tif);
+
+    /* Ok, now test whether we can read written values in the EXIF directory. */
+    tif = TIFFOpen(filename, "r");
+
+    TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset);
+    if (read_dir_offset != dir_offset)
+    {
+        fprintf(stderr, "Did not get expected EXIFIFD.\n");
+        goto failure;
+    }
+
+    TIFFGetField(tif, TIFFTAG_SUBIFD, &count16, &dir_offset2_ptr);
+    read_dir_offset2 = dir_offset2_ptr[0];
+    if (read_dir_offset2 != dir_offset2 || count16 != 1)
+    {
+        fprintf(stderr, "Did not get expected SUBIFD.\n");
+        goto failure;
+    }
+
+    if (!TIFFReadEXIFDirectory(tif, read_dir_offset))
+    {
+        fprintf(stderr, "TIFFReadEXIFDirectory() failed.\n");
+        goto failure;
+    }
+
+    if (!TIFFGetField(tif, EXIFTAG_SPECTRALSENSITIVITY, &ascii_value))
+    {
+        fprintf(stderr, "reading SPECTRALSENSITIVITY failed.\n");
+        goto failure;
+    }
+
+    if (strcmp(ascii_value, "EXIF Spectral Sensitivity") != 0)
+    {
+        fprintf(stderr, "got wrong SPECTRALSENSITIVITY value.\n");
+        goto failure;
+    }
+
+    /* Try reading the Custom directory */
+
+    if (!TIFFReadCustomDirectory(tif, read_dir_offset2, &customFieldArray))
+    {
+        fprintf(stderr, "TIFFReadCustomDirectory() failed.\n");
+        goto failure;
+    }
+
+    if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ascii_value))
+    {
+        fprintf(stderr, "reading pseudo-IMAGEWIDTH failed.\n");
+        goto failure;
+    }
+
+    if (strcmp(ascii_value, "*Custom1") != 0)
+    {
+        fprintf(stderr, "got wrong pseudo-IMAGEWIDTH value.\n");
+        goto failure;
+    }
+
+    if (!TIFFGetField(tif, TIFFTAG_DOTRANGE, &ascii_value))
+    {
+        fprintf(stderr, "reading pseudo-DOTRANGE failed.\n");
+        goto failure;
+    }
+
+    if (strcmp(ascii_value, "*Custom2") != 0)
+    {
+        fprintf(stderr, "got wrong pseudo-DOTRANGE value.\n");
+        goto failure;
+    }
+
+    TIFFClose(tif);
+
+    /* All tests passed; delete file and exit with success status. */
+    unlink(filename);
+    return 0;
 
 failure:
-	/* 
-	 * Something goes wrong; close file and return unsuccessful status.
-	 * Do not remove the file for further manual investigation.
-	 */
-	TIFFClose(tif);
-	return 1;
+    /*
+     * Something goes wrong; close file and return unsuccessful status.
+     * Do not remove the file for further manual investigation.
+     */
+    TIFFClose(tif);
+    return 1;
 }
diff --git a/test/custom_dir_EXIF_231.c b/test/custom_dir_EXIF_231.c
index dfab4a3d..1e8df768 100644
--- a/test/custom_dir_EXIF_231.c
+++ b/test/custom_dir_EXIF_231.c
@@ -1,23 +1,23 @@
 /*
  * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com>
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,

(Patch may be truncated, please check the link at the top of this post.)