Improve code formatting consistency

With rare exceptions ...
- Always separate line continuation characters by one space from
  preceding code.
- Always use two-space indentation.  Never use tabs.
- Always use K&R-style conditional blocks.
- Always surround operators with spaces, except in raw assembly code.
- Always put a space after, but not before, a comma.
- Never put a space between type casts and variables/function calls.
- Never put a space between the function name and the argument list in
  function declarations and prototypes.
- Always surround braces ('{' and '}') with spaces.
- Always surround statements (if, for, else, catch, while, do, switch)
  with spaces.
- Always attach pointer symbols ('*' and '**') to the variable or
  function name.
- Always precede pointer symbols ('*' and '**') by a space in type
  casts.
- Use the MIN() macro from jpegint.h within the libjpeg and TurboJPEG
  API libraries (using min() from tjutil.h is still necessary for
  TJBench.)
- Where it makes sense (particularly in the TurboJPEG code), put a blank
  line after variable declaration blocks.
- Always separate statements in one-liners by two spaces.

The purpose of this was to ease maintenance on my part and also to make
it easier for contributors to figure out how to format patch
submissions.  This was admittedly confusing (even to me sometimes) when
we had 3 or 4 different style conventions in the same source tree.  The
new convention is more consistent with the formatting of other OSS code
bases.

This commit corrects deviations from the chosen formatting style in the
libjpeg API code and reformats the TurboJPEG API code such that it
conforms to the same standard.

NOTES:
- Although it is no longer necessary for the function name in function
  declarations to begin in Column 1 (this was historically necessary
  because of the ansi2knr utility, which allowed libjpeg to be built
  with non-ANSI compilers), we retain that formatting for the libjpeg
  code because it improves readability when using libjpeg's function
  attribute macros (GLOBAL(), etc.)
- This reformatting project was accomplished with the help of AStyle and
  Uncrustify, although neither was completely up to the task, and thus
  a great deal of manual tweaking was required.  Note to developers of
  code formatting utilities:  the libjpeg-turbo code base is an
  excellent test bed, because AFAICT, it breaks every single one of the
  utilities that are currently available.
- The legacy (MMX, SSE, 3DNow!) assembly code for i386 has been
  formatted to match the SSE2 code (refer to
  ff5685d5344273df321eb63a005eaae19d2496e3.)  I hadn't intended to
  bother with this, but the Loongson MMI implementation demonstrated
  that there is still academic value to the MMX implementation, as an
  algorithmic model for other 64-bit vector implementations.  Thus, it
  is desirable to improve its readability in the same manner as that of
  the SSE2 implementation.
diff --git a/rdtarga.c b/rdtarga.c
index b9bbd07..ecb4219 100644
--- a/rdtarga.c
+++ b/rdtarga.c
@@ -29,19 +29,20 @@
 
 #ifdef HAVE_UNSIGNED_CHAR
 typedef unsigned char U_CHAR;
-#define UCH(x)  ((int) (x))
+#define UCH(x)  ((int)(x))
 #else /* !HAVE_UNSIGNED_CHAR */
 #ifdef __CHAR_UNSIGNED__
 typedef char U_CHAR;
-#define UCH(x)  ((int) (x))
+#define UCH(x)  ((int)(x))
 #else
 typedef char U_CHAR;
-#define UCH(x)  ((int) (x) & 0xFF)
+#define UCH(x)  ((int)(x) & 0xFF)
 #endif
 #endif /* HAVE_UNSIGNED_CHAR */
 
 
-#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
+#define ReadOK(file, buffer, len) \
+  (JFREAD(file, buffer, len) == ((size_t)(len)))
 
 
 /* Private version of data source object */
@@ -87,7 +88,7 @@
 
 
 LOCAL(int)
-read_byte (tga_source_ptr sinfo)
+read_byte(tga_source_ptr sinfo)
 /* Read next byte from Targa file */
 {
   register FILE *infile = sinfo->pub.input_file;
@@ -100,7 +101,7 @@
 
 
 LOCAL(void)
-read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize)
+read_colormap(tga_source_ptr sinfo, int cmaplen, int mapentrysize)
 /* Read the colormap from a Targa file */
 {
   int i;
@@ -110,9 +111,9 @@
     ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
 
   for (i = 0; i < cmaplen; i++) {
-    sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);
-    sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);
-    sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);
+    sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
+    sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
+    sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
   }
 }
 
@@ -122,20 +123,20 @@
  */
 
 METHODDEF(void)
-read_non_rle_pixel (tga_source_ptr sinfo)
+read_non_rle_pixel(tga_source_ptr sinfo)
 /* Read one Targa pixel from the input file; no RLE expansion */
 {
   register FILE *infile = sinfo->pub.input_file;
   register int i;
 
   for (i = 0; i < sinfo->pixel_size; i++) {
-    sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
+    sinfo->tga_pixel[i] = (U_CHAR)getc(infile);
   }
 }
 
 
 METHODDEF(void)
-read_rle_pixel (tga_source_ptr sinfo)
+read_rle_pixel(tga_source_ptr sinfo)
 /* Read one Targa pixel from the input file, expanding RLE data as needed */
 {
   register FILE *infile = sinfo->pub.input_file;
@@ -160,7 +161,7 @@
 
   /* Read next pixel */
   for (i = 0; i < sinfo->pixel_size; i++) {
-    sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
+    sinfo->tga_pixel[i] = (U_CHAR)getc(infile);
   }
 }
 
@@ -173,26 +174,26 @@
 
 
 METHODDEF(JDIMENSION)
-get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+get_8bit_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 /* This version is for reading 8-bit grayscale pixels */
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   register JSAMPROW ptr;
   register JDIMENSION col;
 
   ptr = source->pub.buffer[0];
   for (col = cinfo->image_width; col > 0; col--) {
     (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
-    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
+    *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
   }
   return 1;
 }
 
 METHODDEF(JDIMENSION)
-get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 /* This version is for reading 8-bit colormap indexes */
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   register int t;
   register JSAMPROW ptr;
   register JDIMENSION col;
@@ -210,10 +211,10 @@
 }
 
 METHODDEF(JDIMENSION)
-get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+get_16bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 /* This version is for reading 16-bit pixels */
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   register int t;
   register JSAMPROW ptr;
   register JDIMENSION col;
@@ -227,30 +228,30 @@
      * The format of the 16-bit (LSB first) input word is
      *     xRRRRRGGGGGBBBBB
      */
-    ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F];
+    ptr[2] = (JSAMPLE)c5to8bits[t & 0x1F];
     t >>= 5;
-    ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F];
+    ptr[1] = (JSAMPLE)c5to8bits[t & 0x1F];
     t >>= 5;
-    ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F];
+    ptr[0] = (JSAMPLE)c5to8bits[t & 0x1F];
     ptr += 3;
   }
   return 1;
 }
 
 METHODDEF(JDIMENSION)
-get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 /* This version is for reading 24-bit pixels */
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   register JSAMPROW ptr;
   register JDIMENSION col;
 
   ptr = source->pub.buffer[0];
   for (col = cinfo->image_width; col > 0; col--) {
     (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
-    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */
-    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]);
-    *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
+    *ptr++ = (JSAMPLE)UCH(source->tga_pixel[2]); /* change BGR to RGB order */
+    *ptr++ = (JSAMPLE)UCH(source->tga_pixel[1]);
+    *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
   }
   return 1;
 }
@@ -272,9 +273,9 @@
  */
 
 METHODDEF(JDIMENSION)
-get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+get_memory_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   JDIMENSION source_row;
 
   /* Compute row of source that maps to current_row of normal order */
@@ -284,8 +285,8 @@
 
   /* Fetch that row from virtual array */
   source->pub.buffer = (*cinfo->mem->access_virt_sarray)
-    ((j_common_ptr) cinfo, source->whole_image,
-     source_row, (JDIMENSION) 1, FALSE);
+    ((j_common_ptr)cinfo, source->whole_image,
+     source_row, (JDIMENSION)1, FALSE);
 
   source->current_row++;
   return 1;
@@ -299,21 +300,21 @@
  */
 
 METHODDEF(JDIMENSION)
-preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   JDIMENSION row;
-  cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
+  cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
 
   /* Read the data into a virtual array in input-file row order. */
   for (row = 0; row < cinfo->image_height; row++) {
     if (progress != NULL) {
-      progress->pub.pass_counter = (long) row;
-      progress->pub.pass_limit = (long) cinfo->image_height;
-      (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
+      progress->pub.pass_counter = (long)row;
+      progress->pub.pass_limit = (long)cinfo->image_height;
+      (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
     }
     source->pub.buffer = (*cinfo->mem->access_virt_sarray)
-      ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE);
+      ((j_common_ptr)cinfo, source->whole_image, row, (JDIMENSION)1, TRUE);
     (*source->get_pixel_rows) (cinfo, sinfo);
   }
   if (progress != NULL)
@@ -332,18 +333,18 @@
  */
 
 METHODDEF(void)
-start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 {
-  tga_source_ptr source = (tga_source_ptr) sinfo;
+  tga_source_ptr source = (tga_source_ptr)sinfo;
   U_CHAR targaheader[18];
   int idlen, cmaptype, subtype, flags, interlace_type, components;
   unsigned int width, height, maplen;
   boolean is_bottom_up;
 
-#define GET_2B(offset)  ((unsigned int) UCH(targaheader[offset]) + \
-                         (((unsigned int) UCH(targaheader[offset+1])) << 8))
+#define GET_2B(offset)  ((unsigned int)UCH(targaheader[offset]) + \
+                         (((unsigned int)UCH(targaheader[offset + 1])) << 8))
 
-  if (! ReadOK(source->pub.input_file, targaheader, 18))
+  if (!ReadOK(source->pub.input_file, targaheader, 18))
     ERREXIT(cinfo, JERR_INPUT_EOF);
 
   /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */
@@ -425,10 +426,10 @@
   if (is_bottom_up) {
     /* Create a virtual array to buffer the upside-down image. */
     source->whole_image = (*cinfo->mem->request_virt_sarray)
-      ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
-       (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1);
+      ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
+       (JDIMENSION)width * components, (JDIMENSION)height, (JDIMENSION)1);
     if (cinfo->progress != NULL) {
-      cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
+      cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
       progress->total_extra_passes++; /* count file input as separate pass */
     }
     /* source->pub.buffer will point to the virtual array. */
@@ -438,23 +439,23 @@
     /* Don't need a virtual array, but do need a one-row input buffer. */
     source->whole_image = NULL;
     source->pub.buffer = (*cinfo->mem->alloc_sarray)
-      ((j_common_ptr) cinfo, JPOOL_IMAGE,
-       (JDIMENSION) width * components, (JDIMENSION) 1);
+      ((j_common_ptr)cinfo, JPOOL_IMAGE,
+       (JDIMENSION)width * components, (JDIMENSION)1);
     source->pub.buffer_height = 1;
     source->pub.get_pixel_rows = source->get_pixel_rows;
   }
 
   while (idlen--)               /* Throw away ID field */
-    (void) read_byte(source);
+    (void)read_byte(source);
 
   if (maplen > 0) {
     if (maplen > 256 || GET_2B(3) != 0)
       ERREXIT(cinfo, JERR_TGA_BADCMAP);
     /* Allocate space to store the colormap */
     source->colormap = (*cinfo->mem->alloc_sarray)
-      ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3);
+      ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)maplen, (JDIMENSION)3);
     /* and read it from the file */
-    read_colormap(source, (int) maplen, UCH(targaheader[7]));
+    read_colormap(source, (int)maplen, UCH(targaheader[7]));
   } else {
     if (cmaptype)               /* but you promised a cmap! */
       ERREXIT(cinfo, JERR_TGA_BADPARMS);
@@ -473,7 +474,7 @@
  */
 
 METHODDEF(void)
-finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+finish_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
 {
   /* no work */
 }
@@ -484,20 +485,20 @@
  */
 
 GLOBAL(cjpeg_source_ptr)
-jinit_read_targa (j_compress_ptr cinfo)
+jinit_read_targa(j_compress_ptr cinfo)
 {
   tga_source_ptr source;
 
   /* Create module interface object */
   source = (tga_source_ptr)
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                                  sizeof(tga_source_struct));
+    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+                                sizeof(tga_source_struct));
   source->cinfo = cinfo;        /* make back link for subroutines */
   /* Fill in method ptrs, except get_pixel_rows which start_input sets */
   source->pub.start_input = start_input_tga;
   source->pub.finish_input = finish_input_tga;
 
-  return (cjpeg_source_ptr) source;
+  return (cjpeg_source_ptr)source;
 }
 
 #endif /* TARGA_SUPPORTED */