about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-28 19:53:34 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-12-28 19:53:34 +0000
commit5d16663331afd0bc2edaeb2e49042dc219ce9c2f (patch)
tree476fbb2ab4311d4bb6d65b250825e254a7a2c1ef /converter
parent42f0bf8e7f1ff88000a3584c265e6f1631662ec4 (diff)
downloadnetpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.tar.gz
netpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.tar.xz
netpbm-mirror-5d16663331afd0bc2edaeb2e49042dc219ce9c2f.zip
promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4827 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/other/avstopam.c3
-rw-r--r--converter/other/bmptopnm.c4
-rw-r--r--converter/other/cameratopam/camera.c87
-rw-r--r--converter/other/cameratopam/camera.h2
-rw-r--r--converter/other/cameratopam/cameratopam.c46
-rw-r--r--converter/other/cameratopam/canon.c3
-rw-r--r--converter/other/cameratopam/decode.c12
-rw-r--r--converter/other/cameratopam/decode.h14
-rw-r--r--converter/other/cameratopam/dng.c2
-rw-r--r--converter/other/cameratopam/dng.h2
-rw-r--r--converter/other/cameratopam/foveon.c13
-rw-r--r--converter/other/cameratopam/foveon.h6
-rw-r--r--converter/other/cameratopam/identify.c4
-rw-r--r--converter/other/cameratopam/ljpeg.c3
-rw-r--r--converter/other/cameratopam/ljpeg.h4
-rw-r--r--converter/other/cameratopam/util.c11
-rw-r--r--converter/other/exif.c1
-rw-r--r--converter/other/fiasco/Makefile2
-rw-r--r--converter/other/fiasco/binerror.c136
-rw-r--r--converter/other/fiasco/binerror.h50
-rw-r--r--converter/other/fiasco/buttons.c510
-rw-r--r--converter/other/fiasco/buttons.h50
-rw-r--r--converter/other/fiasco/display.c415
-rw-r--r--converter/other/fiasco/display.h49
-rw-r--r--converter/other/fiasco/fiascotopnm.c512
-rw-r--r--converter/other/fiasco/params.c1139
-rw-r--r--converter/other/fiasco/params.h6
-rw-r--r--converter/other/fiasco/pnmtofiasco.c356
-rw-r--r--converter/other/fitstopnm.c5
-rw-r--r--converter/other/gemtopnm.c388
-rw-r--r--converter/other/giftopnm.c13
-rw-r--r--converter/other/hdifftopam.c18
-rw-r--r--converter/other/jbig/jbigtopnm.c1
-rw-r--r--converter/other/jbig/libjbig/jbig.c42
-rw-r--r--converter/other/jbig/libjbig/jbig_ar.c8
-rw-r--r--converter/other/jbig/pnmtojbig.c4
-rw-r--r--converter/other/jpeg2000/libjasper/common.mk3
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_enc.c1
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c1
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c1
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c8
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c1
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c1
-rw-r--r--converter/other/jpegdatasource.c25
-rw-r--r--converter/other/jpegdatasource.h2
-rw-r--r--converter/other/jpegtopnm.c14
-rw-r--r--converter/other/pamtoavs.c3
-rw-r--r--converter/other/pamtodjvurle.c59
-rw-r--r--converter/other/pamtogif.c2
-rw-r--r--converter/other/pamtohdiff.c10
-rw-r--r--converter/other/pamtohtmltbl.c45
-rw-r--r--converter/other/pamtompfont.c9
-rw-r--r--converter/other/pamtooctaveimg.c6
-rw-r--r--converter/other/pamtopam.c3
-rw-r--r--converter/other/pamtopfm.c52
-rw-r--r--converter/other/pamtopng.c1
-rw-r--r--converter/other/pamtopnm.c29
-rw-r--r--converter/other/pamtoqoi.c3
-rw-r--r--converter/other/pamtosrf.c2
-rw-r--r--converter/other/pamtosvg/autotrace.c12
-rw-r--r--converter/other/pamtosvg/bitmap.c29
-rw-r--r--converter/other/pamtosvg/bitmap.h26
-rw-r--r--converter/other/pamtosvg/curve.c4
-rw-r--r--converter/other/pamtosvg/curve.h10
-rw-r--r--converter/other/pamtosvg/epsilon.c4
-rw-r--r--converter/other/pamtosvg/exception.c10
-rw-r--r--converter/other/pamtosvg/exception.h6
-rw-r--r--converter/other/pamtosvg/fit.c8
-rw-r--r--converter/other/pamtosvg/image-header.h8
-rw-r--r--converter/other/pamtosvg/image-proc.c315
-rw-r--r--converter/other/pamtosvg/image-proc.h2
-rw-r--r--converter/other/pamtosvg/logreport.c2
-rw-r--r--converter/other/pamtosvg/logreport.h12
-rw-r--r--converter/other/pamtosvg/message.h8
-rw-r--r--converter/other/pamtosvg/output-svg.c23
-rw-r--r--converter/other/pamtosvg/output-svg.h4
-rw-r--r--converter/other/pamtosvg/pamtosvg.c49
-rw-r--r--converter/other/pamtosvg/pxl-outline.c141
-rw-r--r--converter/other/pamtosvg/pxl-outline.h8
-rw-r--r--converter/other/pamtosvg/spline.c15
-rw-r--r--converter/other/pamtosvg/thin-image.c567
-rw-r--r--converter/other/pamtosvg/vector.c2
-rw-r--r--converter/other/pamtotga.c6
-rw-r--r--converter/other/pamtotiff.c1
-rw-r--r--converter/other/pamtouil.c74
-rw-r--r--converter/other/pamtowinicon.c2
-rw-r--r--converter/other/pbmtopgm.c3
-rw-r--r--converter/other/pdbimgtopam.c1
-rw-r--r--converter/other/pfmtopam.c61
-rw-r--r--converter/other/pm_tiff.h2
-rw-r--r--converter/other/pngtxt.c55
-rw-r--r--converter/other/pngtxt.h4
-rw-r--r--converter/other/pngx.c1
-rw-r--r--converter/other/pnmtoddif.c39
-rw-r--r--converter/other/pnmtojpeg.c12
-rw-r--r--converter/other/pnmtopalm/gen_palm_colormap.c4
-rw-r--r--converter/other/pnmtopalm/palm.h2
-rw-r--r--converter/other/pnmtopalm/palmcolormap.c35
-rw-r--r--converter/other/pnmtopalm/palmtopnm.c4
-rw-r--r--converter/other/pnmtopalm/pnmtopalm.c4
-rw-r--r--converter/other/pnmtopclxl.c4
-rw-r--r--converter/other/pnmtopng.c3
-rw-r--r--converter/other/pnmtops.c20
-rw-r--r--converter/other/pnmtorast.c11
-rw-r--r--converter/other/pnmtorle.c5
-rw-r--r--converter/other/pnmtosgi.c15
-rw-r--r--converter/other/pnmtotiffcmyk.c116
-rw-r--r--converter/other/pnmtoxwd.c50
-rw-r--r--converter/other/ppmtopgm.c15
-rw-r--r--converter/other/pstopnm.c5
-rw-r--r--converter/other/qoi.h4
-rw-r--r--converter/other/qoitopam.c2
-rw-r--r--converter/other/rast.c15
-rw-r--r--converter/other/rast.h52
-rw-r--r--converter/other/rasttopnm.c21
-rw-r--r--converter/other/rla.h6
-rw-r--r--converter/other/rletopnm.c3
-rw-r--r--converter/other/sgitopnm.c1
-rw-r--r--converter/other/sirtopnm.c3
-rw-r--r--converter/other/srf.c16
-rw-r--r--converter/other/srftopam.c7
-rw-r--r--converter/other/sunicontopnm.c3
-rw-r--r--converter/other/svgtopam.c62
-rw-r--r--converter/other/tiff.c11
-rw-r--r--converter/other/tifftopnm.c19
-rw-r--r--converter/other/x10wd.h26
-rw-r--r--converter/other/x11wd.h4
-rw-r--r--converter/other/xwdtopnm.c1
-rw-r--r--converter/other/yuy2topam.c3
-rw-r--r--converter/other/zeisstopnm.c95
-rw-r--r--converter/pbm/atktopbm.c3
-rw-r--r--converter/pbm/brushtopbm.c10
-rw-r--r--converter/pbm/cistopbm.c7
-rw-r--r--converter/pbm/cmuwmtopbm.c11
-rw-r--r--converter/pbm/ddbugtopbm.c19
-rw-r--r--converter/pbm/g3topbm.c1
-rw-r--r--converter/pbm/macp.h12
-rw-r--r--converter/pbm/macptopbm.c6
-rw-r--r--converter/pbm/mrftopbm.c29
-rw-r--r--converter/pbm/pbmto10x.c8
-rw-r--r--converter/pbm/pbmtoascii.c5
-rw-r--r--converter/pbm/pbmtoatk.c3
-rw-r--r--converter/pbm/pbmtobbnbg.c50
-rw-r--r--converter/pbm/pbmtocis.c15
-rw-r--r--converter/pbm/pbmtocmuwm.c13
-rw-r--r--converter/pbm/pbmtodjvurle.c14
-rw-r--r--converter/pbm/pbmtoepsi.c42
-rw-r--r--converter/pbm/pbmtoepson.c35
-rw-r--r--converter/pbm/pbmtoescp2.c3
-rw-r--r--converter/pbm/pbmtog3.c3
-rw-r--r--converter/pbm/pbmtogem.c12
-rw-r--r--converter/pbm/pbmtoibm23xx.c9
-rw-r--r--converter/pbm/pbmtoln03.c1
-rw-r--r--converter/pbm/pbmtolps.c3
-rw-r--r--converter/pbm/pbmtomacp.c2
-rw-r--r--converter/pbm/pbmtomatrixorbital.c12
-rw-r--r--converter/pbm/pbmtomda.c2
-rw-r--r--converter/pbm/pbmtomrf.c52
-rw-r--r--converter/pbm/pbmtonokia.c3
-rw-r--r--converter/pbm/pbmtopi3.c5
-rw-r--r--converter/pbm/pbmtoplot.c49
-rw-r--r--converter/pbm/pbmtoppa/cutswath.c619
-rw-r--r--converter/pbm/pbmtoppa/cutswath.h2
-rw-r--r--converter/pbm/pbmtoppa/pbm.c12
-rw-r--r--converter/pbm/pbmtoppa/ppa.c179
-rw-r--r--converter/pbm/pbmtoppa/ppa.h2
-rw-r--r--converter/pbm/pbmtoppa/ppapbm.h2
-rw-r--r--converter/pbm/pbmtopsg3.c149
-rw-r--r--converter/pbm/pbmtoptx.c1
-rw-r--r--converter/pbm/pbmtosunicon.c18
-rw-r--r--converter/pbm/pbmtowbmp.c18
-rw-r--r--converter/pbm/pbmtoybm.c3
-rw-r--r--converter/pbm/pbmtozinc.c3
-rw-r--r--converter/pbm/pi3topbm.c17
-rw-r--r--converter/pbm/pktopbm.c2
-rw-r--r--converter/pbm/wbmptopbm.c18
-rw-r--r--converter/pbm/xbmtopbm.c2
-rw-r--r--converter/pbm/ybmtopbm.c3
-rw-r--r--converter/pgm/asciitopgm.c7
-rw-r--r--converter/pgm/bioradtopgm.c133
-rw-r--r--converter/pgm/fstopgm.c6
-rw-r--r--converter/pgm/hipstopgm.c50
-rw-r--r--converter/pgm/lispmtopgm.c2
-rw-r--r--converter/pgm/pgmtofs.c30
-rw-r--r--converter/pgm/pgmtolispm.c9
-rw-r--r--converter/pgm/pgmtopgm.c7
-rw-r--r--converter/pgm/pgmtosbig.c3
-rw-r--r--converter/pgm/pgmtost4.c5
-rw-r--r--converter/pgm/psidtopgm.c1
-rw-r--r--converter/pgm/sbigtopgm.c8
-rw-r--r--converter/pgm/spottopgm.c20
-rw-r--r--converter/pgm/st4topgm.c14
-rw-r--r--converter/ppm/411toppm.c6
-rw-r--r--converter/ppm/autocad.h2
-rw-r--r--converter/ppm/eyuvtoppm.c41
-rw-r--r--converter/ppm/gouldtoppm.c149
-rw-r--r--converter/ppm/ilbmtoppm.c11
-rw-r--r--converter/ppm/leaftoppm.c53
-rw-r--r--converter/ppm/mitsu.h27
-rw-r--r--converter/ppm/mtvtoppm.c33
-rw-r--r--converter/ppm/neotoppm.c5
-rw-r--r--converter/ppm/pc1toppm.c23
-rw-r--r--converter/ppm/pi1toppm.c3
-rw-r--r--converter/ppm/picttoppm.c7
-rw-r--r--converter/ppm/ppmtoacad.c23
-rw-r--r--converter/ppm/ppmtoapplevol.c3
-rw-r--r--converter/ppm/ppmtoarbtxt.c59
-rw-r--r--converter/ppm/ppmtoascii.c9
-rw-r--r--converter/ppm/ppmtobmp.c1
-rw-r--r--converter/ppm/ppmtoeyuv.c16
-rw-r--r--converter/ppm/ppmtoicr.c2
-rw-r--r--converter/ppm/ppmtoilbm.c3
-rw-r--r--converter/ppm/ppmtoleaf.c70
-rw-r--r--converter/ppm/ppmtomitsu.c175
-rw-r--r--converter/ppm/ppmtompeg/bframe.c6
-rw-r--r--converter/ppm/ppmtompeg/bitio.c7
-rw-r--r--converter/ppm/ppmtompeg/block.c9
-rw-r--r--converter/ppm/ppmtompeg/bsearch.c7
-rw-r--r--converter/ppm/ppmtompeg/file.c3
-rw-r--r--converter/ppm/ppmtompeg/frame.c3
-rw-r--r--converter/ppm/ppmtompeg/frametype.c1
-rw-r--r--converter/ppm/ppmtompeg/fsize.c4
-rw-r--r--converter/ppm/ppmtompeg/gethostname.c3
-rw-r--r--converter/ppm/ppmtompeg/gethostname_win32.c6
-rw-r--r--converter/ppm/ppmtompeg/headers/frames.h3
-rw-r--r--converter/ppm/ppmtompeg/iframe.c3
-rw-r--r--converter/ppm/ppmtompeg/input.c1
-rw-r--r--converter/ppm/ppmtompeg/jpeg.c1
-rw-r--r--converter/ppm/ppmtompeg/jrevdct.c6
-rw-r--r--converter/ppm/ppmtompeg/memory.c7
-rw-r--r--converter/ppm/ppmtompeg/mfwddct.c3
-rw-r--r--converter/ppm/ppmtompeg/mheaders.c15
-rw-r--r--converter/ppm/ppmtompeg/moutput.c5
-rw-r--r--converter/ppm/ppmtompeg/mpeg.c5
-rw-r--r--converter/ppm/ppmtompeg/mquant.c3
-rw-r--r--converter/ppm/ppmtompeg/nojpeg.c4
-rw-r--r--converter/ppm/ppmtompeg/noparallel.c4
-rw-r--r--converter/ppm/ppmtompeg/opts.c14
-rw-r--r--converter/ppm/ppmtompeg/parallel.c12
-rw-r--r--converter/ppm/ppmtompeg/param.c2
-rw-r--r--converter/ppm/ppmtompeg/pframe.c9
-rw-r--r--converter/ppm/ppmtompeg/postdct.c6
-rw-r--r--converter/ppm/ppmtompeg/ppmtompeg.c5
-rw-r--r--converter/ppm/ppmtompeg/psearch.c9
-rw-r--r--converter/ppm/ppmtompeg/qtest.c3
-rw-r--r--converter/ppm/ppmtompeg/rate.c12
-rw-r--r--converter/ppm/ppmtompeg/readframe.c10
-rw-r--r--converter/ppm/ppmtompeg/rgbtoycc.c4
-rw-r--r--converter/ppm/ppmtompeg/specifics.c14
-rw-r--r--converter/ppm/ppmtompeg/subsample.c5
-rw-r--r--converter/ppm/ppmtoneo.c3
-rw-r--r--converter/ppm/ppmtopi1.c3
-rw-r--r--converter/ppm/ppmtopict.c220
-rw-r--r--converter/ppm/ppmtopj.c480
-rw-r--r--converter/ppm/ppmtopjxl.c552
-rw-r--r--converter/ppm/ppmtoppm.c5
-rw-r--r--converter/ppm/ppmtopuzz.c67
-rw-r--r--converter/ppm/ppmtospu.c22
-rw-r--r--converter/ppm/ppmtoterm.c19
-rw-r--r--converter/ppm/ppmtowinicon.c1076
-rw-r--r--converter/ppm/ppmtoxpm.c340
-rw-r--r--converter/ppm/ppmtoyuv.c9
-rw-r--r--converter/ppm/ppmtoyuvsplit.c3
-rw-r--r--converter/ppm/qrttoppm.c104
-rw-r--r--converter/ppm/rawtoppm.c5
-rw-r--r--converter/ppm/rgb3toppm.c41
-rw-r--r--converter/ppm/sldtoppm.c289
-rw-r--r--converter/ppm/spctoppm.c155
-rw-r--r--converter/ppm/tgatoppm.c1
-rw-r--r--converter/ppm/vidtoppm.c65
-rw-r--r--converter/ppm/winico.h20
-rw-r--r--converter/ppm/winicontoppm.c98
-rw-r--r--converter/ppm/ximtoppm.c400
-rw-r--r--converter/ppm/yuvsplittoppm.c31
-rw-r--r--converter/ppm/yuvtoppm.c9
275 files changed, 6414 insertions, 6697 deletions
diff --git a/converter/other/avstopam.c b/converter/other/avstopam.c
index 322f387d..5b2be683 100644
--- a/converter/other/avstopam.c
+++ b/converter/other/avstopam.c
@@ -101,3 +101,6 @@ main(int argc, const char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c
index 3f66634b..eed428de 100644
--- a/converter/other/bmptopnm.c
+++ b/converter/other/bmptopnm.c
@@ -196,6 +196,8 @@ GetShort(FILE * const fp) {
     return v;
 }
 
+
+
 static short
 GetBigShort(FILE * const fp) {
 
@@ -938,6 +940,7 @@ convertRow32(unsigned char      const bmprow[],
 }
 
 
+
 static void
 validateIndex(unsigned int const index,
               unsigned int const cmapSize ) {
@@ -1718,3 +1721,4 @@ main(int argc, const char ** argv) {
 }
 
 
+
diff --git a/converter/other/cameratopam/camera.c b/converter/other/cameratopam/camera.c
index 4610462c..62b58ad5 100644
--- a/converter/other/cameratopam/camera.c
+++ b/converter/other/cameratopam/camera.c
@@ -56,7 +56,6 @@ merror (const void *ptr, const char *where)
 
 
 
-
 static void
 adobeCopyPixel(Image             const image,
                unsigned int      const row,
@@ -87,6 +86,8 @@ adobeCopyPixel(Image             const image,
         --(*rp);
 }
 
+
+
 void
 adobe_dng_load_raw_lj(Image const image) {
 
@@ -187,6 +188,8 @@ nikon_compressed_load_raw(Image const image) {
     free (curve);
 }
 
+
+
 void
 nikon_load_raw(Image const image) {
 
@@ -213,6 +216,8 @@ nikon_load_raw(Image const image) {
   }
 }
 
+
+
 /*
    Figure out if a NEF file is compressed.  These fancy heuristics
    are only needed for the D100, thanks to a bug in some cameras
@@ -235,6 +240,8 @@ nikon_is_compressed()
   return 0;
 }
 
+
+
 /*
    Returns 1 for a Coolpix 990, 0 for a Coolpix 995.
  */
@@ -254,6 +261,8 @@ nikon_e990()
   return 0;
 }
 
+
+
 /*
    Returns 1 for a Coolpix 2100, 0 for anything else.
  */
@@ -273,6 +282,8 @@ nikon_e2100()
   return 1;
 }
 
+
+
 /*
    Separates a Pentax Optio 33WR from a Nikon E3700.
  */
@@ -289,6 +300,8 @@ pentax_optio33()
   return sum[0] < sum[1]*4;
 }
 
+
+
 /*
    Separates a Minolta DiMAGE Z2 from a Nikon E4300.
  */
@@ -305,6 +318,8 @@ minolta_z2()
   return 0;
 }
 
+
+
 void
 nikon_e2100_load_raw(Image const image) {
 
@@ -333,6 +348,8 @@ nikon_e2100_load_raw(Image const image) {
   }
 }
 
+
+
 void
 nikon_e950_load_raw(Image const image) {
 
@@ -349,6 +366,8 @@ nikon_e950_load_raw(Image const image) {
   maximum = 0x3dd;
 }
 
+
+
 /*
    The Fuji Super CCD is just a Bayer grid rotated 45 degrees.
  */
@@ -368,6 +387,8 @@ fuji_s2_load_raw(Image const image) {
   }
 }
 
+
+
 void
 fuji_s3_load_raw(Image const image) {
   unsigned short pixel[4352];
@@ -384,6 +405,8 @@ fuji_s3_load_raw(Image const image) {
   }
 }
 
+
+
 static void
 fuji_common_load_raw(Image        const image,
                      unsigned int const ncol,
@@ -444,6 +467,8 @@ fuji_f700_load_raw(Image const image) {
   }
 }
 
+
+
 void
 rollei_load_raw(Image const image) {
   unsigned char pixel[10];
@@ -470,6 +495,8 @@ rollei_load_raw(Image const image) {
   maximum = 0x3ff;
 }
 
+
+
 void
 phase_one_load_raw(Image const image) {
   int row, col, a, b;
@@ -496,6 +523,8 @@ phase_one_load_raw(Image const image) {
   free (pixel);
 }
 
+
+
 void
 ixpress_load_raw(Image const image) {
   unsigned short pixel[4090];
@@ -510,6 +539,8 @@ ixpress_load_raw(Image const image) {
   }
 }
 
+
+
 void
 leaf_load_raw(Image const image) {
   unsigned short *pixel;
@@ -526,6 +557,8 @@ leaf_load_raw(Image const image) {
   free (pixel);
 }
 
+
+
 /*
    For this function only, raw_width is in bytes, not pixels!
  */
@@ -542,6 +575,8 @@ packed_12_load_raw(Image const image) {
   }
 }
 
+
+
 void
 unpacked_load_raw(Image const image) {
   unsigned short *pixel;
@@ -557,6 +592,8 @@ unpacked_load_raw(Image const image) {
   free (pixel);
 }
 
+
+
 void
 olympus_e300_load_raw(Image const image) {
   unsigned char  *data,  *dp;
@@ -580,6 +617,8 @@ olympus_e300_load_raw(Image const image) {
   free (data);
 }
 
+
+
 void
 olympus_cseries_load_raw(Image const image) {
   int irow, row, col;
@@ -595,6 +634,8 @@ olympus_cseries_load_raw(Image const image) {
   }
 }
 
+
+
 void
 eight_bit_load_raw(Image const image) {
   unsigned char *pixel;
@@ -611,6 +652,8 @@ eight_bit_load_raw(Image const image) {
   maximum = 0xff;
 }
 
+
+
 void
 casio_qv5700_load_raw(Image const image) {
   unsigned char  data[3232],  *dp;
@@ -631,6 +674,8 @@ casio_qv5700_load_raw(Image const image) {
   maximum = 0x3fc;
 }
 
+
+
 void
 nucore_load_raw(Image const image) {
   unsigned short *pixel;
@@ -647,6 +692,8 @@ nucore_load_raw(Image const image) {
   free (pixel);
 }
 
+
+
 static int  radc_token (int tree)
 {
   int t;
@@ -688,6 +735,8 @@ static int  radc_token (int tree)
   return dindex->leaf;
 }
 
+
+
 #define FORYX for (y=1; y < 3; y++) for (x=col+1; x >= col; x--)
 
 #define PREDICTOR (c ? (buf[c][y-1][x] + buf[c][y][x+1]) / 2 \
@@ -770,6 +819,8 @@ kodak_radc_load_raw(Image const image) {
     maximum = 0x1fff;     /* wild guess */
 }
 
+
+
 #undef FORYX
 #undef PREDICTOR
 
@@ -791,6 +842,8 @@ fill_input_buffer (j_decompress_ptr cinfo)
   return TRUE;
 }
 
+
+
 void
 kodak_jpeg_load_raw(Image const image)
 {
@@ -830,6 +883,8 @@ kodak_jpeg_load_raw(Image const image)
   maximum = 0xff << 1;
 }
 
+
+
 #endif
 
 void
@@ -849,6 +904,8 @@ kodak_dc120_load_raw(Image const image)
   maximum = 0xff;
 }
 
+
+
 void
 kodak_dc20_coeff (float const juice)
 {
@@ -868,6 +925,8 @@ kodak_dc20_coeff (float const juice)
   use_coeff = 1;
 }
 
+
+
 void
 kodak_easy_load_raw(Image const image)
 {
@@ -896,6 +955,8 @@ kodak_easy_load_raw(Image const image)
   maximum = curve[0xff];
 }
 
+
+
 void
 kodak_compressed_load_raw(Image const image)
 {
@@ -960,6 +1021,8 @@ kodak_compressed_load_raw(Image const image)
     }
 }
 
+
+
 void
 kodak_yuv_load_raw(Image const image)
 {
@@ -1019,6 +1082,8 @@ kodak_yuv_load_raw(Image const image)
   maximum = 0xe74;
 }
 
+
+
 static void  sony_decrypt (unsigned *data, int len, int start, int key)
 {
   static uint32_t pad[128];
@@ -1053,6 +1118,8 @@ static void  sony_decrypt (unsigned *data, int len, int start, int key)
   }
 }
 
+
+
 void
 sony_load_raw(Image const image)
 {
@@ -1091,6 +1158,8 @@ sony_load_raw(Image const image)
   maximum = 0x3ff0;
 }
 
+
+
 void
 parse_minolta(FILE * const ifp)
 {
@@ -1124,6 +1193,8 @@ parse_minolta(FILE * const ifp)
   data_offset = offset;
 }
 
+
+
 /*
    CIFF block 0x1030 contains an 8x8 white sample.
    Load this into white[][] for use in scale_colors().
@@ -1151,6 +1222,8 @@ static void  ciff_block_1030()
     }
 }
 
+
+
 /*
    Parse a CIFF file, better known as Canon CRW format.
  */
@@ -1266,6 +1339,8 @@ common:
     camera_red = -1;            /* Use my auto WB for this photo */
 }
 
+
+
 void
 parse_rollei(FILE * const ifp)
 {
@@ -1333,6 +1408,8 @@ parse_mos(FILE * const ifp,
     }
 }
 
+
+
 void
 nikon_e950_coeff()
 {
@@ -1504,6 +1581,8 @@ get_timestamp(FILE * const ifp)
     timestamp = ts;
 }
 
+
+
 static void
 parse_exif(FILE * const ifp, int base)
 {
@@ -1529,6 +1608,8 @@ parse_exif(FILE * const ifp, int base)
   }
 }
 
+
+
 static int
 parse_tiff_ifd(FILE * const ifp, int base, int level)
 {
@@ -1725,6 +1806,8 @@ guess_cfa_pc:
   return done;
 }
 
+
+
 void
 parse_tiff(FILE * const ifp, int base)
 {
@@ -1797,3 +1880,5 @@ parse_external_jpeg(const char * const ifname)
     free (jname);
 }
 
+
+
diff --git a/converter/other/cameratopam/camera.h b/converter/other/cameratopam/camera.h
index 02c3f2af..172bc46e 100644
--- a/converter/other/cameratopam/camera.h
+++ b/converter/other/cameratopam/camera.h
@@ -5,7 +5,7 @@
 
 #include "cameratopam.h"
 
-void 
+void
 parse_ciff(FILE * const ifp,
            int    const offset,
            int    const length);
diff --git a/converter/other/cameratopam/cameratopam.c b/converter/other/cameratopam/cameratopam.c
index 78eb6854..693d280c 100644
--- a/converter/other/cameratopam/cameratopam.c
+++ b/converter/other/cameratopam/cameratopam.c
@@ -88,6 +88,8 @@ static void CLASS merror (const void *ptr, const char *where)
         pm_error ("Out of memory in %s", where);
 }
 
+
+
 struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
@@ -136,37 +138,37 @@ parseCommandLine(int argc, char ** argv,
     opt.allowNegNum = FALSE;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "bright", 
+    OPTENT3(0, "bright",
             OPT_FLOAT,   &cmdlineP->bright,     &brightSpec, 0);
-    OPTENT3(0, "red_scale", 
+    OPTENT3(0, "red_scale",
             OPT_FLOAT,   &cmdlineP->red_scale,  &red_scaleSpec, 0);
-    OPTENT3(0, "blue_scale", 
+    OPTENT3(0, "blue_scale",
             OPT_FLOAT,   &cmdlineP->blue_scale, &blue_scaleSpec, 0);
-    OPTENT3(0, "profile", 
+    OPTENT3(0, "profile",
             OPT_STRING,  &cmdlineP->profile,    &profileSpec, 0);
-    OPTENT3(0,   "identify_only",   
+    OPTENT3(0,   "identify_only",
             OPT_FLAG,    NULL, &cmdlineP->identify_only, 0);
-    OPTENT3(0,   "verbose",   
+    OPTENT3(0,   "verbose",
             OPT_FLAG,    NULL, &cmdlineP->verbose, 0);
-    OPTENT3(0,   "half_size",   
+    OPTENT3(0,   "half_size",
             OPT_FLAG,    NULL, &cmdlineP->half_size, 0);
-    OPTENT3(0,   "four_color_rgb",   
+    OPTENT3(0,   "four_color_rgb",
             OPT_FLAG,    NULL, &cmdlineP->four_color_rgb, 0);
-    OPTENT3(0,   "document_mode",   
+    OPTENT3(0,   "document_mode",
             OPT_FLAG,    NULL, &cmdlineP->document_mode, 0);
-    OPTENT3(0,   "quick_interpolate",   
+    OPTENT3(0,   "quick_interpolate",
             OPT_FLAG,    NULL, &cmdlineP->quick_interpolate, 0);
-    OPTENT3(0,   "balance_auto",   
+    OPTENT3(0,   "balance_auto",
             OPT_FLAG,    NULL, &cmdlineP->use_auto_wb, 0);
-    OPTENT3(0,   "balance_camera",   
+    OPTENT3(0,   "balance_camera",
             OPT_FLAG,    NULL, &cmdlineP->use_camera_wb, 0);
-    OPTENT3(0,   "use_secondary",   
+    OPTENT3(0,   "use_secondary",
             OPT_FLAG,    NULL, &cmdlineP->use_secondary, 0);
-    OPTENT3(0,   "no_clip_color",   
+    OPTENT3(0,   "no_clip_color",
             OPT_FLAG,    NULL, &cmdlineP->no_clip_color, 0);
-    OPTENT3(0,   "rgb",   
+    OPTENT3(0,   "rgb",
             OPT_FLAG,    NULL, &cmdlineP->use_camera_rgb, 0);
-    OPTENT3(0,   "linear",   
+    OPTENT3(0,   "linear",
             OPT_FLAG,    NULL, &cmdlineP->linear, 0);
 
     pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
@@ -185,12 +187,12 @@ parseCommandLine(int argc, char ** argv,
         cmdlineP->inputFileName = strdup("-");  /* he wants stdin */
     else if (argc - 1 == 1)
         cmdlineP->inputFileName = strdup(argv[1]);
-    else 
+    else
         pm_error("Too many arguments.  The only argument accepted "
                  "is the input file name");
 }
 
-  
+
 
 static void CLASS
 fixBadPixels(Image const image) {
@@ -658,9 +660,9 @@ fujiRotate(Image * const imageP) {
                     newImage[row*wide+col][i] =
                         (pix[    0][i]*(1-fc) + pix[      1][i]*fc) * (1-fr) +
                         (pix[width][i]*(1-fc) + pix[width+1][i]*fc) * fr;
-                } 
+                }
             }
-        }        
+        }
         free(*imageP);
         width  = wide;
         height = high;
@@ -920,7 +922,7 @@ convertIt(FILE *       const ifP,
     if (flip) {
         if (cmdline.verbose)
             pm_message ("Flipping image %c:%c:%c...",
-                        flip & 1 ? 'H':'0', flip & 2 ? 'V':'0', 
+                        flip & 1 ? 'H':'0', flip & 2 ? 'V':'0',
                         flip & 4 ? 'T':'0');
         flipImage(image);
     }
@@ -931,7 +933,7 @@ convertIt(FILE *       const ifP,
 
 
 
-int 
+int
 main (int argc, char **argv) {
 
     FILE * const ofP = stdout;
diff --git a/converter/other/cameratopam/canon.c b/converter/other/cameratopam/canon.c
index cbf5ece0..f86f43d8 100644
--- a/converter/other/cameratopam/canon.c
+++ b/converter/other/cameratopam/canon.c
@@ -170,3 +170,6 @@ canon_compressed_load_raw(Image const image) {
     if (raw_width > width)
         black /= (raw_width - width) * height;
 }
+
+
+
diff --git a/converter/other/cameratopam/decode.c b/converter/other/cameratopam/decode.c
index e3a62fab..d42f8619 100644
--- a/converter/other/cameratopam/decode.c
+++ b/converter/other/cameratopam/decode.c
@@ -44,15 +44,15 @@ void init_decoder() {
  */
 
 
-unsigned char * 
-make_decoder(const unsigned char * const source, 
+unsigned char *
+make_decoder(const unsigned char * const source,
              int                   const level) {
 
     struct decode *cur;
     static int leaf;
     int i, next;
 
-    if (level==0) 
+    if (level==0)
         leaf=0;
     cur = free_decode++;
     if (free_decode > first_decode+2048) {
@@ -74,7 +74,7 @@ make_decoder(const unsigned char * const source,
 
 
 
-const int * 
+const int *
 make_decoder_int(const int * const source,
                  int         const level) {
 
@@ -98,7 +98,7 @@ make_decoder_int(const int * const source,
 
 
 
-void 
+void
 crw_init_tables(unsigned int const table) {
 
   unsigned int const clippedTableNum = MIN(2, table);
@@ -170,3 +170,5 @@ crw_init_tables(unsigned int const table) {
   make_decoder (second_tree[clippedTableNum], 0);
 }
 
+
+
diff --git a/converter/other/cameratopam/decode.h b/converter/other/cameratopam/decode.h
index b0addc82..e79a6989 100644
--- a/converter/other/cameratopam/decode.h
+++ b/converter/other/cameratopam/decode.h
@@ -1,22 +1,22 @@
 struct decode {
   struct decode *branch[2];
   int leaf;
-}; 
+};
 
 extern struct decode * free_decode;
 extern struct decode first_decode[2048];
 extern struct decode * second_decode;
 
-void 
+void
 init_decoder(void);
 
-void 
+void
 crw_init_tables(unsigned int const table);
 
-const int * 
-make_decoder_int (const int * const source, 
+const int *
+make_decoder_int (const int * const source,
                   int         const level);
 
-unsigned char * 
-make_decoder(const unsigned char * const source, 
+unsigned char *
+make_decoder(const unsigned char * const source,
              int                   const level);
diff --git a/converter/other/cameratopam/dng.c b/converter/other/cameratopam/dng.c
index bddfd9f4..fbd2028f 100644
--- a/converter/other/cameratopam/dng.c
+++ b/converter/other/cameratopam/dng.c
@@ -3,7 +3,7 @@
 
 #include "dng.h"
 
-void 
+void
 dng_coeff (double cc[4][4],
            double cm[4][3],
            double xyz[3]) {
diff --git a/converter/other/cameratopam/dng.h b/converter/other/cameratopam/dng.h
index 56293563..2b7c96df 100644
--- a/converter/other/cameratopam/dng.h
+++ b/converter/other/cameratopam/dng.h
@@ -1,4 +1,4 @@
-void 
+void
 dng_coeff(double cc[4][4],
           double cm[4][3],
           double xyz[3]);
diff --git a/converter/other/cameratopam/foveon.c b/converter/other/cameratopam/foveon.c
index 5a26777b..23cffe67 100644
--- a/converter/other/cameratopam/foveon.c
+++ b/converter/other/cameratopam/foveon.c
@@ -339,6 +339,8 @@ foveon_fixed (void *       const ptr,
     return 1;
 }
 
+
+
 static float  foveon_avg (unsigned short *pix, int range[2], float cfilt)
 {
     int i;
@@ -353,6 +355,8 @@ static float  foveon_avg (unsigned short *pix, int range[2], float cfilt)
     return (sum - min - max) / (range[1] - range[0] - 1);
 }
 
+
+
 static short *foveon_make_curve (double max, double mul, double filt)
 {
     short *curve;
@@ -373,6 +377,8 @@ static short *foveon_make_curve (double max, double mul, double filt)
     return curve;
 }
 
+
+
 static void foveon_make_curves
 (short **curvep, float dq[3], float div[3], float filt)
 {
@@ -384,12 +390,16 @@ static void foveon_make_curves
     FORC3 curvep[c] = foveon_make_curve (max, mul[c], filt);
 }
 
+
+
 static int  foveon_apply_curve (short *curve, int i)
 {
     if (abs(i) >= (unsigned short)curve[0]) return 0;
     return i < 0 ? -(unsigned short)curve[1-i] : (unsigned short)curve[1+i];
 }
 
+
+
 void
 foveon_interpolate(Image const image,
                    float coeff[3][4]) {
@@ -797,3 +807,6 @@ foveon_interpolate(Image const image,
     width = i;
     height = row;
 }
+
+
+
diff --git a/converter/other/cameratopam/foveon.h b/converter/other/cameratopam/foveon.h
index c9bf48a8..584a38f6 100644
--- a/converter/other/cameratopam/foveon.h
+++ b/converter/other/cameratopam/foveon.h
@@ -3,15 +3,15 @@
 #include "cameratopam.h"
 #include "camera.h"
 
-void 
+void
 parse_foveon(FILE * const ifp);
 
-void  
+void
 foveon_interpolate(Image const image,
                    float coeff[3][4]);
 
 LoadRawFn foveon_load_raw;
 
-void  
+void
 foveon_coeff(int * const useCoeffP,
              float       coeff[3][4]);
diff --git a/converter/other/cameratopam/identify.c b/converter/other/cameratopam/identify.c
index e5df6b22..c1eb8a25 100644
--- a/converter/other/cameratopam/identify.c
+++ b/converter/other/cameratopam/identify.c
@@ -263,7 +263,6 @@ adobeCoeff(const char * const make,
 
 
 
-
 int
 identify(FILE *       const ifp,
          bool         const use_secondary,
@@ -1206,3 +1205,6 @@ dng_skip:
 
     return 0;
 }
+
+
+
diff --git a/converter/other/cameratopam/ljpeg.c b/converter/other/cameratopam/ljpeg.c
index 35f50f4b..d1ede87c 100644
--- a/converter/other/cameratopam/ljpeg.c
+++ b/converter/other/cameratopam/ljpeg.c
@@ -161,3 +161,6 @@ lossless_jpeg_load_raw(Image  const image) {
     if (!strcasecmp(make,"KODAK"))
         black = min;
 }
+
+
+
diff --git a/converter/other/cameratopam/ljpeg.h b/converter/other/cameratopam/ljpeg.h
index 9d9d8ee9..7b1cf364 100644
--- a/converter/other/cameratopam/ljpeg.h
+++ b/converter/other/cameratopam/ljpeg.h
@@ -8,11 +8,11 @@ struct jhead {
 
 LoadRawFn lossless_jpeg_load_raw;
 
-int  
+int
 ljpeg_start (FILE *         const ifP,
              struct jhead * const jhP);
 
-int 
+int
 ljpeg_diff (FILE *          const ifP,
             struct decode * const dindexP);
 
diff --git a/converter/other/cameratopam/util.c b/converter/other/cameratopam/util.c
index ede5ef69..d489b23e 100644
--- a/converter/other/cameratopam/util.c
+++ b/converter/other/cameratopam/util.c
@@ -28,6 +28,8 @@ get2(FILE * const ifp)
         return a << 8 | b;
 }
 
+
+
 /*
    Same for a 4-byte integer.
  */
@@ -45,6 +47,8 @@ get4(FILE * const ifp)
         return a << 24 | b << 16 | c << 8 | d;
 }
 
+
+
 /*
    Faster than calling get2() multiple times.
  */
@@ -68,11 +72,13 @@ read_shorts (FILE * const ifp, unsigned short *pixel, int count)
     }
 }
 
+
+
 /*
    getbits(-1) initializes the buffer
    getbits(n) where 0 <= n <= 25 returns an n-bit integer
  */
-unsigned 
+unsigned
 getbits (FILE * const ifp, int nbits)
 {
     static unsigned long bitbuf=0;
@@ -95,3 +101,6 @@ getbits (FILE * const ifp, int nbits)
     }
     return ret;
 }
+
+
+
diff --git a/converter/other/exif.c b/converter/other/exif.c
index d1eb517f..b2a7bd5d 100644
--- a/converter/other/exif.c
+++ b/converter/other/exif.c
@@ -613,6 +613,7 @@ commentValue(const unsigned char * const valuePtr,
 }
 
 
+
 /* Forward declaration for recursion */
 
 static void
diff --git a/converter/other/fiasco/Makefile b/converter/other/fiasco/Makefile
index 392e843c..5ce529fd 100644
--- a/converter/other/fiasco/Makefile
+++ b/converter/other/fiasco/Makefile
@@ -25,7 +25,7 @@ FIASCOLIBS = codec/libfiasco_codec.a \
 	     output/libfiasco_output.a \
 	     lib/libfiasco_lib.a 
 
-ADDL_OBJECTS = binerror.o getopt.o getopt1.o params.o
+ADDL_OBJECTS = getopt.o getopt1.o params.o
 
 OBJECTS = $(BINARIES:%=%.o) $(ADDL_OBJECTS)
 
diff --git a/converter/other/fiasco/binerror.c b/converter/other/fiasco/binerror.c
deleted file mode 100644
index dd40dc9b..00000000
--- a/converter/other/fiasco/binerror.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *  error.c:            Error handling
- *
- *  Written by:         Stefan Frank
- *                      Ullrich Hafner
- *
- *  Credits:    Modelled after variable argument routines from Jef
- *              Poskanzer's pbmplus package.
- *
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- */
-
-/*
- *  $Date: 2000/03/20 21:29:59 $
- *  $Author: hafner $
- *  $Revision: 4.3 $
- *  $State: Exp $
- */
-
-#define _DEFAULT_SOURCE 1 /* New name for SVID & BSD source defines */
-#define _BSD_SOURCE 1   /* Make sure strdup() is in string.h */
-#define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
-#define _ERROR_C
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#if STDC_HEADERS
-#       include <stdarg.h>
-#       define VA_START(args, lastarg) va_start(args, lastarg)
-#else  /* not STDC_HEADERS */
-#       include <varargs.h>
-#       define VA_START(args, lastarg) va_start(args)
-#endif /* not STDC_HEADERS */
-#include <string.h>
-
-#if HAVE_SETJMP_H
-#       include <setjmp.h>
-#endif /* HAVE_SETJMP_H */
-
-#include "fiasco.h"
-#include "binerror.h"
-
-/*****************************************************************************
-
-                             global variables
-
-*****************************************************************************/
-
-int   error_line = 0;
-const char *error_file = NULL;
-
-/*****************************************************************************
-
-                             local variables
-
-*****************************************************************************/
-
-static const char *executable = "(name not initialized)";
-
-/*****************************************************************************
-
-                               public code
-
-*****************************************************************************/
-
-void
-init_error_handling (const char *name)
-/*
- *  Initialize filename of executable.
- *
- *  No return value.
- */
-{
-   if (name)
-      executable = strdup (name);
-}
-
-void
-_error (const char *format, ...)
-/*
- *  Print error message and exit.
- *
- *  No return value.
- */
-{
-   va_list      args;
-
-   VA_START (args, format);
-
-   fprintf (stderr, "%s: %s: line %d:\nError: ",
-            executable, error_file, error_line);
-   vfprintf (stderr, format, args);
-   fputc ('\n', stderr);
-   va_end(args);
-
-   exit (1);
-}
-
-void
-_file_error (const char *filename)
-/*
- *  Print file error message and exit.
- *
- *  No return value.
- */
-{
-   fprintf (stderr, "%s: %s: line %d:\nError: ",
-            executable, error_file, error_line);
-   perror (filename);
-
-   exit (2);
-}
-
-void
-_warning (const char *format, ...)
-/*
- *  Issue a warning and continue execution.
- *
- *  No return value.
- */
-{
-   va_list args;
-
-   VA_START (args, format);
-
-   fprintf (stderr, "%s: %s: line %d:\nWarning: ",
-            executable, error_file, error_line);
-   vfprintf (stderr, format, args);
-   fputc ('\n', stderr);
-
-   va_end (args);
-}
diff --git a/converter/other/fiasco/binerror.h b/converter/other/fiasco/binerror.h
deleted file mode 100644
index b30f53e0..00000000
--- a/converter/other/fiasco/binerror.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *  error.h
- *
- *  Written by:         Stefan Frank
- *                      Ullrich Hafner
- *
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- */
-
-/*
- *  $Date: 2000/03/20 21:29:59 $
- *  $Author: hafner $
- *  $Revision: 4.3 $
- *  $State: Exp $
- */
-
-#ifndef _ERROR_H
-#define _ERROR_H
-
-#define error          error_line=__LINE__,error_file=__FILE__,_error
-#define warning        error_line=__LINE__,error_file=__FILE__,_warning
-#define file_error(fn) error_line=__LINE__,error_file=__FILE__,_file_error(fn)
-
-#ifdef _ERROR_C
-#define _EXTERN_TYPE
-#else
-#define _EXTERN_TYPE    extern
-#endif
-
-_EXTERN_TYPE int   error_line;
-_EXTERN_TYPE const char *error_file;
-
-void
-init_error_handling (const char *name);
-void
-_error (const char *format, ...);
-void
-_warning (const char *format, ...);
-void
-_file_error (const char *filename);
-
-#if HAVE_ASSERT_H
-#       include <assert.h>
-#else /* not HAVE_ASSERT_H */
-#       define assert(exp)      {if (!(exp)) error ("Assertion `" #exp " != NULL' failed.");}
-#endif /* not HAVE_ASSERT_H */
-
-#endif /* not _ERROR_H */
-
diff --git a/converter/other/fiasco/buttons.c b/converter/other/fiasco/buttons.c
deleted file mode 100644
index 7a6c77a3..00000000
--- a/converter/other/fiasco/buttons.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- *  buttons.c:          Draw MWFA player buttons in X11 window
- *
- *  Written by:         Ullrich Hafner
- *
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- */
-
-/*
- *  $Date: 2000/06/15 17:23:11 $
- *  $Author: hafner $
- *  $Revision: 5.2 $
- *  $State: Exp $
- */
-
-#include "config.h"
-
-#ifndef X_DISPLAY_MISSING
-
-#include <X11/Xlib.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-
-#if STDC_HEADERS
-#       include <stdlib.h>
-#endif /* not STDC_HEADERS */
-
-#include "types.h"
-#include "macros.h"
-
-#include "display.h"
-#include "binerror.h"
-#include "buttons.h"
-
-/*****************************************************************************
-
-                             local variables
-
-*****************************************************************************/
-
-static const int EVENT_MASK = (KeyPressMask | ButtonPressMask |
-                               ButtonReleaseMask | ExposureMask);
-
-/*****************************************************************************
-
-                                prototypes
-
-*****************************************************************************/
-
-static void
-draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-                   unsigned n_frames);
-static void
-draw_button (x11_info_t *xinfo, binfo_t *binfo,
-             buttons_t button, bool_t pressed);
-static void
-draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
-                    unsigned n, unsigned n_frames);
-
-/*****************************************************************************
-
-                                public code
-
-*****************************************************************************/
-
-binfo_t *
-init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
-              unsigned buttons_height, unsigned progbar_height)
-/*
- *  Initialize a toolbar with the typical collection of video player
- *  buttons (pause, play, record, next, etc.) in the window given by 'xinfo'.
- *  'n' gives the current frame, 'whereas' n_frames is the total number of
- *  frames of the video stream.
- *  The size of the button toolbar is given by 'buttons_height',
- *  the size of the progressbar is given by 'progbar_height'.
- *
- *  Return value:
- *      struct managing the toolbar and progressbar information
- */
-{
-   XGCValues  values;
-   XEvent     event;
-   Colormap   cmap;
-   XColor     gray, dgray, lgray, red;
-   XColor     graye, dgraye, lgraye, rede;
-   buttons_t  button;                   /* counter */
-   binfo_t   *binfo = calloc (1, sizeof (binfo_t));
-
-   if (!binfo)
-      error ("Out of memory.");
-
-   binfo->width            = xinfo->ximage->width;
-   binfo->height           = buttons_height;
-   binfo->progbar_height   = progbar_height;
-   binfo->record_is_rewind = NO;
-
-   /*
-    *  Generate sub-window for control panel
-    */
-   binfo->window = XCreateSimpleWindow (xinfo->display, xinfo->window,
-                                        0, xinfo->ximage->height,
-                                        binfo->width, binfo->height, 0,
-                                        BlackPixel (xinfo->display,
-                                                    xinfo->screen),
-                                        WhitePixel (xinfo->display,
-                                                    xinfo->screen));
-   XSelectInput(xinfo->display, binfo->window, StructureNotifyMask);
-   XMapWindow (xinfo->display, binfo->window);
-   do
-   {
-      XNextEvent (xinfo->display, &event);
-   }
-   while (event.type != MapNotify || event.xmap.event != binfo->window);
-   XSelectInput (xinfo->display, binfo->window, EVENT_MASK);
-
-   /*
-    *  Generate graphic contexts for different colors.
-    */
-   cmap = DefaultColormap (xinfo->display, xinfo->screen);
-   XAllocNamedColor (xinfo->display, cmap, "#404040", &dgray, &dgraye);
-   XAllocNamedColor (xinfo->display, cmap, "white", &lgray, &lgraye);
-   XAllocNamedColor (xinfo->display, cmap, "#a8a8a8", &gray, &graye);
-   XAllocNamedColor (xinfo->display, cmap, "red", &red, &rede);
-
-   values.foreground = BlackPixel (xinfo->display, xinfo->screen);
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   binfo->gc [BLACK] = XCreateGC (xinfo->display,
-                                  RootWindow (xinfo->display, xinfo->screen),
-                                  (GCForeground | GCBackground), &values);
-   values.foreground = BlackPixel (xinfo->display, xinfo->screen);
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   values.line_width = 3;
-   values.join_style = JoinRound;
-   binfo->gc [THICKBLACK] = XCreateGC (xinfo->display,
-                                       RootWindow (xinfo->display,
-                                                   xinfo->screen),
-                                       (GCForeground | GCBackground
-                                        | GCLineWidth | GCJoinStyle), &values);
-   values.foreground = gray.pixel;
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   binfo->gc [NGRAY] = XCreateGC (xinfo->display,
-                                  RootWindow (xinfo->display, xinfo->screen),
-                                  (GCForeground | GCBackground), &values);
-   values.foreground = lgray.pixel;
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   binfo->gc [LGRAY] = XCreateGC (xinfo->display,
-                                  RootWindow (xinfo->display, xinfo->screen),
-                                  (GCForeground | GCBackground), &values);
-   values.foreground = dgray.pixel;
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   binfo->gc [DGRAY] = XCreateGC (xinfo->display,
-                                  RootWindow (xinfo->display, xinfo->screen),
-                                  (GCForeground | GCBackground), &values);
-   values.foreground = red.pixel;
-   values.background = WhitePixel (xinfo->display, xinfo->screen);
-   binfo->gc [RED]   = XCreateGC (xinfo->display,
-                                  RootWindow (xinfo->display, xinfo->screen),
-                                  (GCForeground | GCBackground), &values);
-
-   for (button = 0; button < NO_BUTTON; button++)
-      binfo->pressed [button] = NO;
-
-   draw_control_panel (xinfo, binfo, n, n_frames);
-
-   return binfo;
-}
-
-void
-wait_for_input (x11_info_t *xinfo)
-/*
- *  Wait for key press or mouse click in window 'xinfo'.
- *  Redraw 'image' if event other then ButtonPress or KeyPress occurs.
- *  Enlarge or reduce size of image by factor 2^'enlarge_factor'.
- *
- *  No return value.
- *
- *  Side effect:
- *      program is terminated after key press or mouse click.
- */
-{
-   bool_t leave_loop = NO;
-
-   XSelectInput (xinfo->display, xinfo->window, EVENT_MASK);
-
-   while (!leave_loop)
-   {
-      XEvent event;
-
-      XMaskEvent (xinfo->display, EVENT_MASK, &event);
-      switch (event.type)
-      {
-         case ButtonPress:
-         case KeyPress:
-            leave_loop = YES;
-            break;
-         default:
-            display_image (0, 0, xinfo);
-            break;
-      }
-   }
-}
-
-void
-check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames)
-/*
- *  Check the X11 event loop. If the PAUSE buttonin the of panel 'binfo'
- *  is activated wait until next event occurs.
- *  Redraw 'image' if event other then ButtonPress or ButtonRelease occurs.
- *  Enlarge or reduce size of image by factor 2^'enlarge_factor'.
- *  'n' gives the current frame, 'whereas' n_frames is the total number of
- *  frames of the video stream.
- *
- *  No return values.
- *
- *  Side effects:
- *      status of buttons (binfo->pressed [button]) is changed accordingly.
- */
-{
-   bool_t leave_eventloop;
-
-   leave_eventloop = (!binfo->pressed [PAUSE_BUTTON]
-                      && binfo->pressed [PLAY_BUTTON])
-                     || (!binfo->pressed [PAUSE_BUTTON]
-                         && binfo->record_is_rewind
-                         && binfo->pressed [RECORD_BUTTON])
-                     || binfo->pressed [RECORD_BUTTON];
-   draw_progress_bar (xinfo, binfo, n, n_frames);
-
-   if (binfo->pressed [PAUSE_BUTTON] && binfo->pressed [PLAY_BUTTON])
-   {
-      XFlush (xinfo->display);
-      draw_button (xinfo, binfo, PLAY_BUTTON, NO); /* clear PLAY mode */
-      XFlush (xinfo->display);
-   }
-   if (binfo->pressed [PAUSE_BUTTON]
-       && binfo->record_is_rewind && binfo->pressed [RECORD_BUTTON])
-   {
-      XFlush (xinfo->display);
-      draw_button (xinfo, binfo, RECORD_BUTTON, NO); /* clear PLAY mode */
-      XFlush (xinfo->display);
-   }
-
-   if (binfo->pressed [STOP_BUTTON])
-   {
-      XFlush (xinfo->display);
-      draw_button (xinfo, binfo, STOP_BUTTON, NO); /* clear STOP button */
-      XFlush (xinfo->display);
-   }
-
-   do
-   {
-      XEvent event;
-      int    button;
-      bool_t wait_release = NO;
-
-
-      if (XCheckMaskEvent (xinfo->display, EVENT_MASK, &event))
-      {
-         switch (event.type)
-         {
-            case ButtonPress:
-               wait_release = NO;
-               if (!(binfo->pressed [RECORD_BUTTON] &&
-                     !binfo->record_is_rewind))
-                  for (button = 0; button < NO_BUTTON; button++)
-                  {
-                     int x0, y0, x1, y1; /* button coordinates */
-
-                     x0 = button * (binfo->width / NO_BUTTON);
-                     y0 = binfo->progbar_height;
-                     x1 = x0 + binfo->width / NO_BUTTON;
-                     y1 = y0 + binfo->height - binfo->progbar_height - 1;
-                     if (event.xbutton.x > x0 && event.xbutton.x < x1
-                         && event.xbutton.y > y0 && event.xbutton.y < y1)
-                     {
-                        draw_button (xinfo, binfo, button,
-                                     !binfo->pressed [button]);
-                        wait_release = YES;
-                        break;
-                     }
-                  }
-               break;
-            case ButtonRelease:
-               wait_release = NO;
-               break;
-            default:
-               wait_release = NO;
-               draw_control_panel (xinfo, binfo, n, n_frames);
-               display_image (0, 0, xinfo);
-               break;
-         }
-         leave_eventloop = !wait_release
-                           && (binfo->pressed [PLAY_BUTTON]
-                               || binfo->pressed [STOP_BUTTON]
-                               || binfo->pressed [RECORD_BUTTON]
-                               || binfo->pressed [QUIT_BUTTON]);
-      }
-   } while (!leave_eventloop);
-
-   if ((binfo->pressed [RECORD_BUTTON] && !binfo->record_is_rewind)
-       && n == n_frames - 1)
-   {
-      binfo->record_is_rewind = YES;
-      draw_button (xinfo, binfo, RECORD_BUTTON, NO);
-   }
-}
-
-/*****************************************************************************
-
-                                private code
-
-*****************************************************************************/
-
-static void
-draw_control_panel (x11_info_t *xinfo, binfo_t *binfo,
-                    unsigned n, unsigned n_frames)
-/*
- *  Draw control panel 'binfo' with all buttons and progressbar in
- *  the given 'window'.
- *  'n' gives the current frame, 'whereas' n_frames is the total number of
- *  frames of the video stream.
- *
- *  No return value.
- */
-{
-   buttons_t button;
-
-   XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-                   0, 0, binfo->width, binfo->height);
-   draw_progress_bar (xinfo, binfo, n, n_frames);
-   for (button = 0; button < NO_BUTTON; button++)
-      draw_button (xinfo, binfo, button, binfo->pressed [button]);
-}
-
-static void
-draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-                   unsigned n_frames)
-/*
- *  Draw progressbar of control panel 'binfo' in the given 'window'.
- *  'n' gives the current frame, whereas 'n_frames' is the total number of
- *  frames of the video stream.
- *
- *  No return value.
- */
-{
-   unsigned x, y, width, height;
-
-   x      = 2;
-   y      = 1;
-   width  = binfo->width - 5;
-   height = binfo->progbar_height - 3;
-
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],
-              x, y, x + width, y);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],
-              x, y, x, y + height - 1);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],
-              x + width, y + 1, x + width, y + height);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],
-              x, y + height, x + width, y + height);
-
-   x++; y++; width  -= 2; height -= 2;
-   XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-                   x, y, width, height);
-
-   XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-                   x + n * max (1, width / n_frames), y,
-                   max (1, width / n_frames), height);
-}
-
-static void
-draw_button (x11_info_t *xinfo, binfo_t *binfo,
-             buttons_t button, bool_t pressed)
-/*
- *  Draw 'button' of control panel 'binfo' in the given 'window'.
- *  'pressed' indicates whether the button is pressed or not.
- *
- *  No return value.
- */
-{
-   grayscale_t top, bottom;             /* index of GC */
-   unsigned    x, y, width, height;     /* coordinates of button */
-
-   x      = button * (binfo->width / NO_BUTTON);
-   y      = binfo->progbar_height;
-   width  = binfo->width / NO_BUTTON;
-   height = binfo->height - binfo->progbar_height - 1;
-
-   if (width < 4 || height < 4)
-      return;
-
-   if (pressed)
-   {
-      top    = DGRAY;
-      bottom = LGRAY;
-   }
-   else
-   {
-      top    = LGRAY;
-      bottom = DGRAY;
-   }
-
-   x     += 2;
-   width -= 4;
-
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [top],
-              x, y, x + width, y);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [top],
-              x, y, x, y + height - 1);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],
-              x + width, y + 1, x + width, y + height);
-   XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],
-              x, y + height, x + width, y + height);
-
-   x++; y++; width  -= 2; height -= 2;
-   XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],
-                   x, y, width, height);
-
-   switch (button)
-   {
-      case STOP_BUTTON:
-         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-                         x + width / 2 - 6, y + height / 2 - 4, 11, 11);
-         if (pressed && !binfo->pressed [STOP_BUTTON])
-         {
-            draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-            draw_button (xinfo, binfo, PAUSE_BUTTON, NO);
-            draw_button (xinfo, binfo, RECORD_BUTTON, NO);
-         }
-         break;
-      case PAUSE_BUTTON:
-         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-                         x + width / 2 - 6, y + height / 2 - 4, 5, 11);
-         XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-                         x + width / 2 + 1, y + height / 2 - 4, 5, 11);
-         break;
-      case PLAY_BUTTON:
-         {
-            XPoint triangle [3];
-
-            triangle [0].x = x + width / 2 - 5;
-            triangle [0].y = y + height / 2 - 5;
-            triangle [1].x = 10;
-            triangle [1].y = 6;
-            triangle [2].x = -10;
-            triangle [2].y = 6;
-
-            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-                          triangle, 3, Convex, CoordModePrevious);
-            if (pressed && !binfo->pressed [PLAY_BUTTON]
-                && binfo->pressed [RECORD_BUTTON])
-               draw_button (xinfo, binfo, RECORD_BUTTON, NO);
-         }
-         break;
-      case RECORD_BUTTON:
-         if (!binfo->record_is_rewind)
-         {
-            XFillArc (xinfo->display, binfo->window, binfo->gc [RED],
-                      x + width / 2 - 5, y + height / 2 - 5, 11, 11, 0,
-                      360 * 64);
-            if (pressed && !binfo->pressed [RECORD_BUTTON])
-            {
-               draw_button (xinfo, binfo, STOP_BUTTON, YES);
-               draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-               draw_button (xinfo, binfo, PAUSE_BUTTON, NO);
-            }
-         }
-         else
-         {
-            XPoint triangle [3];
-
-            triangle [0].x = x + width / 2 + 5;
-            triangle [0].y = y + height / 2 - 5;
-            triangle [1].x = -10;
-            triangle [1].y = 6;
-            triangle [2].x = 10;
-            triangle [2].y = 6;
-
-            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-                          triangle, 3, Convex, CoordModePrevious);
-            if (pressed && !binfo->pressed [RECORD_BUTTON]
-                && binfo->pressed [PLAY_BUTTON])
-               draw_button (xinfo, binfo, PLAY_BUTTON, NO);
-         }
-         break;
-      case QUIT_BUTTON:
-         {
-            XPoint triangle [3];
-
-            triangle [0].x = x + width / 2 - 6;
-            triangle [0].y = y + height / 2 + 2;
-            triangle [1].x = 6;
-            triangle [1].y = -7;
-            triangle [2].x = 6;
-            triangle [2].y = 7;
-
-            XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],
-                          triangle, 3, Convex, CoordModePrevious);
-            XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],
-                            x + width / 2 - 5, y + height / 2 + 4, 11, 3);
-         }
-         break;
-      default:
-         break;
-   }
-   binfo->pressed [button] = pressed;
-}
-
-#endif /* not X_DISPLAY_MISSING */
diff --git a/converter/other/fiasco/buttons.h b/converter/other/fiasco/buttons.h
deleted file mode 100644
index 19c4935e..00000000
--- a/converter/other/fiasco/buttons.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *  buttons.h
- *
- *  Written by:         Ullrich Hafner
- *
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- */
-
-/*
- *  $Date: 2000/06/14 20:51:17 $
- *  $Author: hafner $
- *  $Revision: 5.1 $
- *  $State: Exp $
- */
-
-#ifndef _BUTTONS_H
-#define _BUTTONS_H
-
-#ifndef X_DISPLAY_MISSING
-
-typedef enum grayscale_e {BLACK, NGRAY, LGRAY, DGRAY, RED,
-                          THICKBLACK, NO_GC} grayscale_t;
-typedef enum buttons_e {STOP_BUTTON, PLAY_BUTTON, PAUSE_BUTTON, RECORD_BUTTON,
-                        QUIT_BUTTON, NO_BUTTON} buttons_t;
-
-typedef struct buttoninfo
-{
-   Window   window;
-   bool_t   pressed [NO_BUTTON];
-   GC       gc [NO_GC];
-   unsigned width;
-   unsigned height;
-   unsigned progbar_height;
-   bool_t   record_is_rewind;
-} binfo_t;
-
-void
-check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n,
-              unsigned n_frames);
-void
-wait_for_input (x11_info_t *xinfo);
-binfo_t *
-init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,
-              unsigned buttons_height, unsigned progbar_height);
-
-#endif /* not X_DISPLAY_MISSING */
-
-#endif /* not _BUTTONS_H */
-
diff --git a/converter/other/fiasco/display.c b/converter/other/fiasco/display.c
deleted file mode 100644
index 5eed6aeb..00000000
--- a/converter/other/fiasco/display.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- *  display.c:          X11 display of frames
- *
- *  Written by:         Ullrich Hafner
- *
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- *
- *  Based on mpeg2decode, (C) 1994, MPEG Software Simulation Group
- *  and      mpeg2play,   (C) 1994 Stefan Eckart
- *                                 <stefan@lis.e-technik.tu-muenchen.de>
- *  and      tmndec       (C) 1995, 1996  Telenor R&D, Norway
- */
-
-/*
- *  $Date: 2000/07/03 19:35:59 $
- *  $Author: hafner $
- *  $Revision: 5.2 $
- *  $State: Exp $
- */
-
-#include "config.h"
-
-#ifndef X_DISPLAY_MISSING
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "types.h"
-#include "macros.h"
-#include "display.h"
-#include "binerror.h"
-
-/*****************************************************************************
-
-               shared memory functions (if USE_SHM is defined)
-
-*****************************************************************************/
-
-#ifdef USE_SHM
-
-#ifdef HAVE_FEATURES_H
-#include <features.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/extensions/XShm.h>
-
-int
-XShmQueryExtension (Display *dpy);
-int
-XShmGetEventBase (Display *dpy);
-
-static int
-HandleXError (Display *dpy, XErrorEvent *event);
-static void
-InstallXErrorHandler (x11_info_t *xinfo);
-static void
-DeInstallXErrorHandler (x11_info_t *xinfo);
-
-static int              shmem_flag;
-static XShmSegmentInfo  shminfo1, shminfo2;
-static int              gXErrorFlag;
-static int              CompletionType = -1;
-
-static int
-HandleXError (Display *dpy, XErrorEvent *event)
-{
-   gXErrorFlag = 1;
-
-   return 0;
-}
-
-static void
-InstallXErrorHandler (x11_info_t *xinfo)
-{
-   XSetErrorHandler (HandleXError);
-   XFlush (xinfo->display);
-}
-
-static void
-DeInstallXErrorHandler (x11_info_t *xinfo)
-{
-   XSetErrorHandler (NULL);
-   XFlush (xinfo->display);
-}
-
-#endif /* USE_SHM */
-
-/*****************************************************************************
-
-                                public code
-
-*****************************************************************************/
-
-void
-display_image (unsigned x0, unsigned y0, x11_info_t *xinfo)
-/*
- *  Display 'image' at pos ('x0', 'y0') in the current window
- *  (given by 'xinfo->window').
- *
- *  No return value.
- */
-{
-   int byte_order_check = 1;
-
-   /*
-    *  Always work in native bit and byte order. This tells Xlib to
-    *  reverse bit and byte order if necessary when crossing a
-    *  network. Frankly, this part of XImages is somewhat
-    *  underdocumented, so this may not be exactly correct.
-    */
-   if (*(char *) & byte_order_check == 1)
-   {
-      xinfo->ximage->byte_order       = LSBFirst;
-      xinfo->ximage->bitmap_bit_order = LSBFirst;
-   }
-   else
-   {
-      xinfo->ximage->byte_order       = MSBFirst;
-      xinfo->ximage->bitmap_bit_order = MSBFirst;
-   }
-
-   /* Display dithered image */
-#ifdef USE_SHM
-   if (shmem_flag)
-   {
-      XEvent xev;
-
-      XShmPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage,
-                    0, 0, x0, y0, xinfo->ximage->width, xinfo->ximage->height,
-                    True);
-      XFlush (xinfo->display);
-
-      while (!XCheckTypedEvent (xinfo->display, CompletionType, &xev))
-         ;
-   }
-   else
-#endif /* USE_SHM */
-   {
-      xinfo->ximage->data = (char *) xinfo->pixels;
-      XPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage, 0, 0,
-                 x0, y0, xinfo->ximage->width, xinfo->ximage->height);
-   }
-}
-
-void
-close_window (x11_info_t *xinfo)
-{
-#ifdef USE_SHM
-   if (shmem_flag && xinfo->ximage)
-   {
-      XShmDetach (xinfo->display, &shminfo1);
-      XDestroyImage (xinfo->ximage);
-      xinfo->ximage = NULL;
-      shmdt (shminfo1.shmaddr);
-   }
-   else
-#endif /* USE_SHM */
-   if (xinfo->ximage)
-   {
-      XDestroyImage (xinfo->ximage);
-      xinfo->ximage = NULL;
-   }
-   if (xinfo->display)
-   {
-      XCloseDisplay (xinfo->display);
-      xinfo->display = NULL;
-   }
-}
-
-x11_info_t *
-open_window (const char *titlename, const char *iconname,
-             unsigned width, unsigned height)
-/*
- *  Open a X11 window of size 'width'x'height'.
- *  If 'color' is false then allocate a colormap with grayscales.
- *  Window and icon titles are given by 'titlename' and 'iconname',
- *  respectively.
- *
- *  Return value:
- *      X11 info struct containing display, gc, window ID and colormap.
- */
-{
-   XVisualInfo          visual_template; /* template for XGetVisualInfo() */
-   XVisualInfo          visual_info;    /* return value of XGetVisualInfo() */
-   int                  visual_n;       /* # of matches of XGetVisualInfo */
-   XEvent               xev;
-   XSizeHints           hint;
-   XSetWindowAttributes xswa;
-   unsigned int         fg, bg;         /* foreground and background color */
-   unsigned int         mask;           /* event mask */
-   x11_info_t           *xinfo = calloc (1, sizeof (x11_info_t));
-   long                 visual_mask;
-
-   if (!xinfo)
-      error ("Out of memory");
-   /*
-    *  Initialization of display
-    */
-   xinfo->display = XOpenDisplay (NULL);
-   if (xinfo->display == NULL)
-      error ("Can't open display.\n"
-             "Make sure that your environment variable DISPLAY "
-             "is set correctly.");
-
-   xinfo->screen = DefaultScreen (xinfo->display);
-   xinfo->gc     = DefaultGC (xinfo->display, xinfo->screen);
-
-   {
-      unsigned   depth []       = {32, 24, 16};
-      int        class []       = {TrueColor, PseudoColor};
-      const char *class_text [] = {"TrueColor", "PseudoColor"};
-      Status     found          = 0;
-      unsigned   d, c;
-
-      for (d = 0; !found && d < sizeof (depth) / sizeof (unsigned); d++)
-         for (c = 0; !found && c < sizeof (class) / sizeof (int); c++)
-         {
-            found = XMatchVisualInfo (xinfo->display, xinfo->screen,
-                                      depth [d], class [c], &visual_info);
-            if (found)
-               fprintf (stderr, "%s : %d bit colordepth.\n",
-                        class_text [c], depth [d]);
-         }
-      if (!found && fiasco_get_verbosity ())
-         error ("Can't find a 16/24/32 bit TrueColor/DirectColor display");
-   }
-
-   /* Width and height of the display window */
-   hint.x = hint.y = 0;
-   hint.min_width  = hint.max_width  = hint.width  = width;
-   hint.min_height = hint.max_height = hint.height = height;
-   hint.flags = PSize | PMinSize | PMaxSize;
-
-   /* Get some colors */
-   bg = WhitePixel (xinfo->display, xinfo->screen);
-   fg = BlackPixel (xinfo->display, xinfo->screen);
-
-   /* Make the window */
-   mask = CWBackPixel | CWBorderPixel;
-   if (visual_info.depth >= 16)
-   {
-      mask |= CWColormap;
-      xswa.colormap = XCreateColormap (xinfo->display,
-                                       DefaultRootWindow (xinfo->display),
-                                       visual_info.visual, AllocNone);
-   }
-   xswa.background_pixel = bg;
-   xswa.border_pixel     = fg;
-   xinfo->window = XCreateWindow (xinfo->display,
-                                  DefaultRootWindow (xinfo->display), 0, 0,
-                                  width, height, 1, visual_info.depth,
-                                  InputOutput, visual_info.visual,
-                                  mask, &xswa);
-
-   XSelectInput (xinfo->display, xinfo->window, StructureNotifyMask);
-
-   /* Tell other applications about this window */
-   XSetStandardProperties (xinfo->display, xinfo->window, titlename, iconname,
-                           None, NULL, 0, &hint);
-
-   /* Map window. */
-   XMapWindow (xinfo->display, xinfo->window);
-
-   /* Wait for map. */
-   do
-   {
-      XNextEvent (xinfo->display, &xev);
-   }
-   while (xev.type != MapNotify || xev.xmap.event != xinfo->window);
-
-   /* Allocate colors */
-
-   return xinfo;
-}
-
-void
-alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height)
-/*
- *  Allocate ximage of size 'width'x'height'.
- *  If USE_SHM is defined then use shared memory extensions.
- *
- *  No return value.
- *
- *  Side effects:
- *      'ximage->ximage' and 'ximage->pixels' are set to useful values.
- */
-{
-   char dummy;
-
-#ifdef USE_SHM
-   if (XShmQueryExtension(xinfo->display))
-   {
-      if (fiasco_get_verbosity ())
-         fprintf (stderr, "Trying shared memory.\n");
-      shmem_flag = 1;
-   }
-   else
-   {
-      shmem_flag = 0;
-      if (fiasco_get_verbosity ())
-         fprintf (stderr,
-              "Shared memory does not work on this system\n"
-              "Reverting to normal Xlib.\n");
-   }
-
-   if (shmem_flag)
-      CompletionType = XShmGetEventBase (xinfo->display) + ShmCompletion;
-
-   InstallXErrorHandler (xinfo);
-
-   if (shmem_flag)
-   {
-      xinfo->ximage = XShmCreateImage (xinfo->display,
-                                       DefaultVisual (xinfo->display,
-                                                      xinfo->screen),
-                                       DefaultDepth (xinfo->display,
-                                                     xinfo->screen), ZPixmap,
-                                       NULL, &shminfo1, width, height);
-
-      /* If no go, then revert to normal Xlib calls. */
-
-      if (xinfo->ximage == NULL)
-      {
-         if (fiasco_get_verbosity ())
-            fprintf (stderr,
-                     "Shared memory error, disabling (Ximage error).\n");
-         goto shmemerror;
-      }
-
-      /* Success here, continue. */
-
-      shminfo1.shmid = shmget (IPC_PRIVATE, xinfo->ximage->bytes_per_line
-                               * xinfo->ximage->height, IPC_CREAT | 0777);
-
-      if (shminfo1.shmid < 0)
-      {
-         XDestroyImage (xinfo->ximage);
-         if (fiasco_get_verbosity ())
-            fprintf (stderr,
-                     "Shared memory error, disabling (seg id error).\n");
-         goto shmemerror;
-      }
-
-      shminfo1.shmaddr = (char *) shmat (shminfo1.shmid, 0, 0);
-      shminfo2.shmaddr = (char *) shmat (shminfo2.shmid, 0, 0);
-
-      if (shminfo1.shmaddr == ((char *) -1))
-      {
-         XDestroyImage (xinfo->ximage);
-         if (shminfo1.shmaddr != ((char *) -1))
-            shmdt (shminfo1.shmaddr);
-         if (fiasco_get_verbosity ())
-            fprintf (stderr,
-                     "Shared memory error, disabling (address error).\n");
-         goto shmemerror;
-      }
-
-      xinfo->ximage->data = shminfo1.shmaddr;
-      xinfo->pixels       = (byte_t *) xinfo->ximage->data;
-      shminfo1.readOnly   = False;
-
-      XShmAttach (xinfo->display, &shminfo1);
-      XSync (xinfo->display, False);
-
-      if (gXErrorFlag)
-      {
-         /* Ultimate failure here. */
-         XDestroyImage (xinfo->ximage);
-         shmdt (shminfo1.shmaddr);
-         if (fiasco_get_verbosity ())
-            fprintf (stderr, "Shared memory error, disabling.\n");
-         gXErrorFlag = 0;
-         goto shmemerror;
-      }
-      else
-         shmctl (shminfo1.shmid, IPC_RMID, 0);
-      if (fiasco_get_verbosity ())
-         fprintf (stderr, "Sharing memory.\n");
-   }
-   else
-   {
-     shmemerror:
-      shmem_flag = 0;
-#endif /* USE_SHM */
-
-      xinfo->ximage = XCreateImage (xinfo->display,
-                                    DefaultVisual (xinfo->display,
-                                                   xinfo->screen),
-                                    DefaultDepth (xinfo->display,
-                                                  xinfo->screen),
-                                    ZPixmap, 0, &dummy, width, height, 8, 0);
-      xinfo->pixels = calloc (width * height,
-                              xinfo->ximage->depth <= 8
-                              ? sizeof (byte_t)
-                              : (xinfo->ximage->depth <= 16
-                                 ? sizeof (u_word_t) : sizeof (unsigned int)));
-      if (!xinfo->pixels)
-         error ("Out of memory.");
-
-#ifdef USE_SHM
-   }
-
-   DeInstallXErrorHandler (xinfo);
-#endif /* USE_SHM */
-}
-
-#endif /* not X_DISPLAY_MISSING */
diff --git a/converter/other/fiasco/display.h b/converter/other/fiasco/display.h
deleted file mode 100644
index 0f9c53dc..00000000
--- a/converter/other/fiasco/display.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  display.h
- *
- *  Written by:         Ullrich Hafner
- *              
- *  This file is part of FIASCO (Fractal Image And Sequence COdec)
- *  Copyright (C) 1994-2000 Ullrich Hafner
- */
-
-/*
- *  $Date: 2000/06/14 20:51:17 $
- *  $Author: hafner $
- *  $Revision: 5.1 $
- *  $State: Exp $
- */
-
-#ifndef _DISPLAY_H
-#define _DISPLAY_H
-
-#ifndef X_DISPLAY_MISSING
-
-#include <X11/Xlib.h>
-
-#include "types.h"
-#include "image.h"
-
-typedef struct x11_info
-{
-   Display *display;
-   int      screen;                     /* default screen number */
-   Window   window;                     
-   XImage  *ximage;
-   GC       gc;
-   byte_t  *pixels;
-} x11_info_t;
-
-void
-display_image (unsigned x0, unsigned y0, x11_info_t *xinfo);
-void
-close_window (x11_info_t *xinfo);
-x11_info_t *
-open_window (const char *titlename, const char *iconname,
-             unsigned width, unsigned height);
-void
-alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height);
-
-#endif /* X_DISPLAY_MISSING */
-
-#endif /* not _DISPLAY_H */
diff --git a/converter/other/fiasco/fiascotopnm.c b/converter/other/fiasco/fiascotopnm.c
index c97e201b..340f9d4e 100644
--- a/converter/other/fiasco/fiascotopnm.c
+++ b/converter/other/fiasco/fiascotopnm.c
@@ -1,5 +1,5 @@
 /*
- *  dwfa.c:     Decoding of WFA-files
+ *  Decode WFA-files
  *
  *  Written by:     Ullrich Hafner
  *          Michael Unger
@@ -25,99 +25,65 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
+#include <getopt.h>
 
+#include "mallocvar.h"
 #include "nstring.h"
 
 #include "types.h"
 #include "macros.h"
 
-#include <getopt.h>
-
-#include "binerror.h"
 #include "misc.h"
 #include "params.h"
 #include "fiasco.h"
 
-#ifndef X_DISPLAY_MISSING
-
-#   include "display.h"
-#   include "buttons.h"
-
-static x11_info_t *xinfo = NULL;
-
-#endif /* not X_DISPLAY_MISSING */
-
-/*****************************************************************************
-
-                prototypes
 
-*****************************************************************************/
-
-static int
-checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
-           int *fps, char **image_name, fiasco_d_options_t **options);
-static void
-video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
-               bool_t double_resolution, int fps, fiasco_d_options_t *options);
-static void
-get_output_template (const char *image_name, const char *wfa_name,
-                     bool_t color, char **basename, char **suffix);
-
-#ifndef X_DISPLAY_MISSING
 
 static void
-show_stored_frames (unsigned char * const *frame_buffer, int last_frame,
-                    x11_info_t *xinfo, binfo_t *binfo, size_t size,
-                    unsigned frame_time);
-
-#endif /* not X_DISPLAY_MISSING */
-
-/*****************************************************************************
-
-                public code
+getOutputTemplate(const char *  const imageName,
+                  const char *  const wfaName,
+                  bool_t        const color,
+                  const char ** const basename,
+                  const char ** const suffixP) {
+/*----------------------------------------------------------------------------
+
+  Generate image filename template for output of image sequences.
+  'wfa_name' is the filename of the WFA stream.
+  Images are either saved with filename 'basename'.'suffix' (still images)
+  or 'basename'.%03d.'suffix' (videos).
+-----------------------------------------------------------------------------*/
+    char * suffixLoc;
+
+    /* Generate filename template */
+    if (!imageName || streq(imageName, "") || streq(imageName, "-")) {
+        if (!wfaName || streq(wfaName, "-"))
+            *basename = strdup("stdin");
+        else
+            *basename = strdup(wfaName);
+        suffixLoc = NULL;
+    } else {
+        *basename = strdup(imageName);
+        suffixLoc = strrchr(*basename, '.');
+    }
 
-*****************************************************************************/
+    if (suffixLoc) {
+        /* found name 'basename.suffix' */
 
-int
-main (int argc, char **argv)
-{
-    char               *image_name        = NULL; /* output filename */
-    bool_t              double_resolution = NO; /* double resolution of image */
-    bool_t              panel             = NO; /* control panel */
-    int             fps               = -1; /* frame display rate */
-    fiasco_d_options_t *options           = NULL; /* additional coder options */
-    int                 last_arg;    /* last processed cmdline parameter */
-
-    init_error_handling (argv[0]);
-
-    last_arg = checkargs (argc, argv, &double_resolution, &panel, &fps,
-                          &image_name, &options);
-
-    if (last_arg >= argc)
-        video_decoder ("-", image_name, panel, double_resolution, fps, options);
-    else
-        while (last_arg++ < argc)
-            video_decoder (argv [last_arg - 1], image_name, panel,
-                           double_resolution, fps, options);
+        *suffixLoc = '\0';         /* remove dot from *basename*/
 
-    return 0;
+        if (*(suffixLoc+1) == '\0')
+            *suffixP = strdup(color ? "ppm" : "pgm");
+        else
+            *suffixP = strdup(suffixLoc + 1);
+    } else             /* no suffix found, generate one */
+        *suffixP = strdup(color ? "ppm" : "pgm");
 }
 
-/*****************************************************************************
 
-                private code
 
-*****************************************************************************/
-
-static param_t params [] =
-{
-#ifdef X_DISPLAY_MISSING
+static param_t params [] = {
     {"output", "FILE", 'o', PSTR, {0}, "-",
      "Write raw PNM frame(s) to `%s'."},
-#else  /* not X_DISPLAY_MISSING */
-    {"output", "FILE", 'o', POSTR, {0}, NULL,
-     "Write raw PNM frame(s) to INPUT.ppm/pgm [or `%s']."},
-#endif /* not X_DISPLAY_MISSING */
     {"double", NULL, 'd', PFLAG, {0}, "FALSE",
      "Interpolate images to double size before display."},
     {"fast", NULL, 'r', PFLAG, {0}, "FALSE",
@@ -134,349 +100,165 @@ static param_t params [] =
 };
 
 static int
-checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel,
-           int *fps, char **image_name, fiasco_d_options_t **options)
-/*
- *  Check validness of command line parameters and of the parameter files.
- *
- *  Return value.
- *  index in argv of the first argv-element that is not an option.
- *
- *  Side effects:
- *  'double_resolution', 'panel', 'fps', 'image_name' and 'options'
- *      are modified.
- */
-{
+checkargs(int                         argc,
+          const char **         const argv,
+          bool_t *              const double_resolution,
+          bool_t *              const panel,
+          int *                 const fps,
+          const char **         const image_name,
+          fiasco_d_options_t ** const options) {
+/*----------------------------------------------------------------------------
+  Check validness of command line parameters and of the parameter files.
+
+  Return value: index in argv of the first argv-element that is not an option.
+
+  Side effects:
+-----------------------------------------------------------------------------*/
     int optind;              /* last processed commandline param */
 
-    optind = parseargs (params, argc, argv,
-#ifdef X_DISPLAY_MISSING
-                        "Decode FIASCO-FILEs and write frame(s) to disk.",
-#else  /* not X_DISPLAY_MISSING */
-                        "Decode and display FIASCO-FILEs using X11.",
-#endif /* not X_DISPLAY_MISSING */
-                        "With no FIASCO-FILE, or if FIASCO-FILE is -, "
-                        "read standard input.\n"
-#ifndef X_DISPLAY_MISSING
-                        "With --output=[FILE] specified, "
-                        "write frames without displaying them.\n\n"
-#endif  /* not X_DISPLAY_MISSING */
-                        "Environment:\n"
-                        "FIASCO_DATA   Search path for automata files. "
-                        "Default: ./\n"
-                        "FIASCO_IMAGES Save path for image files. "
+    optind = parseargs(params, argc, argv,
+                       "Decode FIASCO-FILEs and write frame(s) to disk.",
+                       "With no FIASCO-FILE, or if FIASCO-FILE is -, "
+                       "read standard input.\n"
+                       "Environment:\n"
+                       "FIASCO_DATA   Search path for automata files. "
+                       "Default: ./\n"
+                       "FIASCO_IMAGES Save path for image files. "
                         "Default: ./", " [FIASCO-FILE]...",
-                        FIASCO_SHARE, "system.fiascorc", ".fiascorc");
+                       FIASCO_SHARE, "system.fiascorc", ".fiascorc");
 
     *image_name        =   (char *)   parameter_value (params, "output");
     *double_resolution = *((bool_t *) parameter_value (params, "double"));
     *panel             = *((bool_t *) parameter_value (params, "panel"));
-    *fps           = *((int *)    parameter_value (params, "framerate"));
+    *fps               = *((int *)    parameter_value (params, "framerate"));
 
-    /*
-     *  Additional options ... (have to be set with the fiasco_set_... methods)
+    /* Additional options ... (have to be set with the fiasco_set_... methods)
      */
-    *options = fiasco_d_options_new ();
+    *options = fiasco_d_options_new();
 
     {
-        int const n = *((int *) parameter_value (params, "smoothing"));
+        int const n = *((int *)parameter_value(params, "smoothing"));
 
-        if (!fiasco_d_options_set_smoothing (*options, MAX(-1, n)))
-            error (fiasco_get_error_message ());
+        if (!fiasco_d_options_set_smoothing(*options, MAX(-1, n)))
+            pm_error("%s", fiasco_get_error_message());
     }
 
     {
-        int const n = *((int *) parameter_value (params, "magnify"));
+        int const n = *((int *)parameter_value(params, "magnify"));
 
-        if (!fiasco_d_options_set_magnification (*options, n))
-            error (fiasco_get_error_message ());
+        if (!fiasco_d_options_set_magnification(*options, n))
+            pm_error("%s", fiasco_get_error_message());
     }
 
     {
-        bool_t const n = *((bool_t *) parameter_value (params, "fast"));
+        bool_t const n = *((bool_t *)parameter_value(params, "fast"));
 
-        if (!fiasco_d_options_set_4_2_0_format (*options, n > 0 ? YES : NO))
-            error (fiasco_get_error_message ());
+        if (!fiasco_d_options_set_4_2_0_format(*options, n > 0 ? YES : NO))
+            pm_error("%s", fiasco_get_error_message ());
     }
 
     return optind;
 }
 
+
+
 static void
-video_decoder (const char *wfa_name, const char *image_name, bool_t panel,
-               bool_t double_resolution, int fps, fiasco_d_options_t *options)
-{
-#ifndef X_DISPLAY_MISSING
-    fiasco_renderer_t  *renderer     = NULL;
-    unsigned char     **frame_buffer = NULL;
-    binfo_t            *binfo        = NULL; /* buttons info */
-#endif /* not X_DISPLAY_MISSING */
-
-    do
-    {
-        unsigned      width, height, frames, n;
-        fiasco_decoder_t *decoder_state;
-        char             *filename;
-        char             *basename;   /* basename of decoded frame */
-        char             *suffix;     /* suffix of decoded frame */
-        unsigned      frame_time;
-
-        if (!(decoder_state = fiasco_decoder_new (wfa_name, options)))
-            error (fiasco_get_error_message ());
-
-        if (fps <= 0)         /* then use value of FIASCO file */
-            fps = fiasco_decoder_get_rate (decoder_state);
+video_decoder(const char *         const wfa_name,
+              const char *         const image_name,
+              bool_t               const panel,
+              bool_t               const double_resolution,
+              int                  const fpsArg,
+              fiasco_d_options_t * const options) {
+    do {
+        int                fps;
+        unsigned int       width, height;
+        unsigned int       frames;
+        unsigned int       n;
+        fiasco_decoder_t * decoder_state;
+        char *             filename;
+        const char *       basename;   /* basename of decoded frame */
+        const char *       suffix;     /* suffix of decoded frame */
+        unsigned int       frame_time;
+
+        if (!(decoder_state = fiasco_decoder_new(wfa_name, options)))
+            pm_error("%s", fiasco_get_error_message ());
+
+        if (fpsArg <= 0)         /* then use value of FIASCO file */
+            fps = fiasco_decoder_get_rate(decoder_state);
+        else
+            fps = fpsArg;
+
         frame_time = fps ? (1000 / fps) : (1000 / 25);
 
-        if (!(width = fiasco_decoder_get_width (decoder_state)))
-            error (fiasco_get_error_message ());
+        if (!(width = fiasco_decoder_get_width(decoder_state)))
+            pm_error("%s", fiasco_get_error_message ());
 
-        if (!(height = fiasco_decoder_get_height (decoder_state)))
-            error (fiasco_get_error_message ());
+        if (!(height = fiasco_decoder_get_height(decoder_state)))
+            pm_error("%s", fiasco_get_error_message ());
 
-        if (!(frames = fiasco_decoder_get_length (decoder_state)))
-            error (fiasco_get_error_message ());
+        if (!(frames = fiasco_decoder_get_length(decoder_state)))
+            pm_error("%s", fiasco_get_error_message ());
 
-        get_output_template (image_name, wfa_name,
-                             fiasco_decoder_is_color (decoder_state),
-                             &basename, &suffix);
+        getOutputTemplate(image_name, wfa_name,
+                          fiasco_decoder_is_color(decoder_state),
+                          &basename, &suffix);
 
-        filename = calloc (strlen (basename) + strlen (suffix) + 2
-                           + 10 + (int) (log10 (frames) + 1), sizeof (char));
-        if (!filename)
-            error ("Out of memory.");
+        MALLOCARRAY_NOFAIL(filename,
+                           strlen (basename) + strlen (suffix) + 2
+                           + 10 + (int) (log10 (frames) + 1));
 
-        for (n = 0; n < frames; n++)
-        {
+        for (n = 0; n < frames; ++n) {
             clock_t fps_timer;     /* frames per second timer struct */
 
-            prg_timer (&fps_timer, START);
+            prg_timer(&fps_timer, START);
 
-            if (image_name)        /* just write frame to disk */
-            {
-                if (frames == 1)        /* just one image */
-                {
-                    if (streq (image_name, "-"))
-                        strcpy (filename, "-");
+            if (image_name) {
+                /* just write frame to disk */
+                if (frames == 1) {
+                    if (streq(image_name, "-"))
+                        strcpy(filename, "-");
                     else
-                        sprintf (filename, "%s.%s", basename, suffix);
-                }
-                else
-                {
-                    fprintf (stderr, "Decoding frame %d to file `%s.%0*d.%s\n",
-                             n, basename, (int) (log10 (frames - 1) + 1),
-                             n, suffix);
-                    sprintf (filename, "%s.%0*d.%s", basename,
-                             (int) (log10 (frames - 1) + 1), n, suffix);
+                        sprintf(filename, "%s.%s", basename, suffix);
+                } else {
+                    pm_message("Decoding frame %d to file `%s.%0*d.%s",
+                               n, basename, (int) (log10 (frames - 1) + 1),
+                               n, suffix);
+                    sprintf(filename, "%s.%0*d.%s", basename,
+                            (int) (log10 (frames - 1) + 1), n, suffix);
                 }
 
                 if (!fiasco_decoder_write_frame (decoder_state, filename))
-                    error (fiasco_get_error_message ());
-            }
-#ifndef X_DISPLAY_MISSING
-            else
-            {
-                fiasco_image_t *frame;
-
-                if (!(frame = fiasco_decoder_get_frame (decoder_state)))
-                    error (fiasco_get_error_message ());
-
-                if (frames == 1)
-                    panel = NO;
-
-                if (xinfo == NULL)      /* initialize X11 window */
-                {
-                    const char * const title =
-                        fiasco_decoder_get_title (decoder_state);
-                    char        titlename [MAXSTRLEN];
-
-
-                    sprintf (titlename, "dfiasco " VERSION ": %s",
-                             strlen (title) > 0 ? title : wfa_name);
-                    xinfo =
-                        open_window (titlename, "dfiasco",
-                                     (width  << (double_resolution ? 1 : 0)),
-                                     (height << (double_resolution ? 1 : 0))
-                                     + (panel ? 30 : 0));
-                    alloc_ximage (xinfo, width  << (double_resolution ? 1 : 0),
-                                  height << (double_resolution ? 1 : 0));
-                    if (panel)       /* initialize button panel */
-                        binfo = init_buttons (xinfo, n, frames, 30, 10);
-                    renderer =
-                        fiasco_renderer_new (xinfo->ximage->red_mask,
-                                             xinfo->ximage->green_mask,
-                                             xinfo->ximage->blue_mask,
-                                             xinfo->ximage->bits_per_pixel,
-                                             double_resolution);
-                    if (!renderer)
-                        error (fiasco_get_error_message ());
-                }
-                renderer->render (renderer, xinfo->pixels, frame);
-                frame->delete (frame);
-
-                if (frame_buffer != NULL) /* store next frame */
-                {
-                    size_t size = (width  << (double_resolution ? 1 : 0))
-                        * (height << (double_resolution ? 1 : 0))
-                        * (xinfo->ximage->depth <= 8
-                           ? sizeof (byte_t)
-                           : (xinfo->ximage->depth <= 16
-                              ? sizeof (u_word_t)
-                              : sizeof (unsigned int)));
-
-                    frame_buffer [n] = malloc (size);
-                    if (!frame_buffer [n])
-                        error ("Out of memory.");
-                    memcpy (frame_buffer [n], xinfo->pixels, size);
-
-                    if (n == frames - 1)
-                    {
-                        show_stored_frames (frame_buffer, frames - 1,
-                                            xinfo, binfo, size, frame_time);
-                        break;
-                    }
-                }
-
-                display_image (0, 0, xinfo);
-                if (frames == 1)
-                    wait_for_input (xinfo);
-                else if (panel)
-                {
-                    check_events (xinfo, binfo, n, frames);
-                    if (binfo->pressed [QUIT_BUTTON])
-                        /* start from beginning */
-                        break;
-                    if (binfo->pressed [STOP_BUTTON])
-                        /* start from beginning */
-                        n = frames;
-
-                    if (binfo->pressed [RECORD_BUTTON] && frame_buffer == NULL)
-                    {
-                        n = frames;
-                        frame_buffer =
-                            calloc (frames, sizeof (unsigned char *));
-                        if (!frame_buffer)
-                            error ("Out of memory.");
-                    }
-                }
-                while (prg_timer (&fps_timer, STOP) < frame_time) /* wait */
-                    ;
+                    pm_error("%s", fiasco_get_error_message ());
             }
-#else
             if (frame_time) {/* defeat compiler warning */}
-#endif /* not X_DISPLAY_MISSING */
         }
-        free (filename);
+        free(filename);
 
-        fiasco_decoder_delete (decoder_state);
-    } while (panel
-
-#ifndef X_DISPLAY_MISSING
-             && !binfo->pressed [QUIT_BUTTON]
-#endif /* not X_DISPLAY_MISSING */
+        fiasco_decoder_delete(decoder_state);
+    } while (panel);
+}
 
-        );
+int
+main(int argc, const char **argv) {
 
-#ifndef X_DISPLAY_MISSING
-    if (renderer)
-        renderer->delete (renderer);
+    const char *         imageName; /* output filename */
+    bool_t               doubleResolution;/* double resolution of image */
+    bool_t               panel; /* control panel */
+    int                  fps; /* frame display rate */
+    fiasco_d_options_t * options;/* additional coder options */
+    unsigned int         lastArg;    /* last processed cmdline parameter */
 
-    if (!image_name)
-    {
-        close_window (xinfo);
-        free (xinfo);
-        xinfo = NULL;
-        if (binfo)
-            free (binfo);
-    }
-#endif /* not X_DISPLAY_MISSING */
-}
+    lastArg = checkargs(argc, argv, &doubleResolution, &panel, &fps,
+                        &imageName, &options);
 
-static void
-get_output_template (const char *image_name, const char *wfa_name,
-                     bool_t color, char **basename, char **suffix)
-/*
- *  Generate image filename template for output of image sequences.
- *  'wfa_name' is the filename of the WFA stream.
- *  Images are either saved with filename 'basename'.'suffix' (still images)
- *  or 'basename'.%03d.'suffix' (videos).
- *
- *  No return value.
- *
- *  Side effects:
- *  '*basename' and '*suffix' is set.
- */
-{
-    if (!wfa_name || streq (wfa_name, "-"))
-        wfa_name = "stdin";
-    /*
-     *  Generate filename template
-     */
-    if (!image_name || streq (image_name, "") || streq (image_name, "-"))
-    {
-        *basename = strdup (wfa_name);
-        *suffix   = NULL;
-    }
+    if (lastArg >= argc)
+        video_decoder("-", imageName, panel, doubleResolution, fps, options);
     else
-    {
-        *basename = strdup (image_name);
-        *suffix   = strrchr (*basename, '.');
-    }
+        while (lastArg++ < argc)
+            video_decoder(argv [lastArg - 1], imageName, panel,
+                          doubleResolution, fps, options);
 
-    if (*suffix)         /* found name 'basename.suffix' */
-    {
-        **suffix = 0;         /* remove dot */
-        (*suffix)++;
-        if (**suffix == 0)
-            *suffix = strdup (color ? "ppm" : "pgm");
-    }
-    else             /* no suffix found, generate one */
-        *suffix = strdup (color ? "ppm" : "pgm");
+    return 0;
 }
 
-#ifndef X_DISPLAY_MISSING
-
-static void
-show_stored_frames (unsigned char * const *frame_buffer, int last_frame,
-                    x11_info_t *xinfo, binfo_t *binfo, size_t size,
-                    unsigned frame_time)
-/*
- *  After a WFA video stream has been saved, all frames have been
- *  decoded and stored in memory. These frames are then displayed
- *  in an endless loop.
- *
- *  This function never returns, the program is terminated if the
- *  STOP button is pressed.
- */
-{
-    int n = last_frame;          /* frame number */
-
-    while (1)
-    {
-        clock_t fps_timer;        /* frames per second timer struct */
-
-        prg_timer (&fps_timer, START);
-
-        display_image (0, 0, xinfo);
-        check_events (xinfo, binfo, n, last_frame + 1);
-
-        if (binfo->pressed [STOP_BUTTON])
-            n = 0;
-        else if (binfo->pressed [QUIT_BUTTON])
-            break;
-        else if (binfo->pressed [PLAY_BUTTON])
-            n++;
-        else if (binfo->pressed [RECORD_BUTTON]) /* REWIND is mapped RECORD */
-            n--;
-        if (n < 0)
-            n = last_frame;
-        if (n > last_frame)
-            n = 0;
-
-        memcpy (xinfo->pixels, frame_buffer [n], size);
-        while (prg_timer (&fps_timer, STOP) < frame_time) /* wait */
-            ;
-    };
-}
 
-#endif /* not X_DISPLAY_MISSING */
diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c
index 32145fc3..042a14e2 100644
--- a/converter/other/fiasco/params.c
+++ b/converter/other/fiasco/params.c
@@ -22,6 +22,7 @@
 
 #include "config.h"
 
+#include <assert.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <math.h>                       /* strtod() on SUN sparc */
@@ -32,6 +33,7 @@
 #include <getopt.h>                     /* system or ../lib */
 
 #include "pm_c_util.h"
+#include "mallocvar.h"
 #include "nstring.h"
 
 #include "types.h"
@@ -40,626 +42,181 @@
 #include "misc.h"
 #include "fiasco.h"
 
-#include "binerror.h"
-
 #include "params.h"
 
-/*****************************************************************************
-
-                                prototypes
-
-*****************************************************************************/
 
 static void
-read_parameter_file (param_t *params, FILE *file);
-static int
-get_parameter_index (const param_t *params, const char *search_string);
-static void
-set_parameter (param_t *parameter, const char *value);
-static void
-usage (const param_t *params, const char *progname, const char *synopsis,
-       const char *comment, const char *non_opt_string,
-       bool_t show_all_options, const char *sys_file_name,
-       const char *usr_file_name);
+setParameter(param_t *    const parameter,
+             const char * const value) {
+/*----------------------------------------------------------------------------
 
-/*****************************************************************************
+  Set value of 'parameter' to 'value'.
 
-                                public code
+  No return value.
 
-*****************************************************************************/
+  Side effects:
+     'parameter.value' is changed accordingly
 
-int
-parseargs (param_t *usr_params,
-           int argc, char **argv,
-           const char *synopsis,
-           const char *comment,
-           const char *non_opt_string,
-           const char *path,
-           const char *sys_file_name,
-           const char *usr_file_name)
-/*
- *  Perform the command line parsing.
- *  List of allowed parameters is given by 'usr_params'.
- *  Command line and number of parameters are given by 'argv' and 'argc'.
- *  'synopsis' contains a brief description of the program and
- *  'comment' may contain some additional advice.
- *  Initialization order of parameters:
- *      1.) Default values given by the param_t struct
- *      2.) System parameter-file ('path'/'sys_file_name')
- *      3.) User parameter-file ($HOME/'usr_file_name')
- *      4.) Command line parameters
- *      5.) Parameter-file forced by option -f (--config-file)
- *
- *  Return value:
- *      index in ARGV of the first ARGV-element that is not an option.
- *
- *  Side effects:
- *      the elements of ARGV are permuted
- *      usr_params [].value is modified
- */
-{
-   extern int optind;                   /* index in ARGV of the 1st element
-                                           that is not an option */
-   bool_t     detailed_help = NO;       /* NO if all parameters can be modified
-                                           with short options too */
-   unsigned   n1;                       /* number of user parameters */
-   unsigned   n2;                       /* number of system parameters */
-   bool_t     read_config_file = NO;    /* will override command line */
-   param_t    *params;                  /* array of user and system params */
-   param_t    *sys_params;              /* array of system parameters */
-   param_t    detailed_sys_params [] =  /* detailed system parameters */
-   {
-      {"version", NULL, 'v', PFLAG, {0}, NULL,
-       "Print program version number, then exit."},
-      {"verbose", "NUM", 'V', PINT, {0}, "1",
-       "Set level of verbosity to `%s'."},
-      {"config", "FILE", 'f', PSTR, {0}, NULL,
-       "Load `%s' to initialize parameters."},
-      {"info", NULL, 'h', PFLAG, {0}, NULL,
-       "Print brief help, then exit."},
-      {"help", NULL, 'H', PFLAG, {0}, NULL,
-       "Print detailed help, then exit."},
-      {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
-   };
-   param_t    short_sys_params [] =     /* short system parameters */
-   {
-      {"version", NULL, 'v', PFLAG, {0}, NULL,
-       "Print program version number, then exit."},
-      {"verbose", "NUM", 'V', PINT, {0}, "1",
-       "Set level of verbosity to `%s'."},
-      {"config", "FILE", 'f', PSTR, {0}, NULL,
-       "Load `%s' to initialize parameters."},
-      {"help", NULL, 'h', PFLAG, {0}, NULL,
-       "Print this help, then exit."},
-      {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
-   };
-   char *sys_path;                      /* path to system config file */
-
-   sys_path = calloc (strlen (path) + strlen (sys_file_name) + 2,
-                      sizeof (char));
-   if (!sys_path)
-      error ("Out of memory.");
-   sprintf (sys_path, "%s/%s", path, sys_file_name);
-
-   /*
-    *  Set parameters defaults
-    */
-   {
-       param_t *p;
-
-       for (p = usr_params; p->name != NULL; p++)
-       {
-           set_parameter (p, p->default_value);
-           if (p->optchar == '\0')
-               detailed_help = YES;
-       }
-
-      sys_params = detailed_help ? detailed_sys_params : short_sys_params;
-
-      for (p = sys_params; p->name != NULL; p++)
-          set_parameter (p, p->default_value);
-   }
-   /*
-    *  Append system command line option to user parameters
-    */
-   for (n1 = 0; usr_params [n1].name != NULL; n1++)
-      ;
-   for (n2 = 0; sys_params [n2].name != NULL; n2++)
-      ;
-   params = calloc (n1 + n2 + 1, sizeof (param_t));
-   if (!params)
-      error ("Out of memory.");
-
-   memcpy (params, usr_params, n1 * sizeof (param_t));
-   memcpy (params + n1, sys_params, (n2 + 1) * sizeof (param_t));
-   /*
-    *  Try to open the system resource file 'path'/'sys_file_name'
-    */
-   {
-      FILE *parameter_file = open_file (sys_path, NULL, READ_ACCESS);
-      if (parameter_file == NULL)
-/*
-         warning ("No system resource file found.");
-*/ {}
-      else
-      {
-         read_parameter_file (params, parameter_file);
-         fclose (parameter_file);
-      }
-   }
-   /*
-    *  Try to read user resource file $HOME/'usr_file_name'
-    */
-   {
-      FILE *parameter_file = open_file (usr_file_name, "HOME", READ_ACCESS);
-      if (parameter_file != NULL)
-      {
-         read_parameter_file (params, parameter_file);
-         fclose (parameter_file);
-      }
-   }
-   /*
-    *  Parse command line options
-    */
-   {
-      extern char   *optarg;            /* argument of current option */
-      struct option *long_options;      /* array of long options */
-      int            option_index = 0;
-      char           optstr [MAXSTRLEN]; /* string containing the legitimate
-                                            option characters */
-      int            optchar;           /* found option character */
-
-      /*
-       *  Build short option string for getopt_long ().
-       */
-      {
-         param_t *p;                    /* counter */
-         char    *ptr_optstr;           /* pointer to position in string */
-
-         ptr_optstr = optstr;
-         for (p = params; p->name != NULL; p++)
-            if (p->optchar != '\0')
-            {
-               *ptr_optstr++ = p->optchar;
-               if (p->type == POSTR)
-               {
-                  *ptr_optstr++ = ':';
-                  *ptr_optstr++ = ':';
-               }
-               else if (p->type != PFLAG)
-                  *ptr_optstr++ = ':';
-            }
-         *ptr_optstr = '\0';
-      }
-
-      /*
-       *  Build long option string for getopt_long ().
-       */
-      {
-         int i;
-
-         long_options = calloc (n1 + n2 + 1, sizeof (struct option));
-         if (!long_options)
-            error ("Out of memory.");
-         for (i = 0; params [i].name != NULL; i++)
-         {
-            long_options [i].name    = params [i].name;
-            switch (params [i].type)
-            {
-               case PFLAG:
-                  long_options [i].has_arg = 0;
-                  break;
-               case POSTR:
-                  long_options [i].has_arg = 2;
-                  break;
-               case PINT:
-               case PSTR:
-               case PFLOAT:
-               default:
-                  long_options [i].has_arg = 1;
-                  break;
-            }
-            long_options [i].has_arg = params [i].type != PFLAG;
-            long_options [i].flag    = NULL;
-            long_options [i].val     = 0;
-         }
-      }
-
-      /*
-       *  Parse command line
-       */
-      while ((optchar = getopt_long (argc, argv, optstr, long_options,
-                                     &option_index)) != EOF)
-      {
-         int param_index = -1;
-
-         switch (optchar)
-         {
-            case 0:
-               param_index = option_index;
-               break;
-            case ':':
-               if (detailed_help)
-                  fprintf (stderr,
-                           "Try `%s -h' or `%s --help' for "
-                           "more information.\n",
-                           argv [0], argv [0]);
-               else
-                  fprintf (stderr, "Try `%s --help' for more information.\n",
-                           argv [0]);
-               exit (2);
-               break;
-            case '?':
-               if (detailed_help)
-                  fprintf (stderr,
-                           "Try `%s -h' or `%s --help' "
-                           "for more information.\n",
-                           argv [0], argv [0]);
-               else
-                  fprintf (stderr, "Try `%s --help' for more information.\n",
-                           argv [0]);
-               exit (2);
-               break;
-            default:
-               {
-                  int i;
+-----------------------------------------------------------------------------*/
+    assert (parameter);
 
-                  for (i = 0; params [i].name != NULL; i++)
-                     if (params [i].optchar == optchar)
-                     {
-                        param_index = i;
-                        break;
-                     }
-               }
-         }
-         /*
-          *  Check for system options
-          */
-         if (param_index >= 0)
-         {
-            set_parameter (params + param_index, optarg ? optarg : "");
-            if (streq (params [param_index].name, "help"))
-               usage (params, argv [0], synopsis, comment, non_opt_string,
-                      YES, sys_path, usr_file_name);
-            else if (streq (params [param_index].name, "info"))
-               usage (params, argv [0], synopsis, comment, non_opt_string,
-                      NO, sys_path, usr_file_name);
-            else if (streq (params [param_index].name, "version"))
-            {
-           fprintf (stderr, "%s " VERSION "\n", argv [0]);
-           {
-              /* Kludge for standard Netpbm version announcement */
-              char * modified_argv[2];
-              int argc;
-              modified_argv[0] = argv[0];
-              modified_argv[1] = (char *) "--version";
-              argc = 2;
-              pm_proginit(&argc, (const char **) modified_argv);
-           }
-           exit (2);
+    switch (parameter->type) {
+    case PFLAG:
+        if (value != NULL && *value != '\0') {
+            if (strcaseeq (value, "TRUE"))
+                parameter->value.b = YES;
+            else if (strcaseeq (value, "FALSE"))
+                parameter->value.b = NO;
+            else if (strcaseeq (value, "YES"))
+                parameter->value.b = YES;
+            else if (strcaseeq (value, "NO"))
+                parameter->value.b = NO;
+            else {
+                long int data;
+                char     *endptr;
+
+                data = strtol (value, &endptr, 0);
+                if (*endptr != '\0' || endptr == value)
+                    pm_message("Invalid value `%s' converted to %d",
+                               value, (int) data);
+                parameter->value.b = data ? YES : NO;
             }
-            else if (streq (params [param_index].name, "verbose"))
-               fiasco_set_verbosity (
-               * (fiasco_verbosity_e *) parameter_value (params,
-                                                         "verbose"));
-            else if (streq (params [param_index].name, "config"))
-               read_config_file = YES;
-            param_index = -1;           /* clear index flag */
-         }
-      }
-
-      free (long_options);
-   }
-
-   /*
-    *  Read config-file if specified by option -f
-    */
-   if (read_config_file)
-   {
-      char *filename;
-
-      if ((filename = (char *) parameter_value (params, "config")) != NULL)
-      {
-         FILE *parameter_file;          /* input file */
-
-         warning ("Options set in file `%s' will override"
-                  " command line options.", filename);
-         parameter_file = open_file (filename, NULL, READ_ACCESS);
-         if (parameter_file != NULL)
-         {
-            read_parameter_file (params, parameter_file);
-            fclose (parameter_file);
-         }
-         else
-            file_error (filename);
-      }
-      else
-         error ("Invalid config filename.");
-   }
-
-   memcpy (usr_params, params, n1 * sizeof (param_t)); /* fill user struct */
-   free (sys_path);
-
-   return optind;
+        } else
+            parameter->value.b = !parameter->value.b;
+        break;
+    case PINT: {
+        long int  data;
+        char     *endptr;
+
+        data = strtol (value, &endptr, 0);
+        if (*endptr != '\0' || endptr == value)
+           pm_message("Invalid value `%s' converted to %d",
+                      value, (int) data);
+        parameter->value.i = data;
+    } break;
+    case PFLOAT: {
+        double      data;
+        char        *endptr;
+
+        data = strtod (value, &endptr);
+        if (*endptr != '\0' || endptr == value)
+           pm_message("Invalid value `%s' converted to %f",
+                      value, (double) data);
+        parameter->value.f = data;
+    } break;
+    case PSTR:
+    case POSTR:
+        parameter->value.s = value ? strdup (value) : NULL;
+        break;
+    default:
+         pm_error("Invalid parameter type for %s", parameter->name);
+    }
 }
 
-void *
-parameter_value (const param_t *params, const char *name)
-/*
- *  Extract value of parameter 'name.' of the given parameters 'params'.
- *
- *  Return value:
- *      value of given parameter
- */
-{
-   int pind = get_parameter_index (params, name);
 
-   if (pind < 0)
-      error ("Invalid parameter `%s'.", name);
 
-   if (params [pind].type == PSTR || params [pind].type == POSTR)
-      return (void *) params [pind].value.s;
+static int
+getParameterIndex(const param_t * const params,
+                  const char *    const search_string) {
+/*----------------------------------------------------------------------------
+  Search for parameter with name 'search_string' in parameter struct.
+
+  Return value: index of parameter or -1 if no matching parameter has been
+  found
+-----------------------------------------------------------------------------*/
+    int n;
+    int index = -1;
+
+    assert (params && search_string);
+
+    for (n = 0; params [n].name != NULL; n++) {
+        if (strcaseeq (params [n].name, search_string)) {
+            index = n;
+            break;
+        }
+    }
 
-   return (void *) &(params [pind].value);
+    return index;
 }
 
-void
-ask_and_set (param_t *params, const char *name, const char *msg)
-/*
- *  Ask user (print given message 'msg') for missing mandatory
- *  parameter 'name' of the given parameters 'params'.
- *
- *  No return value.
- *
- *  Side effects:
- *      'params ['name'].value' is changed
- */
-{
-   char answer [MAXSTRLEN];
-   int  index = get_parameter_index (params, name);
-
-   if (index < 0)
-      error ("Invalid parameter %s.", name);
-
-   if (msg)
-      fprintf (stderr, "%s\n", msg);
-
-   switch (params [index].type)
-   {
-      case PFLAG:                       /* Unusual, at least. */
-         warning ("Flags should be initialized and set on demand, "
-                  "not request");
-      case PINT:
-      case PSTR:
-      case POSTR:
-      case PFLOAT:
-         scanf (MAXSTRLEN_SCANF, answer);
-         set_parameter (&params [index], answer);
-         break;
-      default:
-         error ("Invalid parameter type for %s", name);
-   }
-}
 
-void
-write_parameters (const param_t *params, FILE *output)
-/*
- *  Write all parameter settings to 'output'.
- *
- *  No return value.
- */
-{
-   int pind;
-
-   if (!params || !output)
-      error ("Parameters must be not NULL.");
-
-   for (pind = 0; params [pind].name != NULL; pind++)
-   {
-      fprintf (output, "# %s = ", params [pind].name);
-      switch (params [pind].type)
-      {
-         case PFLAG:
-            fprintf (output, "%s\n", params [pind].value.b ? "TRUE" : "FALSE");
-            break;
-         case PINT:
-            fprintf (output, "%d\n", params [pind].value.i);
-            break;
-         case PFLOAT:
-            fprintf (output, "%.4f\n", (double) params [pind].value.f);
-            break;
-         case PSTR:
-         case POSTR:
-            fprintf (output, "%s\n", params [pind].value.s);
-            break;
-         default:
-            error ("Invalid type %d for parameter %s",
-                   params [pind].type, params [pind].name);
-      }
-   }
-   fputc ('\n', output);
-}
 
-/*****************************************************************************
+static void
+readParameterFile(param_t * const params,
+                  FILE *    const file) {
+/*----------------------------------------------------------------------------
 
-                                private code
+  Read parameter settings from 'file'.
 
-*****************************************************************************/
+  No return value.
 
-static void
-set_parameter (param_t *parameter, const char *value)
-/*
- *  Set value of 'parameter' to 'value'.
- *
- *  No return value.
- *
- *  Side effects:
- *      'parameter.value' is changed accordingly
- */
-{
-   assert (parameter);
-
-   switch (parameter->type)
-   {
-      case PFLAG:
-         if (value != NULL && *value != '\0')
-         {
-            if (strcaseeq (value, "TRUE"))
-               parameter->value.b = YES;
-            else if (strcaseeq (value, "FALSE"))
-               parameter->value.b = NO;
-            else if (strcaseeq (value, "YES"))
-               parameter->value.b = YES;
-            else if (strcaseeq (value, "NO"))
-               parameter->value.b = NO;
-            else
-            {
-               long int data;
-               char     *endptr;
-
-               data = strtol (value, &endptr, 0);
-               if (*endptr != '\0' || endptr == value)
-                  warning ("Invalid value `%s' converted to %d",
-                           value, (int) data);
-               parameter->value.b = data ? YES : NO;
-            }
-         }
-         else
-            parameter->value.b = !parameter->value.b;
-         break;
-      case PINT:
-         {
-            long int  data;
-            char     *endptr;
-
-            data = strtol (value, &endptr, 0);
-            if (*endptr != '\0' || endptr == value)
-               warning ("Invalid value `%s' converted to %d",
-                        value, (int) data);
-            parameter->value.i = data;
-         }
-         break;
-      case PFLOAT:
-         {
-            double      data;
-            char        *endptr;
-
-            data = strtod (value, &endptr);
-            if (*endptr != '\0' || endptr == value)
-               warning ("Invalid value `%s' converted to %f",
-                        value, (double) data);
-            parameter->value.f = data;
-         }
-         break;
-      case PSTR:
-      case POSTR:
-         parameter->value.s = value ? strdup (value) : NULL;
-         break;
-      default:
-         error ("Invalid parameter type for %s", parameter->name);
-   }
-}
+  Side effects:
+      'params [].value' are changed if specified in 'file'
+-----------------------------------------------------------------------------*/
+    char buffer [MAXSTRLEN];
+    int  n = 0;
 
-static int
-get_parameter_index (const param_t *params, const char *search_string)
-/*
- *  Search for parameter with name 'search_string' in parameter struct.
- *
- *  Return value:
- *      index of parameter or -1 if no matching parameter has been found
- */
-{
-   int n;
-   int index = -1;
+    assert (params && file);
 
-   assert (params && search_string);
+    while (fgets (buffer, MAXSTRLEN, file) != NULL) {
+        char *b;                          /* temporary variable */
+        char *name;                       /* parameter name */
+        char *value;                      /* parameter value */
+        int   pind;                       /* current argument number */
 
-   for (n = 0; params [n].name != NULL; n++)
-      if (strcaseeq (params [n].name, search_string))
-      {
-         index = n;
-         break;
-      }
+        b = strchr (buffer, '#');
+        if (b != NULL)                    /* Strip comments. */
+            *b = '\0';
 
-   return index;
-}
+        b = strchr (buffer, '=');
+        if (b == NULL)                    /* Strip lines that contain no '=' */
+            continue;
+        *b = '\0';                       /* Replace '=' by string terminator */
 
-static void
-read_parameter_file (param_t *params, FILE *file)
-/*
- *  Read parameter settings from 'file'.
- *
- *  No return value.
- *
- *  Side effects:
- *      'params [].value' are changed if specified in 'file'
- */
-{
-   char buffer [MAXSTRLEN];
-   int  n = 0;
-
-   assert (params && file);
-
-   while (fgets (buffer, MAXSTRLEN, file) != NULL)
-   {
-      char *b;                          /* temporary variable */
-      char *name;                       /* parameter name */
-      char *value;                      /* parameter value */
-      int   pind;                       /* current argument number */
-
-      b = strchr (buffer, '#');
-      if (b != NULL)                    /* Strip comments. */
-         *b = '\0';
-
-      b = strchr (buffer, '=');
-      if (b == NULL)                    /* Strip lines that contain no '=' */
-         continue;
-      *b = '\0';                        /* Replace '=' by string terminator */
-
-      /*
-       *  Extract value of parameter
-       */
-      for (value = b + 1; ISSPACE (*value); value++)
-         ;                              /* Delete leading spaces */
-
-      for (b = value + strlen (value) - 1; b >= value && ISSPACE (*b); b--)
-         *b = '\0';                     /* Delete trailing spaces. */
-
-      /*
-       *  Extract parameter name
-       */
-      for (name = buffer; ISSPACE (*name); name++)
-         ;                              /* Delete leading spaces */
-
-      for (b = name + strlen (name) - 1; b >= name && ISSPACE (*b); b--)
-         *b = '\0';                     /* Delete trailing spaces. */
-
-      pind = get_parameter_index (params, name);
-      if (pind >= 0)
-         set_parameter (&params [pind], value);
-
-      n++;
-   }
+        /* Extract value of parameter */
+        for (value = b + 1; ISSPACE (*value); value++)
+            ;                              /* Delete leading spaces */
+
+        for (b = value + strlen (value) - 1; b >= value && ISSPACE (*b); b--)
+            *b = '\0';                     /* Delete trailing spaces. */
+
+        /* Extract parameter name */
+        for (name = buffer; ISSPACE (*name); name++)
+            ;                              /* Delete leading spaces */
+
+        for (b = name + strlen (name) - 1; b >= name && ISSPACE (*b); b--)
+            *b = '\0';                     /* Delete trailing spaces. */
+
+        pind = getParameterIndex(params, name);
+        if (pind >= 0)
+            setParameter(&params[pind], value);
+
+        ++n;
+    }
 }
 
 
 
 static void
-usage (const param_t *params, const char *progname, const char *synopsis,
-       const char *comment, const char *non_opt_string,
-       bool_t show_all_options, const char *sys_file_name,
-       const char *usr_file_name)
-/*
- *  Generates and prints command line description from param_t struct 'params'.
- *  'progname' is the name of the executable, 'synopsis' a short program
- *  description, and 'comment' some more advice.
- *  If flag 'show_all_options' is set then print also options that are not
- *  associated with a short option character.
- *  'sys_file_name' and 'usr_file_name' are filenames to parameter files.
- *
- *  No return value.
- */
-{
+usage(const param_t *  const params,
+      const char *     const progname,
+      const char *     const synopsis,
+      const char *     const comment,
+      const char *     const non_opt_string,
+      bool_t           const show_all_options,
+      const char *     const sys_file_name,
+      const char *     const usr_file_name) {
+/*----------------------------------------------------------------------------
+
+  Generates and prints command line description from param_t struct 'params'.
+  'progname' is the name of the executable, 'synopsis' a short program
+  description, and 'comment' some more advice.
+  If flag 'show_all_options' is set then print also options that are not
+  associated with a short option character.
+  'sys_file_name' and 'usr_file_name' are filenames to parameter files.
+
+  No return value.
+-----------------------------------------------------------------------------*/
     int   i;
     size_t width = 0;
 
@@ -671,9 +228,8 @@ usage (const param_t *params, const char *progname, const char *synopsis,
     fprintf (stderr, "Mandatory or optional arguments to long options "
              "are mandatory or optional\nfor short options too. "
              "Default values are surrounded by {}.\n");
-    for (i = 0; params [i].name != NULL; i++)
-        if (params [i].optchar != '\0' || show_all_options)
-        {
+    for (i = 0; params [i].name != NULL; i++) {
+        if (params [i].optchar != '\0' || show_all_options) {
             if (params [i].type == POSTR)
                 width = MAX(width, (strlen (params [i].name)
                                      + strlen (params [i].argument_name) + 2));
@@ -683,10 +239,9 @@ usage (const param_t *params, const char *progname, const char *synopsis,
             else
                 width = MAX(width, (strlen (params [i].name)) - 1);
         }
-
-    for (i = 0; params [i].name != NULL; i++)
-        if (params [i].optchar != '\0' || show_all_options)
-        {
+    }
+    for (i = 0; params [i].name != NULL; i++) {
+        if (params [i].optchar != '\0' || show_all_options) {
             if (params [i].optchar != '\0')
                 fprintf (stderr, "  -%c, --", params [i].optchar);
             else
@@ -708,8 +263,7 @@ usage (const param_t *params, const char *progname, const char *synopsis,
 
             fprintf (stderr, params [i].use, params [i].argument_name);
 
-            switch (params [i].type)
-            {
+            switch (params [i].type) {
             case PFLAG:
                 break;
             case PINT:
@@ -724,20 +278,407 @@ usage (const param_t *params, const char *progname, const char *synopsis,
                     fprintf (stderr, "{%s}", params [i].value.s);
                 break;
             default:
-                error ("type %d for %s invalid",
-                       params [i].type, params [i].name);
+               pm_error("type %d for %s invalid",
+                        params [i].type, params [i].name);
             }
             fprintf (stderr, "\n");
         }
+    }
     fprintf (stderr, "\n");
+
     fprintf (stderr, "Parameter initialization order:\n");
     fprintf (stderr,
              "1.) %s\n2.) $HOME/%s\t 3.) command line\t 4.) --config=file",
              sys_file_name, usr_file_name);
     fprintf (stderr, "\n\n");
+
     if (comment != NULL)
         fprintf (stderr, "%s\n", comment);
 
     exit (1);
 }
 
+
+
+const void *
+parameter_value(const param_t * const params,
+                const char *    const name) {
+/*----------------------------------------------------------------------------
+  Extract value of parameter 'name.' of the given parameters 'params'.
+
+  Return value: value of given parameter
+
+-----------------------------------------------------------------------------*/
+    int pind = getParameterIndex(params, name);
+
+    if (pind < 0)
+        pm_error("Invalid parameter '%s'.", name);
+
+    if (params[pind].type == PSTR || params[pind].type == POSTR)
+        return params[pind].value.s;
+
+    return &(params[pind].value);
+}
+
+
+
+int
+parseargs(param_t *     const usr_params,
+          int argc,
+          const char ** const argv,
+          const char *  const synopsis,
+          const char *  const comment,
+          const char *  const non_opt_string,
+          const char *  const path,
+          const char *  const sys_file_name,
+          const char *  const usr_file_name) {
+/*----------------------------------------------------------------------------
+  Perform the command line parsing.
+  List of allowed parameters is given by 'usr_params'.
+  Command line and number of parameters are given by 'argv' and 'argc'.
+  'synopsis' contains a brief description of the program and
+  'comment' may contain some additional advice.
+  Initialization order of parameters:
+     1.) Default values given by the param_t struct
+     2.) System parameter-file ('path'/'sys_file_name')
+     3.) User parameter-file ($HOME/'usr_file_name')
+     4.) Command line parameters
+     5.) Parameter-file forced by option -f (--config-file)
+
+  Return value:
+      index in ARGV of the first ARGV-element that is not an option.
+
+  Side effects:
+      the elements of ARGV are permuted
+      usr_params [].value is modified
+-----------------------------------------------------------------------------*/
+    extern int optind;                   /* index in ARGV of the 1st element
+                                            that is not an option */
+    bool_t     detailed_help = NO;      /* NO if all parameters can be modified
+                                            with short options too */
+    unsigned   n1;                       /* number of user parameters */
+    unsigned   n2;                       /* number of system parameters */
+    bool_t     read_config_file = NO;    /* will override command line */
+    param_t    *params;                  /* array of user and system params */
+    param_t    *sys_params;              /* array of system parameters */
+    param_t    detailed_sys_params [] =  /* detailed system parameters */
+        {
+            {"version", NULL, 'v', PFLAG, {0}, NULL,
+             "Print program version number, then exit."},
+            {"verbose", "NUM", 'V', PINT, {0}, "1",
+             "Set level of verbosity to `%s'."},
+            {"config", "FILE", 'f', PSTR, {0}, NULL,
+             "Load `%s' to initialize parameters."},
+            {"info", NULL, 'h', PFLAG, {0}, NULL,
+             "Print brief help, then exit."},
+            {"help", NULL, 'H', PFLAG, {0}, NULL,
+             "Print detailed help, then exit."},
+            {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
+        };
+    param_t    short_sys_params [] =     /* short system parameters */
+        {
+            {"version", NULL, 'v', PFLAG, {0}, NULL,
+             "Print program version number, then exit."},
+            {"verbose", "NUM", 'V', PINT, {0}, "1",
+             "Set level of verbosity to `%s'."},
+            {"config", "FILE", 'f', PSTR, {0}, NULL,
+             "Load `%s' to initialize parameters."},
+            {"help", NULL, 'h', PFLAG, {0}, NULL,
+             "Print this help, then exit."},
+            {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
+        };
+    const char * sys_path;                     /* path to system config file */
+
+    pm_asprintf(&sys_path, "%s/%s", path, sys_file_name);
+
+    /* Set parameters defaults */
+    {
+        param_t *p;
+
+        for (p = usr_params; p->name != NULL; p++)
+        {
+            setParameter(p, p->default_value);
+            if (p->optchar == '\0')
+                detailed_help = YES;
+        }
+
+        sys_params = detailed_help ? detailed_sys_params : short_sys_params;
+
+        for (p = sys_params; p->name != NULL; p++)
+            setParameter(p, p->default_value);
+    }
+    /* Append system command line option to user parameters */
+    for (n1 = 0; usr_params [n1].name != NULL; n1++)
+        ;
+    for (n2 = 0; sys_params [n2].name != NULL; n2++)
+        ;
+    MALLOCARRAY_NOFAIL(params, n1 + n2 + 1);
+
+    memcpy(params, usr_params, n1 * sizeof(param_t));
+    memcpy(params + n1, sys_params, (n2 + 1) * sizeof(param_t));
+
+    {
+        /* Try to open the system resource file 'path'/'sys_file_name' */
+
+        FILE *parameter_file = open_file(sys_path, NULL, READ_ACCESS);
+
+        if (parameter_file) {
+            readParameterFile(params, parameter_file);
+            fclose(parameter_file);
+        }
+    }
+    {
+        /* Try to read user resource file $HOME/'usr_file_name' */
+
+        FILE *parameter_file = open_file(usr_file_name, "HOME", READ_ACCESS);
+
+        if (parameter_file) {
+            readParameterFile(params, parameter_file);
+            fclose(parameter_file);
+        }
+    }
+    {
+        /* Parse command line options */
+
+        extern char   *optarg;            /* argument of current option */
+        struct option *long_options;      /* array of long options */
+        int            option_index = 0;
+        char           optstr [MAXSTRLEN]; /* string containing the legitimate
+                                              option characters */
+        int            optchar;           /* found option character */
+
+        {
+            /* Build short option string for getopt_long (). */
+            param_t *p;                    /* counter */
+            char    *ptr_optstr;           /* pointer to position in string */
+
+            ptr_optstr = optstr;
+            for (p = params; p->name != NULL; p++)
+                if (p->optchar != '\0')
+                {
+                    *ptr_optstr++ = p->optchar;
+                    if (p->type == POSTR)
+                    {
+                        *ptr_optstr++ = ':';
+                        *ptr_optstr++ = ':';
+                    }
+                    else if (p->type != PFLAG)
+                        *ptr_optstr++ = ':';
+                }
+            *ptr_optstr = '\0';
+        }
+
+        {
+            /* Build long option string for getopt_long (). */
+
+            int i;
+
+            MALLOCARRAY_NOFAIL(long_options, n1 + n2 + 1);
+
+            for (i = 0; params [i].name != NULL; i++) {
+                long_options [i].name    = params [i].name;
+                switch (params [i].type)
+                {
+                case PFLAG:
+                    long_options [i].has_arg = 0;
+                    break;
+                case POSTR:
+                    long_options [i].has_arg = 2;
+                    break;
+                case PINT:
+                case PSTR:
+                case PFLOAT:
+                default:
+                    long_options [i].has_arg = 1;
+                    break;
+                }
+                long_options [i].has_arg = params [i].type != PFLAG;
+                long_options [i].flag    = NULL;
+                long_options [i].val     = 0;
+            }
+        }
+
+        /* Parse command line */
+
+        while ((optchar = getopt_long(argc, (char **)argv, optstr,
+                                      long_options,
+                                      &option_index)) != EOF) {
+            int param_index = -1;
+
+            switch (optchar) {
+            case 0:
+                param_index = option_index;
+                break;
+            case ':':
+                if (detailed_help)
+                    fprintf (stderr,
+                             "Try `%s -h' or `%s --help' for "
+                             "more information.\n",
+                             argv [0], argv [0]);
+                else
+                    fprintf (stderr, "Try `%s --help' for more information.\n",
+                             argv [0]);
+                exit (2);
+                break;
+            case '?':
+                if (detailed_help)
+                    fprintf (stderr,
+                             "Try `%s -h' or `%s --help' "
+                             "for more information.\n",
+                             argv [0], argv [0]);
+                else
+                    fprintf (stderr, "Try `%s --help' for more information.\n",
+                             argv [0]);
+                exit (2);
+                break;
+            default: {
+                int i;
+
+                for (i = 0; params [i].name != NULL; i++) {
+                    if (params [i].optchar == optchar) {
+                        param_index = i;
+                        break;
+                    }
+                }
+            }
+            }
+            /* Check for system options  */
+
+            if (param_index >= 0) {
+                setParameter(params + param_index, optarg ? optarg : "");
+                if (streq(params[param_index].name, "help"))
+                    usage(params, argv [0], synopsis, comment, non_opt_string,
+                          YES, sys_path, usr_file_name);
+                else if (streq(params[param_index].name, "info"))
+                    usage(params, argv [0], synopsis, comment, non_opt_string,
+                           NO, sys_path, usr_file_name);
+                else if (streq(params[param_index].name, "version")) {
+                    fprintf(stderr, "%s " VERSION "\n", argv [0]);
+                    {
+                        /* Kludge for standard Netpbm version announcement */
+                        const char * modifiedArgv[2];
+                        int argc;
+                        modifiedArgv[0] = argv[0];
+                        modifiedArgv[1] = (char *) "--version";
+                        argc = 2;
+                        pm_proginit(&argc, modifiedArgv);
+                    }
+                    exit (2);
+                } else if (streq(params[param_index].name, "verbose"))
+                    fiasco_set_verbosity(
+                        * (fiasco_verbosity_e *) parameter_value(params,
+                                                                 "verbose"));
+                else if (streq(params[param_index].name, "config"))
+                    read_config_file = YES;
+                param_index = -1;           /* clear index flag */
+            }
+        }
+        free(long_options);
+    }
+
+    /* Read config-file if specified by option -f */
+    if (read_config_file) {
+        char * filename;
+
+        if ((filename = (char *) parameter_value(params, "config")) != NULL) {
+            FILE * parameter_file;          /* input file */
+
+            pm_message("Options set in file `%s' will override"
+                       " command line options.", filename);
+            parameter_file = open_file(filename, NULL, READ_ACCESS);
+            if (parameter_file != NULL) {
+                readParameterFile(params, parameter_file);
+                fclose(parameter_file);
+            } else
+                pm_error("Failed to open config file '%s'", filename);
+        } else
+            pm_error("Invalid config filename.");
+    }
+
+    memcpy(usr_params, params, n1 * sizeof (param_t)); /* fill user struct */
+    pm_strfree(sys_path);
+
+    return optind;
+}
+
+
+
+void
+ask_and_set(param_t *    const params,
+            const char * const name,
+            const char * const msg) {
+/*----------------------------------------------------------------------------
+  Ask user (print given message 'msg') for missing mandatory
+  parameter 'name' of the given parameters 'params'.
+
+  No return value.
+
+  Side effects:
+     'params ['name'].value' is changed
+-----------------------------------------------------------------------------*/
+    char answer[MAXSTRLEN];
+    int  index = getParameterIndex(params, name);
+
+    if (index < 0)
+        pm_error("Invalid parameter '%s'.", name);
+
+    if (msg)
+        pm_message("%s", msg);
+
+    switch (params[index].type) {
+    case PFLAG:                       /* Unusual, at least. */
+        pm_message("Flags should be initialized and set on demand, "
+                   "not request");
+    case PINT:
+    case PSTR:
+    case POSTR:
+    case PFLOAT:
+        scanf(MAXSTRLEN_SCANF, answer);
+        setParameter(&params [index], answer);
+        break;
+    default:
+        pm_error("Invalid parameter type for %s", name);
+    }
+}
+
+
+
+void
+write_parameters(const param_t * const params,
+                 FILE *          const output) {
+/*----------------------------------------------------------------------------
+  Write all parameter settings to 'output'.
+
+  No return value.
+-----------------------------------------------------------------------------*/
+    unsigned int pind;
+
+    if (!params || !output)
+        pm_error("Parameters must be not NULL.");
+
+    for (pind = 0; params[pind].name != NULL; pind++) {
+        fprintf(output, "# %s = ", params[pind].name);
+        switch(params[pind].type) {
+        case PFLAG:
+            fprintf(output, "%s\n", params[pind].value.b ? "TRUE" : "FALSE");
+            break;
+        case PINT:
+            fprintf(output, "%d\n", params[pind].value.i);
+            break;
+        case PFLOAT:
+            fprintf(output, "%.4f\n", (double) params[pind].value.f);
+            break;
+        case PSTR:
+        case POSTR:
+            fprintf(output, "%s\n", params[pind].value.s);
+            break;
+        default:
+            pm_error("Invalid type %d for parameter %s",
+                     params[pind].type, params[pind].name);
+        }
+    }
+    fputc ('\n', output);
+}
+
+
+
diff --git a/converter/other/fiasco/params.h b/converter/other/fiasco/params.h
index dd79d43d..85b0b648 100644
--- a/converter/other/fiasco/params.h
+++ b/converter/other/fiasco/params.h
@@ -44,7 +44,7 @@ typedef struct param_t
 
 int
 parseargs (param_t *usr_params,
-           int argc, char **argv,
+           int argc, const char **argv,
            const char *synopsis,
            const char *comment,
            const char *non_opt_string,
@@ -53,9 +53,11 @@ parseargs (param_t *usr_params,
            const char *usr_file_name);
 void
 write_parameters (const param_t *params, FILE *output);
+
 void
 ask_and_set (param_t *params, const char *name, const char *msg);
-void *
+
+const void *
 parameter_value (const param_t *params, const char *name);
 
 #endif /* not PARAMS_H */
diff --git a/converter/other/fiasco/pnmtofiasco.c b/converter/other/fiasco/pnmtofiasco.c
index 9f63e7a1..311a21c3 100644
--- a/converter/other/fiasco/pnmtofiasco.c
+++ b/converter/other/fiasco/pnmtofiasco.c
@@ -1,5 +1,5 @@
 /*
- *  cwfa.c:     FIASCO coder
+ *  FIASCO coder
  *
  *  Written by:     Ullrich Hafner
  *
@@ -15,32 +15,25 @@
  */
 
 #include "config.h"
-#include "pm_c_util.h"
-#include "pnm.h"
-
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
+#include "pm_c_util.h"
+#include "mallocvar.h"
+#include "pnm.h"
+
 #include "types.h"
 #include "macros.h"
 
-#include "binerror.h"
 #include "misc.h"
 #include "params.h"
 #include "fiasco.h"
 
-/*****************************************************************************
 
-                 local variables
 
-*****************************************************************************/
-
-static param_t params [] =
-{
-  /*
-   *  Options for standard user
-   */
+static param_t params[] = {
+  /* Options for standard user */
   {"image-name", "FILE", 'i', PSTR, {0}, NULL,
    "Compress raw PPM/PGM image(s) `%s'."},
   {"output-name", "FILE", 'o', PSTR, {0}, "-",
@@ -136,244 +129,202 @@ static param_t params [] =
   {NULL, NULL, 0, PSTR, {0}, NULL, NULL }
 };
 
-/*****************************************************************************
-
-                prototypes
-
-*****************************************************************************/
-
-static void
-checkargs (int argc, char **argv, char const ***image_template,
-       char **wfa_name, float *quality, fiasco_c_options_t **options);
-
-/*****************************************************************************
-
-                public code
-
-*****************************************************************************/
-
-int
-main (int argc, char **argv)
-{
-   char const         **image_template; /* template for input image files */
-   char                *wfa_name;   /* filename of output WFA */
-   float            quality;    /* approximation quality */
-   fiasco_c_options_t  *options;    /* additional coder options */
-
-   pnm_init(&argc, argv);
-
-   init_error_handling (argv [0]);
-
-   checkargs (argc, argv, &image_template, &wfa_name, &quality, &options);
-
-   if (fiasco_coder (image_template, wfa_name, quality, options))
-      return 0;
-   else
-   {
-       fprintf (stderr, "%s", fiasco_get_error_message ());
-      fprintf (stderr, "\n");
-      return 1;
-   }
-}
-
-/*****************************************************************************
-
-                private code
 
-*****************************************************************************/
 
 static void
-checkargs (int argc, char **argv, char const ***image_template,
-           char **wfa_name, float *quality, fiasco_c_options_t **options)
-/*
- *  Check validness of command line parameters and of the parameter files.
- *
- *  Return value:
- *  1 on success
- *  0 otherwise
- *
- *
- *  Side effects:
- *  'image_template', 'wfa_name', 'quality' and 'options' are set.
- */
-{
-    int   optind;            /* last processed commandline param */
-    char *image_name;            /* filename given by option '--input_name' */
-    int   i;             /* counter */
-
-    optind = parseargs (params, argc, argv,
-                        "Compress raw PPM/PGM image FILEs to a FIASCO file.",
-                        "With no image FILE, or if FILE is -, "
-                        "read standard input.\n"
-                        "FILE must be either a filename"
-                        " or an image template of the form:\n"
-                        "`prefix[start-end{+,-}step]suffix'\n"
-                        "e.g., img0[12-01-1].pgm is substituted by"
-                        " img012.pgm ... img001.pgm\n\n"
-                        "Environment:\n"
-                        "FIASCO_DATA   Search and save path for FIASCO files. "
-                        "Default: ./\n"
-                        "FIASCO_IMAGES Search path for image files. "
-                        "Default: ./", " [FILE]...",
-                        FIASCO_SHARE, "system.fiascorc", ".fiascorc");
-
-    /*
-     *  Default options ...
-     */
-    image_name = (char *) parameter_value (params, "image-name");
-    *wfa_name  = (char *) parameter_value (params, "output-name");
-    for (;;)
-    {
-        *quality = * (float *) parameter_value (params, "quality");
+checkargs(int                         argc,
+          const char **               argv,
+          const char ***        const imageTemplateListP,
+          char **               const wfa_name,
+          float *               const quality,
+          fiasco_c_options_t ** const options) {
+/*----------------------------------------------------------------------------
+  Check validness of command line parameters and of the parameter files.
+
+  Return value:
+    1 on success
+    0 otherwise
+-----------------------------------------------------------------------------*/
+    int    optind;            /* last processed commandline param */
+    char * image_name;            /* filename given by option '--input_name' */
+    const char ** imageTemplateList;
+
+    optind = parseargs(params, argc, argv,
+                       "Compress raw PPM/PGM image FILEs to a FIASCO file.",
+                       "With no image FILE, or if FILE is -, "
+                       "read standard input.\n"
+                       "FILE must be either a filename"
+                       " or an image template of the form:\n"
+                       "`prefix[start-end{+,-}step]suffix'\n"
+                       "e.g., img0[12-01-1].pgm is substituted by"
+                       " img012.pgm ... img001.pgm\n\n"
+                       "Environment:\n"
+                       "FIASCO_DATA   Search and save path for FIASCO files. "
+                       "Default: ./\n"
+                       "FIASCO_IMAGES Search path for image files. "
+                       "Default: ./", " [FILE]...",
+                       FIASCO_SHARE, "system.fiascorc", ".fiascorc");
+
+    /* Default options  */
+    image_name = (char *) parameter_value(params, "image-name");
+    *wfa_name  = (char *) parameter_value(params, "output-name");
+    for (;;) {
+        *quality = * (float *) parameter_value(params, "quality");
         if (*quality > 100)
-            fprintf (stderr, "Typical range of quality: (0,100].\n"
-                     "Expect some trouble on slow machines.\n");
+            pm_message("Typical range of quality: (0,100].  "
+                       "Expect some trouble on slow machines.");
         if (*quality > 0)
             break;
-        ask_and_set (params, "quality",
-                     "Please enter coding quality 'q' ('q' > 0): ");
+        ask_and_set(params, "quality",
+                    "Please enter coding quality 'q' ('q' > 0): ");
     }
 
-    if (optind < argc)           /* Additional command line param */
-    {
+    /* Non-option command line params */
+    if (optind < argc) {
+        unsigned int i;
         if (image_name)
-            error ("Multiple image_template arguments."
-                   "\nOption --input-name %s already specified!", image_name);
-
-        *image_template = calloc (argc - optind + 1, sizeof (char *));
-        if (!*image_template)
-            error ("Out of memory.");
-        for (i = 0; optind < argc; i++, optind++)
-            (*image_template) [i] = argv [optind];
-        (*image_template) [i] = NULL;
-    }
-    else                 /* option -i image_name */
-    {
-        *image_template = calloc (2, sizeof (char *));
-        if (!*image_template)
-            error ("Out of memory.");
-        (*image_template) [0] = image_name;
-        (*image_template) [1] = NULL;
+            pm_error("Multiple image name template arguments.  "
+                     "Option --image-name already specified with '%s'",
+                     image_name);
+
+        MALLOCARRAY_NOFAIL(imageTemplateList, argc - optind + 1);
+
+        for (i = 0; optind < argc; ++i, ++optind)
+            imageTemplateList[i] = argv[optind];
+        imageTemplateList[i] = NULL;
+    } else {
+        /* option -i image_name */
+
+        MALLOCARRAY_NOFAIL(imageTemplateList, 2);
+
+        imageTemplateList[0] = image_name;
+        imageTemplateList[1] = NULL;
     }
-    /*
-     *  Additional options ... (have to be set with the fiasco_set_... methods)
+    /* Additional options ... (have to be set with the fiasco_set_... methods)
      */
     {
-        *options = fiasco_c_options_new ();
+        *options = fiasco_c_options_new();
 
         {
-            char *pattern = (char *) parameter_value (params, "pattern");
+            const char * const pattern = parameter_value(params, "pattern");
 
             if (!fiasco_c_options_set_frame_pattern (*options, pattern))
-                error (fiasco_get_error_message ());
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            char *basis = (char *) parameter_value (params, "basis-name");
+            const char *const basis = parameter_value(params, "basis-name");
 
             if (!fiasco_c_options_set_basisfile (*options, basis))
-                error (fiasco_get_error_message ());
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            int   n = * (int *) parameter_value (params, "chroma-dictionary");
-            float q = * (float *) parameter_value (params, "chroma-qfactor");
+            int   const n =
+                *(int *)parameter_value(params, "chroma-dictionary");
+            float const q =
+                *(float *)parameter_value(params, "chroma-qfactor");
 
-            if (!fiasco_c_options_set_chroma_quality (*options, q, MAX(0, n)))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_chroma_quality(*options, q, MAX(0, n)))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            int n = *((int *) parameter_value (params, "smooth"));
+            int const n = *((int *)parameter_value(params, "smooth"));
 
-            if (!fiasco_c_options_set_smoothing (*options, MAX(0, n)))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_smoothing(*options, MAX(0, n)))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            int n = * (int *) parameter_value (params, "progress-meter");
+            int const n = *(int *)parameter_value(params, "progress-meter");
             fiasco_progress_e type = (n < 0) ?
                 FIASCO_PROGRESS_NONE : (fiasco_progress_e) n;
 
-            if (!fiasco_c_options_set_progress_meter (*options, type))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_progress_meter(*options, type))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            char *t = (char *) parameter_value (params, "title");
+            const char * const t = parameter_value(params, "title");
 
-            if (strlen (t) > 0 && !fiasco_c_options_set_title (*options, t))
-                error (fiasco_get_error_message ());
+            if (strlen(t) > 0 && !fiasco_c_options_set_title(*options, t))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            char *c = (char *) parameter_value (params, "comment");
+            const char * const c = parameter_value(params, "comment");
 
             if (strlen (c) > 0 && !fiasco_c_options_set_comment (*options, c))
-                error (fiasco_get_error_message ());
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
             fiasco_tiling_e method = FIASCO_TILING_VARIANCE_DSC;
-            int   e  = * (int *) parameter_value (params, "tiling-exponent");
-            char *m  = (char *) parameter_value (params, "tiling-method");
+            int    const e =
+                *(int *)parameter_value(params, "tiling-exponent");
+            const char * const m = parameter_value (params, "tiling-method");
 
-            if (strcaseeq (m, "desc-variance"))
+            if (strcaseeq(m, "desc-variance"))
                 method = FIASCO_TILING_VARIANCE_DSC;
-            else if (strcaseeq (m, "asc-variance"))
+            else if (strcaseeq(m, "asc-variance"))
                 method = FIASCO_TILING_VARIANCE_ASC;
-            else if (strcaseeq (m, "asc-spiral"))
+            else if (strcaseeq(m, "asc-spiral"))
                 method = FIASCO_TILING_SPIRAL_ASC;
-            else if (strcaseeq (m, "dsc-spiral"))
+            else if (strcaseeq(m, "dsc-spiral"))
                 method = FIASCO_TILING_SPIRAL_DSC;
             else
-                error (_("Invalid tiling method `%s' specified."), m);
+                pm_error("Invalid tiling method `%s' specified.", m);
 
-            if (!fiasco_c_options_set_tiling (*options, method, MAX(0, e)))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_tiling(*options, method, MAX(0, e)))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
         {
-            int M/*  = * (int *) parameter_value (params, "max-level") */;
-            int m/*  = * (int *) parameter_value (params, "min-level") */;
-            int N/*  = * (int *) parameter_value (params, "max-elements") */;
-            int D = * (int *) parameter_value (params, "dictionary-size");
-            int o = * (int *) parameter_value (params, "optimize");
-
-            if (o <= 0)
-            {
+            int M /*  = * (int *) parameter_value (params, "max-level") */;
+            int m /*  = * (int *) parameter_value (params, "min-level") */;
+            int N /*  = * (int *) parameter_value (params, "max-elements") */;
+            int o;
+            int D = * (int *) parameter_value(params, "dictionary-size");
+            int const optimizeOpt =
+                *(int *)parameter_value(params, "optimize");
+
+            if (optimizeOpt <= 0) {
                 o = 0;
                 M = 10;
                 m = 6;
                 N = 3;
-            }
-            else
-            {
+            } else {
                 o -= 1;
                 M = 12;
                 m = 4;
                 N = 5;
             }
 
-            if (!fiasco_c_options_set_optimizations (*options, m, M, N,
-                                                     MAX(0, D), o))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_optimizations(*options, m, M, N,
+                                                    MAX(0, D), o))
+                pm_error("%s", fiasco_get_error_message ());
         }
         {
-            int M = * (int *) parameter_value (params, "max-level");
-            int m = * (int *) parameter_value (params, "min-level");
-            int p = * (int *) parameter_value (params, "prediction");
+            int const M = *(int *)parameter_value(params, "max-level");
+            int const m = *(int *)parameter_value(params, "min-level");
+            int const p = *(int *)parameter_value(params, "prediction");
 
             if (!fiasco_c_options_set_prediction (*options,
                                                   p, MAX(0, m), MAX(0, M)))
-                error (fiasco_get_error_message ());
+                pm_error("%s", fiasco_get_error_message ());
         }
         {
-            float r    = * (float *)parameter_value(params, "rpf-range");
-            float dc_r = * (float *)parameter_value(params, "dc-rpf-range");
-            int   m    = * (int *)  parameter_value(params, "rpf-mantissa");
-            int   dc_m = * (int *)  parameter_value(params, "dc-rpf-mantissa");
-            fiasco_rpf_range_e range, dc_range;
+            float const r    =
+                *(float *)parameter_value(params, "rpf-range");
+            float const dcR =
+                *(float *)parameter_value(params, "dc-rpf-range");
+            int   const m    =
+                *(int *)parameter_value(params, "rpf-mantissa");
+            int   const dcM =
+                *(int *)parameter_value(params, "dc-rpf-mantissa");
+
+            fiasco_rpf_range_e range, dcRange;
 
             if (r < 1)
                 range = FIASCO_RPF_RANGE_0_75;
@@ -384,24 +335,49 @@ checkargs (int argc, char **argv, char const ***image_template,
             else
                 range = FIASCO_RPF_RANGE_2_00;
 
-            if (dc_r < 1)
-                dc_range = FIASCO_RPF_RANGE_0_75;
-            else if (dc_r < 1.5)
-                dc_range = FIASCO_RPF_RANGE_1_00;
-            else if (dc_r < 2.0)
-                dc_range = FIASCO_RPF_RANGE_1_50;
+            if (dcR < 1)
+                dcRange = FIASCO_RPF_RANGE_0_75;
+            else if (dcR < 1.5)
+                dcRange = FIASCO_RPF_RANGE_1_00;
+            else if (dcR < 2.0)
+                dcRange = FIASCO_RPF_RANGE_1_50;
             else
-                dc_range = FIASCO_RPF_RANGE_2_00;
+                dcRange = FIASCO_RPF_RANGE_2_00;
 
-            if (!fiasco_c_options_set_quantization (*options,
-                                                    MAX(0, m), range,
-                                                    MAX(0, dc_m), dc_range))
-                error (fiasco_get_error_message ());
+            if (!fiasco_c_options_set_quantization(*options,
+                                                   MAX(0, m), range,
+                                                   MAX(0, dcM), dcRange))
+                pm_error("%s", fiasco_get_error_message ());
         }
 
-        if (fiasco_get_verbosity () == FIASCO_ULTIMATE_VERBOSITY)
-            write_parameters (params, stderr);
+        if (fiasco_get_verbosity() == FIASCO_ULTIMATE_VERBOSITY)
+            write_parameters(params, stderr);
+    }
+    *imageTemplateListP = imageTemplateList;
+}
+
+
+
+int
+main(int argc, const char **argv) {
+
+    char const **        image_template; /* template for input image files */
+    char *               wfa_name;   /* filename of output WFA */
+    float                quality;    /* approximation quality */
+    fiasco_c_options_t * options;    /* additional coder options */
+    int                  retval;
+
+    pm_proginit(&argc, argv);
+
+    checkargs(argc, argv, &image_template, &wfa_name, &quality, &options);
+
+    if (fiasco_coder(image_template, wfa_name, quality, options))
+        retval = 0;
+    else {
+        pm_message("Encoding failed.  %s", fiasco_get_error_message());
+        retval = 1;
     }
+    return retval;
 }
 
 
diff --git a/converter/other/fitstopnm.c b/converter/other/fitstopnm.c
index 804d4ae9..ca621164 100644
--- a/converter/other/fitstopnm.c
+++ b/converter/other/fitstopnm.c
@@ -361,7 +361,6 @@ readCard(FILE * const ifP,
 
 
 
-
 static void
 processNaxisN(unsigned int   const n,
               int            const value,
@@ -397,7 +396,7 @@ readFitsHeader(FILE *               const ifP,
 
     bool gotEmpty, gotSimple, gotNaxis, gotN1, gotN2, gotN3, gotBitpix, gotEnd;
 
-    gotEmpty  = false;  /* initial value */    
+    gotEmpty  = false;  /* initial value */
     gotSimple = false;  /* initial value */
     gotNaxis  = false;  /* initial value */
     gotN1     = false;  /* initial value */
@@ -463,7 +462,7 @@ readFitsHeader(FILE *               const ifP,
                 gotEnd = true;
                 if (gotEmpty == true)
                     pm_message("Blank card(s) were encountered before "
-			       "END in header");
+                               "END in header");
             }
         }
     }
diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c
index 6bbfcc05..70debc2e 100644
--- a/converter/other/gemtopnm.c
+++ b/converter/other/gemtopnm.c
@@ -40,6 +40,8 @@
  */
 
 #include <assert.h>
+
+#include "mallocvar.h"
 #include "pnm.h"
 
 #define MAXVAL 3
@@ -47,35 +49,80 @@
 #define DARK   1
 #define BLACK  0
 
-char pattern[8];
 
-static void getinit ARGS ((FILE *file, int *colsP, int *rowsP, int *padrightP,
-               int *patlenP, int *planesP));
+
+static void
+getinit(FILE * const ifP,
+        int *  const colsP,
+        int *  const rowsP,
+        int *  const padrightP,
+        int *  const patlenP,
+        int *  const planesP) {
+
+    short s;
+    short headlen;
+
+    if (pm_readbigshort(ifP, &s) == -1) /* Image file version */
+        pm_error("EOF / read error");
+    if (s != 1)
+        pm_error("unknown version number (%d)", s);
+    if (pm_readbigshort(ifP, &headlen) == -1) /* Header length in words */
+        pm_error("EOF / read error");
+    if (headlen < 8)
+        pm_error("short header (%d)", headlen);
+    if (pm_readbigshort(ifP, &s) == -1) /* Number of planes */
+        pm_error("EOF / read error");
+    if (s != 4 && s != 1)
+        pm_error("This program can interpret IMGs with only 1 or 4 planes");
+    *planesP = s;
+    if (pm_readbigshort(ifP, &s) == -1) /* Pattern definition length (bytes) */
+        pm_error("EOF / read error");
+    if (s < 1 || s > 8)
+        pm_error("illegal pattern length (%d)", s);
+    *patlenP = s;
+    if (pm_readbigshort(ifP, &s) == -1 /* Pixel height (microns) */
+        || pm_readbigshort(ifP, &s) == -1 /* Pixel height (microns) */
+        || pm_readbigshort(ifP, &s) == -1) /* Scan line width */
+        pm_error("EOF / read error");
+    *colsP = s;
+    if (pm_readbigshort(ifP, &s) == -1) /* Number of scan line items */
+        pm_error("EOF / read error");
+    *rowsP = s;
+    *padrightP = 7 - ((*colsP + 7) & 0x7);
+
+    headlen -= 8;
+    while (headlen-- > 0) {
+        getc(ifP);
+        getc(ifP);
+    }
+}
+
+
 
 int
-main(argc, argv)
-    int             argc;
-    char           *argv[];
-{
+main(int argc, const char ** argv) {
+
     int     debug = 0;
-    FILE    *f;
+    FILE    *ifP;
     int     row;
     int     rows, cols, padright, patlen, planes;
       /* attributes of input image */
     int type;  /* The format type (PBM/PPM) of the output image */
-    bit *bitrow[4];
+    bit * bitrow[4];
       /* One row of input, one or four planes.  (If one, only [0] is defined)*/
     xel * xelrow;  /* One row of output */
+    char pattern[8];
     const char * const usage = "[-debug] [gem IMG file]";
     int argn;
 
-/* Process multiple planes by maintaining a separate row of bits for each
- * plane. In a single-plane image, all we have to do is write out the
- * first plane; in a multiple-plane image, we combine them just before writing
- * out the row.
- */
-    pnm_init( &argc, argv );
+    /* Process multiple planes by maintaining a separate row of bits for each
+       plane. In a single-plane image, all we have to do is write out the
+       first plane; in a multiple-plane image, we combine them just before
+       writing out the row.
+    */
+    pm_proginit(&argc, argv);
 
+    debug = 0; /* initial value */
     argn = 1;
 
     while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0')
@@ -88,220 +135,175 @@ main(argc, argv)
       }
 
     if (argc == argn)
-        f = stdin;
+        ifP = stdin;
     else {
-        f = pm_openr (argv[argn]);
+        ifP = pm_openr (argv[argn]);
         ++argn;
     }
 
     if (argn != argc)
       pm_usage (usage);
 
-    getinit (f, &cols, &rows, &padright, &patlen, &planes);
+    getinit(ifP, &cols, &rows, &padright, &patlen, &planes);
 
     if (planes == 1)
         type = PBM_TYPE;
     else
         type = PPM_TYPE;
 
-    pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 );
+    pnm_writepnminit(stdout, cols, rows, MAXVAL, type, 0);
 
     {
         /* allocate input row data structure */
-        int plane;
-        for (plane = 0; plane < planes; plane++)
-            bitrow[plane] = malloc (cols + padright);
+        unsigned int plane;
+        for (plane = 0; plane < planes; ++plane) {
+            MALLOCARRAY(bitrow[plane], cols + padright);
+            if (!bitrow[plane])
+                pm_error("Unable to allocate memory for %u columns", cols);
+        }
     }
-    xelrow = pnm_allocrow(cols+padright);   /* Output row */
+    xelrow = pnm_allocrow(cols + padright);   /* Output row */
 
     for (row = 0; row < rows; ) {
-      int linerep;
-      int plane;
-
-      linerep = 1;
-      for (plane = 0; plane < planes; plane++) {
-        int col;
-        col = 0;
-        while (col < cols) {
-            int c;
-            switch (c = getc(f)) {
-            case 0x80:  /* Bit String */
-            {
-                int j;
-                c = getc(f);    /* Byte count */
-                if (debug)
-                  pm_message("bit string of %d bytes", c);
-
-                if (col + c * 8 > cols + padright)
-                  pm_error ("bad byte count");
-                for (j = 0; j < c; ++j) {
-                    int cc, k;
-                    cc = getc(f);
-                    for (k = 0x80; k; k >>= 1) {
-                        bitrow[plane][col] = (k & cc) ? 0 : 1;
-                        ++col;
-                    }
-                }
-            }
-            break;
-            case 0:     /* Pattern run */
-            {
-                int j, l;
-                c = getc(f);    /* Repeat count */
-                if (debug)
-                    pm_message("pattern run of %d repetitions", c);
-                /* line repeat */
-                if (c == 0) {
-                    c = getc(f);
-                    if (c != 0x00ff)
-                        pm_error( "badly formed line repeat" );
-                    linerep = getc(f);
-                    break;
-                }
-                fread (pattern, 1, patlen, f);
-                if (col + c * patlen * 8 > cols + padright)
-                  pm_error ("bad pattern repeat count");
-                for (j = 0; j < c; ++j)
-                    for (l = 0; l < patlen; ++l) {
-                        int k;
-                        for (k = 0x80; k; k >>= 1) {
-                            bitrow[plane][col] = (k & pattern[l]) ? 0 : 1;
+        int linerep;
+        unsigned int plane;
+
+        linerep = 1;
+
+        for (plane = 0; plane < planes; ++plane) {
+            unsigned int col;
+            col = 0;
+            while (col < cols) {
+                int c;
+                switch (c = getc(ifP)) {
+                case 0x80: { /* Bit String */
+                    unsigned int j;
+                    c = getc(ifP);    /* Byte count */
+                    if (debug)
+                        pm_message("bit string of %d bytes", c);
+
+                    if (col + c * 8 > cols + padright)
+                        pm_error("bad byte count");
+                    for (j = 0; j < c; ++j) {
+                        unsigned char cc;
+                        unsigned char k;
+                        cc = getc(ifP);
+                        for (k = 0x80; k != 0x00; k >>= 1) {
+                            bitrow[plane][col] = (k & cc) ? 0 : 1;
                             ++col;
                         }
                     }
-            }
-            break;
-
-            default:    /* Solid run */
-            {
-                int l, j;
-                if (debug)
-                    pm_message("solid run of %d bytes %s", c & 0x7f,
-                               c & 0x80 ? "on" : "off" );
-                /* each byte had eight bits DSB */
-                l = (c & 0x80) ? 0: 1;
-                c = (c & 0x7f) * 8;
-                if (col + c > cols + padright)
-                    pm_error ("bad solid run repeat count");
-                for (j = 0; j < c; ++j) {
-                    bitrow[plane][col] = l;
-                    ++col;
+                } break;
+                case 0: {    /* Pattern run */
+                    unsigned int j;
+                    c = getc(ifP);    /* Repeat count */
+                    if (debug)
+                        pm_message("pattern run of %d repetitions", c);
+                    /* line repeat */
+                    if (c == 0) {
+                        c = getc(ifP);
+                        if (c != 0x00ff)
+                            pm_error("badly formed line repeat");
+                        linerep = getc(ifP);
+                    } else {
+                        fread(pattern, 1, patlen, ifP);
+                        if (col + c * patlen * 8 > cols + padright)
+                            pm_error("bad pattern repeat count");
+                        for (j = 0; j < c; ++j) {
+                            unsigned int l;
+                            for (l = 0; l < patlen; ++l) {
+                                unsigned int k;
+                                for (k = 0x80; k; k >>= 1) {
+                                    bitrow[plane][col] =
+                                        (k & pattern[l]) ? 0 : 1;
+                                    ++col;
+                                }
+                            }
+                        }
+                    }
+                } break;
+
+                default: {   /* Solid run */
+                    unsigned int const l = (c & 0x80) ? 0: 1;
+
+                    unsigned int j;
+
+                    if (debug)
+                        pm_message("solid run of %d bytes %s", c & 0x7f,
+                                   c & 0x80 ? "on" : "off" );
+                    /* each byte had eight bits DSB */
+                    c = (c & 0x7f) * 8;
+                    if (col + c > cols + padright)
+                        pm_error("bad solid run repeat count");
+                    for (j = 0; j < c; ++j) {
+                        bitrow[plane][col] = l;
+                        ++col;
+                    }
                 }
-            }
                 break;
 
-            case EOF:   /* End of file */
-                pm_error( "end of file reached" );
-
+                case EOF:   /* End of file */
+                    pm_error("end of file reached");
+                }
             }
+            if (debug)
+                pm_message("EOL plane %d row %d", plane, row);
+            if (col != cols + padright)
+                pm_error("EOL beyond edge");
         }
-                if ( debug )
-                        pm_message( "EOL plane %d row %d", plane, row );
-                if (col != cols + padright)
-                        pm_error( "EOL beyond edge" );
-      }
 
-      if (planes == 4) {
-          /* Construct a pixel from the 4 planes of bits for this row */
-          int col;
-          for (col = 0; col < cols; col++) {
-            int r, g, b, i;
-
-            const int r_bit = !bitrow[0][col];
-            const int g_bit = !bitrow[1][col];
-            const int b_bit = !bitrow[2][col];
-            i = bitrow[3][col];
-
-            /* Deal with weird GEM palette - white/black/gray are
-               encoded oddly
-            */
-            if (r_bit == g_bit && g_bit == b_bit) {
-                /* It's black, white, or gray */
-                if (r_bit && i) r = LIGHT;
-                else if (r_bit) r = BLACK;
-                else if (i) r = MAXVAL;
-                else r = DARK;
-                g = b = r;
-            } else {
-                /* It's one of the twelve colored colors */
-                if (!i) {
-                    /* Low intensity */
-                    r = r_bit * LIGHT;
-                    g = g_bit * LIGHT;
-                    b = b_bit * LIGHT;
+        if (planes == 4) {
+            /* Construct a pixel from the 4 planes of bits for this row */
+            unsigned int col;
+            for (col = 0; col < cols; ++col) {
+                unsigned int const r_bit = !bitrow[0][col];
+                unsigned int const g_bit = !bitrow[1][col];
+                unsigned int const b_bit = !bitrow[2][col];
+                unsigned int const i     =  bitrow[3][col];
+
+                unsigned int r, g, b;
+
+                /* Deal with weird GEM palette - white/black/gray are
+                   encoded oddly
+                */
+                if (r_bit == g_bit && g_bit == b_bit) {
+                    /* It's black, white, or gray */
+                    if (r_bit && i) r = LIGHT;
+                    else if (r_bit) r = BLACK;
+                    else if (i) r = MAXVAL;
+                    else r = DARK;
+                    g = b = r;
                 } else {
-                    /* Normal intensity */
-                    r = r_bit * MAXVAL;
-                    g = g_bit * MAXVAL;
-                    b = b_bit * MAXVAL;
+                    /* It's one of the twelve colored colors */
+                    if (!i) {
+                        /* Low intensity */
+                        r = r_bit * LIGHT;
+                        g = g_bit * LIGHT;
+                        b = b_bit * LIGHT;
+                    } else {
+                        /* Normal intensity */
+                        r = r_bit * MAXVAL;
+                        g = g_bit * MAXVAL;
+                        b = b_bit * MAXVAL;
+                    }
                 }
+                PPM_ASSIGN(xelrow[col], r, g, b);
             }
-            PPM_ASSIGN(xelrow[col], r, g, b);
+        } else {
+            unsigned int col;
+            for (col = 0; col < cols; ++col)
+                PNM_ASSIGN1(xelrow[col], bitrow[0][col]);
+        }
+        while (linerep--) {
+            pnm_writepnmrow(stdout, xelrow, cols, MAXVAL, type, 0);
+            ++row;
         }
-      } else {
-          int col;
-          for (col = 0; col < cols; col++)
-              PNM_ASSIGN1(xelrow[col], bitrow[0][col]);
-      }
-      while (linerep--) {
-        pnm_writepnmrow( stdout, xelrow, cols, MAXVAL, type, 0 );
-        ++row;
-      }
     }
     pnm_freerow(xelrow);
-    pm_close( f );
-    pm_close( stdout );
+    pm_close(ifP);
+    pm_close(stdout);
     exit(0);
 }
 
 
-static void
-getinit (file, colsP, rowsP, padrightP, patlenP, planesP)
-     FILE *file;
-     int *colsP;
-     int *rowsP;
-     int *padrightP;
-     int *patlenP;
-     int *planesP;
-{
-  short s;
-  short headlen;
-
-  if (pm_readbigshort (file, &s) == -1) /* Image file version */
-    pm_error ("EOF / read error");
-  if (s != 1)
-    pm_error ("unknown version number (%d)", (int) s);
-  if (pm_readbigshort (file, &headlen) == -1) /* Header length in words */
-    pm_error ("EOF / read error");
-  if (headlen < 8)
-    pm_error ("short header (%d)", (int) headlen);
-  if (pm_readbigshort (file, &s) == -1) /* Number of planes */
-    pm_error ("EOF / read error");
-  if (s != 4 && s != 1)
-    pm_error ("This program can interpret IMGs with only 1 or 4 planes");
-  *planesP = s;
-  if (pm_readbigshort (file, &s) == -1) /* Pattern definition length (bytes) */
-    pm_error ("EOF / read error");
-  if (s < 1 || s > 8)
-    pm_error ("illegal pattern length (%d)", (int) s);
-  *patlenP = (int) s;
-  if (pm_readbigshort (file, &s) == -1 /* Pixel height (microns) */
-      || pm_readbigshort (file, &s) == -1 /* Pixel height (microns) */
-      || pm_readbigshort (file, &s) == -1) /* Scan line width */
-    pm_error ("EOF / read error");
-  *colsP = (int) s;
-  if (pm_readbigshort (file, &s) == -1) /* Number of scan line items */
-    pm_error ("EOF / read error");
-  *rowsP = (int) s;
-  *padrightP = 7 - ((*colsP + 7) & 7);
-
-  headlen -= 8;
-  while (headlen-- > 0)
-    {
-      (void) getc (file);
-      (void) getc (file);
-    }
-}
-
-
 
diff --git a/converter/other/giftopnm.c b/converter/other/giftopnm.c
index 470c85b7..c1c79e26 100644
--- a/converter/other/giftopnm.c
+++ b/converter/other/giftopnm.c
@@ -291,6 +291,7 @@ initGif89(struct Gif89 * const gif89P) {
 }
 
 
+
 static bool verbose;
 static bool showComment;
 
@@ -1237,7 +1238,6 @@ lzwReadByteFresh(struct GetCodeState * const getCodeStateP,
 
 
 
-
 static void
 lzwReadByte(Decompressor *  const decompP,
             unsigned char * const dataReadP,
@@ -1357,6 +1357,7 @@ bumpRowInterlace(unsigned int   const rows,
 }
 
 
+
 static void
 renderRow(unsigned char *    const cmapIndexRow,
           unsigned int       const cols,
@@ -1448,20 +1449,14 @@ pnmFormat(bool const hasGray,
   by 'hasGray' and 'hasColor'.
 -----------------------------------------------------------------------------*/
     int format;
-    const char * formatName;
 
     if (hasColor) {
         format = PPM_FORMAT;
-        formatName = "PPM";
     } else if (hasGray) {
         format = PGM_FORMAT;
-        formatName = "PGM";
     } else {
         format = PBM_FORMAT;
-        formatName = "PBM";
     }
-    if (verbose)
-        pm_message("writing a %s file", formatName);
 
     return format;
 }
@@ -1554,6 +1549,9 @@ convertRaster(Decompressor * const decompP,
 
     MALLOCARRAY2(cmapIndexArray, interlace ? rows : 1 , cols);
 
+    if (verbose)
+        pm_message("writing a %s file", pnm_formattypenm(format));
+
     if (imageOutFileP)
         pnm_writepnminit(imageOutFileP, cols, rows, GIFMAXVAL, format, false);
     if (alphaFileP)
@@ -2198,3 +2196,4 @@ main(int argc, const char **argv) {
 }
 
 
+
diff --git a/converter/other/hdifftopam.c b/converter/other/hdifftopam.c
index c9363040..7464bb1a 100644
--- a/converter/other/hdifftopam.c
+++ b/converter/other/hdifftopam.c
@@ -1,7 +1,7 @@
 /******************************************************************************
                                 hdifftopam
 *******************************************************************************
-  This program recovers a PAM image from a horizontal difference images 
+  This program recovers a PAM image from a horizontal difference images
   such as created by Pamtohdiff.
 
   By Bryan Henderson, San Jose, CA 2002.04.15.
@@ -64,7 +64,7 @@ static void
 makePnm(struct pam * const pamP) {
 
     switch (pamP->depth) {
-    case 1: 
+    case 1:
         pamP->format = PGM_FORMAT;
         break;
     case 3:
@@ -87,7 +87,7 @@ static void
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
     FILE *ifP;
     struct cmdlineInfo cmdline;
@@ -105,9 +105,9 @@ main(int argc, char *argv[]) {
 
     pnm_readpaminit(ifP, &diffpam, PAM_STRUCT_SIZE(tuple_type));
 
-    if (diffpam.format != PAM_FORMAT) 
+    if (diffpam.format != PAM_FORMAT)
         pm_error("Input must be a PAM file, not PNM");
-    else if (!streq(diffpam.tuple_type, "hdiff")) 
+    else if (!streq(diffpam.tuple_type, "hdiff"))
         pm_error("Input tuple type is '%s'.  Must be 'hdiff'",
                  diffpam.tuple_type);
 
@@ -130,7 +130,7 @@ main(int argc, char *argv[]) {
 
     {
         unsigned int const bias = diffpam.maxval/2;
-        
+
         for (row = 0; row < diffpam.height; ++row) {
             unsigned int col;
             pnm_readpamrow(&diffpam, diffrow);
@@ -139,8 +139,8 @@ main(int argc, char *argv[]) {
                 for (plane = 0; plane < diffpam.depth; ++plane) {
                     sample const prevSample = prevrow[col][plane];
                     sample const diffSample = diffrow[col][plane];
-                    
-                    outrow[col][plane] = 
+
+                    outrow[col][plane] =
                         (-bias + prevSample + diffSample) % (outpam.maxval+1);
                     prevrow[col][plane] = outrow[col][plane];
                 }
@@ -155,3 +155,5 @@ main(int argc, char *argv[]) {
     exit(0);
 }
 
+
+
diff --git a/converter/other/jbig/jbigtopnm.c b/converter/other/jbig/jbigtopnm.c
index 0d55ccc1..69767e11 100644
--- a/converter/other/jbig/jbigtopnm.c
+++ b/converter/other/jbig/jbigtopnm.c
@@ -198,6 +198,7 @@ diagnose_bie(FILE *f)
 }
 
 
+
 int main (int argc, const char **argv)
 {
     CmdlineInfo cmdline;
diff --git a/converter/other/jbig/libjbig/jbig.c b/converter/other/jbig/libjbig/jbig.c
index 42932ca7..fcb39f5c 100644
--- a/converter/other/jbig/libjbig/jbig.c
+++ b/converter/other/jbig/libjbig/jbig.c
@@ -150,6 +150,7 @@ static void *checked_malloc(size_t nmemb, size_t size)
 }
 
 
+
 static void *checked_realloc(void *ptr, size_t nmemb, size_t size)
 {
   void *p;
@@ -176,6 +177,7 @@ static void *checked_realloc(void *ptr, size_t nmemb, size_t size)
 }
 
 
+
 static void checked_free(void *ptr)
 {
   free(ptr);
@@ -188,7 +190,6 @@ static void checked_free(void *ptr)
 
 
 
-
 /*
  * Memory management for buffers which are used for temporarily
  * storing SDEs by the encoder.
@@ -229,6 +230,7 @@ static struct jbg_buf *jbg_buf_init(struct jbg_buf **free_list)
 }
 
 
+
 /*
  * Return an entire free_list to the memory management of stdlib.
  * This is only done by jbg_enc_free().
@@ -247,6 +249,7 @@ static void jbg_buf_free(struct jbg_buf **free_list)
 }
 
 
+
 /*
  * Append a single byte to a single list that starts with the block
  * *(struct jbg_buf *) head. The type of *head is void here in order to
@@ -272,6 +275,7 @@ static void jbg_buf_write(int b, void *head)
 }
 
 
+
 /*
  * Remove any trailing zero bytes from the end of a linked jbg_buf list,
  * however make sure that no zero byte is removed which directly
@@ -311,6 +315,7 @@ static void jbg_buf_remove_zeros(struct jbg_buf *head)
 }
 
 
+
 /*
  * The jbg_buf list which starts with block *new_prefix is concatenated
  * with the list which starts with block **start and *start will then point
@@ -327,6 +332,7 @@ static void jbg_buf_prefix(struct jbg_buf *new_prefix, struct jbg_buf **start)
 }
 
 
+
 /*
  * Send the contents of a jbg_buf list that starts with block **head to
  * the call back function data_out and return the blocks of the jbg_buf
@@ -352,6 +358,7 @@ static void jbg_buf_output(struct jbg_buf **head,
 }
 
 
+
 /*
  * Calculate y = ceil(x/2) applied n times, which is equivalent to
  * y = ceil(x/(2^n)). This function is used to
@@ -369,6 +376,7 @@ unsigned long jbg_ceil_half(unsigned long x, int n)
 }
 
 
+
 /*
  * Set L0 (the number of lines in a stripe at lowest resolution)
  * to a default value, such that there are about 35 stripes, as
@@ -384,6 +392,7 @@ static void jbg_set_default_l0(struct jbg_enc_state *s)
 }
 
 
+
 /*
  * Calculate the number of stripes, as defined in clause 6.2.3 of T.82.
  */
@@ -396,6 +405,7 @@ static unsigned long jbg_stripes(unsigned long l0, unsigned long yd,
 }
 
 
+
 /*
  * Resolution reduction table given by ITU-T T.82 Table 17
  */
@@ -818,6 +828,7 @@ void jbg_enc_init(struct jbg_enc_state *s, unsigned long x, unsigned long y,
 }
 
 
+
 /*
  * This function selects the number of differential layers based on
  * the maximum size requested for the lowest resolution layer. If
@@ -843,6 +854,7 @@ int jbg_enc_lrlmax(struct jbg_enc_state *s, unsigned long x,
 }
 
 
+
 /*
  * As an alternative to jbg_enc_lrlmax(), the following function allows the
  * user to specify the number of layers directly. The stripe height and layer
@@ -860,6 +872,7 @@ void jbg_enc_layers(struct jbg_enc_state *s, int d)
 }
 
 
+
 /*
  * Specify the highest and lowest resolution layers which will be
  * written to the output file. Call this function not before
@@ -876,6 +889,7 @@ int jbg_enc_lrange(struct jbg_enc_state *s, int dl, int dh)
 }
 
 
+
 /*
  * The following function allows the user to specify the bits describing the
  * options of the format as well as the maximum AT movement window and the
@@ -894,6 +908,7 @@ void jbg_enc_options(struct jbg_enc_state *s, int order, int options,
 }
 
 
+
 /*
  * This function actually does all the tricky work involved in producing
  * a SDE, which is stored in the appropriate s->sde[][][] element
@@ -1507,6 +1522,7 @@ static void encode_sde(struct jbg_enc_state *s,
 }
 
 
+
 /*
  * Create the next lower resolution version of an image
  */
@@ -1619,6 +1635,7 @@ static void resolution_reduction(struct jbg_enc_state *s, int plane,
 }
 
 
+
 /*
  * This function is called inside the three loops of jbg_enc_out() in
  * order to write the next SDE. It has first to generate the required
@@ -1697,6 +1714,7 @@ static void output_sde(struct jbg_enc_state *s,
 }
 
 
+
 /*
  * Convert the table which controls the deterministic prediction
  * process from the internal format into the representation required
@@ -1748,6 +1766,7 @@ void jbg_int2dppriv(unsigned char *dptable, const char *internal)
 }
 
 
+
 /*
  * Convert the table which controls the deterministic prediction
  * process from the 1728 byte long DPTABLE format into the 6912 byte long
@@ -1779,6 +1798,7 @@ void jbg_dppriv2int(char *internal, const unsigned char *dptable)
 }
 
 
+
 /*
  * Encode one full BIE and pass the generated data to the specified
  * call-back function
@@ -1973,6 +1993,7 @@ void jbg_enc_out(struct jbg_enc_state *s)
 }
 
 
+
 void jbg_enc_free(struct jbg_enc_state *s)
 {
   unsigned long stripe;
@@ -2023,6 +2044,7 @@ void jbg_enc_free(struct jbg_enc_state *s)
 }
 
 
+
 /*
  * Convert the error codes used by jbg_dec_in() into an English ASCII string
  */
@@ -2036,6 +2058,7 @@ const char *jbg_strerror(int errnum)
 }
 
 
+
 /*
  * The constructor for a decoder
  */
@@ -2055,6 +2078,7 @@ void jbg_dec_init(struct jbg_dec_state *s)
 }
 
 
+
 /*
  * Specify a maximum image size for the decoder. If the JBIG file has
  * the order bit ILEAVE, but not the bit SEQ set, then the decoder
@@ -2072,6 +2096,7 @@ void jbg_dec_maxsize(struct jbg_dec_state *s, unsigned long xmax,
 }
 
 
+
 /*
  * Decode the new len PSDC bytes to which data points and add them to
  * the current stripe. Return the number of bytes which have actually
@@ -2528,6 +2553,7 @@ static size_t decode_pscd(struct jbg_dec_state *s, unsigned char *data,
 }
 
 
+
 /*
  * Provide to the decoder a new BIE fragment of len bytes starting at data.
  *
@@ -2893,6 +2919,7 @@ int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,
 }
 
 
+
 /*
  * After jbg_dec_in() returned JBG_EOK or JBG_EOK_INTR, you can call this
  * function in order to find out the width of the image. Returns 0 if
@@ -2913,6 +2940,7 @@ unsigned long jbg_dec_getwidth(const struct jbg_dec_state *s)
 }
 
 
+
 /*
  * After jbg_dec_in() returned JBG_EOK or JBG_EOK_INTR, you can call this
  * function in order to find out the height of the image. Returns 0 if
@@ -2933,6 +2961,7 @@ unsigned long jbg_dec_getheight(const struct jbg_dec_state *s)
 }
 
 
+
 /*
  * After jbg_dec_in() returned JBG_EOK or JBG_EOK_INTR, you can call this
  * function in order to get a pointer to the image. Returns NULL if
@@ -2953,6 +2982,7 @@ unsigned char *jbg_dec_getimage(const struct jbg_dec_state *s, int plane)
 }
 
 
+
 /*
  * After jbg_dec_in() returned JBG_EOK or JBG_EOK_INTR, you can call
  * this function in order to find out the size in bytes of one
@@ -2975,6 +3005,7 @@ unsigned long jbg_dec_getsize(const struct jbg_dec_state *s)
 }
 
 
+
 /*
  * After jbg_dec_in() returned JBG_EOK or JBG_EOK_INTR, you can call
  * this function in order to find out the size of the image that you
@@ -2998,6 +3029,7 @@ unsigned long jbg_dec_getsize_merged(const struct jbg_dec_state *s)
 }
 
 
+
 /*
  * The destructor function which releases any resources obtained by the
  * other decoder functions.
@@ -3036,6 +3068,7 @@ void jbg_dec_free(struct jbg_dec_state *s)
 }
 
 
+
 /*
  * Split bigendian integer pixel field into separate bit planes. In the
  * src array, every pixel is represented by a ((has_planes + 7) / 8) byte
@@ -3100,6 +3133,8 @@ void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,
   return;
 }
 
+
+
 /*
  * Merge the separate bit planes decoded by the JBIG decoder into an
  * integer pixel field. This is essentially the counterpart to
@@ -3163,6 +3198,7 @@ void jbg_dec_merge_planes(const struct jbg_dec_state *s, int use_graycode,
 }
 
 
+
 /*
  * Given a pointer p to the first byte of either a marker segment or a
  * PSCD, as well as the length len of the remaining data, return
@@ -3232,6 +3268,7 @@ static unsigned char *jbg_next_pscdms(unsigned char *p, size_t len)
 }
 
 
+
 /*
  * Scan a complete BIE for a NEWLEN marker segment, then read the new
  * YD value found in it and use it to overwrite the one in the BIE
@@ -3281,3 +3318,6 @@ int jbg_newlen(unsigned char *bie, size_t len)
   }
   return JBG_EINVAL | 0;
 }
+
+
+
diff --git a/converter/other/jbig/libjbig/jbig_ar.c b/converter/other/jbig/libjbig/jbig_ar.c
index 194e13eb..aad293f2 100644
--- a/converter/other/jbig/libjbig/jbig_ar.c
+++ b/converter/other/jbig/libjbig/jbig_ar.c
@@ -119,6 +119,7 @@ void arith_encode_init(struct jbg_arenc_state *s, int reuse_st)
 }
 
 
+
 void arith_encode_flush(struct jbg_arenc_state *s)
 {
   unsigned long temp;
@@ -167,6 +168,7 @@ void arith_encode_flush(struct jbg_arenc_state *s)
 }
 
 
+
 void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
 {
   register unsigned lsz, ss;
@@ -259,6 +261,7 @@ void arith_encode(struct jbg_arenc_state *s, int cx, int pix)
 }
 
 
+
 void arith_decode_init(struct jbg_ardec_state *s, int reuse_st)
 {
   int i;
@@ -273,6 +276,8 @@ void arith_decode_init(struct jbg_ardec_state *s, int reuse_st)
   return;
 }
 
+
+
 /*
  * Decode and return one symbol from the provided PSCD byte stream
  * that starts in s->pscd_ptr and ends in the byte before s->pscd_end.
@@ -415,3 +420,6 @@ int arith_decode(struct jbg_ardec_state *s, int cx)
 
   return pix;
 }
+
+
+
diff --git a/converter/other/jbig/pnmtojbig.c b/converter/other/jbig/pnmtojbig.c
index 5757680e..ebdb4993 100644
--- a/converter/other/jbig/pnmtojbig.c
+++ b/converter/other/jbig/pnmtojbig.c
@@ -64,6 +64,7 @@ static void
 }
 
 
+
 /*
  * Callback procedure which is used by JBIG encoder to deliver the
  * encoded data. It simply sends the bytes to the output file.
@@ -461,3 +462,6 @@ main(int argc, char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/jpeg2000/libjasper/common.mk b/converter/other/jpeg2000/libjasper/common.mk
index a333f5d6..194ce3c1 100644
--- a/converter/other/jpeg2000/libjasper/common.mk
+++ b/converter/other/jpeg2000/libjasper/common.mk
@@ -24,8 +24,7 @@ INCLUDES := -I$(JASPERSRCDIR)/include $(INCLUDES)
 DEFS = -DHAVE_LIBM=1 -DSTDC_HEADERS=1 -DHAVE_FCNTL_H=1 -DHAVE_LIMITS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STDDEF_H=1 -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_RAS_SUPPORT -DEXCLUDE_MIF_SUPPORT -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_PGX_SUPPORT -DEXCLUDE_PNM_SUPPORT
 
 $(LIB_OBJECTS):%.o:%.c
-	$(CC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) \
-	  $(CFLAGS_PERSONAL) $(CADD) $<
+	$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS_ALL) $<
 
 $(LIB_OBJECTS): importinc
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
index c964eeff..eb2020bf 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
@@ -11,7 +11,6 @@
 #include "jasper/jas_string.h"
 #include "jasper/jas_malloc.h"
 #include "jasper/jas_image.h"
-#include "jasper/jas_fix.h"
 #include "jasper/jas_tvp.h"
 #include "jasper/jas_version.h"
 #include "jasper/jas_math.h"
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
index 3962f5ad..c2a87e19 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c
@@ -122,7 +122,6 @@
 
 #include <assert.h>
 
-#include "jasper/jas_fix.h"
 #include "jasper/jas_malloc.h"
 #include "jasper/jas_math.h"
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
index 437e9dd6..dd6ae05a 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c
@@ -126,7 +126,6 @@
 
 #include "netpbm/nstring.h"
 
-#include "jasper/jas_fix.h"
 #include "jasper/jas_stream.h"
 #include "jasper/jas_math.h"
 
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
index e9ec12d4..367dd020 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c
@@ -126,7 +126,6 @@
 
 #include "netpbm/nstring.h"
 
-#include "jasper/jas_fix.h"
 #include "jasper/jas_malloc.h"
 #include "jasper/jas_math.h"
 
@@ -190,11 +189,8 @@ encodeBlocksOfPrecinct(jpc_enc_prc_t *   const prcP,
             cblkP->numbps = MAX(jpc_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0);
         }
 
-        for (cblkno = 0; cblkno < prcP->numcblks; ++ cblkno) {
-            jpc_enc_cblk_t * const cblkP = &prcP->cblks[cblkno];
-
-            assert(cblkP->numbps <= bandP->numbps);
-        }
+        for (cblkno = 0; cblkno < prcP->numcblks; ++ cblkno)
+            assert(prcP->cblks[cblkno].numbps <= bandP->numbps);
 
         for (cblkno = 0, *errorP = NULL;
              cblkno < prcP->numcblks && !*errorP;
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
index a05e1c10..32e68db7 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c
@@ -125,7 +125,6 @@
 #include <assert.h>
 
 #include "jasper/jas_types.h"
-#include "jasper/jas_fix.h"
 #include "jasper/jas_malloc.h"
 #include "jasper/jas_math.h"
 #include "jasper/jas_stream.h"
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
index 2d03cb29..9eb2e92c 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c
@@ -124,7 +124,6 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "jasper/jas_fix.h"
 #include "jasper/jas_malloc.h"
 #include "jasper/jas_math.h"
 #include "jasper/jas_debug.h"
diff --git a/converter/other/jpegdatasource.c b/converter/other/jpegdatasource.c
index 1f53c2a4..34393a7b 100644
--- a/converter/other/jpegdatasource.c
+++ b/converter/other/jpegdatasource.c
@@ -7,18 +7,18 @@
    This data source manager is the same as the Jpeg library's built in
    "stdio" one, except that it looks ahead and one can query it to see
    if there is any data in the stream that the Jpeg library hasn't seen
-   yet.  Thus, you can use it in a program that reads multiple JPEG 
+   yet.  Thus, you can use it in a program that reads multiple JPEG
    images and know when to stop.  You can also nicely handle completely
    empty input files more gracefully than just crying input error.
 
-   This data source manager does 4K fread() reads and passes 4K buffers 
+   This data source manager does 4K fread() reads and passes 4K buffers
    to the Jpeg library.  It reads one 4K block ahead, so there is up to
    8K of image buffered at any time.
 
    By Bryan Henderson, San Jose CA 2002.10.13
 *****************************************************************************/
 
-#include <ctype.h>	   
+#include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
@@ -92,7 +92,7 @@ dsFillInputBuffer(j_decompress_ptr const cinfoP) {
            truncation and pad out the image with gray.
         */
         srcP->prematureEof = TRUE;
-        
+
         srcP->jpegSourceMgr.next_input_byte = jfifEoiMarker;
         srcP->jpegSourceMgr.bytes_in_buffer = sizeof(jfifEoiMarker);
     } else {
@@ -107,7 +107,7 @@ dsFillInputBuffer(j_decompress_ptr const cinfoP) {
         }
 
         /* Fill the new "next" buffer */
-        srcP->bytesInNextBuffer = 
+        srcP->bytesInNextBuffer =
             fread(srcP->nextBuffer, 1, BUFFER_SIZE, srcP->ifP);
     }
     return TRUE;
@@ -166,7 +166,7 @@ dsPrematureEof(struct sourceManager * const srcP) {
 
 
 
-struct sourceManager * 
+struct sourceManager *
 dsCreateSource(const char * const fileName) {
 
     struct sourceManager * srcP;
@@ -182,22 +182,24 @@ dsCreateSource(const char * const fileName) {
     srcP->jpegSourceMgr.skip_input_data = dsSkipInputData;
     srcP->jpegSourceMgr.resync_to_restart = jpeg_resync_to_restart;
     srcP->jpegSourceMgr.term_source = dsTermSource;
-    
+
     srcP->prematureEof = FALSE;
     srcP->currentBuffer = srcP->buffer1;
     srcP->nextBuffer = srcP->buffer2;
-    srcP->jpegSourceMgr.bytes_in_buffer = 
+    srcP->jpegSourceMgr.bytes_in_buffer =
         fread(srcP->currentBuffer, 1, BUFFER_SIZE, srcP->ifP);
     srcP->jpegSourceMgr.next_input_byte = srcP->currentBuffer;
-    srcP->bytesInNextBuffer = 
+    srcP->bytesInNextBuffer =
         fread(srcP->nextBuffer, 1, BUFFER_SIZE, srcP->ifP);
 
     return srcP;
 }
 
+
+
 void
 dsDestroySource(struct sourceManager * const srcP) {
-    
+
     pm_close(srcP->ifP);
     free(srcP);
 
@@ -209,3 +211,6 @@ struct jpeg_source_mgr *
 dsJpegSourceMgr(struct sourceManager * const srcP) {
     return &srcP->jpegSourceMgr;
 }
+
+
+
diff --git a/converter/other/jpegdatasource.h b/converter/other/jpegdatasource.h
index 58648fe4..70d55d11 100644
--- a/converter/other/jpegdatasource.h
+++ b/converter/other/jpegdatasource.h
@@ -3,7 +3,7 @@
 
 #include "pm_c_util.h"
 
-struct sourceManager * 
+struct sourceManager *
 dsCreateSource(const char * const fileName);
 
 void
diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
index 518d80ac..33f69be9 100644
--- a/converter/other/jpegtopnm.c
+++ b/converter/other/jpegtopnm.c
@@ -53,7 +53,7 @@
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 
 #include <stdbool.h>
-#include <ctype.h>		/* to declare isprint() */
+#include <ctype.h>              /* to declare isprint() */
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -142,6 +142,7 @@ interpretMaxmemory(bool         const maxmemorySpec,
 }
 
 
+
 static void
 interpretAdobe(int             const adobe,
                int             const notadobe,
@@ -265,6 +266,7 @@ parseCommandLine(int                  const argc,
 }
 
 
+
 /*
  * Marker processor for COM and interesting APPn markers.
  * This replaces the library's built-in processor, which just skips the marker.
@@ -288,6 +290,7 @@ jpegGetc (j_decompress_ptr const cinfoP) {
 }
 
 
+
 static bool
 printTextMarker(j_decompress_ptr const cinfoP) {
 /*----------------------------------------------------------------------------
@@ -320,12 +323,12 @@ printTextMarker(j_decompress_ptr const cinfoP) {
 
     length = jpeg_getc(cinfoP) << 8;
     length += jpeg_getc(cinfoP);
-    length -= 2;			/* discount the length word itself */
+    length -= 2;                        /* discount the length word itself */
 
     if (traceit) {
         if (cinfoP->unread_marker == JPEG_COM)
             fprintf(stderr, "Comment, length %ld:\n", (long) length);
-        else			/* assume it is an APPn otherwise */
+        else                    /* assume it is an APPn otherwise */
             fprintf(stderr, "APP%d, length %ld:\n",
                     cinfoP->unread_marker - JPEG_APP0, (long) length);
     }
@@ -409,6 +412,7 @@ printMarker(struct jpeg_marker_struct const marker) {
 }
 
 
+
 typedef struct rgb {unsigned int r; unsigned int g; unsigned int b;} rgb_type;
 
 
@@ -551,8 +555,7 @@ setColorSpaces(J_COLOR_SPACE   const jpegColorSpace,
         pm_error("INTERNAL ERROR: unknown color space code %d passed "
                  "to setColorSpaces().", jpegColorSpace);
     }
-    pm_message("WRITING %s FILE",
-               *outputTypeP == PPM_TYPE ? "PPM" : "PGM");
+    pm_message("WRITING %s FILE", pnm_formattypenm(*outputTypeP));
 }
 
 
@@ -916,7 +919,6 @@ convertImage(FILE *                          const ofP,
 
 
 
-
 static void
 saveMarkers(struct jpeg_decompress_struct * const cinfoP) {
 
diff --git a/converter/other/pamtoavs.c b/converter/other/pamtoavs.c
index 4764c9e8..2e2bf254 100644
--- a/converter/other/pamtoavs.c
+++ b/converter/other/pamtoavs.c
@@ -39,6 +39,7 @@ sample2char(sample const s,
 }
 
 
+
 #define THIS_SAMPLE_CHAR(PLANE) \
   sample2char(tuplerow[col][PLANE], pamP->maxval)
 
@@ -148,3 +149,5 @@ main(int argc, const char *argv[]) {
     return 0;
 }
 
+
+
diff --git a/converter/other/pamtodjvurle.c b/converter/other/pamtodjvurle.c
index cae9e026..cc3a119c 100644
--- a/converter/other/pamtodjvurle.c
+++ b/converter/other/pamtodjvurle.c
@@ -2,7 +2,7 @@
                                pamtodjvurle
 ******************************************************************************
   This program converts a PAM image to DjVu Color RLE format.
-  
+
   By Bryan Henderson, San Jose, CA April 2004.
 
   Contributed to the public domain by its author.
@@ -30,13 +30,13 @@ struct cmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -47,16 +47,16 @@ parseCommandLine(int argc,
     optEntry *option_def = malloc( 100*sizeof( optEntry ) );
     /* Instructions to pm_optParseOptions3 on how to parse our options. */
     optStruct3 opt;
-  
+
     unsigned int option_def_index;
     unsigned int transparentSpec;
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0, "transparent",   OPT_STRING, &cmdlineP->transparent, 
+    OPTENT3(0, "transparent",   OPT_STRING, &cmdlineP->transparent,
             &transparentSpec,        0);
     OPTENT3(0, "showcolormap",  OPT_FLAG, NULL,
             &cmdlineP->showcolormap,        0);
-  
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
@@ -73,7 +73,7 @@ parseCommandLine(int argc,
         cmdlineP->inputFilespec = argv[1];
     else
         cmdlineP->inputFilespec = "-";
-    
+
     if (argc-1 > 1)
         pm_error("Program takes at most one argument:  the file name.  "
                  "You specified %d", argc-1);
@@ -96,7 +96,7 @@ computeColorMap(struct pam *   const pamP,
     if (numColors > 0xFF0)
         pm_error("too many colors; "
                  "use pnmquant to reduce to no more than %u colors", 0xFF0);
-    
+
     if (show) {
         unsigned int colorIndex;
         fprintf(stderr, "Color map:\n");
@@ -123,7 +123,7 @@ makeDjvurleHeader(FILE *       const ofP,
                   struct pam * const pamP,
                   unsigned int const numColors,
                   tupletable   const colormap) {
-    
+
     unsigned int colorIndex;
 
     fprintf(ofP, "R6\n");
@@ -138,7 +138,7 @@ makeDjvurleHeader(FILE *       const ofP,
             blu = colormap[colorIndex]->tuple[PAM_BLU_PLANE];
         } else
             red = grn = blu = colormap[colorIndex]->tuple[0];
-        
+
         fputc(pnm_scalesample(red, pamP->maxval, 255), ofP);
         fputc(pnm_scalesample(grn, pamP->maxval, 255), ofP);
         fputc(pnm_scalesample(blu, pamP->maxval, 255), ofP);
@@ -166,18 +166,18 @@ colorEqual(tuple        comparand,
 
 
 
-static void 
-writeRleRun(FILE *       const ofP, 
+static void
+writeRleRun(FILE *       const ofP,
             struct pam * const pamP,
-            tuple        const color, 
+            tuple        const color,
             int          const count,
             tuplehash    const colorhash,
             tuple        const transcolor) {
 /*----------------------------------------------------------------------------
-  Write one DjVu Color RLE run to the file 'ofP'.  The run is 
+  Write one DjVu Color RLE run to the file 'ofP'.  The run is
   'count' pixels of color 'color', using the color index given by
   'colorhash' and assuming 'transcolor' is the transparent color.
-  
+
   'transcolor' is a 3-deep tuple with the same maxval as the image.
 -----------------------------------------------------------------------------*/
     uint32_t rlevalue;         /* RLE-encoded color/valuex */
@@ -192,7 +192,7 @@ writeRleRun(FILE *       const ofP,
             assert(found);
         }
         rlevalue = (index << 20) | count;
-      
+
         pm_writebiglong(ofP, rlevalue);
     }
 }
@@ -212,10 +212,10 @@ writeDjvurleRow(FILE *       const ofP,
 
     prevpixel = tupleRow[0];
     runlength = 0;
-    
+
     for (col = 0; col < pamP->width; ++col) {
         tuple const newpixel = tupleRow[col];      /* Current pixel color */
-        
+
         if (pnm_tupleequal(pamP, newpixel, prevpixel))
             /* This is a continuation of the current run */
             ++runlength;
@@ -223,7 +223,7 @@ writeDjvurleRow(FILE *       const ofP,
               /* The run is over.  Write it out and start a run of the next
                  color.
               */
-              writeRleRun(ofP, pamP, prevpixel, runlength, 
+              writeRleRun(ofP, pamP, prevpixel, runlength,
                           colorhash, transcolor);
               runlength = 1;
               prevpixel = newpixel;
@@ -232,7 +232,7 @@ writeDjvurleRow(FILE *       const ofP,
             /* Can't make the run any longer.  Write it out and start a
                new run.
             */
-            writeRleRun(ofP, pamP, prevpixel, runlength, 
+            writeRleRun(ofP, pamP, prevpixel, runlength,
                         colorhash, transcolor);
             runlength = 1;
         }
@@ -243,7 +243,7 @@ writeDjvurleRow(FILE *       const ofP,
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
 
     FILE * const rlefile = stdout;
@@ -254,7 +254,7 @@ main(int argc, char *argv[]) {
     tuple ** tupleArray;       /* The image raster */
     tupletable colormap;       /* List of all of the colors used */
     unsigned int numColors;    /* Number of unique colors in the color map */
-    tuplehash colorhash; 
+    tuplehash colorhash;
         /* Mapping from color to index into colormap[] */
     tuple transcolor;
         /* Color that should be considered transparent */
@@ -268,10 +268,10 @@ main(int argc, char *argv[]) {
     tupleArray = pnm_readpam(ifP, &pam, PAM_STRUCT_SIZE(tuple_type));
 
     transcolor = pnm_parsecolor(cmdline.transparent, pam.maxval);
-    
+
     computeColorMap(&pam, tupleArray, &numColors, &colormap, &colorhash,
                     cmdline.showcolormap);
-    
+
     makeDjvurleHeader(rlefile, &pam, numColors, colormap);
 
     /* Write the raster */
@@ -279,11 +279,11 @@ main(int argc, char *argv[]) {
     {
         unsigned int row;
         for (row = 0; row < pam.height; ++row)
-            writeDjvurleRow(rlefile, &pam, tupleArray[row], colorhash, 
+            writeDjvurleRow(rlefile, &pam, tupleArray[row], colorhash,
                             transcolor);
     }
     /* Clean up */
-    
+
     pnm_freepamarray(tupleArray, &pam);
     pnm_freetupletable(&pam, colormap);
     pnm_destroytuplehash(colorhash);
@@ -292,3 +292,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c
index 341c9c03..11e9bdcd 100644
--- a/converter/other/pamtogif.c
+++ b/converter/other/pamtogif.c
@@ -406,7 +406,6 @@ rowReaderGotoNextInterlaceRow(RowReader * const rdrP) {
 
 
 
-
 static void
 rowReaderGotoNextStraightRow(RowReader * const rdrP) {
 /*----------------------------------------------------------------------------
@@ -1269,6 +1268,7 @@ writePixelUncompressed(LzwCompressor * const lzwP,
 }
 
 
+
 static void
 writeRaster(struct pam *  const pamP,
             RowReader *   const rowReaderP,
diff --git a/converter/other/pamtohdiff.c b/converter/other/pamtohdiff.c
index 8d785f5b..d28cdb14 100644
--- a/converter/other/pamtohdiff.c
+++ b/converter/other/pamtohdiff.c
@@ -64,7 +64,7 @@ parseCommandLine(int argc, char ** argv,
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
     FILE *ifP;
     struct cmdlineInfo cmdline;
@@ -106,7 +106,7 @@ main(int argc, char *argv[]) {
        knows the "20" can't be +20, because that would create the
        sample 90 + 20 = 110, and violate maxval.  So it must be -80.
        Modulus arithmetic by the interpreter effectively makes that
-       decision.  
+       decision.
     */
 
 
@@ -115,7 +115,7 @@ main(int argc, char *argv[]) {
        all +/- half of maxval, you can see positive transitions as bright
        spots and negative transitions as dark spots.
     */
-    
+
     {
         unsigned int const bias = outpam.maxval/2;
         for (row = 0; row < inpam.height; ++row) {
@@ -124,7 +124,7 @@ main(int argc, char *argv[]) {
             for (col = 0; col < inpam.width; ++col) {
             unsigned int plane;
             for (plane = 0; plane < inpam.depth; ++plane) {
-                
+
                 sample const sampleValue = inrow[col][plane];
                 int const difference = sampleValue - prevrow[col][plane];
                 outrow[col][plane] = (difference + bias) % (outpam.maxval+1);
@@ -141,3 +141,5 @@ main(int argc, char *argv[]) {
     exit(0);
 }
 
+
+
diff --git a/converter/other/pamtohtmltbl.c b/converter/other/pamtohtmltbl.c
index d1482073..960d26b8 100644
--- a/converter/other/pamtohtmltbl.c
+++ b/converter/other/pamtohtmltbl.c
@@ -24,7 +24,7 @@ parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -44,7 +44,7 @@ parseCommandLine(int argc, char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "verbose",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "verbose",     OPT_FLAG,   NULL,
             &cmdlineP->verbose,       0 );
     OPTENT3(0, "transparent", OPT_STRING, &cmdlineP->transparent,
             &transparentSpec,  0 );
@@ -71,23 +71,22 @@ parseCommandLine(int argc, char ** argv,
 
 
 
-
 static void
 pripix(struct pam * const pamP,
-       tuple        const color, 
-       unsigned int const rectWidth, 
-       unsigned int const rectHeight, 
+       tuple        const color,
+       unsigned int const rectWidth,
+       unsigned int const rectHeight,
        tuple        const transparentColor) {
 
     if (rectWidth > 0 && rectHeight > 0) {
         printf("<TD VALIGN=CENTER ALIGN=CENTER");
 
-        if (rectWidth != 1) 
+        if (rectWidth != 1)
             printf(" COLSPAN=%d", rectWidth);
-        if (rectHeight != 1) 
+        if (rectHeight != 1)
             printf(" ROWSPAN=%d", rectHeight);
 
-        if (transparentColor && 
+        if (transparentColor &&
             !pnm_tupleequal(pamP, color,transparentColor)) {
             /* No BGCOLOR attribute */
         } else {
@@ -123,7 +122,7 @@ findSameColorRectangle(struct pam *   const pamP,
                        unsigned int * const rectWidthP,
                        unsigned int * const rectHeightP) {
 /*----------------------------------------------------------------------------
-   Find the largest rectangle, in the image described by 'pam' and 
+   Find the largest rectangle, in the image described by 'pam' and
    'tuples', of uniform color, whose upper left corner is at (row, col).
 
    Return the width and height of that rectangle as *rectWidthP
@@ -142,23 +141,23 @@ findSameColorRectangle(struct pam *   const pamP,
         int j;
         for (j = 0; j <= i; ++j) {
             if (!my) {
-                if (i >= cny) 
+                if (i >= cny)
                     my = cny;
                 else {
                     if ((!mx || j < mx) && (j < cnx)) {
                         if (!pnm_tupleequal(pamP, tuples[row+i][col+j],
-                                            rectangleColor)) 
+                                            rectangleColor))
                             my = i;
                     }
                 }
             }
             if (!mx) {
-                if (i >= cnx) 
+                if (i >= cnx)
                     mx = cnx;
                 else {
                     if ((!my || (j < my)) && (j < cny)) {
                         if (!pnm_tupleequal(pamP, tuples[row+j][col+i],
-                                            rectangleColor)) 
+                                            rectangleColor))
                             mx = i;
                     }
                 }
@@ -204,7 +203,6 @@ freeOutputtedArray(bool **       const outputted,
 
 
 
-                       
 static void
 markNotOutputted(bool **      const outputted,
                  unsigned int const upperLeftCol,
@@ -218,10 +216,10 @@ markNotOutputted(bool **      const outputted,
     unsigned int const lowerRightCol = upperLeftCol + width;
     unsigned int const lowerRightRow = upperLeftRow + height;
     unsigned int row;
-    
+
     for (row = upperLeftRow; row < lowerRightRow; ++row) {
         unsigned int col;
-        for (col = upperLeftCol; col < lowerRightCol; ++col) 
+        for (col = upperLeftCol; col < lowerRightCol; ++col)
             outputted[row][col] = FALSE;
     }
 }
@@ -241,10 +239,10 @@ markOutputted(bool **      const outputted,
     unsigned int const lowerRightCol = upperLeftCol + width;
     unsigned int const lowerRightRow = upperLeftRow + height;
     unsigned int row;
-    
+
     for (row = upperLeftRow; row < lowerRightRow; ++row) {
         unsigned int col;
-        for (col = upperLeftCol; col < lowerRightCol; ++col) 
+        for (col = upperLeftCol; col < lowerRightCol; ++col)
             outputted[row][col] = TRUE;
     }
 }
@@ -294,17 +292,17 @@ main(int argc, char **argv) {
     for (row = 0; row < inpam.height; ++row) {
         unsigned int col;
         printf("<TR>\n");
-        pripix(&inpam, tuples[row][0], 1, 1, transparentColor); 
+        pripix(&inpam, tuples[row][0], 1, 1, transparentColor);
         markOutputted(outputted, 0, row, 1, 1);
 
         for (col = 1; col < inpam.width; ++col) {
             if (!outputted[row][col]) {
-                findSameColorRectangle(&inpam, tuples, row, col, 
+                findSameColorRectangle(&inpam, tuples, row, col,
                                        &rectWidth, &rectHeight);
                 if (cmdline.verbose)
                     pm_message("[%u/%u] [%u/%u]",
                                col, row, rectWidth, rectHeight);
-                pripix(&inpam, tuples[row][col], rectWidth, rectHeight, 
+                pripix(&inpam, tuples[row][col], rectWidth, rectHeight,
                        transparentColor);
                 markOutputted(outputted, col, row, rectWidth, rectHeight);
             }
@@ -320,3 +318,6 @@ main(int argc, char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtompfont.c b/converter/other/pamtompfont.c
index 92f8de29..dd92fc7c 100644
--- a/converter/other/pamtompfont.c
+++ b/converter/other/pamtompfont.c
@@ -62,7 +62,7 @@ parseCommandLine(int argc, char ** argv,
     pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFilename = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -126,7 +126,7 @@ writeMpFontHeader(FILE *       const ofP,
 static void
 convertRaster(struct pam * const inpamP,
               FILE *       const ofP) {
-            
+
     tuple * tuplerow;
     unsigned char * outrow;
     unsigned int row;
@@ -150,7 +150,7 @@ convertRaster(struct pam * const inpamP,
             outrow[col] =
                 pnm_scalesample(tuplerow[col][0], inpamP->maxval, 255);
         }
-        
+
         fwrite(outrow, 1, inpamP->width, ofP);
     }
     free(outrow);
@@ -182,3 +182,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtooctaveimg.c b/converter/other/pamtooctaveimg.c
index 28bc4cd4..b89b8229 100644
--- a/converter/other/pamtooctaveimg.c
+++ b/converter/other/pamtooctaveimg.c
@@ -144,7 +144,7 @@ convertToOctave(FILE * const ifP,
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(allocation_depth));
 
     pnm_setminallocationdepth(&inpam, 3);
-    
+
     /* Output the image as a GNU Octave matrix.  For each row of the
      * input file we immediately output indexes into the colormap then,
      * when we're finished, we output the colormap as a second
@@ -191,14 +191,14 @@ main(int argc, char *argv[]) {
     inputName = argc-1 > 0 ? argv[1] : "-";
 
     ifP = pm_openr(inputName);
-    
+
     if (streq(inputName, "-"))
         fprintf(stdout, "# Created by pamtooctave\n");
     else
         fprintf(stdout, "# Created from '%s' by pamtooctave\n", inputName);
 
     convertToOctave(ifP, stdout);
-    
+
     pm_close(ifP);
 
     return 0;
diff --git a/converter/other/pamtopam.c b/converter/other/pamtopam.c
index 9cb82f7a..45f67d98 100644
--- a/converter/other/pamtopam.c
+++ b/converter/other/pamtopam.c
@@ -55,3 +55,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtopfm.c b/converter/other/pamtopfm.c
index 25a8a0af..7991e0dd 100644
--- a/converter/other/pamtopfm.c
+++ b/converter/other/pamtopfm.c
@@ -2,7 +2,7 @@
                                   pamtopfm
 ******************************************************************************
   This program converts a PAM image to PFM (Portable Float Map).
-  
+
   By Bryan Henderson, San Jose, CA April 2004.
 
   Contributed to the public domain by its author.
@@ -37,13 +37,13 @@ static enum endian machineEndianness;
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -54,7 +54,7 @@ parseCommandLine(int argc,
     optEntry *option_def = malloc( 100*sizeof( optEntry ) );
     /* Instructions to pm_optParseOptions3 on how to parse our options. */
     optStruct3 opt;
-  
+
     unsigned int option_def_index;
     char * endianOpt;
     unsigned int endianSpec, scaleSpec;
@@ -62,7 +62,7 @@ parseCommandLine(int argc,
     option_def_index = 0;   /* incremented by OPTENTRY */
     OPTENT3(0, "endian",   OPT_STRING, &endianOpt, &endianSpec,        0);
     OPTENT3(0, "scale",    OPT_FLOAT,  &cmdlineP->scale, &scaleSpec,   0);
-  
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
@@ -93,7 +93,7 @@ parseCommandLine(int argc,
         cmdlineP->inputFilespec = argv[1];
     else
         cmdlineP->inputFilespec = "-";
-    
+
     if (argc-1 > 1)
         pm_error("Program takes at most one argument:  the file name.  "
                  "You specified %d", argc-1);
@@ -109,7 +109,7 @@ thisMachineEndianness(void) {
    that varies among typical machines.
 
    Big endianness is the natural format.  In this format, if an integer is
-   4 bytes, to be stored at memory address 100-103, the most significant 
+   4 bytes, to be stored at memory address 100-103, the most significant
    byte goes at 100, the next most significant at 101, and the least
    significant byte at 103.  This is natural because it matches the way
    humans read and write numbers.  I.e. 258 is stored as 0x00000102.
@@ -125,7 +125,7 @@ thisMachineEndianness(void) {
 
     unsigned char * const storedNumber = (unsigned char *)&testNumber;
     enum endian endianness;
-    
+
     if (storedNumber[0] == 0x01)
         endianness = ENDIAN_LITTLE;
     else
@@ -156,11 +156,11 @@ floatToPfmSample(float       const input,
         unsigned int i, j;
 
         MEMSCPY(&reversed, &input);
-        
-        for (i = 0, j = sizeof(pfmSample)-1; 
-             i < sizeof(pfmSample); 
+
+        for (i = 0, j = sizeof(pfmSample)-1;
+             i < sizeof(pfmSample);
              ++i, --j)
-            
+
             outputP->bytes[i] = reversed[j];
     }
 }
@@ -181,8 +181,8 @@ writePfmHeader(FILE *           const ofP,
                struct pfmHeader const pfmHeader) {
 
     const char * const magic = pfmHeader.color ? "PF" : "Pf";
-    float const scaleFactorEndian = 
-        pfmHeader.endian == ENDIAN_BIG ? 
+    float const scaleFactorEndian =
+        pfmHeader.endian == ENDIAN_BIG ?
             pfmHeader.scaleFactor :
             - pfmHeader.scaleFactor;
 
@@ -217,7 +217,7 @@ writePfmRow(struct pam * const pamP,
         unsigned int plane;
         for (plane = 0; plane < pamP->depth; ++plane) {
             pfmSample val;
-            floatToPfmSample(tuplenRow[col][plane] * scaleFactor, 
+            floatToPfmSample(tuplenRow[col][plane] * scaleFactor,
                              &val, endian);
             pfmRowBuffer[pfmCursor++] = val;
         }
@@ -226,7 +226,7 @@ writePfmRow(struct pam * const pamP,
 
     rc = fwrite(pfmRowBuffer, sizeof(pfmSample), pfmSamplesPerRow, ofP);
     if (rc != pfmSamplesPerRow)
-        pm_error("Unable to write to output file in the middle of row %d", 
+        pm_error("Unable to write to output file in the middle of row %d",
                  pfmRow);
 
 
@@ -238,9 +238,9 @@ static struct pfmHeader
 makePfmHeader(const struct pam * const pamP,
               float              const scaleFactor,
               enum endian        const endian) {
-    
+
     struct pfmHeader pfmHeader;
-    
+
     pfmHeader.width  = pamP->width;
     pfmHeader.height = pamP->height;
 
@@ -256,11 +256,12 @@ makePfmHeader(const struct pam * const pamP,
 
     pfmHeader.scaleFactor = scaleFactor;
     pfmHeader.endian = endian;
-        
+
     return pfmHeader;
 }
 
 
+
 int
 main(int argc, char **argv ) {
 
@@ -282,11 +283,11 @@ main(int argc, char **argv ) {
 
     tuplenArray = pnm_readpamn(ifP, &pam, PAM_STRUCT_SIZE(tuple_type));
 
-    writePfmHeader(stdout, 
+    writePfmHeader(stdout,
                    makePfmHeader(&pam, cmdline.scale, cmdline.endian));
 
     pfmSamplesPerRow = pam.width * pam.depth;
-    
+
     MALLOCARRAY_NOFAIL(pfmRowBuffer, pfmSamplesPerRow);
 
     /* PFMs are upside down like BMPs */
@@ -297,9 +298,12 @@ main(int argc, char **argv ) {
 
     pnm_freepamarrayn(tuplenArray, &pam);
     free(pfmRowBuffer);
-    
+
     pm_close(stdout);
     pm_close(pam.file);
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtopng.c b/converter/other/pamtopng.c
index 831c3242..24eb1ca2 100644
--- a/converter/other/pamtopng.c
+++ b/converter/other/pamtopng.c
@@ -527,7 +527,6 @@ doZtxtChunkSet(struct pngx * const pngxP,
 
 
 
-
 static void
 doItxtChunkSet(struct pngx * const pngxP,
                const char *  const textFileName) {
diff --git a/converter/other/pamtopnm.c b/converter/other/pamtopnm.c
index f0ad451a..11e34b45 100644
--- a/converter/other/pamtopnm.c
+++ b/converter/other/pamtopnm.c
@@ -52,7 +52,7 @@ parseCommandLine(int argc, const char ** argv,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -66,7 +66,7 @@ parseCommandLine(int argc, const char ** argv,
 
 
 static void
-validateTupleType(struct pam const inpam, 
+validateTupleType(struct pam const inpam,
                   int        const assumeTupleType) {
 /*----------------------------------------------------------------------------
    Make sure the image has a tuple type we know how to convert to PNM.
@@ -83,18 +83,18 @@ validateTupleType(struct pam const inpam,
     if (assumeTupleType) {
         /* User says tuple type is appropriate regardless of tuple_type. */
     } else {
-        if (inpam.depth >= 1 && 
-            strncmp(inpam.tuple_type, "BLACKANDWHITE", 
+        if (inpam.depth >= 1 &&
+            strncmp(inpam.tuple_type, "BLACKANDWHITE",
                     sizeof("BLACKANDWHITE")-1) == 0) {
             /* It's a PBMable image */
-        } else if (inpam.depth >= 1 && 
+        } else if (inpam.depth >= 1 &&
                    strncmp(inpam.tuple_type, "GRAYSCALE",
                            sizeof("GRAYSCALE")-1) == 0) {
             /* It's a PGMable image */
         } else if (inpam.depth >= 3 &&
                    strncmp(inpam.tuple_type, "RGB", sizeof("RGB")-1) == 0) {
             /* It's a PPMable image */
-        } else 
+        } else
             pm_error("PAM image does not have a depth and tuple_type "
                      "consistent with a PNM image.  "
                      "According to its "
@@ -129,12 +129,12 @@ main(int argc, const char **argv) {
 
         outpam = inpam;
         outpam.file = stdout;
-        
+
         if (inpam.depth < 3) {
             outpam.depth = 1;
             if (inpam.maxval == 1)
                 outpam.format = PBM_FORMAT;
-            else 
+            else
                 outpam.format = PGM_FORMAT;
         } else {
             outpam.depth = 3;
@@ -145,17 +145,17 @@ main(int argc, const char **argv) {
 
         {
             tuple *tuplerow;
-            
-            tuplerow = pnm_allocpamrow(&inpam);      
-            { 
+
+            tuplerow = pnm_allocpamrow(&inpam);
+            {
                 int row;
-                
+
                 for (row = 0; row < inpam.height; row++) {
                     pnm_readpamrow(&inpam, tuplerow);
                     pnm_writepamrow(&outpam, tuplerow);
                 }
             }
-            pnm_freepamrow(tuplerow);        
+            pnm_freepamrow(tuplerow);
         }
 
         pnm_nextimage(ifP, &eof);
@@ -163,3 +163,6 @@ main(int argc, const char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtoqoi.c b/converter/other/pamtoqoi.c
index 638efa3a..e3f87ae0 100644
--- a/converter/other/pamtoqoi.c
+++ b/converter/other/pamtoqoi.c
@@ -113,6 +113,8 @@ encodeQoiHeader(qoi_Desc const qoiDesc) {
 
 }
 
+
+
 enum Tupletype {BW, BWAlpha, GRAY, GRAYAlpha, RGB, RGBAlpha,
                 GRAY255, GRAY255Alpha, RGB255, RGB255Alpha};
 
@@ -437,3 +439,4 @@ main(int argc, const char **argv) {
 }
 
 
+
diff --git a/converter/other/pamtosrf.c b/converter/other/pamtosrf.c
index 3800d77c..b62b19df 100644
--- a/converter/other/pamtosrf.c
+++ b/converter/other/pamtosrf.c
@@ -206,7 +206,7 @@ main(int argc, const char * argv[]) {
   }
 
   srf_write(stdout, &srf);
-    
+
   srf_term(&srf);
   pm_closer(ifP);
 
diff --git a/converter/other/pamtosvg/autotrace.c b/converter/other/pamtosvg/autotrace.c
index fa5b7e15..37f5d5ec 100644
--- a/converter/other/pamtosvg/autotrace.c
+++ b/converter/other/pamtosvg/autotrace.c
@@ -42,6 +42,8 @@ at_fitting_opts_new(void)
   return opts;
 }
 
+
+
 at_fitting_opts_type *
 at_fitting_opts_copy (at_fitting_opts_type * original)
 {
@@ -56,12 +58,16 @@ at_fitting_opts_copy (at_fitting_opts_type * original)
   return new_opts;
 }
 
+
+
 void
 at_fitting_opts_free(at_fitting_opts_type * opts)
 {
   free(opts);
 }
 
+
+
 at_output_opts_type *
 at_output_opts_new(void)
 {
@@ -71,6 +77,8 @@ at_output_opts_new(void)
   return opts;
 }
 
+
+
 at_output_opts_type *
 at_output_opts_copy(at_output_opts_type * original)
 {
@@ -79,12 +87,16 @@ at_output_opts_copy(at_output_opts_type * original)
   return opts;
 }
 
+
+
 void
 at_output_opts_free(at_output_opts_type * opts)
 {
   free(opts);
 }
 
+
+
 /* at_splines_new_full modifies its 'bitmap' argument
    when it does the thin_image thing.
 */
diff --git a/converter/other/pamtosvg/bitmap.c b/converter/other/pamtosvg/bitmap.c
index 84a8a8ae..8b8ce092 100644
--- a/converter/other/pamtosvg/bitmap.c
+++ b/converter/other/pamtosvg/bitmap.c
@@ -13,7 +13,7 @@ at_bitmap_new(unsigned short width,
 
     at_bitmap_type * bitmap;
 
-    MALLOCVAR_NOFAIL(bitmap); 
+    MALLOCVAR_NOFAIL(bitmap);
 
     *bitmap = at_bitmap_init(NULL, width, height, planes);
 
@@ -31,10 +31,10 @@ at_bitmap_copy(at_bitmap_type * src)
     width  = at_bitmap_get_width(src);
     height = at_bitmap_get_height(src);
     planes = at_bitmap_get_planes(src);
-    
+
     dist = at_bitmap_new(width, height, planes);
-    memcpy(dist->bitmap, 
-           src->bitmap, 
+    memcpy(dist->bitmap,
+           src->bitmap,
            width * height * planes * sizeof(unsigned char));
     return dist;
 }
@@ -48,7 +48,7 @@ at_bitmap_init(unsigned char * area,
                unsigned int planes) {
 
     at_bitmap_type bitmap;
-    
+
     if (area)
         bitmap.bitmap = area;
     else {
@@ -63,33 +63,41 @@ at_bitmap_init(unsigned char * area,
                    0, width * height * planes * sizeof(unsigned char));
         }
     }
-    
+
     bitmap.width  = width;
     bitmap.height = height;
     bitmap.np     =  planes;
 
-    return bitmap;  
+    return bitmap;
 }
 
-void 
+
+
+void
 at_bitmap_free (at_bitmap_type * bitmap)
 {
     free_bitmap (bitmap);
     free(bitmap);
 }
 
+
+
 unsigned short
 at_bitmap_get_width (at_bitmap_type * bitmap)
 {
     return bitmap->width;
 }
 
+
+
 unsigned short
 at_bitmap_get_height (at_bitmap_type * bitmap)
 {
     return bitmap->height;
 }
 
+
+
 unsigned short
 at_bitmap_get_planes (at_bitmap_type * bitmap)
 {
@@ -104,6 +112,8 @@ new_bitmap (unsigned short width, unsigned short height)
     return at_bitmap_init(NULL,width,height,1);
 }
 
+
+
 /* Free the storage that is allocated for a bitmap.  On the other hand,
    the bitmap might not have any storage allocated for it if it is zero
    in either dimension; in that case, don't free it.  */
@@ -114,3 +124,6 @@ free_bitmap (bitmap_type *b)
     if (b->bitmap != NULL)
         free (b->bitmap);
 }
+
+
+
diff --git a/converter/other/pamtosvg/bitmap.h b/converter/other/pamtosvg/bitmap.h
index b979e0c0..ae5da2a8 100644
--- a/converter/other/pamtosvg/bitmap.h
+++ b/converter/other/pamtosvg/bitmap.h
@@ -12,16 +12,16 @@
 /* at_ prefix removed version */
 typedef at_bitmap_type bitmap_type;
 #define BITMAP_PLANES(b)          AT_BITMAP_PLANES(b)
-#define BITMAP_BITS(b)            AT_BITMAP_BITS(b)  
-#define BITMAP_WIDTH(b)           AT_BITMAP_WIDTH(b)  
-#define BITMAP_HEIGHT(b)          AT_BITMAP_HEIGHT(b) 
+#define BITMAP_BITS(b)            AT_BITMAP_BITS(b)
+#define BITMAP_WIDTH(b)           AT_BITMAP_WIDTH(b)
+#define BITMAP_HEIGHT(b)          AT_BITMAP_HEIGHT(b)
 
 /* This is the pixel at [ROW,COL].  */
-#define BITMAP_PIXEL(b, row, col)					\
+#define BITMAP_PIXEL(b, row, col)                                       \
   ((b).bitmap + ((row) * (b).width + (col)) * (b).np)
 
-#define BITMAP_VALID_PIXEL(b, row, col)					\
-   	((row) < (b).height && (col) < (b).width)
+#define BITMAP_VALID_PIXEL(b, row, col)                                 \
+        ((row) < (b).height && (col) < (b).width)
 
 /* Allocate storage for the bits, set them all to white, and return an
    initialized structure.  */
@@ -32,12 +32,12 @@ extern void free_bitmap (bitmap_type *);
 
 
 at_bitmap_type * at_bitmap_new(unsigned short width,
-			       unsigned short height,
-			       unsigned int planes);
+                               unsigned short height,
+                               unsigned int planes);
 at_bitmap_type * at_bitmap_copy(at_bitmap_type * src);
 
-/* We have to export functions that allows internal datum 
-   access. Such functions might be useful for 
+/* We have to export functions that allows internal datum
+   access. Such functions might be useful for
    at_bitmap_new user. */
 unsigned short at_bitmap_get_width (at_bitmap_type * bitmap);
 unsigned short at_bitmap_get_height (at_bitmap_type * bitmap);
@@ -46,8 +46,8 @@ void at_bitmap_free (at_bitmap_type * bitmap);
 
 at_bitmap_type
 at_bitmap_init(unsigned char * area,
-	       unsigned short width,
-	       unsigned short height,
-	       unsigned int planes);
+               unsigned short width,
+               unsigned short height,
+               unsigned int planes);
 
 #endif /* not BITMAP_H */
diff --git a/converter/other/pamtosvg/curve.c b/converter/other/pamtosvg/curve.c
index d7fff87d..bd0ca70b 100644
--- a/converter/other/pamtosvg/curve.c
+++ b/converter/other/pamtosvg/curve.c
@@ -61,6 +61,7 @@ curve_new(void) {
 }
 
 
+
 Curve *
 curve_copyMost(Curve * const oldCurveP) {
 /*----------------------------------------------------------------------------
@@ -77,6 +78,8 @@ curve_copyMost(Curve * const oldCurveP) {
     return curveP;
 }
 
+
+
 void
 curve_move(Curve * const dstP,
            Curve * const srcP) {
@@ -285,7 +288,6 @@ curve_logEntire(Curve * const curveP) {
 
 
 
-
 CurveList
 curve_newList(void) {
 /*----------------------------------------------------------------------------
diff --git a/converter/other/pamtosvg/curve.h b/converter/other/pamtosvg/curve.h
index 65d4e26b..946bb2f3 100644
--- a/converter/other/pamtosvg/curve.h
+++ b/converter/other/pamtosvg/curve.h
@@ -64,12 +64,12 @@ typedef struct Curve {
 /* If the curve is cyclic, the next and previous points should wrap
    around; otherwise, if we get to the end, we return CURVE_LENGTH and
    -1, respectively.  */
-#define CURVE_NEXT(c, n)						\
-  ((n) + 1 >= CURVE_LENGTH (c)						\
-  ? CURVE_CYCLIC (c) ? ((n) + 1) % CURVE_LENGTH (c) : CURVE_LENGTH (c)	\
+#define CURVE_NEXT(c, n)                                                \
+  ((n) + 1 >= CURVE_LENGTH (c)                                          \
+  ? CURVE_CYCLIC (c) ? ((n) + 1) % CURVE_LENGTH (c) : CURVE_LENGTH (c)  \
   : (n) + 1)
-#define CURVE_PREV(c, n)						\
-  ((signed int) (n) - 1 < 0							\
+#define CURVE_PREV(c, n)                                                \
+  ((signed int) (n) - 1 < 0                                                     \
   ? CURVE_CYCLIC (c) ? (signed int) CURVE_LENGTH (c) + (signed int) (n) - 1 : -1\
   : (signed int) (n) - 1)
 
diff --git a/converter/other/pamtosvg/epsilon.c b/converter/other/pamtosvg/epsilon.c
index 0c914dae..f5370475 100644
--- a/converter/other/pamtosvg/epsilon.c
+++ b/converter/other/pamtosvg/epsilon.c
@@ -11,7 +11,9 @@ epsilon_equal(float const v1,
               float const v2) {
 
     return
-        v1 == v2		       /* Usually they'll be exactly equal, anyway.  */
+        v1 == v2                       /* Usually they'll be exactly equal, anyway.  */
         || fabs(v1 - v2) <= REAL_EPSILON;
 }
 
+
+
diff --git a/converter/other/pamtosvg/exception.c b/converter/other/pamtosvg/exception.c
index 43761936..bf8228ae 100644
--- a/converter/other/pamtosvg/exception.c
+++ b/converter/other/pamtosvg/exception.c
@@ -1,4 +1,3 @@
-
 #include "exception.h"
 
 at_exception_type
@@ -10,7 +9,7 @@ at_exception_new(at_msg_func       client_func,
     e.msg_type = 0;
     e.client_func = client_func;
     e.client_data = client_data;
-    
+
     return e;
 }
 
@@ -31,7 +30,7 @@ at_exception_fatal(at_exception_type * const exception,
     if (exception) {
         exception->msg_type = AT_MSG_FATAL;
         if (exception->client_func) {
-            exception->client_func(message, 
+            exception->client_func(message,
                                    AT_MSG_FATAL,
                                    exception->client_data);
         }
@@ -47,9 +46,12 @@ at_exception_warning(at_exception_type * const exception,
     if (exception) {
         exception->msg_type = AT_MSG_WARNING;
         if (exception->client_func) {
-            exception->client_func(message, 
+            exception->client_func(message,
                                    AT_MSG_WARNING,
                                    exception->client_data);
         }
     }
 }
+
+
+
diff --git a/converter/other/pamtosvg/exception.h b/converter/other/pamtosvg/exception.h
index 113f65e6..06de7182 100644
--- a/converter/other/pamtosvg/exception.h
+++ b/converter/other/pamtosvg/exception.h
@@ -1,7 +1,7 @@
 /* exception.h: facility to handle error in autotrace */
 
 #ifndef AT_EXCEPTION_H
-#define AT_EXCEPTION_H 
+#define AT_EXCEPTION_H
 
 #include "autotrace.h"
 
@@ -10,8 +10,8 @@ extern "C" {
 #endif /* __cplusplus */
 
 /* Protocol:
-   If a function raises a FATAL(including propagation), 
-   the function must release resources allocated by the 
+   If a function raises a FATAL(including propagation),
+   the function must release resources allocated by the
    function itself.
 */
 typedef struct _at_exception_type at_exception_type;
diff --git a/converter/other/pamtosvg/fit.c b/converter/other/pamtosvg/fit.c
index f8a23ffb..9c6f20d4 100644
--- a/converter/other/pamtosvg/fit.c
+++ b/converter/other/pamtosvg/fit.c
@@ -87,6 +87,7 @@ intCoordFmReal(Point const realCoord) {
 }
 
 
+
 /* Lists of array indices (well, that is what we use it for).  */
 
 static IndexList
@@ -1283,7 +1284,8 @@ computeCX(Curve *                 const curveP,
 
     unsigned int pointSeq;
 
-    cP->beg.beg = 0.0; cP->beg.end = 0.0; cP->end.beg = 0.0; cP->end.end = 0.0;/* initial value */
+    cP->beg.beg = 0.0; cP->beg.end = 0.0; cP->end.beg = 0.0; cP->end.end = 0.0;
+        /* initial value */
 
     xP->beg = 0.0; xP->end = 0.0; /* initial value */
 
@@ -1799,8 +1801,8 @@ divideAndFit(Curve *                   const curveP,
 
 static spline_list_type *
 fitWithLeastSquares(Curve *                   const curveP,
-                    Vector               const begSlope,
-                    Vector               const endSlope,
+                    Vector                    const begSlope,
+                    Vector                    const endSlope,
                     const fitting_opts_type * const fittingOptsP,
                     at_exception_type *       const exceptionP) {
 /*----------------------------------------------------------------------------
diff --git a/converter/other/pamtosvg/image-header.h b/converter/other/pamtosvg/image-header.h
index adcf4771..ef387572 100644
--- a/converter/other/pamtosvg/image-header.h
+++ b/converter/other/pamtosvg/image-header.h
@@ -9,10 +9,10 @@
    the particular formats.  */
 typedef struct
 {
-  unsigned short hres, vres;	/* In pixels per inch.  */
-  unsigned short width, height;	/* In bits.  */
-  unsigned short depth;		/* Perhaps the depth?  */
-  unsigned format;		/* (for pbm) Whether packed or not.  */
+  unsigned short hres, vres;    /* In pixels per inch.  */
+  unsigned short width, height; /* In bits.  */
+  unsigned short depth;         /* Perhaps the depth?  */
+  unsigned format;              /* (for pbm) Whether packed or not.  */
 } image_header_type;
 
 #endif /* not IMAGE_HEADER_H */
diff --git a/converter/other/pamtosvg/image-proc.c b/converter/other/pamtosvg/image-proc.c
index d025ee1e..7462219c 100644
--- a/converter/other/pamtosvg/image-proc.c
+++ b/converter/other/pamtosvg/image-proc.c
@@ -53,7 +53,7 @@ new_distance_map(bitmap_type bitmap, unsigned char target_value, bool padded, at
         if (dist.d[y] == NULL)
             pm_error("Unable to get memory for distance map");
         memset(dist.d[y], 0, w * sizeof(float));
-        
+
         MALLOCARRAY(dist.weight[y], w);
         if (dist.weight[y] == NULL)
             pm_error("Unable to get memory for distance map");
@@ -72,7 +72,7 @@ new_distance_map(bitmap_type bitmap, unsigned char target_value, bool padded, at
           dist.weight[y][x] = 1.0F - fgray;
 /*        dist.weight[y][x] = 1.0F - (fgray * fgray);*/
 /*        dist.weight[y][x] = (fgray < 0.5F ? 1.0F - fgray : -2.0F * fgray * (fgray - 1.0F));*/
-	    }
+            }
       }
     }
     else
@@ -158,15 +158,15 @@ new_distance_map(bitmap_type bitmap, unsigned char target_value, bool padded, at
 
             /* lower-right neighbor */
             d = dist.d[y + 1][x + 1] + (float) M_SQRT2 * dist.weight[y][x];
-	        if (d < min) min = dist.d[y][x] = d;
+                if (d < min) min = dist.d[y][x] = d;
 
             /* lower neighbor */
             d = dist.d[y + 1][x] + dist.weight[y][x];
-	        if (d < min) min = dist.d[y][x] = d;
+                if (d < min) min = dist.d[y][x] = d;
 
             /* right neighbor */
             d = dist.d[y][x + 1] + dist.weight[y][x];
-	        if (d < min) min = dist.d[y][x] = d;
+                if (d < min) min = dist.d[y][x] = d;
 
             /* lower-left neighbor (except at the first column) */
             if (x - 1 >= 0)
@@ -180,6 +180,7 @@ new_distance_map(bitmap_type bitmap, unsigned char target_value, bool padded, at
 }
 
 
+
 /* Free the dynamically-allocated storage associated with a distance map. */
 
 void
@@ -193,19 +194,20 @@ free_distance_map(distance_map_type *dist)
 
     if (dist->d != NULL)
     {
-	for (y = 0; y < h; y++)
-	    free(dist->d[y]);
+        for (y = 0; y < h; y++)
+            free(dist->d[y]);
         free(dist->d);
     }
     if (dist->weight != NULL)
     {
-	for (y = 0; y < h; y++)
-	    free(dist->weight[y]);
+        for (y = 0; y < h; y++)
+            free(dist->weight[y]);
         free(dist->weight);
     }
 }
 
 
+
 #if 0
 void
 medial_axis(bitmap_type *bitmap, distance_map_type *dist,
@@ -233,7 +235,7 @@ medial_axis(bitmap_type *bitmap, distance_map_type *dist,
 
     if (bgSpec)
         bg = bg_color;
-    else 
+    else
         PPM_ASSIGN(bg, 255, 255, 255);
 
     f = d[0][0] + 0.5;
@@ -246,44 +248,44 @@ medial_axis(bitmap_type *bitmap, distance_map_type *dist,
 
     for (x = 1; x < w - 1; x++)
     {
-	    f = d[0][x] + 0.5;
-	    test = (f < d[0][x-1]) + (f < d[0][x+1]) + (f < d[1][x-1])
-	        + (f < d[1][x]) + (f < d[1][x+1]);
-	    if (test > 1) b[x] = PPM_GETR(bg);
+            f = d[0][x] + 0.5;
+            test = (f < d[0][x-1]) + (f < d[0][x+1]) + (f < d[1][x-1])
+                + (f < d[1][x]) + (f < d[1][x+1]);
+            if (test > 1) b[x] = PPM_GETR(bg);
     }
     b += w;
 
     for (y = 1; y < h - 1; y++)
     {
-	    f = d[y][0] + 0.5;
-	    test = (f < d[y-1][0]) + (f < d[y-1][1]) + (f < d[y][1])
-	        + (f < d[y+1][0]) + (f < d[y+1][1]);
-	    if (test > 1) b[0] = PPM_GETR(bg);
-
-	    for (x = 1; x < w - 1; x++)
-		{
-	        f = d[y][x] + 0.5;
-	        test = (f < d[y-1][x-1]) + (f < d[y-1][x]) + (f < d[y-1][x+1])
-		    + (f < d[y][x-1]) + (f < d[y][x+1])
-		    + (f < d[y+1][x-1]) + (f < d[y+1][x]) + (f < d[y+1][x+1]);
-	        if (test > 1) b[x] = PPM_GETR(bg)
-		}
-
-	    f = d[y][w-1] + 0.5;
-	    test = (f < d[y-1][w-1]) + (f < d[y-1][w-2]) + (f < d[y][w-2])
-	        + (f < d[y+1][w-1]) + (f < d[y+1][w-2]);
-	    if (test > 1)
-	        b[w-1] = PPM_GETR(bg);
+            f = d[y][0] + 0.5;
+            test = (f < d[y-1][0]) + (f < d[y-1][1]) + (f < d[y][1])
+                + (f < d[y+1][0]) + (f < d[y+1][1]);
+            if (test > 1) b[0] = PPM_GETR(bg);
+
+            for (x = 1; x < w - 1; x++)
+                {
+                f = d[y][x] + 0.5;
+                test = (f < d[y-1][x-1]) + (f < d[y-1][x]) + (f < d[y-1][x+1])
+                    + (f < d[y][x-1]) + (f < d[y][x+1])
+                    + (f < d[y+1][x-1]) + (f < d[y+1][x]) + (f < d[y+1][x+1]);
+                if (test > 1) b[x] = PPM_GETR(bg)
+                }
+
+            f = d[y][w-1] + 0.5;
+            test = (f < d[y-1][w-1]) + (f < d[y-1][w-2]) + (f < d[y][w-2])
+                + (f < d[y+1][w-1]) + (f < d[y+1][w-2]);
+            if (test > 1)
+                b[w-1] = PPM_GETR(bg);
 
         b += w;
     }
 
     for (x = 1; x < w - 1; x++)
     {
-	    f = d[h-1][x] + 0.5;
-	    test = (f < d[h-1][x-1]) + (f < d[h-1][x+1])
-	        + (f < d[h-2][x-1]) + (f < d[h-2][x]) + (f < d[h-2][x+1]);
-	    if (test > 1) b[x] = PPM_GETR(bg);
+            f = d[h-1][x] + 0.5;
+            test = (f < d[h-1][x-1]) + (f < d[h-1][x+1])
+                + (f < d[h-2][x-1]) + (f < d[h-2][x]) + (f < d[h-2][x+1]);
+            if (test > 1) b[x] = PPM_GETR(bg);
     }
 
     f = d[h-1][0] + 0.5;
@@ -314,27 +316,28 @@ binarize(bitmap_type *bitmap)
 
     if (spp == 1)
     {
-	    for (i = 0; i < npixels; i++)
-	        b[i] = (b[i] > GRAY_THRESHOLD ? WHITE : BLACK);
+            for (i = 0; i < npixels; i++)
+                b[i] = (b[i] > GRAY_THRESHOLD ? WHITE : BLACK);
     }
     else if (spp == 3)
     {
-	    unsigned char *rgb = b;
-	    for (i = 0; i < npixels; i++, rgb += 3)
-		{
-	        b[i] = (LUMINANCE(rgb[0], rgb[1], rgb[2]) > GRAY_THRESHOLD
-		        ? WHITE : BLACK);
-		}
-	    REALLOCARRAY_NOFAIL(bitmap->bitmap, npixels);
-	    bitmap->np = 1;
+            unsigned char *rgb = b;
+            for (i = 0; i < npixels; i++, rgb += 3)
+                {
+                b[i] = (LUMINANCE(rgb[0], rgb[1], rgb[2]) > GRAY_THRESHOLD
+                        ? WHITE : BLACK);
+                }
+            REALLOCARRAY_NOFAIL(bitmap->bitmap, npixels);
+            bitmap->np = 1;
     }
     else
     {
-	    WARNING1("binarize: don't know how to interpret %u-plane images", spp);
+            WARNING1("binarize: don't know how to interpret %u-plane images", spp);
     }
 }
 
 
+
 #if 0
 /* Thin a binary image, replacing the original image with the thinned one. */
 
@@ -351,9 +354,9 @@ ip_thin(bitmap_type input_b)
 
     if (BITMAP_PLANES(input_b) != 1)
     {
-	    FATAL1("thin: single-plane image required; "
-	        "%u-plane images cannot be thinned", BITMAP_PLANES(input_b));
-	    return b;
+            FATAL1("thin: single-plane image required; "
+                "%u-plane images cannot be thinned", BITMAP_PLANES(input_b));
+            return b;
     }
 
     /* Process and return a copy of the input image. */
@@ -364,149 +367,151 @@ ip_thin(bitmap_type input_b)
 
     /* Set background pixels to zero, foreground pixels to one. */
     for (i = 0; i < num_bytes; i++)
-	b.bitmap[i] = (b.bitmap[i] == BLACK ? 1 : 0);
+        b.bitmap[i] = (b.bitmap[i] == BLACK ? 1 : 0);
 
     again = true;
     while (again)
     {
-	again = false;
-
-	for (y = 1; y < h - 1; y++)
-	{
-	    for (x = 1; x < w - 1; x++)
-	    {
-		    /* During processing, pixels are used to store edge
-		       type codes, so we can't just test for WHITE or BLACK. */
-		    if (*BITMAP_PIXEL(b, y, x) == 0) continue;
-
-		    k = (!get_edge(b, y, x, &t)
-		        || (get_edge(b, y, x+1, &t) && *BITMAP_PIXEL(b, y-1, x)
-			    && *BITMAP_PIXEL(b, y+1, x))
-		        || (get_edge(b, y+1, x, &t) && *BITMAP_PIXEL(b, y, x-1)
-			    && *BITMAP_PIXEL(b, y, x+1))
-		        || (get_edge(b, y, x+1, &t) && get_edge(b, y+1, x+1, &t)
-			    && get_edge(b, y+1, x, &t)));
-		    if (k) continue;
-
-		    get_edge(b, y, x, &t);
-		    if (t.t01) *BITMAP_PIXEL(b, y, x) |= 4;
-		    *BITMAP_PIXEL(b, y, x) |= 2;
-		    again = true;
-	    }
-	}
-
-	for (y = 0; y < h; y++)
-	    for (x = 0; x < w; x++)
-		    if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
-
-	for (y = 1; y < h - 1; y++)
-	{
-	    for (x = 1; x < w - 1; x++)
-	    {
-		    if (*BITMAP_PIXEL(b, y, x) == 0) continue;
-
-		    k = (!get_edge(b, y, x, &t)
-		        || ((*BITMAP_PIXEL(b, y, x) & 04) == 0)
-		        || (get_edge(b, y+1, x, &t) && (*BITMAP_PIXEL(b, y, x-1))
-			    && *BITMAP_PIXEL(b, y, x+1))
-		        || (get_edge(b, y, x+1, &t) && *BITMAP_PIXEL(b, y-1, x)
-			    && *BITMAP_PIXEL(b, y+1, x))
-		        || (get_edge(b, y+1, x, &t) && get_edge(b, y, x+1, &t)
-			    && get_edge(b, y+1, x+1, &t)));
-		    if (k) continue;
-
-		    *BITMAP_PIXEL(b, y, x) |= 02;
-		    again = true;
-	    }
-	}
-
-	for (y = 0; y < h; y++)
-	{
-	    for (x = 0; x < w; x++)
-	    {
-		    if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
-		    else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
-	    }
-	}
+        again = false;
+
+        for (y = 1; y < h - 1; y++)
+        {
+            for (x = 1; x < w - 1; x++)
+            {
+                    /* During processing, pixels are used to store edge
+                       type codes, so we can't just test for WHITE or BLACK. */
+                    if (*BITMAP_PIXEL(b, y, x) == 0) continue;
+
+                    k = (!get_edge(b, y, x, &t)
+                        || (get_edge(b, y, x+1, &t) && *BITMAP_PIXEL(b, y-1, x)
+                            && *BITMAP_PIXEL(b, y+1, x))
+                        || (get_edge(b, y+1, x, &t) && *BITMAP_PIXEL(b, y, x-1)
+                            && *BITMAP_PIXEL(b, y, x+1))
+                        || (get_edge(b, y, x+1, &t) && get_edge(b, y+1, x+1, &t)
+                            && get_edge(b, y+1, x, &t)));
+                    if (k) continue;
+
+                    get_edge(b, y, x, &t);
+                    if (t.t01) *BITMAP_PIXEL(b, y, x) |= 4;
+                    *BITMAP_PIXEL(b, y, x) |= 2;
+                    again = true;
+            }
+        }
+
+        for (y = 0; y < h; y++)
+            for (x = 0; x < w; x++)
+                    if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
+
+        for (y = 1; y < h - 1; y++)
+        {
+            for (x = 1; x < w - 1; x++)
+            {
+                    if (*BITMAP_PIXEL(b, y, x) == 0) continue;
+
+                    k = (!get_edge(b, y, x, &t)
+                        || ((*BITMAP_PIXEL(b, y, x) & 04) == 0)
+                        || (get_edge(b, y+1, x, &t) && (*BITMAP_PIXEL(b, y, x-1))
+                            && *BITMAP_PIXEL(b, y, x+1))
+                        || (get_edge(b, y, x+1, &t) && *BITMAP_PIXEL(b, y-1, x)
+                            && *BITMAP_PIXEL(b, y+1, x))
+                        || (get_edge(b, y+1, x, &t) && get_edge(b, y, x+1, &t)
+                            && get_edge(b, y+1, x+1, &t)));
+                    if (k) continue;
+
+                    *BITMAP_PIXEL(b, y, x) |= 02;
+                    again = true;
+            }
+        }
+
+        for (y = 0; y < h; y++)
+        {
+            for (x = 0; x < w; x++)
+            {
+                    if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
+                    else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
+            }
+        }
     }
 
     /* Staircase removal; northward bias. */
     for (y = 1; y < h - 1; y++)
     {
-	    for (x = 1; x < w - 1; x++)
-		{
-	        if (*BITMAP_PIXEL(b, y, x) == 0) continue;
-
-	        k = !(*BITMAP_PIXEL(b, y-1, x)
-		        && ((*BITMAP_PIXEL(b, y, x+1) && !*BITMAP_PIXEL(b, y-1, x+1)
-		        && !*BITMAP_PIXEL(b, y+1, x-1)
-		        && (!*BITMAP_PIXEL(b, y, x-1) || !*BITMAP_PIXEL(b, y+1, x)))
-		        || (*BITMAP_PIXEL(b, y, x-1) && !*BITMAP_PIXEL(b, y-1, x-1)
-		        && !*BITMAP_PIXEL(b, y+1, x+1) &&
-		        (!*BITMAP_PIXEL(b, y, x+1) || !*BITMAP_PIXEL(b, y+1, x)))));
-	        if (k) continue;
-
-	        *BITMAP_PIXEL(b, y, x) |= 02;
-		}
+            for (x = 1; x < w - 1; x++)
+                {
+                if (*BITMAP_PIXEL(b, y, x) == 0) continue;
+
+                k = !(*BITMAP_PIXEL(b, y-1, x)
+                        && ((*BITMAP_PIXEL(b, y, x+1) && !*BITMAP_PIXEL(b, y-1, x+1)
+                        && !*BITMAP_PIXEL(b, y+1, x-1)
+                        && (!*BITMAP_PIXEL(b, y, x-1) || !*BITMAP_PIXEL(b, y+1, x)))
+                        || (*BITMAP_PIXEL(b, y, x-1) && !*BITMAP_PIXEL(b, y-1, x-1)
+                        && !*BITMAP_PIXEL(b, y+1, x+1) &&
+                        (!*BITMAP_PIXEL(b, y, x+1) || !*BITMAP_PIXEL(b, y+1, x)))));
+                if (k) continue;
+
+                *BITMAP_PIXEL(b, y, x) |= 02;
+                }
     }
     for (y = 0; y < h; y++)
     {
-	    for (x = 0; x < w; x++)
-		{
-	        if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
-	        else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
-		}
+            for (x = 0; x < w; x++)
+                {
+                if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
+                else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
+                }
     }
 
     /* Southward bias */
     for (y = 1; y < h - 1; y++)
     {
-	    for (x = 1; x < w - 1; x++)
-		{
-	        if (*BITMAP_PIXEL(b, y, x) == 0) continue;
-
-	        k = !(*BITMAP_PIXEL(b, y+1, x)
-		    && ((*BITMAP_PIXEL(b, y, x+1) && !*BITMAP_PIXEL(b, y+1, x+1)
-		    && !*BITMAP_PIXEL(b, y-1, x-1) && (!*BITMAP_PIXEL(b, y, x-1)
-		    || !*BITMAP_PIXEL(b, y-1, x))) || (*BITMAP_PIXEL(b, y, x-1)
-		    && !*BITMAP_PIXEL(b, y+1, x-1) && !*BITMAP_PIXEL(b, y-1, x+1)
-		    && (!*BITMAP_PIXEL(b, y, x+1) || !*BITMAP_PIXEL(b, y-1, x)) )));
-	        if (k) continue;
-
-	        *BITMAP_PIXEL(b, y, x) |= 02;
-		}
+            for (x = 1; x < w - 1; x++)
+                {
+                if (*BITMAP_PIXEL(b, y, x) == 0) continue;
+
+                k = !(*BITMAP_PIXEL(b, y+1, x)
+                    && ((*BITMAP_PIXEL(b, y, x+1) && !*BITMAP_PIXEL(b, y+1, x+1)
+                    && !*BITMAP_PIXEL(b, y-1, x-1) && (!*BITMAP_PIXEL(b, y, x-1)
+                    || !*BITMAP_PIXEL(b, y-1, x))) || (*BITMAP_PIXEL(b, y, x-1)
+                    && !*BITMAP_PIXEL(b, y+1, x-1) && !*BITMAP_PIXEL(b, y-1, x+1)
+                    && (!*BITMAP_PIXEL(b, y, x+1) || !*BITMAP_PIXEL(b, y-1, x)) )));
+                if (k) continue;
+
+                *BITMAP_PIXEL(b, y, x) |= 02;
+                }
     }
     for (y = 0; y < h; y++)
     {
-	    for (x = 0; x < w; x++)
-		{
-	        if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
-	        else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
-		}
+            for (x = 0; x < w; x++)
+                {
+                if (*BITMAP_PIXEL(b, y, x) & 02) *BITMAP_PIXEL(b, y, x) = 0;
+                else if (*BITMAP_PIXEL(b, y, x) > 0) *BITMAP_PIXEL(b, y, x) = 1;
+                }
     }
 
     /* Set background pixels to WHITE, foreground pixels to BLACK. */
     for (i = 0; i < num_bytes; i++)
-	b.bitmap[i] = (b.bitmap[i] == 0 ? WHITE : BLACK);
+        b.bitmap[i] = (b.bitmap[i] == 0 ? WHITE : BLACK);
     return b;
 }
 
 
+
 bool get_edge(bitmap_type b, int y, int x, struct etyp *t)
 {
     t->t00 = 0; t->t01 = 0; t->t01s = 0; t->t11 = 0;
     check(*BITMAP_PIXEL(b, y - 1, x - 1), *BITMAP_PIXEL(b, y - 1, x),
-	*BITMAP_PIXEL(b, y - 1, x + 1), t);
+        *BITMAP_PIXEL(b, y - 1, x + 1), t);
     check(*BITMAP_PIXEL(b, y - 1, x + 1), *BITMAP_PIXEL(b, y, x + 1),
-	*BITMAP_PIXEL(b, y + 1, x + 1), t);
+        *BITMAP_PIXEL(b, y + 1, x + 1), t);
     check(*BITMAP_PIXEL(b, y + 1, x + 1), *BITMAP_PIXEL(b, y + 1, x),
-	*BITMAP_PIXEL(b, y + 1, x - 1), t);
+        *BITMAP_PIXEL(b, y + 1, x - 1), t);
     check(*BITMAP_PIXEL(b, y + 1, x - 1), *BITMAP_PIXEL(b, y, x - 1),
-	*BITMAP_PIXEL(b, y - 1, x - 1), t);
+        *BITMAP_PIXEL(b, y - 1, x - 1), t);
     return *BITMAP_PIXEL(b, y, x) && t->t00 && t->t11 && !t->t01s;
 }
 
 
+
 void check(int v1, int v2, int v3, struct etyp *t)
 {
     if (!v2 && (!v1 || !v3)) t->t00 = 1;
diff --git a/converter/other/pamtosvg/image-proc.h b/converter/other/pamtosvg/image-proc.h
index a5b86ec1..0607d3dd 100644
--- a/converter/other/pamtosvg/image-proc.h
+++ b/converter/other/pamtosvg/image-proc.h
@@ -25,7 +25,7 @@ typedef struct
 /* Allocate and compute a new distance map. */
 extern distance_map_type new_distance_map(bitmap_type,
     unsigned char target_value, bool padded,
-					  at_exception_type * exp);
+                                          at_exception_type * exp);
 
 /* Free the dynamically-allocated storage associated with a distance map. */
 extern void free_distance_map(distance_map_type*);
diff --git a/converter/other/pamtosvg/logreport.c b/converter/other/pamtosvg/logreport.c
index 7d726584..63568b96 100644
--- a/converter/other/pamtosvg/logreport.c
+++ b/converter/other/pamtosvg/logreport.c
@@ -15,3 +15,5 @@ flush_log_output (void)
     fflush (log_file);
 }
 
+
+
diff --git a/converter/other/pamtosvg/logreport.h b/converter/other/pamtosvg/logreport.h
index 577da8df..071d42c3 100644
--- a/converter/other/pamtosvg/logreport.h
+++ b/converter/other/pamtosvg/logreport.h
@@ -11,17 +11,17 @@ extern FILE *at_log_file;
 
 extern void flush_log_output (void);
 
-#define LOG(s)								\
+#define LOG(s)                                                          \
   do { if (log_file) fputs (s, log_file); } while (0)
-#define LOG1(s, e)							\
+#define LOG1(s, e)                                                      \
   do { if (log_file) fprintf (log_file, s, e); } while (0)
-#define LOG2(s, e1, e2)							\
+#define LOG2(s, e1, e2)                                                 \
   do { if (log_file) fprintf (log_file, s, e1, e2); } while (0)
-#define LOG3(s, e1, e2, e3)						\
+#define LOG3(s, e1, e2, e3)                                             \
   do { if (log_file) fprintf (log_file, s, e1, e2, e3); } while (0)
-#define LOG4(s, e1, e2, e3, e4)						\
+#define LOG4(s, e1, e2, e3, e4)                                         \
   do { if (log_file) fprintf (log_file, s, e1, e2, e3, e4); } while (0)
-#define LOG5(s, e1, e2, e3, e4, e5)					\
+#define LOG5(s, e1, e2, e3, e4, e5)                                     \
   do { if (log_file) fprintf (log_file, s, e1, e2, e3, e4, e5); } while (0)
 
 #endif /* not LOGREPORT_H */
diff --git a/converter/other/pamtosvg/message.h b/converter/other/pamtosvg/message.h
index 0d0b9db5..e6822432 100644
--- a/converter/other/pamtosvg/message.h
+++ b/converter/other/pamtosvg/message.h
@@ -13,18 +13,18 @@
 #define START_FATAL() do { fputs ("fatal: ", stderr); LOG("fatal: ")
 #define END_FATAL() fputs (".\n", stderr); exit (1); } while (0)
 
-#define FATAL(s)							\
+#define FATAL(s)                                                        \
   START_FATAL (); fprintf (stderr, "%s", s); LOG (s); END_FATAL ()
-#define FATAL1(s, e1)							\
+#define FATAL1(s, e1)                                                   \
   START_FATAL (); fprintf (stderr, s, e1); LOG1 (s, e1); END_FATAL ()
 
 
 #define START_WARNING() do { fputs ("warning: ", stderr); LOG ("warning: ")
 #define END_WARNING() fputs (".\n", stderr); } while (0)
 
-#define WARNING(s)							\
+#define WARNING(s)                                                      \
   START_WARNING (); fprintf (stderr, "%s", s); LOG (s); END_WARNING ()
-#define WARNING1(s, e1)							\
+#define WARNING1(s, e1)                                                 \
   START_WARNING (); fprintf (stderr, s, e1); LOG1 (s, e1); END_WARNING ()
 
 #endif /* not MESSAGE_H */
diff --git a/converter/other/pamtosvg/output-svg.c b/converter/other/pamtosvg/output-svg.c
index 13ac5201..59733094 100644
--- a/converter/other/pamtosvg/output-svg.c
+++ b/converter/other/pamtosvg/output-svg.c
@@ -26,15 +26,15 @@ static void
 outSplineList(FILE *           const fileP,
               spline_list_type const splineList,
               unsigned int     const height) {
-              
+
     unsigned splineSeq;
-        
+
     for (splineSeq = 0;
          splineSeq < SPLINE_LIST_LENGTH(splineList);
          ++splineSeq) {
-        
+
         spline_type const spline = SPLINE_LIST_ELT(splineList, splineSeq);
-        
+
         if (SPLINE_DEGREE(spline) == LINEARTYPE) {
             fprintf(fileP, "L%g %g",
                     END_POINT(spline).x, height - END_POINT(spline).y);
@@ -55,13 +55,13 @@ out_splines(FILE *                 const fileP,
 
     unsigned listSeq;
     pixel lastColor;
-    
+
     PPM_ASSIGN(lastColor, 0, 0, 0);
-    
+
     for (listSeq = 0;
          listSeq < SPLINE_LIST_ARRAY_LENGTH(shape);
          ++listSeq) {
-        
+
         spline_list_type const splineList =
             SPLINE_LIST_ARRAY_ELT(shape, listSeq);
         spline_type const first = SPLINE_LIST_ELT(splineList, 0);
@@ -109,10 +109,10 @@ output_svg_writer(FILE *                    const fileP,
                   int                       const llx,
                   int                       const lly,
                   int                       const urx,
-                  int                       const ury, 
+                  int                       const ury,
                   at_output_opts_type *     const opts,
                   at_spline_list_array_type const shape,
-                  at_msg_func                     msg_func, 
+                  at_msg_func                     msg_func,
                   void *                    const msg_data) {
 
     int const width  = urx - llx;
@@ -125,6 +125,9 @@ output_svg_writer(FILE *                    const fileP,
     out_splines(fileP, shape, height);
 
     fputs("</svg>\n", fileP);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtosvg/output-svg.h b/converter/other/pamtosvg/output-svg.h
index 46fc8f8f..a02e8334 100644
--- a/converter/other/pamtosvg/output-svg.h
+++ b/converter/other/pamtosvg/output-svg.h
@@ -26,10 +26,10 @@ output_svg_writer(FILE *                    const file,
                   int                       const llx,
                   int                       const lly,
                   int                       const urx,
-                  int                       const ury, 
+                  int                       const ury,
                   at_output_opts_type *     const opts,
                   at_spline_list_array_type const shape,
-                  at_msg_func                     msg_func, 
+                  at_msg_func                     msg_func,
                   void *                    const msg_data);
 
 
diff --git a/converter/other/pamtosvg/pamtosvg.c b/converter/other/pamtosvg/pamtosvg.c
index adf76801..03b0a80f 100644
--- a/converter/other/pamtosvg/pamtosvg.c
+++ b/converter/other/pamtosvg/pamtosvg.c
@@ -47,12 +47,12 @@ readImageToBitmap(FILE *            const ifP,
         unsigned int col;
 
         pnm_scaletuplerow(&pam, row255, tuples[row], 255);
-        
+
         for (col = 0; col < pam.width; ++col) {
             unsigned int plane;
 
             for (plane = 0; plane < pam.depth; ++plane) {
-                unsigned int const bitmapIndex = 
+                unsigned int const bitmapIndex =
                     (row * pam.width + col) * pam.depth + plane;
                 bitmapP->bitmap[bitmapIndex] = row255[col][plane];
             }
@@ -60,7 +60,7 @@ readImageToBitmap(FILE *            const ifP,
     }
     pnm_freepamrow(row255);
     pnm_freepamarray(tuples, &pam);
-    
+
     *bitmapPP = bitmapP;
 }
 
@@ -73,7 +73,7 @@ dotPrinter(float  const percentage,
     int * const currentP = (int *)clientData;
     float const unit     = (float)1.0 / (float)(dot_printer_max_column) ;
     int   const maximum  = (int)(percentage / unit);
-    
+
     while (*currentP < maximum) {
         fputc(dot_printer_char, stderr);
         (*currentP)++;
@@ -120,13 +120,13 @@ struct cmdlineInfo {
 };
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -139,7 +139,7 @@ parseCommandLine(int argc,
     optStruct3 opt;
 
     const char * background_colorOpt;
-  
+
     unsigned int option_def_index;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
@@ -151,7 +151,7 @@ parseCommandLine(int argc,
             &background_colorOpt,        &cmdlineP->backgroundSpec,         0);
     OPTENT3(0, "centerline",          OPT_FLAG,
             NULL,                        &cmdlineP->centerline,             0);
-    OPTENT3(0, "corner-always-threshold", OPT_FLOAT, 
+    OPTENT3(0, "corner-always-threshold", OPT_FLOAT,
             &cmdlineP->corner_always_threshold, NULL,                       0);
     OPTENT3(0, "corner-surround",     OPT_UINT,
             &cmdlineP->corner_surround,  NULL,                              0);
@@ -173,11 +173,11 @@ parseCommandLine(int argc,
             NULL,                         &cmdlineP->preserve_width,        0);
     OPTENT3(0, "remove-adjacent-corners", OPT_UINT,
             NULL,                       &cmdlineP->remove_adjacent_corners, 0);
-    OPTENT3(0, "tangent-surround",    OPT_UINT,    
+    OPTENT3(0, "tangent-surround",    OPT_UINT,
             &cmdlineP->tangent_surround, NULL,                              0);
     OPTENT3(0, "report-progress",     OPT_FLAG,
             NULL,                       &cmdlineP->report_progress,         0);
-    OPTENT3(0, "width-weight-factor", OPT_FLOAT,    
+    OPTENT3(0, "width-weight-factor", OPT_FLOAT,
             &cmdlineP->width_weight_factor, NULL,                           0);
 
 
@@ -207,7 +207,7 @@ parseCommandLine(int argc,
         cmdlineP->inputFileName = "-";
     else {
         cmdlineP->inputFileName = argv[1];
-        
+
         if (argc-1 > 1)
             pm_error("Too many arguments (%u).  The only non-option argument "
                      "is the input file name.", argc-1);
@@ -228,7 +228,7 @@ fitSplines(at_bitmap_type *             const bitmapP,
     at_fitting_opts_type * fittingOptsP;
 
     progressStat = 0;
-           
+
     fittingOptsP = at_fitting_opts_new();
 
     fittingOptsP->backgroundSpec           = cmdline.backgroundSpec;
@@ -253,7 +253,7 @@ fitSplines(at_bitmap_type *             const bitmapP,
 
     at_fitting_opts_free(fittingOptsP);
 }
-  
+
 
 
 static void
@@ -267,12 +267,12 @@ writeSplines(at_spline_list_array_type * const splinesP,
 
     outputOptsP = at_output_opts_new();
     outputOptsP->dpi = cmdline.dpi;
-    
+
     at_splines_write(outputWriter, ofP, outputOptsP,
                      splinesP, exceptionHandler, NULL);
 
     at_output_opts_free(outputOptsP);
-}  
+}
 
 
 
@@ -315,13 +315,13 @@ filenameRoot(const char * const filename) {
         rootEnd = strlen(filename);
 
     MALLOCARRAY(buffer, rootEnd - rootStart + 1);
-    
+
     j = 0;
     for (i = rootStart; i < rootEnd; ++i)
         buffer[j++] = filename[i];
 
     buffer[j] = '\0';
-    
+
     return buffer;
 }
 
@@ -342,7 +342,7 @@ openLogFile(FILE **      const logFileP,
         if (inputRootName == NULL)
             pm_error("Can't find the root portion of file name '%s'",
                      inputFileArg);
-    
+
         pm_asprintf(&logfileName, "%s.log", inputRootName);
 
         pm_strfree(inputRootName);
@@ -352,7 +352,7 @@ openLogFile(FILE **      const logFileP,
 
     pm_strfree(logfileName);
 }
-    
+
 
 
 int
@@ -374,7 +374,7 @@ main(int argc, char * argv[]) {
         openLogFile(&log_file, cmdline.inputFileName);
 
     readImageToBitmap(ifP, &bitmapP);
-    
+
     if (cmdline.report_progress) {
         progressReporter = dotPrinter;
         fprintf(stderr, "%-15s", cmdline.inputFileName);
@@ -397,6 +397,9 @@ main(int argc, char * argv[]) {
 
     if (cmdline.report_progress)
         fputs("\n", stderr);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtosvg/pxl-outline.c b/converter/other/pamtosvg/pxl-outline.c
index 19451c04..ff7d6e25 100644
--- a/converter/other/pamtosvg/pxl-outline.c
+++ b/converter/other/pamtosvg/pxl-outline.c
@@ -85,7 +85,7 @@ getBitmapColor(bitmap_type  const bitmap,
     unsigned char * const p = BITMAP_PIXEL(bitmap, row, col);
 
     pixel pix;
-  
+
     if (bitmap.np >= 3)
         PPM_ASSIGN(pix, p[0], p[1], p[2]);
     else
@@ -96,7 +96,6 @@ getBitmapColor(bitmap_type  const bitmap,
 
 
 
-
 static void
 append_outline_pixel(pixel_outline_type * const pixelOutlineP,
                      pm_pixelcoord        const coord) {
@@ -156,6 +155,7 @@ is_outline_edge (edge_type edge, bitmap_type bitmap,
 }
 
 
+
 /* Is this really an edge and is it still unmarked? */
 
 static bool
@@ -173,13 +173,14 @@ is_unmarked_outline_edge(unsigned short row,
 }
 
 
+
 static bool
 is_valid_dir(unsigned int   const row,
              unsigned int   const col,
              direction_type const dir,
              bitmap_type    const bitmap,
              bitmap_type    const marked) {
-  
+
     return(!is_marked_dir(row, col, dir, marked)
            && COMPUTE_DELTA(ROW, dir)+row > 0
            && COMPUTE_DELTA(COL, dir)+col > 0
@@ -233,7 +234,7 @@ next_unmarked_pixel(unsigned int *   const row,
             break;
     } while (1);
 
-    if ((*row != orig_row || *col != orig_col) && 
+    if ((*row != orig_row || *col != orig_col) &&
         (!(is_other_dir_marked(orig_row, orig_col, test_dir, *marked) &&
            is_other_dir_marked(orig_row + COMPUTE_DELTA(ROW, test_dir),
                                orig_col + COMPUTE_DELTA(COL, test_dir),
@@ -297,7 +298,7 @@ findOneCenterline(bitmap_type    const bitmap,
         if (row == originalRow && col == originalCol)
             break;
 
-        
+
         {
             /* Add the new pixel to the output list. */
             pm_pixelcoord pos;
@@ -338,7 +339,7 @@ wrongDirection(unsigned int   const row,
 
 pixel_outline_list_type
 find_centerline_pixels(bitmap_type         const bitmap,
-                       pixel               const bg_color, 
+                       pixel               const bg_color,
                        at_progress_func          notify_progress,
                        void *              const progress_data,
                        at_testcancel_func        test_cancel,
@@ -349,7 +350,7 @@ find_centerline_pixels(bitmap_type         const bitmap,
   signed short row;
   bitmap_type marked = new_bitmap(bitmap.width, bitmap.height);
   unsigned int const max_progress = bitmap.height * bitmap.width;
-    
+
   O_LIST_LENGTH(outline_list) = 0;
   outline_list.data = NULL;
 
@@ -366,9 +367,9 @@ find_centerline_pixels(bitmap_type         const bitmap,
                               ((float) max_progress * (float)3.0),
                               progress_data);
 
-		  if (PPM_EQUAL(getBitmapColor(bitmap, row, col), bg_color)) {
-	          ++col;
-			  continue;
+                  if (PPM_EQUAL(getBitmapColor(bitmap, row, col), bg_color)) {
+                  ++col;
+                          continue;
           }
 
           dir = EAST;
@@ -380,8 +381,8 @@ find_centerline_pixels(bitmap_type         const bitmap,
                   if (wrongDirection(row, col, dir, bitmap, marked)) {
                       dir = SOUTHWEST;
                       if (wrongDirection(row, col, dir, bitmap, marked)) {
-						  ++col;
-						  continue;
+                                                  ++col;
+                                                  continue;
                       }
                   }
               }
@@ -454,8 +455,8 @@ find_centerline_pixels(bitmap_type         const bitmap,
                       free(partial_outline.data);
               } else
                   ++col;
-          }        
-            
+          }
+
           /* Outside outlines will start at a top edge, and move
              counterclockwise, and inside outlines will start at a
              bottom edge, and move clockwise.  This happens because of
@@ -493,6 +494,7 @@ append_pixel_outline (pixel_outline_list_type *outline_list,
 }
 
 
+
 /* Free the list of outline lists. */
 
 void
@@ -517,6 +519,7 @@ free_pixel_outline_list (pixel_outline_list_type *outline_list)
 }
 
 
+
 /* Return an empty list of pixels.  */
 
 
@@ -532,6 +535,8 @@ new_pixel_outline (void)
   return pixel_outline;
 }
 
+
+
 static void
 free_pixel_outline (pixel_outline_type * outline)
 {
@@ -543,6 +548,8 @@ free_pixel_outline (pixel_outline_type * outline)
     }
 }
 
+
+
 /* Concatenate two pixel lists. The two lists are assumed to have the
    same starting pixel and to proceed in opposite directions therefrom. */
 
@@ -569,6 +576,7 @@ concat_pixel_outline(pixel_outline_type *o1, const pixel_outline_type *o2)
 }
 
 
+
 /* If EDGE is not already marked, we mark it; otherwise, it's a fatal error.
    The position ROW and COL should be inside the bitmap MARKED. EDGE can be
    NO_EDGE. */
@@ -581,6 +589,7 @@ mark_edge (edge_type edge, unsigned short row,
 }
 
 
+
 /* Mark the direction of the pixel ROW/COL in MARKED. */
 
 static void
@@ -590,6 +599,7 @@ mark_dir(unsigned short row, unsigned short col, direction_type dir, bitmap_type
 }
 
 
+
 /* Test if the direction of pixel at ROW/COL in MARKED is marked. */
 
 static bool
@@ -599,6 +609,7 @@ is_marked_dir(unsigned short row, unsigned short col, direction_type dir, bitmap
 }
 
 
+
 static bool
 is_other_dir_marked(unsigned short row, unsigned short col, direction_type dir, bitmap_type marked)
 {
@@ -606,6 +617,7 @@ is_other_dir_marked(unsigned short row, unsigned short col, direction_type dir,
 }
 
 
+
 /* Return the number of pixels adjacent to pixel ROW/COL that are black. */
 
 static unsigned
@@ -615,18 +627,19 @@ num_neighbors(unsigned short row, unsigned short col, bitmap_type bitmap)
     pixel color = getBitmapColor(bitmap, row, col);
     for (dir = NORTH; dir <= NORTHEAST; dir++)
     {
-	int delta_r = COMPUTE_DELTA(ROW, dir);
-	int delta_c = COMPUTE_DELTA(COL, dir);
-	unsigned int test_row = row + delta_r;
-	unsigned int test_col = col + delta_c;
-	if (BITMAP_VALID_PIXEL(bitmap, test_row, test_col)
-	    && PPM_EQUAL(getBitmapColor(bitmap, test_row, test_col), color))
-	    ++count;
+        int delta_r = COMPUTE_DELTA(ROW, dir);
+        int delta_c = COMPUTE_DELTA(COL, dir);
+        unsigned int test_row = row + delta_r;
+        unsigned int test_col = col + delta_c;
+        if (BITMAP_VALID_PIXEL(bitmap, test_row, test_col)
+            && PPM_EQUAL(getBitmapColor(bitmap, test_row, test_col), color))
+            ++count;
     }
     return count;
 }
 
 
+
 /* Test if the edge EDGE at ROW/COL in MARKED is marked.  */
 
 static bool
@@ -679,7 +692,7 @@ nextClockwisePointTop(bitmap_type         const bitmap,
         posP->col = *col + 1;
         posP->row = bitmap.height - *row;
         return;
-    } 
+    }
 
     RETURN_IF_FATAL();
 
@@ -714,7 +727,7 @@ nextClockwisePointRight(bitmap_type         const bitmap,
          is_outline_edge(RIGHT, bitmap, *row-1, *col, color, exp))) {
 
          /* NORTH */
-        
+
         *edge = RIGHT;
         --*row;
         posP->col = *col+1;
@@ -723,7 +736,7 @@ nextClockwisePointRight(bitmap_type         const bitmap,
     }
 
     RETURN_IF_FATAL();
-    
+
     if ((*col+1 < marked.width && *row >= 1 &&
          !is_marked_edge(BOTTOM, *row-1, *col+1, marked) &&
          is_outline_edge(BOTTOM, bitmap, *row-1, *col+1,
@@ -740,7 +753,7 @@ nextClockwisePointRight(bitmap_type         const bitmap,
         posP->col = *col + 1;
         posP->row = bitmap.height - *row - 1;
         return;
-    } 
+    }
 
     RETURN_IF_FATAL();
 
@@ -769,7 +782,7 @@ nextClockwisePointBottom(bitmap_type         const bitmap,
                          bitmap_type         const marked,
                          at_exception_type * const exp,
                          pm_pixelcoord *     const posP) {
-    
+
     if ((*col+1 < marked.width &&
          !is_marked_edge(BOTTOM, *row, *col+1, marked) &&
          is_outline_edge(BOTTOM, bitmap, *row, *col+1, color, exp))) {
@@ -853,16 +866,16 @@ nextClockwisePointLeft(bitmap_type         const bitmap,
           is_marked_edge(TOP, *row+1, *col, marked)) &&
         !(is_marked_edge(BOTTOM, *row, *col-1, marked) &&
           is_marked_edge(LEFT, *row+1, *col, marked))) {
-        
+
         /* SOUTHWEST */
-        
+
         *edge = TOP;
         --*col;
         ++*row;
         posP->col = *col;
         posP->row = bitmap.height - *row;
         return;
-    } 
+    }
 
     RETURN_IF_FATAL();
 
@@ -889,21 +902,21 @@ nextClockwisePoint(bitmap_type         const bitmap,
                    bitmap_type         const marked,
                    at_exception_type * const exp,
                    pm_pixelcoord *     const posP) {
-    
+
     switch (*edge) {
     case TOP:
         nextClockwisePointTop(  bitmap, edge, row, col, color,
                                 marked, exp, posP);
         break;
-    case RIGHT: 
+    case RIGHT:
         nextClockwisePointRight(bitmap, edge, row, col, color,
                                 marked, exp, posP);
         break;
-    case BOTTOM: 
+    case BOTTOM:
         nextClockwisePointBottom(bitmap, edge, row, col, color,
                                  marked, exp, posP);
         break;
-    case LEFT: 
+    case LEFT:
         nextClockwisePointLeft(  bitmap, edge, row, col, color,
                                  marked, exp, posP);
         break;
@@ -952,7 +965,7 @@ nextCcwPointTop(bitmap_type         const bitmap,
     }
 
     RETURN_IF_FATAL();
-    
+
     if ((*col >= 1 && *row >= 1 &&
          !is_marked_edge(RIGHT, *row-1, *col-1, marked) &&
          is_outline_edge(RIGHT, bitmap, *row-1, *col-1, color, exp))) {
@@ -965,7 +978,7 @@ nextCcwPointTop(bitmap_type         const bitmap,
         posP->col = *col + 1;
         posP->row = bitmap.height - *row;
         return;
-    } 
+    }
 
     RETURN_IF_FATAL();
 
@@ -1000,7 +1013,7 @@ nextCcwPointRight(bitmap_type         const bitmap,
          is_outline_edge(RIGHT, bitmap, *row-1, *col, color, exp))) {
 
         /* NORTH */
-        
+
         *edge = RIGHT;
         --*row;
         posP->col = *col + 1;
@@ -1082,7 +1095,7 @@ nextCcwPointBottom(bitmap_type         const bitmap,
     }
 
     RETURN_IF_FATAL();
-    
+
     *edge = NO_EDGE;
 }
 
@@ -1124,7 +1137,7 @@ nextCcwPointLeft(bitmap_type         const bitmap,
     }
 
     RETURN_IF_FATAL();
-    
+
     if ((*col >= 1 && *row + 1 < marked.height &&
          !is_marked_edge(TOP, *row+1, *col-1, marked) &&
          is_outline_edge(TOP, bitmap, *row+1, *col-1, color, exp))) {
@@ -1144,6 +1157,8 @@ nextCcwPointLeft(bitmap_type         const bitmap,
     *edge = NO_EDGE;
 }
 
+
+
 static void
 nextCounterClockwisePoint(bitmap_type         const bitmap,
                           edge_type *         const edge,
@@ -1158,18 +1173,18 @@ nextCounterClockwisePoint(bitmap_type         const bitmap,
     case TOP:
         nextCcwPointTop(   bitmap, edge, row, col, color, marked, exp, posP);
         break;
-    case RIGHT: 
+    case RIGHT:
         nextCcwPointRight( bitmap, edge, row, col, color, marked, exp, posP);
         break;
-    case BOTTOM: 
+    case BOTTOM:
         nextCcwPointBottom(bitmap, edge, row, col, color, marked, exp, posP);
         break;
-    case LEFT: 
+    case LEFT:
         nextCcwPointLeft(  bitmap, edge, row, col, color, marked, exp, posP);
         break;
     case NO_EDGE:
         break;
-    default: 
+    default:
         *edge = NO_EDGE;
         break;
     }
@@ -1218,7 +1233,7 @@ find_one_outline(bitmap_type         const bitmap,
 
     pixel_outline_type outline;
     pm_pixelcoord pos;
-    
+
     outline = new_pixel_outline();
     outline.color = getBitmapColor(bitmap, originalRow, originalCol);
 
@@ -1228,7 +1243,7 @@ find_one_outline(bitmap_type         const bitmap,
 
     /* Set initial position */
     pos.col = col + ((edge == RIGHT) || (edge == BOTTOM) ? 1 : 0);
-    pos.row = bitmap.height - row - 1 + 
+    pos.row = bitmap.height - row - 1 +
         (edge == TOP || edge == RIGHT ? 1 : 0);
 
     do {
@@ -1237,7 +1252,7 @@ find_one_outline(bitmap_type         const bitmap,
             LOG2(" (%d,%d)", pos.col, pos.row);
             append_outline_pixel(&outline, pos);
         }
-        
+
         mark_edge(edge, row, col, marked);
         nextPoint(bitmap, &edge, &row, &col, &pos, outline.color, clockwise,
                   *marked, exp);
@@ -1255,7 +1270,7 @@ find_one_outline(bitmap_type         const bitmap,
 pixel_outline_list_type
 find_outline_pixels(bitmap_type         const bitmap,
                     bool                const bg_spec,
-                    pixel               const bg_color, 
+                    pixel               const bg_color,
                     at_progress_func          notify_progress,
                     void *              const progress_data,
                     at_testcancel_func        test_cancel,
@@ -1273,16 +1288,16 @@ find_outline_pixels(bitmap_type         const bitmap,
        to the list, marking the edges in it as we go.
     */
     unsigned int const max_progress = bitmap.height * bitmap.width;
-    
+
     pixel_outline_list_type outline_list;
     unsigned int row;
     bitmap_type marked;
-    
+
     marked = new_bitmap (bitmap.width, bitmap.height);
-    
+
     O_LIST_LENGTH(outline_list) = 0;
     outline_list.data = NULL;
-    
+
     for (row = 0; row < bitmap.height; ++row) {
         unsigned int col;
         for (col = 0; col < bitmap.width; ++col) {
@@ -1303,21 +1318,21 @@ find_outline_pixels(bitmap_type         const bitmap,
                 is_unmarked_outline_edge(row, col, TOP,
                                          bitmap, marked, color, exp)) {
                 pixel_outline_type outline;
-                
+
                 CHECK_FATAL();   /* FREE(DONE) outline_list */
-                
+
                 LOG1("#%u: (counterclockwise)", O_LIST_LENGTH(outline_list));
-                
+
                 outline = find_one_outline(bitmap, TOP, row, col, &marked,
                                            false, false, exp);
                 CHECK_FATAL();    /* FREE(DONE) outline_list */
-                
+
                 O_CLOCKWISE(outline) = false;
                 append_pixel_outline(&outline_list, outline);
-                
+
                 LOG1(" [%u].\n", O_LENGTH (outline));
             } else
-                CHECK_FATAL ();	/* FREE(DONE) outline_list */
+                CHECK_FATAL (); /* FREE(DONE) outline_list */
 
             /* A valid edge can be BOTTOM for an inside outline.
                Inside outlines are traced clockwise.
@@ -1328,20 +1343,20 @@ find_outline_pixels(bitmap_type         const bitmap,
                     is_unmarked_outline_edge(row-1, col, BOTTOM,
                                              bitmap, marked, colorAbove,exp)) {
                     CHECK_FATAL(); /* FREE(DONE) outline_list */
-                    
+
                     /* This lines are for debugging only:*/
                     if (is_background) {
                         pixel_outline_type outline;
-                    
+
                         LOG1("#%u: (clockwise)", O_LIST_LENGTH(outline_list));
-                        
+
                         outline = find_one_outline(bitmap, BOTTOM, row-1, col,
                                                    &marked, true, false, exp);
                         CHECK_FATAL(); /* FREE(DONE) outline_list */
-                        
+
                         O_CLOCKWISE(outline) = true;
                         append_pixel_outline(&outline_list, outline);
-                        
+
                         LOG1(" [%u].\n", O_LENGTH(outline));
                     } else {
                         find_one_outline(bitmap, BOTTOM, row-1, col,
@@ -1349,7 +1364,7 @@ find_outline_pixels(bitmap_type         const bitmap,
                         CHECK_FATAL(); /* FREE(DONE) outline_list */
                     }
                 } else
-                    CHECK_FATAL();	/* FREE(DONE) outline_list */
+                    CHECK_FATAL();      /* FREE(DONE) outline_list */
             }
             if (test_cancel && test_cancel(testcancel_data)) {
                 free_pixel_outline_list(&outline_list);
@@ -1366,3 +1381,5 @@ find_outline_pixels(bitmap_type         const bitmap,
     return outline_list;
 }
 
+
+
diff --git a/converter/other/pamtosvg/pxl-outline.h b/converter/other/pamtosvg/pxl-outline.h
index e37ccaf6..64e312cc 100644
--- a/converter/other/pamtosvg/pxl-outline.h
+++ b/converter/other/pamtosvg/pxl-outline.h
@@ -34,8 +34,8 @@ typedef struct
    after the last is the first, and the previous coordinate before the
    first is the last.  */
 #define O_NEXT(p_o, n) (((n) + 1) % O_LENGTH (p_o))
-#define O_PREV(p_o, n) ((n) == 0				\
-                         ? O_LENGTH (p_o) - 1			\
+#define O_PREV(p_o, n) ((n) == 0                                \
+                         ? O_LENGTH (p_o) - 1                   \
                          : (n) - 1)
 
 /* And the character turns into a list of such lists.  */
@@ -55,7 +55,7 @@ typedef struct
 pixel_outline_list_type
 find_outline_pixels (bitmap_type         const type,
                      bool                const bg_spec,
-                     pixel               const bg_color, 
+                     pixel               const bg_color,
                      at_progress_func          notify_progress,
                      void *              const progress_data,
                      at_testcancel_func        test_cancel,
@@ -65,7 +65,7 @@ find_outline_pixels (bitmap_type         const type,
 /* Find all pixels on the center line of the character C.  */
 pixel_outline_list_type
 find_centerline_pixels (bitmap_type         const type,
-                        pixel               const bg_color, 
+                        pixel               const bg_color,
                         at_progress_func          notify_progress,
                         void *              const progress_data,
                         at_testcancel_func        test_cancel,
diff --git a/converter/other/pamtosvg/spline.c b/converter/other/pamtosvg/spline.c
index 6d867131..a62ce895 100644
--- a/converter/other/pamtosvg/spline.c
+++ b/converter/other/pamtosvg/spline.c
@@ -30,6 +30,7 @@ print_spline (FILE *f, spline_type s)
 }
 
 
+
 /* Evaluate the spline S at a given T value.  This is an implementation
    of de Casteljau's algorithm.  See Schneider's thesis, p.37.
    The variable names are taken from there.  */
@@ -64,6 +65,7 @@ evaluate_spline (spline_type s, float t)
 }
 
 
+
 /* Return a new, empty, spline list.  */
 
 spline_list_type *
@@ -76,6 +78,8 @@ new_spline_list (void)
   return answer;
 }
 
+
+
 spline_list_type
 empty_spline_list (void)
 {
@@ -85,6 +89,8 @@ empty_spline_list (void)
   return answer;
 }
 
+
+
 /* Return a new spline list with SPLINE as the first element.  */
 
 spline_list_type *
@@ -101,6 +107,7 @@ new_spline_list_with_spline (spline_type spline)
 }
 
 
+
 /* Free the storage in a spline list.  We don't have to free the
    elements, since they are arrays in automatic storage.  And we don't
    want to free the list if it was empty.  */
@@ -115,6 +122,7 @@ free_spline_list(spline_list_type spline_list) {
 }
 
 
+
 /* Append the spline S to the list SPLINE_LIST.  */
 
 void
@@ -128,6 +136,7 @@ append_spline (spline_list_type *l, spline_type s)
 }
 
 
+
 /* Tack the elements in the list S2 onto the end of S1.
    S2 is not changed.  */
 
@@ -149,6 +158,7 @@ concat_spline_lists (spline_list_type *s1, spline_list_type s2)
 }
 
 
+
 /* Return a new, empty, spline list array.  */
 
 spline_list_array_type
@@ -163,6 +173,7 @@ new_spline_list_array (void)
 }
 
 
+
 /* Free the storage in a spline list array.  We don't
    want to free the list if it is empty.  */
 void
@@ -182,6 +193,7 @@ free_spline_list_array (spline_list_array_type *spline_list_array)
 }
 
 
+
 /* Append the spline S to the list SPLINE_LIST_ARRAY.  */
 
 void
@@ -192,3 +204,6 @@ append_spline_list (spline_list_array_type *l, spline_list_type s)
                       SPLINE_LIST_ARRAY_LENGTH(*l));
   LAST_SPLINE_LIST_ARRAY_ELT (*l) = s;
 }
+
+
+
diff --git a/converter/other/pamtosvg/thin-image.c b/converter/other/pamtosvg/thin-image.c
index 364f67cc..ad15247f 100644
--- a/converter/other/pamtosvg/thin-image.c
+++ b/converter/other/pamtosvg/thin-image.c
@@ -27,78 +27,78 @@
 #include "logreport.h"
 #include "message.h"
 #include "bitmap.h"
- 
+
 #define PIXEL_SET(p, new)  ((void)memcpy((p), (new), sizeof(Pixel)))
 #define PIXEL_EQUAL(p1, p2) \
     ((p1)[0] == (p2)[0] && (p1)[1] == (p2)[1] && (p1)[2] == (p2)[2])
 
- 
-typedef unsigned char Pixel[3];  /* RGB pixel data type */ 
-
- 
-void thin3(bitmap_type *image, Pixel colour); 
-void thin1(bitmap_type *image, unsigned char colour); 
- 
- 
-/* -------------------------------- ThinImage - Thin binary image. --------------------------- * 
- *                                                            
- *    Description:                                                    
- *        Thins the supplied binary image using Rosenfeld's parallel   
- *        thinning algorithm.                                         
- *                                                                     
- *    On Entry:                                                        
- *        image = Image to thin.                                       
- *                                                                     
- * -------------------------------------------------------------------------------------------- */ 
- 
- 
-/* Direction masks:                  */ 
-/*   N     S     W        E            */ 
-static        unsigned int     masks[]         = { 0200, 0002, 0040, 0010 }; 
- 
-/*    True if pixel neighbor map indicates the pixel is 8-simple and  */ 
-/*    not an end point and thus can be deleted.  The neighborhood     */ 
-/*    map is defined as an integer of bits abcdefghi with a non-zero  */ 
-/*    bit representing a non-zero pixel.  The bit assignment for the  */ 
-/*    neighborhood is:                                                */ 
-/*                                                                    */ 
-/*                            a b c                                   */ 
-/*                            d e f                                   */ 
-/*                            g h i                                   */ 
- 
-static        unsigned char   todelete[512] = { 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 
-              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 
+
+typedef unsigned char Pixel[3];  /* RGB pixel data type */
+
+
+void thin3(bitmap_type *image, Pixel colour);
+void thin1(bitmap_type *image, unsigned char colour);
+
+
+/* -------------------------------- ThinImage - Thin binary image. --------------------------- *
+ *
+ *    Description:
+ *        Thins the supplied binary image using Rosenfeld's parallel
+ *        thinning algorithm.
+ *
+ *    On Entry:
+ *        image = Image to thin.
+ *
+ * -------------------------------------------------------------------------------------------- */
+
+
+/* Direction masks:                  */
+/*   N     S     W        E            */
+static        unsigned int     masks[]         = { 0200, 0002, 0040, 0010 };
+
+/*    True if pixel neighbor map indicates the pixel is 8-simple and  */
+/*    not an end point and thus can be deleted.  The neighborhood     */
+/*    map is defined as an integer of bits abcdefghi with a non-zero  */
+/*    bit representing a non-zero pixel.  The bit assignment for the  */
+/*    neighborhood is:                                                */
+/*                                                                    */
+/*                            a b c                                   */
+/*                            d e f                                   */
+/*                            g h i                                   */
+
+static        unsigned char   todelete[512] = {
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
+              0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+              1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
 
 static pixel background;
 
@@ -106,268 +106,273 @@ static pixel background;
 void
 thin_image(bitmap_type *image, bool bgSpec, pixel bg,
            at_exception_type * exp)
-{ 
-    /* This is nasty as we need to call thin once for each  
-     * colour in the image the way I do this is to keep a second  
-     * copy of the bitmap and to use this to keep 
-     * track of which colours have not yet been processed, 
-     * trades time for pathological case memory.....*/ 
+{
+    /* This is nasty as we need to call thin once for each
+     * colour in the image the way I do this is to keep a second
+     * copy of the bitmap and to use this to keep
+     * track of which colours have not yet been processed,
+     * trades time for pathological case memory.....*/
     long m, n, num_pixels;
-    bitmap_type bm; 
+    bitmap_type bm;
     unsigned int const spp = image->np;
-	unsigned int const width = image->width;
-	unsigned int const height = image->height;
+        unsigned int const width = image->width;
+        unsigned int const height = image->height;
 
     if (bgSpec)
         background = bg;
-    else 
+    else
         PPM_ASSIGN(background, 255, 255, 255);
 
     /* Clone the image */
     bm.height = image->height;
     bm.width = image->width;
     bm.np = image->np;
-    MALLOCARRAY(bm.bitmap, height * width * spp); 
+    MALLOCARRAY(bm.bitmap, height * width * spp);
     if (bm.bitmap == NULL)
         pm_error("Unable to get memory for thin image bitmap clone");
-    memcpy(bm.bitmap, image->bitmap, height * width * spp); 
+    memcpy(bm.bitmap, image->bitmap, height * width * spp);
 
     num_pixels = height * width;
     switch (spp)
     {
-	case 3:
-	{
-	    Pixel *ptr = (Pixel*)bm.bitmap;
-	    Pixel bg_color;
-	    bg_color[0] = PPM_GETR(background);
-	    bg_color[1] = PPM_GETG(background);
-	    bg_color[2] = PPM_GETB(background);
-
-	    for (n = num_pixels - 1; n >= 0L; --n)
-	    {
-		Pixel p;
-
-		PIXEL_SET(p, ptr[n]);
-		if (!PIXEL_EQUAL(p, bg_color))
-		{ 
-		    /* we have a new colour in the image */ 
-		    LOG3("Thinning colour (%x, %x, %x)\n", p[0], p[1], p[2]);
-		    for (m = n - 1; m >= 0L; --m)
-		    {
-			if (PIXEL_EQUAL(ptr[m], p))
-			    PIXEL_SET(ptr[m], bg_color);
-		    }
-		    thin3(image, p); 
-		} 
-	    } 
-	    break;
-	} 
-
-	case 1:
-	{
-	    unsigned char * const ptr = bm.bitmap;
-	    unsigned char bg_color;
-
-	    if (PPM_ISGRAY(background))
+        case 3:
+        {
+            Pixel *ptr = (Pixel*)bm.bitmap;
+            Pixel bg_color;
+            bg_color[0] = PPM_GETR(background);
+            bg_color[1] = PPM_GETG(background);
+            bg_color[2] = PPM_GETB(background);
+
+            for (n = num_pixels - 1; n >= 0L; --n)
+            {
+                Pixel p;
+
+                PIXEL_SET(p, ptr[n]);
+                if (!PIXEL_EQUAL(p, bg_color))
+                {
+                    /* we have a new colour in the image */
+                    LOG3("Thinning colour (%x, %x, %x)\n", p[0], p[1], p[2]);
+                    for (m = n - 1; m >= 0L; --m)
+                    {
+                        if (PIXEL_EQUAL(ptr[m], p))
+                            PIXEL_SET(ptr[m], bg_color);
+                    }
+                    thin3(image, p);
+                }
+            }
+            break;
+        }
+
+        case 1:
+        {
+            unsigned char * const ptr = bm.bitmap;
+            unsigned char bg_color;
+
+            if (PPM_ISGRAY(background))
             bg_color = PPM_GETR(background);
-	    else
+            else
             bg_color = ppm_luminosity(background);
 
-	    for (n = num_pixels - 1; n >= 0L; --n)
-	    {
-		unsigned char c = ptr[n];
-		if (c != bg_color)
-		{ 
-		    LOG1 ("Thinning colour %x\n", c);
-		    for (m = n - 1; m >= 0L; --m)
-			if (ptr[m] == c) ptr[m] = bg_color;
-		    thin1(image, c); 
-		} 
-	    } 
-	    break;
-	} 
-
-	default:
-	{
-	  LOG1 ("thin_image: Don't know how to interpret %u-plane images", spp);
-	  at_exception_fatal(exp, "thin_image: wrong plane images are passed");
-	  goto cleanup;
-	}
+            for (n = num_pixels - 1; n >= 0L; --n)
+            {
+                unsigned char c = ptr[n];
+                if (c != bg_color)
+                {
+                    LOG1 ("Thinning colour %x\n", c);
+                    for (m = n - 1; m >= 0L; --m)
+                        if (ptr[m] == c) ptr[m] = bg_color;
+                    thin1(image, c);
+                }
+            }
+            break;
+        }
+
+        default:
+        {
+          LOG1 ("thin_image: Don't know how to interpret %u-plane images", spp);
+          at_exception_fatal(exp, "thin_image: wrong plane images are passed");
+          goto cleanup;
+        }
     }
  cleanup:
-    free (bm.bitmap); 
-} 
+    free (bm.bitmap);
+}
+
 
- 
-void thin3(bitmap_type *image, Pixel colour) 
-{ 
+
+void thin3(bitmap_type *image, Pixel colour)
+{
       Pixel *ptr, *y_ptr, *y1_ptr;
       Pixel bg_color;
-      unsigned int    xsize, ysize;   /* Image resolution             */ 
-      unsigned int    x, y;           /* Pixel location               */ 
-      unsigned int    i;              /* Pass index           */ 
-      unsigned int    pc      = 0;    /* Pass count           */ 
-      unsigned int    count   = 1;    /* Deleted pixel count          */ 
-      unsigned int    p, q;           /* Neighborhood maps of adjacent*/ 
-                                      /* cells                        */ 
-      unsigned char   *qb;            /* Neighborhood maps of previous*/ 
-                                      /* scanline                     */ 
-      unsigned int    m;              /* Deletion direction mask      */ 
- 
+      unsigned int    xsize, ysize;   /* Image resolution             */
+      unsigned int    x, y;           /* Pixel location               */
+      unsigned int    i;              /* Pass index           */
+      unsigned int    pc      = 0;    /* Pass count           */
+      unsigned int    count   = 1;    /* Deleted pixel count          */
+      unsigned int    p, q;           /* Neighborhood maps of adjacent*/
+                                      /* cells                        */
+      unsigned char   *qb;            /* Neighborhood maps of previous*/
+                                      /* scanline                     */
+      unsigned int    m;              /* Deletion direction mask      */
+
       bg_color[0] = PPM_GETR(background);
       bg_color[1] = PPM_GETG(background);
       bg_color[2] = PPM_GETB(background);
 
-      LOG (" Thinning image.....\n "); 
+      LOG (" Thinning image.....\n ");
       xsize = image->width;
       ysize = image->height;
-      MALLOCARRAY_NOFAIL(qb, xsize); 
-      qb[xsize-1] = 0;                /* Used for lower-right pixel   */ 
+      MALLOCARRAY_NOFAIL(qb, xsize);
+      qb[xsize-1] = 0;                /* Used for lower-right pixel   */
       ptr = (Pixel*)image->bitmap;
- 
-      while ( count ) {               /* Scan image while deletions   */ 
-          pc++; 
-          count = 0; 
- 
-          for ( i = 0 ; i < 4 ; i++ ) { 
- 
-              m = masks[i]; 
- 
-              /* Build initial previous scan buffer.                  */ 
-              p = PIXEL_EQUAL(ptr[0], colour); 
-              for ( x = 0 ; x < xsize-1 ; x++ ) 
+
+      while ( count ) {               /* Scan image while deletions   */
+          pc++;
+          count = 0;
+
+          for ( i = 0 ; i < 4 ; i++ ) {
+
+              m = masks[i];
+
+              /* Build initial previous scan buffer.                  */
+              p = PIXEL_EQUAL(ptr[0], colour);
+              for ( x = 0 ; x < xsize-1 ; x++ )
                   qb[x] = (unsigned char) (p = ((p<<1)&0006) | (unsigned int) PIXEL_EQUAL(ptr[x+1],
-				   colour)); 
- 
-              /* Scan image for pixel deletion candidates.            */ 
-	      y_ptr = ptr; y1_ptr = ptr + xsize; 
+                                   colour));
+
+              /* Scan image for pixel deletion candidates.            */
+              y_ptr = ptr; y1_ptr = ptr + xsize;
               for (y = 0; y < ysize - 1; y++, y_ptr += xsize, y1_ptr += xsize)
-	      { 
-                  q = qb[0]; 
-                  p = ((q<<2)&0330) | (unsigned int) PIXEL_EQUAL(y1_ptr[0], colour); 
- 
-                  for ( x = 0 ; x < xsize-1 ; x++ ) { 
-                      q = qb[x]; 
-                      p = ((p<<1)&0666) | ((q<<3)&0110) | 
-			  (unsigned int) PIXEL_EQUAL(y1_ptr[x+1], colour);
-                      qb[x] = (unsigned char) p; 
-                      if ((i != 2 || x != 0) && ((p&m) == 0) && todelete[p] ) { 
-                          count++;  /* delete the pixel */ 
-			  PIXEL_SET(y_ptr[x], bg_color);
-                      } 
-                  } 
- 
-                  /* Process right edge pixel.                        */ 
-                  p = (p<<1)&0666; 
-                  if  (i != 3 && (p&m) == 0 && todelete[p] ) { 
-                      count++; 
-		      PIXEL_SET(y_ptr[xsize-1], bg_color);
-                  } 
-              } 
- 
-	      if (i != 1)
-	      {
-            /* Process bottom scan line.                            */ 
-            q = qb[0]; 
-            p = ((q<<2)&0330); 
+              {
+                  q = qb[0];
+                  p = ((q<<2)&0330) | (unsigned int) PIXEL_EQUAL(y1_ptr[0], colour);
+
+                  for ( x = 0 ; x < xsize-1 ; x++ ) {
+                      q = qb[x];
+                      p = ((p<<1)&0666) | ((q<<3)&0110) |
+                          (unsigned int) PIXEL_EQUAL(y1_ptr[x+1], colour);
+                      qb[x] = (unsigned char) p;
+                      if ((i != 2 || x != 0) && ((p&m) == 0) && todelete[p] ) {
+                          count++;  /* delete the pixel */
+                          PIXEL_SET(y_ptr[x], bg_color);
+                      }
+                  }
+
+                  /* Process right edge pixel.                        */
+                  p = (p<<1)&0666;
+                  if  (i != 3 && (p&m) == 0 && todelete[p] ) {
+                      count++;
+                      PIXEL_SET(y_ptr[xsize-1], bg_color);
+                  }
+              }
+
+              if (i != 1)
+              {
+            /* Process bottom scan line.                            */
+            q = qb[0];
+            p = ((q<<2)&0330);
 
             y_ptr = ptr + xsize * (ysize - 1);
-            for ( x = 0 ; x < xsize ; x++ ) { 
-              q = qb[x]; 
-              p = ((p<<1)&0666) | ((q<<3)&0110); 
-              if ((i != 2 || x != 0) && (p&m) == 0 && todelete[p]) { 
-                count++; 
+            for ( x = 0 ; x < xsize ; x++ ) {
+              q = qb[x];
+              p = ((p<<1)&0666) | ((q<<3)&0110);
+              if ((i != 2 || x != 0) && (p&m) == 0 && todelete[p]) {
+                count++;
                 PIXEL_SET(y_ptr[x], bg_color);
-		      } 
-            } 
+                      }
+            }
            }
-          } 
-          LOG2 ("ThinImage: pass %d, %d pixels deleted\n", pc, count); 
-      } 
-      free (qb); 
-} 
-
- 
-void thin1(bitmap_type *image, unsigned char colour) 
-{ 
+          }
+          LOG2 ("ThinImage: pass %d, %d pixels deleted\n", pc, count);
+      }
+      free (qb);
+}
+
+
+
+void thin1(bitmap_type *image, unsigned char colour)
+{
       unsigned char *ptr, *y_ptr, *y1_ptr;
       unsigned char bg_color;
-      unsigned int    xsize, ysize;   /* Image resolution             */ 
-      unsigned int    x, y;           /* Pixel location               */ 
-      unsigned int    i;              /* Pass index           */ 
-      unsigned int    pc      = 0;    /* Pass count           */ 
-      unsigned int    count   = 1;    /* Deleted pixel count          */ 
-      unsigned int    p, q;           /* Neighborhood maps of adjacent*/ 
-                                      /* cells                        */ 
-      unsigned char   *qb;            /* Neighborhood maps of previous*/ 
-                                      /* scanline                     */ 
-      unsigned int    m;              /* Deletion direction mask      */ 
+      unsigned int    xsize, ysize;   /* Image resolution             */
+      unsigned int    x, y;           /* Pixel location               */
+      unsigned int    i;              /* Pass index           */
+      unsigned int    pc      = 0;    /* Pass count           */
+      unsigned int    count   = 1;    /* Deleted pixel count          */
+      unsigned int    p, q;           /* Neighborhood maps of adjacent*/
+                                      /* cells                        */
+      unsigned char   *qb;            /* Neighborhood maps of previous*/
+                                      /* scanline                     */
+      unsigned int    m;              /* Deletion direction mask      */
 
       if (PPM_ISGRAY(background))
           bg_color = PPM_GETR(background);
       else
           bg_color = ppm_luminosity(background);
 
-      LOG (" Thinning image.....\n "); 
+      LOG (" Thinning image.....\n ");
       xsize = image->width;
       ysize = image->height;
-      MALLOCARRAY_NOFAIL(qb, xsize); 
-      qb[xsize-1] = 0;                /* Used for lower-right pixel   */ 
+      MALLOCARRAY_NOFAIL(qb, xsize);
+      qb[xsize-1] = 0;                /* Used for lower-right pixel   */
       ptr = image->bitmap;
- 
-      while ( count ) {               /* Scan image while deletions   */ 
-          pc++; 
-          count = 0; 
- 
-          for ( i = 0 ; i < 4 ; i++ ) { 
- 
-              m = masks[i]; 
- 
-              /* Build initial previous scan buffer.                  */ 
-              p = (ptr[0] == colour); 
-              for ( x = 0 ; x < xsize-1 ; x++ ) 
-                  qb[x] = (unsigned char) (p = ((p<<1)&0006) | (unsigned int)(ptr[x+1] == colour)); 
- 
-              /* Scan image for pixel deletion candidates.            */ 
-	      y_ptr = ptr; y1_ptr = ptr + xsize; 
+
+      while ( count ) {               /* Scan image while deletions   */
+          pc++;
+          count = 0;
+
+          for ( i = 0 ; i < 4 ; i++ ) {
+
+              m = masks[i];
+
+              /* Build initial previous scan buffer.                  */
+              p = (ptr[0] == colour);
+              for ( x = 0 ; x < xsize-1 ; x++ )
+                  qb[x] = (unsigned char) (p = ((p<<1)&0006) | (unsigned int)(ptr[x+1] == colour));
+
+              /* Scan image for pixel deletion candidates.            */
+              y_ptr = ptr; y1_ptr = ptr + xsize;
               for (y = 0; y < ysize - 1; y++, y_ptr += xsize, y1_ptr += xsize)
-	      { 
-                  q = qb[0]; 
-                  p = ((q<<2)&0330) | (y1_ptr[0] == colour); 
- 
-                  for ( x = 0 ; x < xsize-1 ; x++ ) { 
-                      q = qb[x]; 
-                      p = ((p<<1)&0666) | ((q<<3)&0110) | (unsigned int) (y1_ptr[x+1]==colour); 
-                      qb[x] = (unsigned char) p; 
-                      if  ( ((p&m) == 0) && todelete[p] ) { 
-                          count++; 
-			  y_ptr[x] = bg_color;  /* delete the pixel */ 
-                      } 
-                  } 
- 
-                  /* Process right edge pixel.                        */ 
-                  p = (p<<1)&0666; 
-                  if  ( (p&m) == 0 && todelete[p] ) { 
-                      count++; 
+              {
+                  q = qb[0];
+                  p = ((q<<2)&0330) | (y1_ptr[0] == colour);
+
+                  for ( x = 0 ; x < xsize-1 ; x++ ) {
+                      q = qb[x];
+                      p = ((p<<1)&0666) | ((q<<3)&0110) | (unsigned int) (y1_ptr[x+1]==colour);
+                      qb[x] = (unsigned char) p;
+                      if  ( ((p&m) == 0) && todelete[p] ) {
+                          count++;
+                          y_ptr[x] = bg_color;  /* delete the pixel */
+                      }
+                  }
+
+                  /* Process right edge pixel.                        */
+                  p = (p<<1)&0666;
+                  if  ( (p&m) == 0 && todelete[p] ) {
+                      count++;
                       y_ptr[xsize-1] = bg_color;
-                  } 
-              } 
- 
-              /* Process bottom scan line.                            */ 
-	      q = qb[0]; 
-	      p = ((q<<2)&0330); 
- 
-	      y_ptr = ptr + xsize * (ysize - 1);
-              for ( x = 0 ; x < xsize ; x++ ) { 
-                  q = qb[x]; 
-                  p = ((p<<1)&0666) | ((q<<3)&0110); 
-                  if  ( (p&m) == 0 && todelete[p] ) { 
-                      count++; 
+                  }
+              }
+
+              /* Process bottom scan line.                            */
+              q = qb[0];
+              p = ((q<<2)&0330);
+
+              y_ptr = ptr + xsize * (ysize - 1);
+              for ( x = 0 ; x < xsize ; x++ ) {
+                  q = qb[x];
+                  p = ((p<<1)&0666) | ((q<<3)&0110);
+                  if  ( (p&m) == 0 && todelete[p] ) {
+                      count++;
                       y_ptr[x] = bg_color;
-                  } 
-              } 
-          } 
-          LOG2("thin1: pass %d, %d pixels deleted\n", pc, count); 
-      } 
-      free (qb); 
-} 
+                  }
+              }
+          }
+          LOG2("thin1: pass %d, %d pixels deleted\n", pc, count);
+      }
+      free (qb);
+}
+
+
+
diff --git a/converter/other/pamtosvg/vector.c b/converter/other/pamtosvg/vector.c
index 8972f4a5..a02b933b 100644
--- a/converter/other/pamtosvg/vector.c
+++ b/converter/other/pamtosvg/vector.c
@@ -271,6 +271,7 @@ vector_horizontal(void) {
 }
 
 
+
 Vector
 vector_zero(void) {
 
@@ -284,6 +285,7 @@ vector_zero(void) {
 }
 
 
+
 bool
 vector_equal(Vector const comparand,
              Vector const comparator) {
diff --git a/converter/other/pamtotga.c b/converter/other/pamtotga.c
index 1daa1e25..f596a313 100644
--- a/converter/other/pamtotga.c
+++ b/converter/other/pamtotga.c
@@ -120,6 +120,7 @@ parseCommandLine(int argc, const char ** argv,
 }
 
 
+
 static void
 putPixel(struct pam *          const pamP,
          tuple                 const tuple,
@@ -271,7 +272,7 @@ computeOutName(struct CmdlineInfo const cmdline,
         workarea = strdup(cmdline.inputFileName);
         cp = strchr(workarea, '.');
         if (cp != NULL)
-        	*cp = '\0';	/* remove extension */
+                *cp = '\0';     /* remove extension */
     }
 
     if (workarea == NULL)
@@ -648,3 +649,6 @@ main(int argc, const char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtotiff.c b/converter/other/pamtotiff.c
index 1718c933..4f25d93a 100644
--- a/converter/other/pamtotiff.c
+++ b/converter/other/pamtotiff.c
@@ -1311,3 +1311,4 @@ main(int argc, const char *argv[]) {
 }
 
 
+
diff --git a/converter/other/pamtouil.c b/converter/other/pamtouil.c
index 01858cbc..46fb76e7 100644
--- a/converter/other/pamtouil.c
+++ b/converter/other/pamtouil.c
@@ -71,9 +71,9 @@ parseCommandLine(int argc, char ** argv,
     const char *outnameOpt;
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0, "name",       OPT_STRING, &outnameOpt, 
+    OPTENT3(0, "name",       OPT_STRING, &outnameOpt,
             &outnameSpec,       0);
-    OPTENT3(0, "verbose",    OPT_FLAG,   NULL, 
+    OPTENT3(0, "verbose",    OPT_FLAG,   NULL,
             &cmdlineP->verbose, 0);
 
     opt.opt_table = option_def;
@@ -87,7 +87,7 @@ parseCommandLine(int argc, char ** argv,
         cmdlineP->inputFilespec = "-";  /* stdin */
     else if (argc-1 == 1)
         cmdlineP->inputFilespec = argv[1];
-    else 
+    else
         pm_error("Too many arguments (%d).  "
                  "Only need one: the input filespec", argc-1);
 
@@ -98,7 +98,7 @@ parseCommandLine(int argc, char ** argv,
 
         /* Remove trailing "_icon" */
         barPos = strrchr(cmdlineP->outname, '_');
-        if (barPos && streq(barPos, "_icon")) 
+        if (barPos && streq(barPos, "_icon"))
             *barPos = '\0';
     } else {
         if (streq(cmdlineP->inputFilespec, "-"))
@@ -118,11 +118,10 @@ parseCommandLine(int argc, char ** argv,
 
 
 
-
 static char*
-genNumstr(int  const number, 
-          int  const base, 
-          char const low_char, 
+genNumstr(int  const number,
+          int  const base,
+          char const low_char,
           int  const digits ) {
 /*----------------------------------------------------------------------------
   Generate a string 'digits' characters long in newly malloc'ed
@@ -130,7 +129,7 @@ genNumstr(int  const number,
   the left with zero digits and truncate on the left if it doesn't fit.
 
   Use the characters 'low_char' to 'low_char' + 'base' to represent the
-  digits 0 to 'base'. 
+  digits 0 to 'base'.
 -----------------------------------------------------------------------------*/
     char* str;
     char* p;
@@ -156,11 +155,11 @@ genNumstr(int  const number,
 
 
 
-static const char * 
+static const char *
 uilName(const char * const rgbname,
         bool         const transparent) {
 /*----------------------------------------------------------------------------
-   Return a string in newly malloc'ed storage which is an appropriate 
+   Return a string in newly malloc'ed storage which is an appropriate
    color name for the UIL palette.  It is the same as the rgb name,
    except that blanks are replaced by underscores, and if 'transparent'
    is true, it is "background color".  The latter is a strange name of
@@ -176,7 +175,7 @@ uilName(const char * const rgbname,
         output = malloc(strlen(rgbname) + 5 + 1);
         if (output == NULL)
             pm_error( "out of memory allocating color name" );
-        
+
         for (i = 0; i < strlen(rgbname); ++i) {
             if (rgbname[i] == ' ')
                 output[i] = '_';
@@ -193,9 +192,9 @@ uilName(const char * const rgbname,
 
 static void
 genCmap(struct pam *   const pamP,
-        tupletable     const chv, 
-        unsigned int   const ncolors, 
-        cixel_map            cmap[MAXCOLORS], 
+        tupletable     const chv,
+        unsigned int   const ncolors,
+        cixel_map            cmap[MAXCOLORS],
         unsigned int * const charsppP,
         bool           const verbose) {
 
@@ -205,7 +204,7 @@ genCmap(struct pam *   const pamP,
     {
         /* Figure out how many characters per pixel we'll be using.
            Don't want to be forced to link with libm.a, so using a
-           division loop rather than a log function.  
+           division loop rather than a log function.
         */
         unsigned int i;
         for (*charsppP = 0, i = ncolors; i > 0; ++(*charsppP))
@@ -220,15 +219,15 @@ genCmap(struct pam *   const pamP,
         unsigned int indexOfName;
         bool transparent;
         int j;
-        
+
         if (pamP->depth-1 < PAM_TRN_PLANE)
             transparent = FALSE;
-        else 
-            transparent = 
+        else
+            transparent =
                 chv[colorIndex]->tuple[PAM_TRN_PLANE] < pamP->maxval/2;
 
         /* Generate color name string. */
-        colorname = pam_colorname(pamP, chv[colorIndex]->tuple, 
+        colorname = pam_colorname(pamP, chv[colorIndex]->tuple,
                                   PAM_COLORNAME_ENGLISH);
 
         /* We may have already assigned a character code to this color
@@ -236,11 +235,11 @@ genCmap(struct pam *   const pamP,
            two different colors because we said we wanted the closest
            matching color that has an English name, and we recognize
            only one transparent color.  If that's the case, we just
-           make a cross-reference.  
+           make a cross-reference.
         */
         nameAlreadyInCmap = FALSE;   /* initial assumption */
         for (j = 0; j < colorIndex; ++j) {
-            if (cmap[j].rgbname != NULL && 
+            if (cmap[j].rgbname != NULL &&
                 streq(colorname, cmap[j].rgbname) &&
                 cmap[j].transparent == transparent) {
                 nameAlreadyInCmap = TRUE;
@@ -257,15 +256,15 @@ genCmap(struct pam *   const pamP,
             cmap[colorIndex].rgbname = strdup(colorname);
             if (cmap[colorIndex].rgbname == NULL)
                 pm_error("out of memory allocating color name");
-            
+
             cmap[colorIndex].transparent = transparent;
-            
+
             /* Generate color value characters. */
-            cmap[colorIndex].cixel = 
+            cmap[colorIndex].cixel =
                 genNumstr(colorIndex, base, LOW_CHAR, *charsppP);
             if (verbose)
                 pm_message("Adding color '%s' %s = '%s' to UIL colormap",
-                           cmap[colorIndex].rgbname, 
+                           cmap[colorIndex].rgbname,
                            cmap[colorIndex].transparent ? "TRANS" : "OPAQUE",
                            cmap[colorIndex].cixel);
         }
@@ -286,8 +285,8 @@ writeUilHeader(const char * const outname) {
 
 
 static void
-writeColormap(const char * const outname, 
-              cixel_map          cmap[MAXCOLORS], 
+writeColormap(const char * const outname,
+              cixel_map          cmap[MAXCOLORS],
               unsigned int const ncolors) {
 
     {
@@ -297,8 +296,8 @@ writeColormap(const char * const outname,
         printf("\n");
         printf("value\n");
         for (i = 0; i < ncolors; ++i)
-            if (cmap[i].uilname != NULL && !cmap[i].transparent) 
-                printf("    %s : color( '%s' );\n", 
+            if (cmap[i].uilname != NULL && !cmap[i].transparent)
+                printf("    %s : color( '%s' );\n",
                        cmap[i].uilname, cmap[i].rgbname );
     }
     {
@@ -310,14 +309,14 @@ writeColormap(const char * const outname,
         printf("\n");
         printf("value\n");
         printf("  %s_rgb : color_table (\n", outname);
-        printedOne = FALSE; 
+        printedOne = FALSE;
         for (i = 0; i < ncolors; ++i)
             if (cmap[i].uilname != NULL) {
                 if (printedOne)
                     printf(",\n");
                 printf("    %s = '%s'", cmap[i].uilname, cmap[i].cixel);
                 printedOne = TRUE;
-            }     
+            }
         printf("\n");
         printf("    );\n");
     }
@@ -326,12 +325,12 @@ writeColormap(const char * const outname,
 
 
 static void
-writeRaster(struct pam *  const pamP, 
+writeRaster(struct pam *  const pamP,
             tuple **      const tuples,
             const char *  const outname,
-            cixel_map           cmap[MAXCOLORS], 
+            cixel_map           cmap[MAXCOLORS],
             unsigned int  const ncolors,
-            tuplehash     const cht, 
+            tuplehash     const cht,
             unsigned int  const charspp) {
 /*----------------------------------------------------------------------------
    Write out the ascii character-pixel image.
@@ -358,7 +357,7 @@ writeRaster(struct pam *  const pamP,
         if (row != pamP->height - 1)
             printf("',\n");
         else
-            printf("'\n"); 
+            printf("'\n");
     }
     printf(");\n");
     printf("\n");
@@ -433,3 +432,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pamtowinicon.c b/converter/other/pamtowinicon.c
index 3c2c06bf..14b29f34 100644
--- a/converter/other/pamtowinicon.c
+++ b/converter/other/pamtowinicon.c
@@ -177,6 +177,7 @@ get_rgbPixel(tuple **     const tuples,
 }
 
 
+
 static bool
 andMakesOpaque(const struct pam * const pamP,
                tuple **           const tuples,
@@ -701,7 +702,6 @@ blackenXor(const struct pam * const pamP,
 
 
 
-
 static void
 readAndScalePam(struct pam * const pamP,
                 bool         const doingPng,
diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
index 44d8cbc2..8344bcf2 100644
--- a/converter/other/pbmtopgm.c
+++ b/converter/other/pbmtopgm.c
@@ -124,3 +124,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pdbimgtopam.c b/converter/other/pdbimgtopam.c
index b191644f..4c064630 100644
--- a/converter/other/pdbimgtopam.c
+++ b/converter/other/pdbimgtopam.c
@@ -313,6 +313,7 @@ imageReadHeader(FILE *  const fileP,
 }
 
 
+
 static int
 imageReadData(FILE *   const fileP,
               IMAGE *  const imgP,
diff --git a/converter/other/pfmtopam.c b/converter/other/pfmtopam.c
index 080ec7ff..7e26d9c2 100644
--- a/converter/other/pfmtopam.c
+++ b/converter/other/pfmtopam.c
@@ -2,7 +2,7 @@
                                   pfmtopam
 ******************************************************************************
   This program converts a PFM (Portable Float Map) image to PAM.
-  
+
   By Bryan Henderson, San Jose, CA April 2004.
 
   Contributed to the public domain by its author.
@@ -30,13 +30,13 @@ struct cmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -47,14 +47,14 @@ parseCommandLine(int argc,
     optEntry *option_def = malloc( 100*sizeof( optEntry ) );
     /* Instructions to pm_optParseOptions3 on how to parse our options. */
     optStruct3 opt;
-  
+
     unsigned int option_def_index;
     unsigned int maxvalSpec;
 
     option_def_index = 0;   /* incremented by OPTENTRY */
     OPTENT3(0, "maxval",   OPT_UINT, &cmdlineP->maxval, &maxvalSpec,        0);
     OPTENT3(0, "verbose",  OPT_FLAG, NULL,             &cmdlineP->verbose, 0);
-  
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
@@ -77,13 +77,14 @@ parseCommandLine(int argc,
         cmdlineP->inputFilespec = argv[1];
     else
         cmdlineP->inputFilespec = "-";
-    
+
     if (argc-1 > 1)
         pm_error("Program takes at most one argument:  the file name.  "
                  "You specified %d", argc-1);
 }
 
 
+
 enum endian {ENDIAN_BIG, ENDIAN_LITTLE};
 
 
@@ -99,7 +100,7 @@ thisMachineEndianness(void) {
    that varies among typical machines.
 
    Big endianness is the natural format.  In this format, if an integer is
-   4 bytes, to be stored at memory address 100-103, the most significant 
+   4 bytes, to be stored at memory address 100-103, the most significant
    byte goes at 100, the next most significant at 101, and the least
    significant byte at 103.  This is natural because it matches the way
    humans read and write numbers.  I.e. 258 is stored as 0x00000102.
@@ -115,7 +116,7 @@ thisMachineEndianness(void) {
 
     unsigned char * const storedNumber = (unsigned char *)&testNumber;
     enum endian endianness;
-    
+
     if (storedNumber[0] == 0x01)
         endianness = ENDIAN_LITTLE;
     else
@@ -137,7 +138,7 @@ typedef union {
 
 
 static float
-floatFromPfmSample(pfmSample   const sample, 
+floatFromPfmSample(pfmSample   const sample,
                    enum endian const pfmEndianness) {
 /*----------------------------------------------------------------------------
    Type converter
@@ -147,11 +148,11 @@ floatFromPfmSample(pfmSample   const sample,
     } else {
         pfmSample rightEndianSample;
         unsigned int i, j;
-        
-        for (i = 0, j = sizeof(sample.bytes)-1; 
-             i < sizeof(sample.bytes); 
+
+        for (i = 0, j = sizeof(sample.bytes)-1;
+             i < sizeof(sample.bytes);
              ++i, --j)
-            
+
             rightEndianSample.bytes[i] = sample.bytes[j];
 
         return rightEndianSample.value;
@@ -203,7 +204,7 @@ readPfmHeader(FILE *             const ifP,
         int rc;
         char whitespace;
 
-        rc = fscanf(ifP, "%u %u%c", 
+        rc = fscanf(ifP, "%u %u%c",
                     &pfmHeaderP->width, &pfmHeaderP->height, &whitespace);
 
         if (rc == EOF)
@@ -213,7 +214,7 @@ readPfmHeader(FILE *             const ifP,
                      "are supposed to be (should be two positive decimal "
                      "integers separated by a space and followed by "
                      "white space)");
-        
+
         if (!isspace(whitespace))
             pm_error("Invalid input file format -- '%c' instead of "
                      "white space after height", whitespace);
@@ -235,13 +236,13 @@ readPfmHeader(FILE *             const ifP,
             pm_error("Invalid input file format where scale factor "
                      "is supposed to be (should be a floating point decimal "
                      "number followed by white space");
-        
+
         if (!isspace(whitespace))
             pm_error("Invalid input file format -- '%c' instead of "
                      "white space after scale factor", whitespace);
     }
 
-    pfmHeaderP->color = (secondChar == 'F');  
+    pfmHeaderP->color = (secondChar == 'F');
         /* 'PF' = RGB, 'Pf' = monochrome */
 
     if (scaleFactorEndian > 0.0) {
@@ -255,12 +256,13 @@ readPfmHeader(FILE *             const ifP,
 }
 
 
+
 static void
 dumpPfmHeader(struct pfmHeader const pfmHeader) {
 
     pm_message("width: %u, height: %u", pfmHeader.width, pfmHeader.height);
     pm_message("color: %s", pfmHeader.color ? "YES" : "NO");
-    pm_message("endian: %s", 
+    pm_message("endian: %s",
                pfmHeader.endian == ENDIAN_BIG ? "BIG" : "LITTLE");
     pm_message("scale factor: %f", pfmHeader.scaleFactor);
 }
@@ -268,9 +270,9 @@ dumpPfmHeader(struct pfmHeader const pfmHeader) {
 
 
 static void
-initPam(struct pam * const pamP, 
-        int          const width, 
-        int          const height, 
+initPam(struct pam * const pamP,
+        int          const width,
+        int          const height,
         bool         const color,
         sample       const maxval) {
 
@@ -306,7 +308,7 @@ makePamRow(struct pam * const pamP,
    Make a PAM (tuple) row of the form described by *pamP, from the next
    row in the PFM file identified by 'ifP'.  Place it in the proper location
    in the tuple array 'tuplenArray'.
-  
+
    'endian' is the endianness of the samples in the PFM file.
 
    'pfmRowNum' is the sequence number (starting at 0, which is the
@@ -333,7 +335,7 @@ makePamRow(struct pam * const pamP,
         /* The order of planes (R, G, B) is the same in PFM as in PAM. */
         unsigned int plane;
         for (plane = 0; plane < pamP->depth; ++plane) {
-            float const val = 
+            float const val =
                 floatFromPfmSample(pfmRowBuffer[pfmCursor++], endian);
             tuplenRow[col][plane] = val / scaleFactor;
         }
@@ -368,14 +370,14 @@ main(int argc, char **argv ) {
     if (cmdline.verbose)
         dumpPfmHeader(pfmHeader);
 
-    initPam(&pam, 
+    initPam(&pam,
             pfmHeader.width, pfmHeader.height, pfmHeader.color,
             cmdline.maxval);
 
     tuplenArray = pnm_allocpamarrayn(&pam);
 
     pfmSamplesPerRow = pam.width * pam.depth;
-    
+
     MALLOCARRAY_NOFAIL(pfmRowBuffer, pfmSamplesPerRow);
 
     /* PFMs are upside down like BMPs */
@@ -388,9 +390,12 @@ main(int argc, char **argv ) {
 
     pnm_freepamarrayn(tuplenArray, &pam);
     free(pfmRowBuffer);
-    
+
     pm_close(ifP);
     pm_close(pam.file);
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pm_tiff.h b/converter/other/pm_tiff.h
index f98110e3..f6fb8403 100644
--- a/converter/other/pm_tiff.h
+++ b/converter/other/pm_tiff.h
@@ -18,7 +18,7 @@ typedef struct tagDefinition {
    This is the definition of a type of tag, e.g. ORIENTATION.
 -----------------------------------------------------------------------------*/
     const char * name;
-        /* The name by which our user knows the tag type, e.g. 
+        /* The name by which our user knows the tag type, e.g.
            "ORIENTATION"
         */
     unsigned int tagnum;
diff --git a/converter/other/pngtxt.c b/converter/other/pngtxt.c
index e02ee227..cf331bd9 100644
--- a/converter/other/pngtxt.c
+++ b/converter/other/pngtxt.c
@@ -32,15 +32,15 @@ readToken(char           const textline[],
     unsigned int cursor;
 
     cursor = *cursorP;
-    
+
     MALLOCARRAY(tokenBuffer, lineLength + 1);
     /* leave room for terminating NUL */
-    if (tokenBuffer == NULL) 
+    if (tokenBuffer == NULL)
         pm_error("Unable to allocate memory for a %u-character "
                  "text string file line", lineLength);
 
     cp = &tokenBuffer[0];  /* initial value */
-    
+
     if (textline[0] == '"') {
         ++cursor;  /* skip past opening quotation mark */
         while (textline[cursor] != '"') {
@@ -56,9 +56,9 @@ readToken(char           const textline[],
         }
         ++cursor;  /* skip past closing quotation mark */
     } else {
-        while ((cursor < lineLength) && 
+        while ((cursor < lineLength) &&
                (textline[cursor] != ' ') && (textline[cursor] != '\t')) {
-            
+
             if (textline[cursor] == '\0')
                 pm_error("Invalid text string file format:  Token contains "
                          "a NUL character.  Text leading up to the NUL "
@@ -75,7 +75,6 @@ readToken(char           const textline[],
 
 
 
-
 static void
 skipWhiteSpace(char           const textline[],
                unsigned int   const lineLength,
@@ -88,7 +87,7 @@ skipWhiteSpace(char           const textline[],
 
     cursor = *cursorP;  /* initial value */
 
-    while (cursor < lineLength && 
+    while (cursor < lineLength &&
            (textline[cursor] == ' ' || textline[cursor] == '\t' ||
             textline[cursor] == '\0'))
         ++cursor;
@@ -113,7 +112,7 @@ readTextString(char          const textline[],
     char * cp;
 
     MALLOCARRAY(cp, lineLength + 1);  /* incl '\0' */
-    if (!cp) 
+    if (!cp)
         pm_error("Unable to allocate memory for text chunks");
 
     memcpy(cp, textline + startPos, lineLength - startPos);
@@ -125,7 +124,7 @@ readTextString(char          const textline[],
 
 
 static void
-startTextChunkEngl(png_text *   const textChunkP, 
+startTextChunkEngl(png_text *   const textChunkP,
                    char         const textline[],
                    unsigned int const lineLength,
                    bool         const isCompressed,
@@ -169,7 +168,7 @@ startTextChunkEngl(png_text *   const textChunkP,
 
 
 static void
-startTextChunkIntl(png_text *   const textChunkP, 
+startTextChunkIntl(png_text *   const textChunkP,
                    char         const textline[],
                    unsigned int const lineLength,
                    bool         const isCompressed,
@@ -219,7 +218,7 @@ startTextChunkIntl(png_text *   const textChunkP,
 
     {
         const char * langKey;
-    
+
         readToken(textline, lineLength, &cursor, &langKey);
 
         pngx_setTextLangKey(textChunkP, langKey);
@@ -233,14 +232,14 @@ startTextChunkIntl(png_text *   const textChunkP,
     readTextString(textline, lineLength, cursor, &textChunkP->text,
                    &textChunkP->text_length);
 
-    textChunkP->compression = 
+    textChunkP->compression =
         isCompressed ? PNG_ITXT_COMPRESSION_zTXt :PNG_ITXT_COMPRESSION_NONE;
 }
 
 
 
 static void
-continueTextString(png_text *   const textChunkP, 
+continueTextString(png_text *   const textChunkP,
                    char         const textline[],
                    unsigned int const lineLength) {
 /*----------------------------------------------------------------------------
@@ -264,7 +263,7 @@ continueTextString(png_text *   const textChunkP,
 
     textChunkP->text[textChunkP->text_length++] = '\n';
 
-    cursor = 0; 
+    cursor = 0;
 
     skipWhiteSpace(textline, lineLength, &cursor);
 
@@ -280,12 +279,12 @@ continueTextString(png_text *   const textChunkP,
 
 
 static void
-getFileLine(FILE *         const fileP, 
-            const char **  const textP, 
+getFileLine(FILE *         const fileP,
+            const char **  const textP,
             unsigned int * const lengthP) {
 /*----------------------------------------------------------------------------
    Read the next line (characters from current position through the first
-   newline character) and return it.  Put the text in newly malloc'ed 
+   newline character) and return it.  Put the text in newly malloc'ed
    storage.
 
    Do not include the newline.
@@ -300,7 +299,7 @@ getFileLine(FILE *         const fileP,
     unsigned int cursor;  /* cursor into textline[] */
     unsigned int allocatedSz;
         /* The number of characters of space that are allocated for
-           'textline' 
+           'textline'
         */
     bool eol;
     bool gotSomething;
@@ -310,14 +309,14 @@ getFileLine(FILE *         const fileP,
     MALLOCARRAY(textline, allocatedSz);
     if (textline == NULL)
         pm_error("Unable to allocate buffer to read a line of a file.");
-    
+
     cursor = 0;
     eol = FALSE;
     gotSomething = FALSE;
 
     while (!eol) {
         int const c = getc(fileP);
-        
+
         if (c != EOF)
             gotSomething = TRUE;
 
@@ -356,7 +355,7 @@ handleArrayAllocation(png_text **    const arrayP,
     if (chunkIdx >= *allocatedChunkCtP) {
         *allocatedChunkCtP *= 2;
         REALLOCARRAY(*arrayP, *allocatedChunkCtP);
-        if (*arrayP == NULL) 
+        if (*arrayP == NULL)
             pm_error("unable to allocate memory for %u text chunks",
                 *allocatedChunkCtP);
     }
@@ -404,9 +403,9 @@ reportChunkCt(bool         const ztxt,
 ******************************************************************************/
 
 
-void 
+void
 pngtxt_addChunk(struct pngx * const pngxP,
-                FILE *        const tfP, 
+                FILE *        const tfP,
                 bool          const ztxt,
                 bool          const itxt,
                 bool          const verbose) {
@@ -436,7 +435,7 @@ pngtxt_addChunk(struct pngx * const pngxP,
     allocatedChunkCt = 256;  /* initial value */
 
     MALLOCARRAY(text, allocatedChunkCt);
-    if (text == NULL) 
+    if (text == NULL)
         pm_error("unable to allocate memory for text chunk array");
 
     for (chunkCt = 0, noChunksYet = true, eof = false; !eof; ) {
@@ -460,15 +459,15 @@ pngtxt_addChunk(struct pngx * const pngxP,
                     } else
                         ++chunkCt;
                     noChunksYet = false;
-                    
+
                     textChunkP = &text[chunkCt];
-                
+
                     if (itxt)
-                        startTextChunkIntl(textChunkP, 
+                        startTextChunkIntl(textChunkP,
                                            textline, lineLength, ztxt,
                                            verbose);
                     else
-                        startTextChunkEngl(textChunkP, 
+                        startTextChunkEngl(textChunkP,
                                            textline, lineLength, ztxt,
                                            verbose);
                 } else {
diff --git a/converter/other/pngtxt.h b/converter/other/pngtxt.h
index 3e6ff2af..30fba1fc 100644
--- a/converter/other/pngtxt.h
+++ b/converter/other/pngtxt.h
@@ -7,9 +7,9 @@
 
 struct pngx;
 
-void 
+void
 pngtxt_addChunk(struct pngx * const pngxP,
-                FILE *        const tfp, 
+                FILE *        const tfp,
                 bool          const ztxt,
                 bool          const itxt,
                 bool          const verbose);
diff --git a/converter/other/pngx.c b/converter/other/pngx.c
index c8703443..d360e554 100644
--- a/converter/other/pngx.c
+++ b/converter/other/pngx.c
@@ -653,6 +653,7 @@ pngx_setTextLangKey(png_text *   const textP,
 }
 
 
+
 void
 pngx_termText(png_text * const textP) {
 
diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
index b7b942b3..868ece92 100644
--- a/converter/other/pnmtoddif.c
+++ b/converter/other/pnmtoddif.c
@@ -1,7 +1,7 @@
 /*
  * Author:      Burkhard Neidecker-Lutz
  *              Digital CEC Karlsruhe
- *      neideck@nestvx.enet.dec.com 
+ *      neideck@nestvx.enet.dec.com
 
  Copyright (c) Digital Equipment Corporation, 1992
 
@@ -75,7 +75,7 @@ static void tag(unsigned char ** buffer, int cl, int constructed,
         *p++ = tag_first | 31;
         sp = 0;
         while (t > 0) {
-            stack[sp++] = t & 0x7f; 
+            stack[sp++] = t & 0x7f;
             t >>= 7;
         }
         while (--sp > 0) {  /* Tag values with continuation bits */
@@ -89,7 +89,7 @@ static void tag(unsigned char ** buffer, int cl, int constructed,
 
 
 /* Emit indefinite length encoding */
-static void 
+static void
 ind(unsigned char **buffer)
 {
     unsigned char *p = *buffer;
@@ -101,7 +101,7 @@ ind(unsigned char **buffer)
 
 
 /* Emit ASN.1 NULL */
-static void 
+static void
 wr_null(unsigned char **buffer)
 {
     unsigned char *p = *buffer;
@@ -113,7 +113,7 @@ wr_null(unsigned char **buffer)
 
 
 /* Emit ASN.1 length only into buffer, no data */
-static void 
+static void
 wr_length(unsigned char ** buffer, int amount)
 {
     int length;
@@ -144,7 +144,7 @@ wr_length(unsigned char ** buffer, int amount)
 
 
 /* BER encode an integer and write it's length and value */
-static void 
+static void
 wr_int(unsigned char ** buffer, int val)
 {
     int length;
@@ -178,7 +178,7 @@ wr_int(unsigned char ** buffer, int val)
 
 
 /* Emit and End Of Coding sequence  */
-static void 
+static void
 eoc(unsigned char ** buffer)
 {
     unsigned char *p = *buffer;
@@ -191,13 +191,13 @@ eoc(unsigned char ** buffer)
 
 
 /* Emit a simple string */
-static 
+static
 void wr_string(unsigned char ** const buffer, const char * const val)
 {
     int length;
     unsigned char *p = *buffer;
 
-    length  = strlen(val);        
+    length  = strlen(val);
     if (length > 127) {
         fprintf(stderr,"Can't encode length > 127 yet (%d)\n",length);
         exit(1);
@@ -214,7 +214,7 @@ void wr_string(unsigned char ** const buffer, const char * const val)
 
 
 /* Emit a ISOLATIN-1 string */
-static void 
+static void
 emit_isolatin1(unsigned char ** const buffer, const char * const val)
 {
     int length;
@@ -242,7 +242,7 @@ emit_isolatin1(unsigned char ** const buffer, const char * const val)
 /* values. A lot of the values here are hardcoded to be just right for   */
 /* the bit grammars that the PBMPLUS formats want.           */
 
-static int 
+static int
 write_header(FILE *file, imageparams *ip)
 {
     unsigned char buffer[300];            /* Be careful with the size ! */
@@ -287,7 +287,7 @@ write_header(FILE *file, imageparams *ip)
     tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1); /* PP Pixel Dist */
     tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1); /* LP Pixel Dist */
     eoc(&p);                /* Pixel Aspect Ratio */
-    tag(&p,CONTEXT,PRIM, 4); wr_int(&p,ip->polarity);  
+    tag(&p,CONTEXT,PRIM, 4); wr_int(&p,ip->polarity);
         /* Brightness Polarity */
     tag(&p,CONTEXT,PRIM, 5); wr_int(&p,1);  /* Grid Type    */
     tag(&p,CONTEXT,PRIM, 7); wr_int(&p,ip->spectral);  /* Spectral Mapping */
@@ -300,7 +300,7 @@ write_header(FILE *file, imageparams *ip)
     tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1);  /* Component Space Organization */
     tag(&p,CONTEXT,PRIM, 1); wr_int(&p,1);  /* Planes per Pixel */
     tag(&p,CONTEXT,PRIM, 2); wr_int(&p,1);  /* Plane Significance   */
-    tag(&p,CONTEXT,PRIM, 3); wr_int(&p,ip->components);  
+    tag(&p,CONTEXT,PRIM, 3); wr_int(&p,ip->components);
         /* Number of Components    */
     tag(&p,CONTEXT,CONS, 4); ind(&p);   /* Bits per Component   */
     for (i = 0; i < ip->components; i++) {
@@ -355,7 +355,7 @@ write_header(FILE *file, imageparams *ip)
     tag(&p,CONTEXT,PRIM, 7); wr_int(&p,ip->bytes_per_line * 8);
         /* Scanline Stride    */
     tag(&p,CONTEXT,PRIM, 8); wr_int(&p,1);   /* Bit Order        */
-    tag(&p,CONTEXT,PRIM, 9); wr_int(&p,ip->bits_per_pixel);  
+    tag(&p,CONTEXT,PRIM, 9); wr_int(&p,ip->bits_per_pixel);
         /* Planebits per Pixel */
     tag(&p,CONTEXT,CONS,10); ind(&p);    /* Byteorder Info   */
     tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1);  /* Byte Unit        */
@@ -363,7 +363,7 @@ write_header(FILE *file, imageparams *ip)
     eoc(&p);                 /* Byteorder Info   */
     tag(&p,CONTEXT,PRIM,11); wr_int(&p,3);   /* Data Type        */
     eoc(&p);                              /* Image Coding Attributes */
-    tag(&p,CONTEXT,PRIM, 1); wr_length(&p,ip->bytes_per_line*ip->height);  
+    tag(&p,CONTEXT,PRIM, 1); wr_length(&p,ip->bytes_per_line*ip->height);
         /* Component Plane Data */
     /* End of DDIF document Indentation */
     headersize = p - buffer;
@@ -380,7 +380,7 @@ write_header(FILE *file, imageparams *ip)
 /* Write all the closing brackets of the DDIF grammar that are missing */
 /* The strange indentation reflects exactly the same indentation that  */
 /* we left off in the write_header procedure.                  */
-static int 
+static int
 write_trailer(FILE * file)
 {
     unsigned char buffer[30];
@@ -406,7 +406,6 @@ write_trailer(FILE * file)
 
 
 
-
 static void
 convertPbmRaster(FILE *          const ifP,
                  int             const format,
@@ -415,7 +414,7 @@ convertPbmRaster(FILE *          const ifP,
                  FILE *          const ofP,
                  unsigned int    const bytesPerLine,
                  unsigned char * const data) {
-                 
+
     bit * const pixels = pbm_allocrow(cols);
 
     unsigned int row;
@@ -490,7 +489,6 @@ convertPgmRaster(FILE *          const ifP,
 
 
 
-
 static void
 convertPpmRaster(FILE *          const ifP,
                  int             const format,
@@ -677,3 +675,6 @@ main(int argc, char *argv[]) {
 
     return(0);
 }
+
+
+
diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
index 1a7aa22c..99efa734 100644
--- a/converter/other/pnmtojpeg.c
+++ b/converter/other/pnmtojpeg.c
@@ -20,7 +20,7 @@
 #define _BSD_SOURCE 1      /* Make sure strdup() is in string.h */
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 
-#include <ctype.h>		/* to declare isdigit(), etc. */
+#include <ctype.h>              /* to declare isdigit(), etc. */
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
@@ -147,7 +147,6 @@ interpretRestart(const char *       const restartOpt,
 
 
 
-
 static void
 interpretDensity(const char *     const densityString,
                  struct Density * const densityP) {
@@ -506,7 +505,7 @@ readScanInteger(FILE * const fileP,
         while (ch != EOF && isspace(ch))
             ch = textGetc(fileP);
 
-        if (isdigit(ch)) {		/* oops, put it back */
+        if (isdigit(ch)) {              /* oops, put it back */
             if (ungetc(ch, fileP) == EOF)
                 pm_error("Unexpected failure of ungetc");
             ch = ' ';
@@ -820,10 +819,10 @@ setQuantSlots(j_compress_ptr const cinfo,
 
     for (ci = 0, i = 0; ci < MAX_COMPONENTS; ++ci) {
         if (arg[i]) {
-            ch = ',';			/* if not set by sscanf, will be ',' */
+            ch = ',';                   /* if not set by sscanf, will be ',' */
             if (sscanf(&arg[i], "%d%c", &val, &ch) < 1)
                 return false;
-            if (ch != ',')		/* syntax check */
+            if (ch != ',')              /* syntax check */
                 return false;
             if (val < 0 || val >= NUM_QUANT_TBLS) {
                 pm_message("Invalid quantization table number: %d.  "
@@ -845,6 +844,7 @@ setQuantSlots(j_compress_ptr const cinfo,
 }
 
 
+
 static bool
 setSampleFactors (j_compress_ptr const cinfo,
                   const char *   const arg) {
@@ -861,7 +861,7 @@ setSampleFactors (j_compress_ptr const cinfo,
 
     for (ci = 0, i = 0; ci < MAX_COMPONENTS; ++ci) {
         if (arg[i]) {
-            ch2 = ',';		/* if not set by sscanf, will be ',' */
+            ch2 = ',';          /* if not set by sscanf, will be ',' */
             if (sscanf(&arg[i], "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
                 return false;
             if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
diff --git a/converter/other/pnmtopalm/gen_palm_colormap.c b/converter/other/pnmtopalm/gen_palm_colormap.c
index 0f3f8a5f..04555221 100644
--- a/converter/other/pnmtopalm/gen_palm_colormap.c
+++ b/converter/other/pnmtopalm/gen_palm_colormap.c
@@ -15,7 +15,7 @@ main(int     argc,
     Colormap defaultMap;
     unsigned int i;
     pixel pix;
-    
+
     defaultMap = palmcolor_build_default_8bit_colormap();
     qsort (defaultMap->color_entries, defaultMap->ncolors,
            sizeof(Color_s), palmcolor_compare_indices);
@@ -44,3 +44,5 @@ main(int     argc,
     return 0;
 }
 
+
+
diff --git a/converter/other/pnmtopalm/palm.h b/converter/other/pnmtopalm/palm.h
index 0edf9a28..0a2a7cfc 100644
--- a/converter/other/pnmtopalm/palm.h
+++ b/converter/other/pnmtopalm/palm.h
@@ -7,7 +7,7 @@
 #define PALM_INDIRECT_BITMAP        0x1000  /* Palm says internal use only */
 #define PALM_FOR_SCREEN             0x0800  /* Palm says internal use only */
 #define PALM_DIRECT_COLOR_FLAG      0x0400
-#define PALM_INDIRECT_COLORMAP      0x0200  /* Palm says internal use only */ 
+#define PALM_INDIRECT_COLORMAP      0x0200  /* Palm says internal use only */
 #define PALM_NO_DITHER_FLAG         0x0100  /* rather mysterious */
 
 #define PALM_COMPRESSION_SCANLINE   0x00
diff --git a/converter/other/pnmtopalm/palmcolormap.c b/converter/other/pnmtopalm/palmcolormap.c
index 1341ca2b..de3def22 100644
--- a/converter/other/pnmtopalm/palmcolormap.c
+++ b/converter/other/pnmtopalm/palmcolormap.c
@@ -28,7 +28,7 @@ palmcolor_mapEntryColorFmPixel(pixel  const color,
 
     return
         0
-        | (scaleSample(PPM_GETR(color), maxval, newMaxval) << 16) 
+        | (scaleSample(PPM_GETR(color), maxval, newMaxval) << 16)
         | (scaleSample(PPM_GETG(color), maxval, newMaxval) <<  8)
         | (scaleSample(PPM_GETB(color), maxval, newMaxval) <<  0);
 }
@@ -68,6 +68,8 @@ palmcolor_compare_colors(const void * const p1,
         return 0;
 }
 
+
+
 /***********************************************************************
  ***********************************************************************
  ***********************************************************************
@@ -81,7 +83,7 @@ palmcolor_compare_colors(const void * const p1,
 /*
  * The 1bit-2 color system palette for Palm Computing Devices.
  */
-static int PalmPalette1bpp[2][3] = 
+static int PalmPalette1bpp[2][3] =
 {
   { 255, 255, 255}, {   0,   0,   0 }
 };
@@ -89,7 +91,7 @@ static int PalmPalette1bpp[2][3] =
 /*
  * The 2bit-4 color system palette for Palm Computing Devices.
  */
-static int PalmPalette2bpp[4][3] = 
+static int PalmPalette2bpp[4][3] =
 {
   { 255, 255, 255}, { 192, 192, 192}, { 128, 128, 128 }, {   0,   0,   0 }
 };
@@ -97,7 +99,7 @@ static int PalmPalette2bpp[4][3] =
 /*
  * The 4bit-16 color system palette for Palm Computing Devices.
  */
-static int PalmPalette4bpp[16][3] = 
+static int PalmPalette4bpp[16][3] =
 {
   { 255, 255, 255}, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 },
   { 187, 187, 187}, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 },
@@ -108,7 +110,7 @@ static int PalmPalette4bpp[16][3] =
 /*
  * The 4bit-16 color system palette for Palm Computing Devices.
  */
-static int PalmPalette4bppColor[16][3] = 
+static int PalmPalette4bppColor[16][3] =
 {
   { 255, 255, 255}, { 128, 128, 128 }, { 128,   0,   0 }, { 128, 128,   0 },
   {   0, 128,   0}, {   0, 128, 128 }, {   0,   0, 128 }, { 128,   0, 128 },
@@ -123,12 +125,12 @@ static int PalmPalette4bppColor[16][3] =
  *
  * NOTE:  only the first 231, plus the last one, are valid.
  */
-static int PalmPalette8bpp[256][3] = 
+static int PalmPalette8bpp[256][3] =
 {
-  { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, 
-  { 255,  51, 255 }, { 255,   0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, 
-  { 255, 153, 204 }, { 255, 102, 204 }, { 255,  51, 204 }, { 255,   0, 204 }, 
-  { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, 
+  { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 },
+  { 255,  51, 255 }, { 255,   0, 255 }, { 255, 255, 204 }, { 255, 204, 204 },
+  { 255, 153, 204 }, { 255, 102, 204 }, { 255,  51, 204 }, { 255,   0, 204 },
+  { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 },
   { 255,  51, 153 }, { 255,   0, 153 }, { 204, 255, 255 }, { 204, 204, 255 },
   { 204, 153, 255 }, { 204, 102, 255 }, { 204,  51, 255 }, { 204,   0, 255 },
   { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 },
@@ -215,7 +217,7 @@ palmcolor_build_default_8bit_colormap(void) {
     cmP->ncolors = 232;
 
     /* now sort the table */
-    qsort(cmP->color_entries, cmP->ncolors, sizeof(ColormapEntry), 
+    qsort(cmP->color_entries, cmP->ncolors, sizeof(ColormapEntry),
           palmcolor_compare_colors);
     return cmP;
 }
@@ -235,7 +237,7 @@ palmcolor_build_custom_8bit_colormap(pixel **     const pixels,
     colormapP->nentries = 256;
     MALLOCARRAY_NOFAIL(colormapP->color_entries, colormapP->nentries);
     colormapP->ncolors = 0;  /* initial value */
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         for (col = 0; col < cols; ++col) {
@@ -259,7 +261,7 @@ palmcolor_build_custom_8bit_colormap(pixel **     const pixels,
                     ColormapEntry const newEntry =
                         searchTarget | (colorIndex << 24);
                     colormapP->color_entries[colorIndex] = newEntry;
-                    qsort(colormapP->color_entries, colormapP->ncolors, 
+                    qsort(colormapP->color_entries, colormapP->ncolors,
                           sizeof(ColormapEntry), palmcolor_compare_colors);
                 }
             }
@@ -276,7 +278,7 @@ palmcolor_read_colormap (FILE * const ifP) {
     unsigned short ncolors;
     Colormap * retval;
     int rc;
-    
+
     rc = pm_readbigshort(ifP, (short *) &ncolors);
     if (rc != 0)
         retval = NULL;
@@ -289,7 +291,7 @@ palmcolor_read_colormap (FILE * const ifP) {
         MALLOCVAR_NOFAIL(colormapP);
         colormapP->nentries = ncolors;
         MALLOCARRAY_NOFAIL(colormapP->color_entries, colormapP->nentries);
-        
+
         for (i = 0, error = FALSE;  i < ncolors && !error;  ++i) {
             int rc;
             rc = pm_readbiglong(ifP, &colorentry);
@@ -309,3 +311,6 @@ palmcolor_read_colormap (FILE * const ifP) {
     }
     return retval;
 }
+
+
+
diff --git a/converter/other/pnmtopalm/palmtopnm.c b/converter/other/pnmtopalm/palmtopnm.c
index a64ab01c..0e83f5e0 100644
--- a/converter/other/pnmtopalm/palmtopnm.c
+++ b/converter/other/pnmtopalm/palmtopnm.c
@@ -445,6 +445,7 @@ yesno(bool const arg) {
 }
 
 
+
 static void
 reportPalmHeader(struct PalmHeader      const palmHeader,
                  struct DirectColorInfo const directColorInfo) {
@@ -1250,3 +1251,6 @@ main(int argc, const char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pnmtopalm/pnmtopalm.c b/converter/other/pnmtopalm/pnmtopalm.c
index 9fc92790..ab82996e 100644
--- a/converter/other/pnmtopalm/pnmtopalm.c
+++ b/converter/other/pnmtopalm/pnmtopalm.c
@@ -816,6 +816,7 @@ computeRawRowNonDirect(const xel *     const xelrow,
 }
 
 
+
 typedef struct {
 /*----------------------------------------------------------------------------
    A buffer to which one can write bytes sequentially.
@@ -1352,3 +1353,6 @@ main( int argc, const char **argv ) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pnmtopclxl.c b/converter/other/pnmtopclxl.c
index f7db62ee..c7d0642c 100644
--- a/converter/other/pnmtopclxl.c
+++ b/converter/other/pnmtopclxl.c
@@ -456,7 +456,6 @@ createPclGenerator(struct pam *        const pamP,
 
 
 
-
 struct tPrinter {
     const char *name;
     float topmargin;
@@ -1136,3 +1135,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c
index 3c84e1d3..08647045 100644
--- a/converter/other/pnmtopng.c
+++ b/converter/other/pnmtopng.c
@@ -601,6 +601,7 @@ alloccoloralphahash(void)  {
 }
 
 
+
 static void
 freecoloralphahash(coloralphahash_table const caht) {
     int i;
@@ -2210,6 +2211,7 @@ computeRasterWidth(bool           const colorMapped,
 }
 
 
+
 static void
 createPngPalette(pixel              palette_pnm[],
                  unsigned int const paletteSize,
@@ -2556,6 +2558,7 @@ reportTrans(struct pngx * const pngxP) {
 }
 
 
+
 static void
 doTrnsChunk(struct pngx * const pngxP,
             png_byte      const transPalette[],
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 3ca158b5..d2577dd6 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -58,6 +58,10 @@
 
 
 
+unsigned int const psScaleFactor = 72;
+
+
+
 static void
 setSignals() {
 /*----------------------------------------------------------------------------
@@ -291,21 +295,21 @@ parseCommandLine(int argc, const char ** argv,
     cmdlineP->canturn =  !noturn;
     cmdlineP->showpage = !noshowpage;
 
-    validateCompDimension(width, 72, "-width value");
-    validateCompDimension(height, 72, "-height value");
+    validateCompDimension(width,  psScaleFactor, "-width value");
+    validateCompDimension(height, psScaleFactor, "-height value");
 
-    cmdlineP->width  = width * 72;
-    cmdlineP->height = height * 72;
+    cmdlineP->width  = width  * psScaleFactor;
+    cmdlineP->height = height * psScaleFactor;
 
     if (imagewidthSpec) {
-        validateCompDimension(imagewidth, 72, "-imagewidth value");
-        cmdlineP->imagewidth = imagewidth * 72;
+        validateCompDimension(imagewidth, psScaleFactor, "-imagewidth value");
+        cmdlineP->imagewidth = imagewidth * psScaleFactor;
     }
     else
         cmdlineP->imagewidth = 0;
     if (imageheightSpec) {
-        validateCompDimension(imagewidth, 72, "-imageheight value");
-        cmdlineP->imageheight = imageheight * 72;
+        validateCompDimension(imagewidth, psScaleFactor, "-imageheight value");
+        cmdlineP->imageheight = imageheight * psScaleFactor;
     }
     else
         cmdlineP->imageheight = 0;
diff --git a/converter/other/pnmtorast.c b/converter/other/pnmtorast.c
index e11d3cb7..14c0be0a 100644
--- a/converter/other/pnmtorast.c
+++ b/converter/other/pnmtorast.c
@@ -31,7 +31,7 @@ allocPrColormap(void) {
     MALLOCARRAY(prColormapP->map[0], MAXCOLORS);
     MALLOCARRAY(prColormapP->map[1], MAXCOLORS);
     MALLOCARRAY(prColormapP->map[2], MAXCOLORS);
-    if (prColormapP->map[0] == NULL || 
+    if (prColormapP->map[0] == NULL ||
         prColormapP->map[1] == NULL ||
         prColormapP->map[2] == NULL)
         pm_error("out of memory");
@@ -92,7 +92,7 @@ doRowDepth1(const xel *     const xelrow,
             xelval          const maxval,
             colorhash_table const cht,
             unsigned int *  const lenP) {
-                
+
     unsigned int col;
     int bitcount;
     unsigned int cursor;
@@ -191,7 +191,6 @@ doRowDepth8(const xel *     const xelrow,
 
 
 
-
 static void
 doRowDepth24(const xel *     const xelrow,
              unsigned char * const rastRow,
@@ -232,7 +231,7 @@ computeRaster(unsigned char * const rastRaster,
               xelval          const maxval,
               xel **          const xels,
               colorhash_table const cht) {
-                  
+
     unsigned int row;
     unsigned char * rastRow;
 
@@ -375,7 +374,7 @@ main(int argc, const char ** argv) {
     if (maxval > 255 && depth != 1)
         pm_message(
             "maxval is not 255 - automatically rescaling colors");
-    
+
     /* Allocate space for the Sun-format image. */
     prP = mem_create(cols, rows, depth);
     if (!prP)
@@ -398,3 +397,5 @@ main(int argc, const char ** argv) {
     return 0;
 }
 
+
+
diff --git a/converter/other/pnmtorle.c b/converter/other/pnmtorle.c
index 17c9cfbc..a75ab218 100644
--- a/converter/other/pnmtorle.c
+++ b/converter/other/pnmtorle.c
@@ -334,7 +334,7 @@ skipData(FILE      *  const ifP,
 
 
 int
-main(int argc, char ** argv) {
+main(int argc, const char ** argv) {
 
     struct CmdlineInfo cmdline;
 
@@ -388,3 +388,6 @@ main(int argc, char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pnmtosgi.c b/converter/other/pnmtosgi.c
index cc57349f..adf89bce 100644
--- a/converter/other/pnmtosgi.c
+++ b/converter/other/pnmtosgi.c
@@ -225,12 +225,12 @@ buildChannels(FILE *       const ifP,
 
 
 static void
-writeHeader(unsigned int const cols, 
-            unsigned int const rows, 
-            xelval       const maxval, 
-            unsigned int const bpc, 
-            unsigned int const dimensions, 
-            unsigned int const channels, 
+writeHeader(unsigned int const cols,
+            unsigned int const rows,
+            xelval       const maxval,
+            unsigned int const bpc,
+            unsigned int const dimensions,
+            unsigned int const channels,
             const char * const imagename) {
 
     unsigned int i;
@@ -314,7 +314,7 @@ main(int argc,char * argv[]) {
         pm_error ("Input image is too large.");
 
     pnmrow = pnm_allocrow(cols);
-    
+
     switch (PNM_FORMAT_TYPE(format)) {
         case PBM_TYPE:
             pm_message("promoting PBM to PGM");
@@ -359,3 +359,4 @@ main(int argc,char * argv[]) {
 }
 
 
+
diff --git a/converter/other/pnmtotiffcmyk.c b/converter/other/pnmtotiffcmyk.c
index b7e3228e..a2fa0a4c 100644
--- a/converter/other/pnmtotiffcmyk.c
+++ b/converter/other/pnmtotiffcmyk.c
@@ -79,7 +79,7 @@ Software copyrights will soon need family trees... :-)
 
 /* only support 8 bit values */
 #define MAXTIFFBITS 8
-#define MAXTIFFVAL 255 
+#define MAXTIFFVAL 255
 
 
 /* definitions for error values */
@@ -111,9 +111,9 @@ typedef int Err ;
 #ifndef PI
 #define PI 3.1415926
 #endif
-#define ONETWENTY ( 2.0 * PI / 3.0 ) 
+#define ONETWENTY ( 2.0 * PI / 3.0 )
 #define TWOFORTY ( 4.0 * PI / 3.0 )
-#define THREESIXTY ( 2.0 * PI ) 
+#define THREESIXTY ( 2.0 * PI )
 /* expand from 0-90 to 0-120 degrees */
 #define EXPAND(x) ( 4.0 * ( x ) / 3.0 )
 /* contract from 0-120 to 0-90 degrees */
@@ -144,7 +144,7 @@ typedef struct {
 
 /* parse an arg with a float value.  name should be the full key name,
    preceded by '-' */
-static Err 
+static Err
 floatArg( float *arg, const char *name, int size, float lo, float hi,
           int *argn, int argc, char **argv ) {
 
@@ -165,7 +165,7 @@ floatArg( float *arg, const char *name, int size, float lo, float hi,
                extra, name ) ;
     }
     if ( *arg > hi || *arg < lo ) {
-      fprintf( stderr, "%s (%f) must be in range %f to %f\n", 
+      fprintf( stderr, "%s (%f) must be in range %f to %f\n",
                name, *arg, lo, hi ) ;
       return ERR_ARG ;
     }
@@ -176,9 +176,10 @@ floatArg( float *arg, const char *name, int size, float lo, float hi,
 }
 
 
+
 /* parse an arg with a long value.  name should be the full key name,
    preceded by '-' */
-static Err 
+static Err
 longArg( long *arg, const char *name, int size, long lo, long hi,
          int *argn, int argc, char **argv ) {
 
@@ -199,7 +200,7 @@ longArg( long *arg, const char *name, int size, long lo, long hi,
                extra, name ) ;
     }
     if ( *arg > hi || *arg < lo ) {
-      fprintf( stderr, "%s (%ld) must be in range %ld to %ld\n", 
+      fprintf( stderr, "%s (%ld) must be in range %ld to %ld\n",
                name, *arg, lo, hi ) ;
       return ERR_ARG ;
     }
@@ -210,13 +211,14 @@ longArg( long *arg, const char *name, int size, long lo, long hi,
 }
 
 
+
 /* print usage.  for simplicity this routine is *not* split amongst
    the various components - when you add a component (eg a new
    conversion algorithm, or maybe new input or output code), you must
    also change this routine.  by keeping all the options in one place
    it is also easier to calculate the minimum key name length (passed
    to pnm_keymatch) */
-static void 
+static void
 printUsage( ) {
   fprintf( stderr, "\nusage: pnmtocmyk [Compargs] [Tiffargs] [Convargs] [pnmfile]\n" ) ;
   fprintf( stderr, " Compargs: [-none|-packbits|-lzw [-predictor 1|-predictor 2]]\n" ) ;
@@ -233,6 +235,8 @@ printUsage( ) {
   fprintf( stderr, "No warranty.\n\n" ) ;
 }
 
+
+
 /* list of key args and number of significant letters required
 -default      2
 -gamma        6
@@ -261,11 +265,11 @@ printUsage( ) {
 /* encapsulate the file reader - uses pnm library at the moment, but
    could be changed if we move to libtiff */
 
-typedef Err OptIn( struct tagIn *conv, Root *r, 
+typedef Err OptIn( struct tagIn *conv, Root *r,
                    int *argn, int argc, char **argv ) ;
 typedef int HasMore( struct tagIn *in ) ;
 typedef Err Next( struct tagIn *in, float *r, float *g, float *b ) ;
-typedef Err OpenIn( struct tagIn *in, Root *r ) ; 
+typedef Err OpenIn( struct tagIn *in, Root *r ) ;
 typedef void CloseIn( struct tagIn *in ) ;
 
 typedef struct tagIn {
@@ -294,7 +298,7 @@ typedef struct {
 
 /* the only output option is the filename, which will be the last
    argument, if it doesn't start with '-' */
-static Err 
+static Err
 pnmOpt( In *in, Root *r, int *argn, int argc, char **argv ) {
   PnmIn *p = (PnmIn*)in->private ;
   if ( *argn + 1 == argc && argv[*argn][0] != '\0' &&
@@ -306,8 +310,9 @@ pnmOpt( In *in, Root *r, int *argn, int argc, char **argv ) {
 }
 
 
+
 /* free the row buffer when closing the input */
-static void 
+static void
 pnmClose( In *in ) {
   if ( in ) {
     PnmIn *p = (PnmIn*)in->private ;
@@ -320,16 +325,17 @@ pnmClose( In *in ) {
 }
 
 
+
 /* open the file, storing dimensions both locally and in the global
    root structure */
-static Err 
+static Err
 pnmOpen( In *in, Root *r ) {
 
   PnmIn *p = (PnmIn*)in->private ;
 
   if ( ! p->in ) p->in = stdin ;
 
-  pnm_readpnminit( p->in, &(r->nCols), &(r->nRows), &(p->maxVal), 
+  pnm_readpnminit( p->in, &(r->nCols), &(r->nRows), &(p->maxVal),
                    &(p->type) ) ;
   p->maxPix = r->nCols * r->nRows ;
   p->iPix = 0 ;
@@ -341,16 +347,18 @@ pnmOpen( In *in, Root *r ) {
 }
 
 
+
 /* more data available? */
-static int 
+static int
 pnmHasMore( In *in ) {
   PnmIn *p = (PnmIn*)in->private ;
   return p->iPix < p->maxPix ;
 }
 
 
+
 /* read next pixel - buffered by row.  return values in range 0 to 1 */
-static Err 
+static Err
 pnmNext( In *in, float *r, float *g, float *b ) {
 
   PnmIn *p = (PnmIn*)in->private ;
@@ -374,8 +382,9 @@ pnmNext( In *in, float *r, float *g, float *b ) {
 }
 
 
+
 /* build the input struct */
-static Err 
+static Err
 newPnmInput( In **in ) {
   if ( ! (*in = (In*)calloc( 1, sizeof( In ) )) ) {
     fprintf( stderr, "cannot allocate memory\n" ) ;
@@ -433,7 +442,7 @@ typedef struct {
 
 /* these options come from either the tiff 6.0 spec or the pnmtotiff
    code */
-static Err 
+static Err
 tiffOpt( Out *out, Root* rt, int *argn, int argc, char **argv ) {
 
   Err err ;
@@ -478,14 +487,14 @@ tiffOpt( Out *out, Root* rt, int *argn, int argc, char **argv ) {
     if ( oldn != *argn ) {
       t->rowsperstrip = (uint32)lVal ;
     } else {
-      if ( (err = longArg( &lVal, "-lowdotrange", 3, 0, 
+      if ( (err = longArg( &lVal, "-lowdotrange", 3, 0,
                            (int)(t->highdotrange - 1),
                            argn, argc, argv )) ) return err ;
     }
     if ( oldn != *argn ) {
       t->lowdotrange = (uint16)lVal ;
     } else {
-      if ( (err = longArg( &lVal, "-highdotrange", 2, 
+      if ( (err = longArg( &lVal, "-highdotrange", 2,
                            (int)(t->lowdotrange + 1), MAXTIFFVAL,
                            argn, argc, argv )) ) return err ;
     }
@@ -498,8 +507,9 @@ tiffOpt( Out *out, Root* rt, int *argn, int argc, char **argv ) {
 }
 
 
+
 /* helper routine - writes individual bytes */
-static Err 
+static Err
 tiffWriteByte( TiffOut *t, int b ) {
   ((unsigned char*)(t->buffer))[t->iBuffer] = (unsigned char)b ;
   if ( ++(t->iBuffer) == t->maxBuffer ) {
@@ -513,8 +523,9 @@ tiffWriteByte( TiffOut *t, int b ) {
 }
 
 
+
 /* write the pixel to the tiff file */
-static Err 
+static Err
 tiffWrite( Out *out, int c, int m, int y, int k ) {
   Err err ;
   TiffOut *t = (TiffOut*)out->private ;
@@ -531,8 +542,9 @@ tiffWrite( Out *out, int c, int m, int y, int k ) {
 }
 
 
+
 /* open output to stdout - see warning below */
-static Err 
+static Err
 tiffOpen( Out* out, Root *r ) {
 
   TiffOut *t = (TiffOut*)out->private ;
@@ -554,7 +566,7 @@ tiffOpen( Out* out, Root *r ) {
   TIFFSetField( t->tiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT ) ;
   TIFFSetField( t->tiff, TIFFTAG_COMPRESSION, t->compression ) ;
   if ( t->compression == COMPRESSION_LZW && t->predictor ) {
-	TIFFSetField( t->tiff, TIFFTAG_PREDICTOR, t->predictor ) ;
+        TIFFSetField( t->tiff, TIFFTAG_PREDICTOR, t->predictor ) ;
   }
   TIFFSetField( t->tiff, TIFFTAG_PHOTOMETRIC, photometric ) ;
   TIFFSetField( t->tiff, TIFFTAG_FILLORDER, t->fillorder ) ;
@@ -575,13 +587,14 @@ tiffOpen( Out* out, Root *r ) {
     fprintf( stderr, "cannot allocate memory\n" ) ;
     return ERR_MEMORY ;
   }
-  
+
   return ERR_OK ;
 }
 
 
+
 /* close file and tidy memory */
-static void 
+static void
 tiffClose( Out *out ) {
   if ( out ) {
     TiffOut *t = (TiffOut*)out->private ;
@@ -595,8 +608,9 @@ tiffClose( Out *out ) {
 }
 
 
+
 /* assemble the routines above into a single struct/object */
-static Err 
+static Err
 newTiffOutput( Out **out ) {
 
   TiffOut *t ;
@@ -635,7 +649,7 @@ newTiffOutput( Out **out ) {
 typedef Err Opt( struct tagConv *conv, Root *r,
                  int *argn, int argc, char **argv ) ;
 typedef Err Convert( struct tagConv *conv, Root *rt,
-                     float r, float g, float b, 
+                     float r, float g, float b,
                      int *c, int *m, int *y, int *k ) ;
 typedef void Close( struct tagConv *conv ) ;
 
@@ -649,7 +663,7 @@ typedef struct tagConv {
 
 /* include two conversion routines to show how the code can be
    extended.  first, the standard converter, as outlined in the
-   proposal, then a simple replacement that produces colour 
+   proposal, then a simple replacement that produces colour
    negatives */
 
 
@@ -667,8 +681,8 @@ typedef struct {
 
 /* represent an rgb colour as a hue (angle), white level and colour
    strength */
-static void 
-rgbToHueWhiteColour( float r, float g, float b, 
+static void
+rgbToHueWhiteColour( float r, float g, float b,
                      double *phi, float *white, float *colour ) {
   *white = MIN( r, MIN( g, b ) ) ;
   r -= *white ;
@@ -676,19 +690,20 @@ rgbToHueWhiteColour( float r, float g, float b,
   b -= *white ;
   *colour = sqrt( r * r + g * g + b * b ) ;
   if ( r > TINY || g > TINY || b > TINY ) {
-    if ( b < r && b <= g ) { 
+    if ( b < r && b <= g ) {
       *phi = EXPAND( atan2( g, r ) ) ;
     } else if ( r < g && r <= b ) {
       *phi = ONETWENTY + EXPAND( atan2( b, g ) ) ;
     } else {
       *phi = TWOFORTY + EXPAND( atan2( r, b ) ) ;
     }
-  } 
+  }
 }
 
 
+
 /* represent hue, white and colour values as rgb */
-static void 
+static void
 hueWhiteColourToRgb( double phi, float white, float colour,
                      float *r, float *g, float *b ) {
   while ( phi < 0 ) { phi += THREESIXTY ; }
@@ -715,10 +730,11 @@ hueWhiteColourToRgb( double phi, float white, float colour,
 }
 
 
+
 /* for details, see the proposal.  it's pretty simple - a rotation
    before conversion, with colour removal */
-static Err 
-standardConvert( Conv *conv, Root *rt, float r, float g, float b, 
+static Err
+standardConvert( Conv *conv, Root *rt, float r, float g, float b,
                  int *c, int *m, int *y, int *k ) {
 
   float c0, m0, y0, k0 ; /* CMYK before colour removal */
@@ -767,9 +783,10 @@ standardConvert( Conv *conv, Root *rt, float r, float g, float b,
 }
 
 
+
 /* parse options for this conversion - note the ugly use of -1 for
    gammap to indicate no removal of cmy under k */
-static Err 
+static Err
 standardOpt( Conv *conv, Root *r, int *argn, int argc, char **argv ) {
 
   Err err ;
@@ -790,7 +807,7 @@ standardOpt( Conv *conv, Root *r, int *argn, int argc, char **argv ) {
        *argn + 1 < argc && streq(argv[*argn + 1], "-1") ) {
     p->remove = 0 ;
     *argn = (*argn) + 2 ;
-  } 
+  }
   if ( oldn == *argn ) {
     if ( (err = floatArg( &(p->gammap), "-gammap", 7, 0.1, 10.0,
                                argn, argc, argv )) ) return err ;
@@ -801,18 +818,20 @@ standardOpt( Conv *conv, Root *r, int *argn, int argc, char **argv ) {
 }
 
 
+
 /* free conversion structure */
-static void 
+static void
 standardClose( Conv *conv ) {
   if ( conv ) {
     if ( conv->private ) { free( conv->private ) ; }
-    free( conv ) ; 
+    free( conv ) ;
   }
 }
 
 
+
 /* build new conversion structure */
-static Err 
+static Err
 newStandardMap( Conv **conv ) {
 
   Standard *s ;
@@ -842,7 +861,7 @@ newStandardMap( Conv **conv ) {
 
 
 /* the conversion routine must match the Convert typedef */
-static Err 
+static Err
 negativeConvert( Conv *conv, Root *rt, float r, float g, float b,
                  int *c, int *m, int *y, int *k ) {
 
@@ -858,24 +877,26 @@ negativeConvert( Conv *conv, Root *rt, float r, float g, float b,
 }
 
 
+
 /* since this simple conversion takes no parameters, we don't need to
    parse them - this routine must match the Opt typedef */
-static Err 
+static Err
 negativeOpt( Conv *conv, Root *r, int *argn, int argc, char **argv ) {
   return ERR_OK ;
 }
 
 
+
 /* with no parameters we haven't needed the private data structure, so
    closing is trivial - this routine must match the Close typedef */
-static void 
+static void
 negativeClose( Conv *conv ) { }
 
 
 /* and that's it, apart from assembling the routines above into a
    single struct/object (and adding code in parseOpts to select the
    algorithm and printUsage to help the user) */
-static Err 
+static Err
 newNegativeMap( Conv **conv ) {
 
   if ( ! (*conv = (Conv*)calloc( 1, sizeof( Conv ) )) ) goto error ;
@@ -896,7 +917,7 @@ newNegativeMap( Conv **conv ) {
 
 
 /* run through args, passing to sub components */
-static Err 
+static Err
 parseOpts( int argc, char **argv, Root *r ) {
 
   int argn = 1 ;
@@ -947,6 +968,7 @@ parseOpts( int argc, char **argv, Root *r ) {
 }
 
 
+
 /* drive the reading, conversion, and writing */
 int main( int argc, char **argv ) {
 
@@ -966,7 +988,7 @@ int main( int argc, char **argv ) {
   rt->maxOut = MAXTIFFVAL ;
 
   if ( (err = parseOpts( argc, argv, rt )) ) goto exit ;
-  
+
   if ( (err = rt->in->open( rt->in, rt )) ) goto exit ;
   if ( (err = rt->out->open( rt->out, rt )) ) goto exit ;
 
diff --git a/converter/other/pnmtoxwd.c b/converter/other/pnmtoxwd.c
index eda2ee8f..6a008610 100644
--- a/converter/other/pnmtoxwd.c
+++ b/converter/other/pnmtoxwd.c
@@ -31,13 +31,13 @@ struct CmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct CmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -53,12 +53,12 @@ parseCommandLine(int argc,
     unsigned int depthSpec;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
-  
+
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3(0, "directcolor", OPT_FLAG,    NULL,   &cmdlineP->directcolor,  0);
-    OPTENT3(0, "pseudodepth",    OPT_UINT,  &cmdlineP->pseudodepth,    
+    OPTENT3(0, "pseudodepth",    OPT_UINT,  &cmdlineP->pseudodepth,
             &depthSpec,          0);
-  
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
@@ -77,7 +77,7 @@ parseCommandLine(int argc,
                      "You specified %u", cmdlineP->pseudodepth);
     }
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFilename = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -165,7 +165,6 @@ setupX11Header(X11WDFileHeader * const h11P,
 
 
 
-
 static void
 writeX11Header(X11WDFileHeader const h11,
                FILE *          const ofP) {
@@ -209,7 +208,7 @@ writePseudoColormap(FILE *           const ofP,
                     bool             const backwardMap,
                     xelval           const maxval) {
     /* Write out the colormap, big-endian order. */
-    
+
     X11XColor color;
     unsigned int i;
 
@@ -219,13 +218,13 @@ writePseudoColormap(FILE *           const ofP,
         color.num = i;
         if (grayscale) {
             /* Stupid hack because xloadimage and xwud disagree on
-               how to interpret bitmaps. 
+               how to interpret bitmaps.
             */
             if (backwardMap)
                 color.red = (long) (colors-1-i) * 65535L / (colors - 1);
             else
                 color.red = (long) i * 65535L / (colors - 1);
-            
+
             color.green = color.red;
             color.blue = color.red;
         } else {
@@ -269,7 +268,7 @@ writeDirectColormap(FILE * const ofP) {
         color.green = (short)(i << 8 | i);
         color.blue  = (short)(i << 8 | i);
         color.num   = i << 16 | i << 8 | i;
-        
+
         pm_writebiglong( ofP, color.num);
         pm_writebigshort(ofP, color.red);
         pm_writebigshort(ofP, color.green);
@@ -288,12 +287,12 @@ writeRowDirect(FILE *       const ofP,
                int          const format,
                long         const xmaxval,
                xelval       const maxval) {
-    
+
     switch (PNM_FORMAT_TYPE(format)) {
     case PPM_TYPE: {
         unsigned int col;
         for (col = 0; col < cols; ++col) {
-            unsigned long const ul = 
+            unsigned long const ul =
                 ((PPM_GETR(xelrow[col]) * xmaxval / maxval) << 16) |
                 ((PPM_GETG(xelrow[col]) * xmaxval / maxval) << 8) |
                 (PPM_GETB(xelrow[col]) * xmaxval / maxval);
@@ -331,7 +330,7 @@ writeRowGrayscale(FILE *       const ofP,
     int bitshift;
     unsigned char byte;
     unsigned int col;
-    
+
     bigger_maxval = pm_bitstomaxval(bitsPerPixel);
     bitshift = 8 - bitsPerPixel;
     byte = 0;
@@ -340,7 +339,7 @@ writeRowGrayscale(FILE *       const ofP,
         s = PNM_GET1(xelrow[col]);
         if (backwardMap)
             s = 1 - s;
-        
+
         if (maxval != bigger_maxval)
             s = (long) s * bigger_maxval / maxval;
         byte |= s << bitshift;
@@ -362,7 +361,7 @@ writeRowPseudoColor(FILE *          const ofP,
                     xel *           const xelrow,
                     unsigned int    const cols,
                     colorhash_table const cht) {
-                       
+
     unsigned int col;
 
     for (col = 0; col < cols; ++col)
@@ -391,7 +390,7 @@ writeRaster(FILE *           const ofP,
 
     if (chv)
         cht = ppm_colorhisttocolorhash(chv, colors);
-            
+
     for (row = 0; row < rows; ++row) {
         if (direct)
             writeRowDirect(ofP, xels[row], cols, format, xmaxval, maxval);
@@ -431,7 +430,7 @@ main(int argc, char * argv[]) {
     xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format);
     xmaxval = (1 << cmdline.pseudodepth) - 1;
     pm_close(ifP);
-    
+
     if (cmdline.directcolor) {
         direct = TRUE;
         grayscale = FALSE;
@@ -482,7 +481,7 @@ main(int argc, char * argv[]) {
             dumpname = cmdline.inputFilename;
     }
 
-    setupX11Header(&h11, dumpname, cols, rows, format, 
+    setupX11Header(&h11, dumpname, cols, rows, format,
                    direct, grayscale, colors,
                    cmdline.pseudodepth);
 
@@ -496,12 +495,15 @@ main(int argc, char * argv[]) {
     if (direct)
         writeDirectColormap(stdout);
     else
-        writePseudoColormap(stdout, chv, colors, 
+        writePseudoColormap(stdout, chv, colors,
                             grayscale, backwardMap, maxval);
-    
-    writeRaster(stdout, xels, cols, rows, format, maxval, xmaxval, 
+
+    writeRaster(stdout, xels, cols, rows, format, maxval, xmaxval,
                 chv, colors, direct, grayscale,
                 backwardMap, h11.bits_per_pixel);
 
     return 0;
 }
+
+
+
diff --git a/converter/other/ppmtopgm.c b/converter/other/ppmtopgm.c
index e20c5660..40df422e 100644
--- a/converter/other/ppmtopgm.c
+++ b/converter/other/ppmtopgm.c
@@ -20,9 +20,9 @@ convertRaster(FILE *       const ifP,
               unsigned int const cols,
               unsigned int const rows,
               pixval       const maxval,
-              int          const format, 
+              int          const format,
               pixel *      const inputRow,
-              gray *       const outputRow, 
+              gray *       const outputRow,
               FILE *       const ofP) {
 
     unsigned int row;
@@ -37,7 +37,7 @@ convertRaster(FILE *       const ifP,
         } else {
             /* Can't use fast approximation, so fall back on floats. */
             unsigned int col;
-            for (col = 0; col < cols; ++col) 
+            for (col = 0; col < cols; ++col)
                 outputRow[col] = ppm_luminosity(inputRow[col]);
         }
         pgm_writepgmrow(ofP, outputRow, cols, maxval, 0);
@@ -52,7 +52,7 @@ main(int argc, char *argv[]) {
     FILE* ifP;
     const char * inputFilespec;
     int eof;
-    
+
     ppm_init( &argc, argv );
 
     if (argc-1 > 1)
@@ -62,7 +62,7 @@ main(int argc, char *argv[]) {
         inputFilespec = argv[1];
     else
         inputFilespec = "-";
-    
+
     ifP = pm_openr(inputFilespec);
 
     eof = FALSE;  /* initial assumption */
@@ -81,7 +81,7 @@ main(int argc, char *argv[]) {
             inputRow = ppm_allocrow(cols);
             outputRow = pgm_allocrow(cols);
 
-            convertRaster(ifP, cols, rows, maxval, format, 
+            convertRaster(ifP, cols, rows, maxval, format,
                           inputRow, outputRow, stdout);
 
             ppm_freerow(inputRow);
@@ -93,3 +93,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index 25f2c429..dfc1b1b8 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -899,8 +899,8 @@ execGhostscript(int               const inputPipeFd,
                    "-dSAFER", "-");
     }
 
-    execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt, 
-	  textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
+    execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt,
+          textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
 
     pm_error("execl() of Ghostscript ('%s') failed, errno=%d (%s)",
              ghostscriptProg, errno, strerror(errno));
@@ -1161,3 +1161,4 @@ main(int argc, char ** argv) {
 }
 
 
+
diff --git a/converter/other/qoi.h b/converter/other/qoi.h
index 52ee95e2..4bd7c024 100644
--- a/converter/other/qoi.h
+++ b/converter/other/qoi.h
@@ -82,6 +82,8 @@ qoi_colorHash(qoi_Rgba const x) {
         (x.rgba.r*3 + x.rgba.g*5 + x.rgba.b*7 + x.rgba.a*11) % QOI_INDEX_SIZE;
 }
 
+
+
 static __inline__ void
 qoi_clearQoiIndex(qoi_Rgba * index) {
 
@@ -89,6 +91,8 @@ qoi_clearQoiIndex(qoi_Rgba * index) {
 
 }
 
+
+
 #define QOI_MAGIC_SIZE 4
 
 static char const qoi_magic[QOI_MAGIC_SIZE + 1] = {'q','o','i','f','\0'};
diff --git a/converter/other/qoitopam.c b/converter/other/qoitopam.c
index af6817b7..51dfd1e8 100644
--- a/converter/other/qoitopam.c
+++ b/converter/other/qoitopam.c
@@ -122,6 +122,7 @@ readAndValidateMagic(FILE * const ifP){
 }
 
 
+
 /* The following two functions are from lib/pmfileio.c */
 
 static void
@@ -321,3 +322,4 @@ main(int argc, const char **argv) {
 }
 
 
+
diff --git a/converter/other/rast.c b/converter/other/rast.c
index 1c787089..1a64f7e5 100644
--- a/converter/other/rast.c
+++ b/converter/other/rast.c
@@ -61,6 +61,8 @@ mem_create( w, h, depth )
     return p;
 }
 
+
+
 void
 mem_free( p )
     struct pixrect* p;
@@ -70,6 +72,8 @@ mem_free( p )
     free( p );
 }
 
+
+
 int
 pr_dump( p, out, colormap, type, copy_flag )
     struct pixrect* p;
@@ -371,11 +375,11 @@ pr_load_colormap( in, hP, colormap )
                 free( colormap->map[1] );
                 return PIX_ERR;
             }
-            if ( fread( colormap->map[0], 1, colormap->length, in ) != 
+            if ( fread( colormap->map[0], 1, colormap->length, in ) !=
                  colormap->length ||
-                 fread( colormap->map[1], 1, colormap->length, in ) != 
+                 fread( colormap->map[1], 1, colormap->length, in ) !=
                  colormap->length ||
-                 fread( colormap->map[2], 1, colormap->length, in ) != 
+                 fread( colormap->map[2], 1, colormap->length, in ) !=
                  colormap->length )
             {
                 free( colormap->map[0] );
@@ -409,6 +413,8 @@ pr_load_colormap( in, hP, colormap )
     return 0;
 }
 
+
+
 struct pixrect*
 pr_load_image( in, hP, colormap )
     FILE* in;
@@ -502,3 +508,6 @@ pr_load_image( in, hP, colormap )
 
     return p;
 }
+
+
+
diff --git a/converter/other/rast.h b/converter/other/rast.h
index eb6f4ec4..2a6b0126 100644
--- a/converter/other/rast.h
+++ b/converter/other/rast.h
@@ -27,44 +27,44 @@
 #ifndef RAST_H_INCLUDED
 #define RAST_H_INCLUDED
 
-#define PIX_ERR		-1
+#define PIX_ERR         -1
 
 struct rasterfile {
     long ras_magic;
-#define	RAS_MAGIC	0x59a66a95
+#define RAS_MAGIC       0x59a66a95
     long ras_width;
     long ras_height;
     long ras_depth;
     long ras_length;
     long ras_type;
-#define RT_OLD		0	/* Raw pixrect image in 68000 byte order */
-#define RT_STANDARD	1	/* Raw pixrect image in 68000 byte order */
-#define RT_BYTE_ENCODED	2	/* Run-length compression of bytes */
-#define RT_FORMAT_RGB	3	/* XRGB or RGB instead of XBGR or BGR */
-#define RT_FORMAT_TIFF	4	/* tiff <-> standard rasterfile */
-#define RT_FORMAT_IFF	5	/* iff (TAAC format) <-> standard rasterfile */
-#define RT_EXPERIMENTAL 0xffff	/* Reserved for testing */
+#define RT_OLD          0       /* Raw pixrect image in 68000 byte order */
+#define RT_STANDARD     1       /* Raw pixrect image in 68000 byte order */
+#define RT_BYTE_ENCODED 2       /* Run-length compression of bytes */
+#define RT_FORMAT_RGB   3       /* XRGB or RGB instead of XBGR or BGR */
+#define RT_FORMAT_TIFF  4       /* tiff <-> standard rasterfile */
+#define RT_FORMAT_IFF   5       /* iff (TAAC format) <-> standard rasterfile */
+#define RT_EXPERIMENTAL 0xffff  /* Reserved for testing */
     long ras_maptype;
-#define RMT_NONE	0
-#define RMT_EQUAL_RGB	1
-#define RMT_RAW		2
+#define RMT_NONE        0
+#define RMT_EQUAL_RGB   1
+#define RMT_RAW         2
     long ras_maplength;
 };
 
 struct pixrectops {
-    int	(*pro_rop)();
-    int	(*pro_stencil)();
-    int	(*pro_batchrop)();
-    int	(*pro_nop)();
-    int	(*pro_destroy)();
-    int	(*pro_get)();
-    int	(*pro_put)();
-    int	(*pro_vector)();
+    int (*pro_rop)();
+    int (*pro_stencil)();
+    int (*pro_batchrop)();
+    int (*pro_nop)();
+    int (*pro_destroy)();
+    int (*pro_get)();
+    int (*pro_put)();
+    int (*pro_vector)();
     struct pixrect* (*pro_region)();
-    int	(*pro_putcolormap)();
-    int	(*pro_getcolormap)();
-    int	(*pro_putattributes)();
-    int	(*pro_getattributes)();
+    int (*pro_putcolormap)();
+    int (*pro_getcolormap)();
+    int (*pro_putattributes)();
+    int (*pro_getattributes)();
 };
 
 struct pr_size {
@@ -79,12 +79,12 @@ struct pixrect {
     struct pixrectops* pr_ops;
     struct pr_size pr_size;
     int pr_depth;
-    struct mpr_data* pr_data;	/* work-alike only handles memory pixrects */
+    struct mpr_data* pr_data;   /* work-alike only handles memory pixrects */
 };
 
 struct mpr_data {
     int md_linebytes;
-    unsigned char* md_image;	/* note, byte not short -- avoid pr_flip() */
+    unsigned char* md_image;    /* note, byte not short -- avoid pr_flip() */
     struct pr_pos md_offset;
     short md_primary;
     short md_flags;
diff --git a/converter/other/rasttopnm.c b/converter/other/rasttopnm.c
index 285fc5e0..7f6015a3 100644
--- a/converter/other/rasttopnm.c
+++ b/converter/other/rasttopnm.c
@@ -47,7 +47,7 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
- 
+
     opt.opt_table = option_def;
     opt.short_allowed = false;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = false;  /* We have no parms that are negative numbers */
@@ -62,7 +62,7 @@ parseCommandLine(int argc, const char ** argv,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -258,7 +258,7 @@ convertRowDepth8(const unsigned char * const lineStart,
 
         ++byteP;
     }
-} 
+}
 
 
 
@@ -299,7 +299,7 @@ convertRowRgb(const unsigned char * const lineStart,
         else
             PPM_ASSIGN(xelrow[col], r, g, b);
     }
-} 
+}
 
 
 
@@ -387,9 +387,9 @@ dumpHeader(struct rasterfile const header) {
 
 
 static void
-dumpHeaderAnalysis(bool         const grayscale, 
+dumpHeaderAnalysis(bool         const grayscale,
                    unsigned int const depth,
-                   xel          const zero, 
+                   xel          const zero,
                    xel          const one) {
 
     pm_message("grayscale: %s", grayscale ? "YES" : "NO");
@@ -464,9 +464,9 @@ main(int argc, const char ** const argv) {
 
     if (header.ras_maplength != 0) {
         int rc;
-        
+
         rc = pr_load_colormap(ifP, &header, &colorMap);
-        
+
         if (rc != 0 )
             pm_error("unable to read colormap from RAST file");
 
@@ -488,7 +488,7 @@ main(int argc, const char ** const argv) {
                  "but this is not a color mapped image");
 
     writePnm(stdout, pr, header.ras_width, header.ras_height, maxval, format,
-             header.ras_depth, header.ras_type, grayscale, 
+             header.ras_depth, header.ras_type, grayscale,
              header.ras_maplength > 0, colorMap, zero, one, cmdline.index);
 
     pm_close(ifP);
@@ -496,3 +496,6 @@ main(int argc, const char ** const argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/rla.h b/converter/other/rla.h
index 875cbfc6..e8bb6da1 100644
--- a/converter/other/rla.h
+++ b/converter/other/rla.h
@@ -8,9 +8,9 @@ typedef struct
 
 typedef struct
 {
-    window_s	window;
-    window_s	active_window;
-    short	    frame;
+    window_s    window;
+    window_s    active_window;
+    short           frame;
     short       storage_type;
     short       num_chan;
     short       num_matte;
diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c
index 97f271dc..2edad50b 100644
--- a/converter/other/rletopnm.c
+++ b/converter/other/rletopnm.c
@@ -503,3 +503,6 @@ main(int argc, char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/sgitopnm.c b/converter/other/sgitopnm.c
index 6fd4efcf..4bacc411 100644
--- a/converter/other/sgitopnm.c
+++ b/converter/other/sgitopnm.c
@@ -522,3 +522,4 @@ main(int argc, const char * argv[]) {
 }
 
 
+
diff --git a/converter/other/sirtopnm.c b/converter/other/sirtopnm.c
index 6a36a110..8bdeb6b5 100644
--- a/converter/other/sirtopnm.c
+++ b/converter/other/sirtopnm.c
@@ -159,3 +159,6 @@ main(int argc, const char ** argv) {
 
     exit(0);
 }
+
+
+
diff --git a/converter/other/srf.c b/converter/other/srf.c
index b0f97242..a6d51a5d 100644
--- a/converter/other/srf.c
+++ b/converter/other/srf.c
@@ -24,7 +24,7 @@ csumRaw(void * const p,
 
     for (i = 0, retval = 0, c = p; i < len; ++i)
         retval += *c++;
-    
+
     return retval;
 }
 
@@ -419,10 +419,10 @@ csum(struct srf * const srfP,
 
     for (i = 0; i < srfP->header.img_cnt; ++i)
         retval += csumImg(&srfP->imgs[i]);
-    
+
     for (i = 0; i < padLen; ++i)
         retval += 0xff;
-    
+
     return retval;
 }
 
@@ -540,7 +540,7 @@ void
 srf_term(struct srf * const srfP) {
 
     unsigned int i;
-    
+
     free(srfP->header.s578.val);
     free(srfP->header.ver.val);
     free(srfP->header.prod.val);
@@ -634,12 +634,12 @@ srf_create_img(struct srf * const srfP,
                uint16_t     const width,
                uint16_t     const height) {
 /*----------------------------------------------------------------------------
-   Add an "image" to the SRF.  An image is a horizontal series of 36 
+   Add an "image" to the SRF.  An image is a horizontal series of 36
    square frames, each showing a different angle view of an object, 10
    degrees about.  At least that's what it's supposed to be.  We don't
    really care -- it's just an arbitrary rectangular raster image to us.
 -----------------------------------------------------------------------------*/
-    
+
     ++srfP->header.img_cnt;
 
     REALLOCARRAY(srfP->imgs, srfP->header.img_cnt);
@@ -650,4 +650,6 @@ srf_create_img(struct srf * const srfP,
 
     srf_img_init(&srfP->imgs[srfP->header.img_cnt-1], width, height);
 }
-                 
+
+
+
diff --git a/converter/other/srftopam.c b/converter/other/srftopam.c
index efe55253..78d535fb 100644
--- a/converter/other/srftopam.c
+++ b/converter/other/srftopam.c
@@ -82,18 +82,21 @@ srfRed(uint16_t const pixel) {
 }
 
 
+
 static unsigned int
 srfGrn(uint16_t const pixel) {
     return ((pixel >>  6) & 0x1f) << 3;
 }
 
 
+
 static unsigned int
 srfBlu(uint16_t const pixel) {
     return ((pixel >>  0) & 0x1f) << 3;
 }
 
 
+
 static uint8_t
 srfAlpha(uint8_t const d) {
 
@@ -130,7 +133,7 @@ writeRaster(struct pam *     const pamP,
             uint16_t const alpha = imgP->alpha.data[rowStart + col];
 
             assert(col < pamP->width);
-            
+
             tuplerow[col][PAM_RED_PLANE] = srfRed(data);
             tuplerow[col][PAM_GRN_PLANE] = srfGrn(data);
             tuplerow[col][PAM_BLU_PLANE] = srfBlu(data);
@@ -142,7 +145,7 @@ writeRaster(struct pam *     const pamP,
             tuplerow[col][PAM_GRN_PLANE] = 0;
             tuplerow[col][PAM_BLU_PLANE] = 0;
             tuplerow[col][PAM_TRN_PLANE] = 0;
-        }            
+        }
 
         pnm_writepamrow(pamP, tuplerow);
     }
diff --git a/converter/other/sunicontopnm.c b/converter/other/sunicontopnm.c
index 93ddc0ab..8d67179a 100644
--- a/converter/other/sunicontopnm.c
+++ b/converter/other/sunicontopnm.c
@@ -184,3 +184,6 @@ main(int argc, const char ** argv) {
     pm_close(stdout);
     return 0;
 }
+
+
+
diff --git a/converter/other/svgtopam.c b/converter/other/svgtopam.c
index ca6f4dc7..060d8cde 100644
--- a/converter/other/svgtopam.c
+++ b/converter/other/svgtopam.c
@@ -23,7 +23,7 @@
    10.3.9 user reports in April 2007 that he has 2.6.16 installed and it
    doesn't have xmlReaderTypes.  Another MacOS user reported that in December
    2008.  Apparently that OS has a broken libxml2 installation.
-   
+
 ============================================================================*/
 
 #define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */
@@ -54,13 +54,13 @@ struct cmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 char ** argv, 
+static void
+parseCommandLine(int argc,
+                 char ** argv,
                  struct cmdlineInfo  * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -77,7 +77,7 @@ parseCommandLine(int argc,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "trace",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "trace",     OPT_FLAG,   NULL,
             &cmdlineP->trace,       0);
 
     opt.opt_table = option_def;
@@ -91,7 +91,7 @@ parseCommandLine(int argc,
         cmdlineP->inputFileName = "-";
     else {
         cmdlineP->inputFileName = argv[1];
-        
+
         if (argc-1 > 1)
             pm_error("Too many arguments (%u).  The only non-option argument "
                      "is the input file name.", argc-1);
@@ -177,7 +177,7 @@ createPath(const char * const pathText,
 -----------------------------------------------------------------------------*/
     bool error;
     Path * pathP;
-    
+
     MALLOCVAR(pathP);
     if (pathP == NULL)
         error = TRUE;
@@ -205,7 +205,7 @@ createPath(const char * const pathText,
 
 static void
 destroyPath(Path * const pathP) {
-    
+
     assert(pathP->pathTextLength == strlen(pathP->pathText));
 
     pm_strfree(pathP->pathText);
@@ -225,13 +225,15 @@ makePoint(unsigned int const x,
           unsigned int const y) {
 
     Point p;
-    
+
     p.x = x;
     p.y = y;
-    
+
     return p;
 }
 
+
+
 static ppmd_point
 makePpmdPoint(Point const arg) {
 
@@ -243,6 +245,8 @@ makePpmdPoint(Point const arg) {
     return p;
 }
 
+
+
 typedef enum {
     PATH_MOVETO,
     PATH_LINETO,
@@ -310,6 +314,8 @@ pathReader_create(Path *        const pathP,
     *pathReaderPP = pathReaderP;
 }
 
+
+
 static void
 pathReader_destroy(PathReader * const pathReaderP) {
     free(pathReaderP);
@@ -432,7 +438,7 @@ pathReader_getNextCommand(PathReader *  const pathReaderP,
             break;
         default: {
             const char * const context = pathReader_context(pathReaderP);
-            
+
             pm_errormsg("Unrecognized command in <path>: '%c'.  %s",
                         pathText[pathReaderP->cursor++], context);
 
@@ -544,7 +550,7 @@ drawPath(Canvas * const canvasP,
 
     ppmd_fill(canvasP->pixels, canvasP->width, canvasP->height,
               canvasP->maxval,
-              fillObjP, 
+              fillObjP,
               PPMD_NULLDRAWPROC, &pathP->style.fillColor);
 
     ppmd_fill_destroy(fillObjP);
@@ -574,7 +580,7 @@ interpretStyle(const char * const styleAttr) {
         char * buffer;
 
         for (p = &token[0]; isspace(*p); ++p);
-        
+
         strippedToken = p;
 
         buffer = strdup(strippedToken);
@@ -589,7 +595,7 @@ interpretStyle(const char * const styleAttr) {
             else {
                 const char * const value = colonPos + 1;
                 const char * const name  = &buffer[0];
-                
+
                 *colonPos = '\0';
 
                 if (streq(name, "fill")) {
@@ -614,6 +620,7 @@ interpretStyle(const char * const styleAttr) {
 }
 
 
+
 static void
 getPathAttributes(xmlTextReaderPtr const xmlReaderP,
                   Style *          const styleP,
@@ -652,7 +659,7 @@ processSubPathNode(xmlTextReaderPtr const xmlReaderP,
         } break;
     default:
         /* Just ignore whatever this is.  Contents of <path> are
-           meaningless; all the information is in the attributes 
+           meaningless; all the information is in the attributes
         */
         break;
     }
@@ -687,7 +694,7 @@ processPathElement(xmlTextReaderPtr const xmlReaderP,
         int rc;
 
         rc = xmlTextReaderRead(xmlReaderP);
-        
+
         switch (rc) {
         case 1:
             processSubPathNode(xmlReaderP, &endOfPath);
@@ -736,7 +743,7 @@ processSubSvgElement(xmlTextReaderPtr const xmlReaderP,
     const char * const nodeName = currentNodeName(xmlReaderP);
 
     assert(xmlTextReaderNodeType(xmlReaderP) == XML_READER_TYPE_ELEMENT);
-    
+
     if (streq(nodeName, "path"))
         processPathElement(xmlReaderP, canvasP);
     else
@@ -822,7 +829,7 @@ writePam(FILE *   const ofP,
     pam.depth            = 3;
     pam.maxval           = OUTPUT_MAXVAL;
     strcpy(pam.tuple_type, PAM_PPM_TUPLETYPE);
-    
+
     pnm_writepaminit(&pam);
 
     tuplerow = pnm_allocpamrow(&pam);
@@ -867,7 +874,7 @@ processSvgElement(xmlTextReaderPtr const xmlReaderP,
         int rc;
 
         rc = xmlTextReaderRead(xmlReaderP);
-        
+
         switch (rc) {
         case 1:
             processSubSvgNode(xmlReaderP, canvasP, &endOfSvg);
@@ -938,7 +945,7 @@ processDocument(xmlTextReaderPtr const xmlReaderP,
         int rc;
 
         rc = xmlTextReaderRead(xmlReaderP);
-        
+
         switch (rc) {
         case 1:
             processTopLevelNode(xmlReaderP, ofP);
@@ -968,12 +975,20 @@ main(int argc, char **argv) {
     LIBXML_TEST_VERSION;
 
     parseCommandLine(argc, argv, &cmdline);
-    
+
     traceDraw = cmdline.trace;
 
     ifP = pm_openr(cmdline.inputFileName);
 
     xmlReaderP = xmlReaderForFd(fileno(ifP), "SVG_IMAGE", NULL, 0);
+        /* 'xmlReaderForFd' issues an error message to Standard Error if it
+           cannot interpret the XML document on *ifP; that message identifies
+           the document as "SVG_IMAGE".  It issues the bogus message
+           "Extra content at the end of the document" if the document is
+           empty.  It issues the bogus message "Document is empty" if the
+           file starts with something other than an XML element.
+           libxml2 2.9.10 23.10.09
+        */
 
     if (xmlReaderP) {
         processDocument(xmlReaderP, stdout);
@@ -990,3 +1005,6 @@ main(int argc, char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/tiff.c b/converter/other/tiff.c
index 39e3b0ce..62a6dc94 100644
--- a/converter/other/tiff.c
+++ b/converter/other/tiff.c
@@ -24,14 +24,14 @@
 static uint32
 number(const char * const value,
        tagvalmap    const tagvallist[]) {
-    
+
     char * ep;
     long num;
 
     if (strlen(value) == 0)
         pm_error("null string where numeric tag value or enumerated tag "
                  "value name expected");
-    
+
     num = strtol(value, &ep, 10);
     if (*ep != '\0') {
         /* It's not a numeric string, so it must be an enumerated value name */
@@ -53,7 +53,7 @@ dnumber(const char * const value) {
 
     char * ep;
     double num;
-    
+
     num = strtod(value, &ep);
     if (ep == value || *ep != '\0')
         pm_error("Bad floating point number %s", value);
@@ -162,7 +162,7 @@ putCountBytes(TIFF *       const tifP,
 
 #define TV(p,a) { #a, p##a, }
 
-static tagvalmap const 
+static tagvalmap const
 tvm_compression[] = {
     TV(COMPRESSION_,NONE),
     TV(COMPRESSION_,CCITTRLE),
@@ -463,3 +463,6 @@ tagDefFind(const char * const name) {
 
     return NULL;
 }
+
+
+
diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
index e8f076a4..44b3461b 100644
--- a/converter/other/tifftopnm.c
+++ b/converter/other/tifftopnm.c
@@ -714,23 +714,6 @@ analyzeImageType(TIFF *             const tiffP,
 
 
 
-static void
-reportOutputFormat(int const format) {
-
-    const char * formatDesc;
-
-    switch (format) {
-    case PBM_TYPE: formatDesc = "PBM"; break;
-    case PGM_TYPE: formatDesc = "PGM"; break;
-    case PPM_TYPE: formatDesc = "PPM"; break;
-    default: assert(false);
-    }
-
-    pm_message("writing %s file", formatDesc);
-}
-
-
-
 typedef struct {
     FILE *       imageoutFileP;
         /* The stream to which we write the PNM image.  Null for none. */
@@ -1687,7 +1670,7 @@ convertImage(TIFF *             const tifP,
     analyzeImageType(tifP, tiffDir.bps, tiffDir.spp, tiffDir.photomet,
                      &maxval, &format, colormap, cmdline.headerdump, cmdline);
 
-    reportOutputFormat(format);
+    pm_message("writing %s file", pnm_formattypenm(format));
 
     pnmOut_init(imageoutFileP, alphaFileP, tiffDir.width, tiffDir.height,
                 tiffDir.orientation, maxval, format, maxval,
diff --git a/converter/other/x10wd.h b/converter/other/x10wd.h
index 3c4fb8ca..e60e416a 100644
--- a/converter/other/x10wd.h
+++ b/converter/other/x10wd.h
@@ -9,19 +9,19 @@
 
 #define X10WD_FILE_VERSION 6
 typedef struct {
-    int header_size;		/* Size of the entire file header (bytes). */
-    int file_version;		/* X10WD_FILE_VERSION */
-    int display_type;		/* Display type. */
-    int display_planes;		/* Number of display planes. */
-    int pixmap_format;		/* Pixmap format. */
-    int pixmap_width;		/* Pixmap width. */
-    int pixmap_height;		/* Pixmap height. */
-    short window_width;		/* Window width. */
-    short window_height;	/* Window height. */
-    short window_x;		/* Window upper left X coordinate. */
-    short window_y;		/* Window upper left Y coordinate. */
-    short window_bdrwidth;	/* Window border width. */
-    short window_ncolors;	/* number of Color entries in this window */
+    int header_size;            /* Size of the entire file header (bytes). */
+    int file_version;           /* X10WD_FILE_VERSION */
+    int display_type;           /* Display type. */
+    int display_planes;         /* Number of display planes. */
+    int pixmap_format;          /* Pixmap format. */
+    int pixmap_width;           /* Pixmap width. */
+    int pixmap_height;          /* Pixmap height. */
+    short window_width;         /* Window width. */
+    short window_height;        /* Window height. */
+    short window_x;             /* Window upper left X coordinate. */
+    short window_y;             /* Window upper left Y coordinate. */
+    short window_bdrwidth;      /* Window border width. */
+    short window_ncolors;       /* number of Color entries in this window */
     } X10WDFileHeader;
 
 typedef struct {
diff --git a/converter/other/x11wd.h b/converter/other/x11wd.h
index 7161260b..3c1d996d 100644
--- a/converter/other/x11wd.h
+++ b/converter/other/x11wd.h
@@ -55,7 +55,7 @@ typedef struct {
            instead.  That's how Pnmtoxwd sets ncolors, and is how Xwdtopnm
            interprets it.  Xwdtopnm doesn't even look at 'colormap_entries'.
 
-           This could be an old mistake; maybe colormap_entries was 
+           This could be an old mistake; maybe colormap_entries was
            originally the number of entries in the colormap, and ncolors
            was the number of distinct colors in the image (which might be
            less than colormap_entries or, for direct color, could be much
@@ -63,7 +63,7 @@ typedef struct {
         */
     xwdval ncolors;
         /* Number of entries in the color map (for direct color, it's the
-           number of entries in each of them).  See 'colormap_entries'. 
+           number of entries in each of them).  See 'colormap_entries'.
         */
     xwdval window_width;    /* Window width */
     xwdval window_height;   /* Window height */
diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
index 5523acab..810d302a 100644
--- a/converter/other/xwdtopnm.c
+++ b/converter/other/xwdtopnm.c
@@ -504,6 +504,7 @@ computeComponentMasks(X11WDFileHeader * const h11P,
 }
 
 
+
 /* About TrueColor maxval:
 
    The X11 spec says that in TrueColor, you use the bits in the raster for a
diff --git a/converter/other/yuy2topam.c b/converter/other/yuy2topam.c
index 49f284ac..b4742bf5 100644
--- a/converter/other/yuy2topam.c
+++ b/converter/other/yuy2topam.c
@@ -264,3 +264,6 @@ main(int argc, const char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/other/zeisstopnm.c b/converter/other/zeisstopnm.c
index e94d9b44..5f1e97ec 100644
--- a/converter/other/zeisstopnm.c
+++ b/converter/other/zeisstopnm.c
@@ -75,34 +75,34 @@ main( argc, argv )
     argn = 1;
 
     while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
-	{
-	if ( pm_keymatch( argv[argn], "-pgm", 3 ) )
-	    {
-	    if ( argn >= argc )
-		pm_usage( usage );
-	    format = PGM_TYPE;
-	    }
-	else if ( pm_keymatch( argv[argn], "-ppm", 3 ) )
-	    {
-	    if ( argn >= argc )
-		pm_usage( usage );
-	    format = PPM_TYPE;
-	    }
-	else
-	    pm_usage( usage );
-	++argn;
-	}
+        {
+        if ( pm_keymatch( argv[argn], "-pgm", 3 ) )
+            {
+            if ( argn >= argc )
+                pm_usage( usage );
+            format = PGM_TYPE;
+            }
+        else if ( pm_keymatch( argv[argn], "-ppm", 3 ) )
+            {
+            if ( argn >= argc )
+                pm_usage( usage );
+            format = PPM_TYPE;
+            }
+        else
+            pm_usage( usage );
+        ++argn;
+        }
 
     if ( argn < argc )
-	{
-	ifp = pm_openr( argv[argn] );
-	++argn;
-	}
+        {
+        ifp = pm_openr( argv[argn] );
+        ++argn;
+        }
     else
-	ifp = stdin;
+        ifp = stdin;
 
     if ( argn != argc )
-	pm_usage( usage );
+        pm_usage( usage );
 
     /* Read the image to a buffer */
 
@@ -111,35 +111,35 @@ main( argc, argv )
     /* Check the format of the file */
 
     if (nread <=1024)
-	pm_error( "Input file not in Zeiss format (too small)" );
+        pm_error( "Input file not in Zeiss format (too small)" );
 
     lutg = (unsigned char *)buf+(nread-1024+512);
     lutr = (unsigned char *)buf+(nread-1024+256);
     lutb = (unsigned char *)buf+(nread-1024);
 
     cols = ((unsigned char) buf[nread-1024+768+8]) +
-	(((unsigned char) buf[nread-1024+768+9]) << 8);
+        (((unsigned char) buf[nread-1024+768+9]) << 8);
     rows = ((unsigned char) buf[nread-1024+768+10]) +
-	(((unsigned char) buf[nread-1024+768+11]) << 8);
+        (((unsigned char) buf[nread-1024+768+11]) << 8);
 
     if ( cols <= 0 )
-	pm_error( "invalid cols: %d", cols );
+        pm_error( "invalid cols: %d", cols );
     if ( rows <= 0 )
-	pm_error( "invalid rows: %d", rows );
+        pm_error( "invalid rows: %d", rows );
 
     if (cols*rows != nread-1024)
-	pm_error( "Hmm, %d rows, %d cols, %ld total image size",
-		 rows, cols, nread-1024);
+        pm_error( "Hmm, %d rows, %d cols, %ld total image size",
+                 rows, cols, nread-1024);
 
     /* Choose pgm or ppm */
     /* If the LUTs all contain 0,1,2,3,4..255, it is a pgm file */
 
     for (i=0; i<256 && format==0; i++)
-	if (lutr[i] != i || lutg[i] != i || lutb[i] != i)
-	    format = PPM_TYPE;
+        if (lutr[i] != i || lutg[i] != i || lutb[i] != i)
+            format = PPM_TYPE;
 
     if (format == 0)
-	format = PGM_TYPE;
+        format = PGM_TYPE;
 
     pnm_writepnminit( stdout, cols, rows, 255, format, 0 );
     xelrow = pnm_allocrow( cols );
@@ -161,23 +161,23 @@ main( argc, argv )
 
     for ( row = 0; row < rows; ++row )
     {
-	switch ( PNM_FORMAT_TYPE(format) )
-	{
-	case PGM_TYPE:
-	    for ( col = 0, xP = xelrow; col < cols; ++col, ++xP, ++byteP )
-		PNM_ASSIGN1( *xP, *byteP );
-	    break;
-
-	case PPM_TYPE:
-	    for ( col = 0, xP = xelrow; col < cols; ++col, ++xP, ++byteP )
-		PPM_ASSIGN( *xP, lutr[*byteP], lutg[*byteP], lutb[*byteP] );
-	    break;
+        switch ( PNM_FORMAT_TYPE(format) )
+        {
+        case PGM_TYPE:
+            for ( col = 0, xP = xelrow; col < cols; ++col, ++xP, ++byteP )
+                PNM_ASSIGN1( *xP, *byteP );
+            break;
+
+        case PPM_TYPE:
+            for ( col = 0, xP = xelrow; col < cols; ++col, ++xP, ++byteP )
+                PPM_ASSIGN( *xP, lutr[*byteP], lutg[*byteP], lutb[*byteP] );
+            break;
 
         default:
-	    pm_error( "shouldn't happen" );
+            pm_error( "shouldn't happen" );
         }
 
-	pnm_writepnmrow( stdout, xelrow, cols, 255, format, 0 );
+        pnm_writepnmrow( stdout, xelrow, cols, 255, format, 0 );
     }
 
     free( buf );
@@ -185,3 +185,6 @@ main( argc, argv )
 
     exit( 0 );
 }
+
+
+
diff --git a/converter/pbm/atktopbm.c b/converter/pbm/atktopbm.c
index 57782d91..eb3c071a 100644
--- a/converter/pbm/atktopbm.c
+++ b/converter/pbm/atktopbm.c
@@ -353,3 +353,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/brushtopbm.c b/converter/pbm/brushtopbm.c
index ebd817be..63cd0d04 100644
--- a/converter/pbm/brushtopbm.c
+++ b/converter/pbm/brushtopbm.c
@@ -26,7 +26,7 @@ getinit(FILE *         const ifP,
 
     bytesRead = fread(header, sizeof(header), 1, ifP);
     if (bytesRead !=1)
-        pm_error("Error reading header");   
+        pm_error("Error reading header");
 
     if (header[0] != 1)
         pm_error("bad magic number 1");
@@ -49,6 +49,7 @@ validateEof(FILE * const ifP) {
 }
 
 
+
 /*
    The routine for converting the raster closely resembles the pbm
    case of pnminvert.  Input is padded up to 16 bit border.
@@ -85,7 +86,7 @@ main(int argc, const char ** argv)  {
         unsigned int i;
         size_t bytesRead;
 
-        bytesRead = fread (bitrow, 1, inRowBytes, ifP); 
+        bytesRead = fread (bitrow, 1, inRowBytes, ifP);
         if (bytesRead != inRowBytes)
             pm_error("Error reading a row of data from brushfile");
 
@@ -102,6 +103,9 @@ main(int argc, const char ** argv)  {
 
     pm_close(ifP);
     pm_close(stdout);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/pbm/cistopbm.c b/converter/pbm/cistopbm.c
index 591e2aa5..b62f6045 100644
--- a/converter/pbm/cistopbm.c
+++ b/converter/pbm/cistopbm.c
@@ -38,6 +38,8 @@ static void syntax(const char *prog)
                  );
 }
 
+
+
 int main(int argc, const char **argv)
 {
     FILE *ifP;
@@ -176,5 +178,8 @@ int main(int argc, const char **argv)
     }
     pbm_writepbm(stdout, bits, width, height, 0);
     pm_close(ifP);
-    return 0;       
+    return 0;
 }
+
+
+
diff --git a/converter/pbm/cmuwmtopbm.c b/converter/pbm/cmuwmtopbm.c
index be8a7fc1..c2e3bde0 100644
--- a/converter/pbm/cmuwmtopbm.c
+++ b/converter/pbm/cmuwmtopbm.c
@@ -87,7 +87,7 @@ main(int           argc,
         inputFileName = argv[1];
     else
         inputFileName = "-";
-    
+
     ifP = pm_openr(inputFileName);
 
     readCmuwmHeader(ifP, &cols, &rows, &depth);
@@ -105,15 +105,15 @@ main(int           argc,
         bytesRead = fread(bitrow, 1, bytesPerRow, ifP);
         if (bytesRead != bytesPerRow)
             pm_error("CWU window manager bitmap EOF / read error");
-            
+
         /* Invert all bits in row - raster formats are similar.
            CMUWM Black:0 White:1  End of row padded with 1
            PBM   Black:1 White:0  End preferably padded with 0
         */
-   
+
         for (byteSeq = 0; byteSeq < bytesPerRow; ++byteSeq)
             bitrow[byteSeq] = ~bitrow[byteSeq];
-                
+
         pbm_writepbmrow_packed(stdout, bitrow, cols, 0);
     }
 
@@ -123,3 +123,6 @@ main(int           argc,
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/ddbugtopbm.c b/converter/pbm/ddbugtopbm.c
index 8b0a6d0e..75b39b77 100644
--- a/converter/pbm/ddbugtopbm.c
+++ b/converter/pbm/ddbugtopbm.c
@@ -13,15 +13,15 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at
  * your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  * Adapted to Netpbm by Bryan Henderson 2003.08.09.  Bryan got his copy
  * from ftp:ibiblio.com/pub/linux/apps/graphics/convert, dated 2002.08.21.
@@ -37,7 +37,7 @@
 #include "mallocvar.h"
 
 /* this is basically UncompressSketch() from DiddleBug 2.50's diddlebug.c */
-static void 
+static void
 uncompress_sketch(unsigned char * const cPtr,
                   unsigned char * const uPtr,
                   int             const size) {
@@ -79,7 +79,7 @@ make_noname(void) {
 
     do {
         num++;
-        if (out != NULL) 
+        if (out != NULL)
             fclose(out);
         sprintf(name, "sketch-%04d.pbm", num);
     } while (num<10000 && (out = fopen(name, "rb")) != NULL);
@@ -92,7 +92,7 @@ make_noname(void) {
 
 
 
-int 
+int
 main(int argc, char ** argv) {
     FILE * const in=stdin;
 
@@ -147,7 +147,7 @@ main(int argc, char ** argv) {
         for (ptr = nameptr; *ptr; ++ptr) {
             if (!isalnum(*ptr) && strchr("()-_+=[]:;,.<>?",*ptr) == NULL)
                 *ptr='_';
-            if (isupper(*ptr)) 
+            if (isupper(*ptr))
                 *ptr = tolower(*ptr);
         }
 
@@ -161,7 +161,7 @@ main(int argc, char ** argv) {
 
         pm_message("extracting sketch %2d as `%s'", f, outfilename);
         if((out=fopen(outfilename,"wb"))==NULL)
-            pm_message("WARNING: couldn't open file '%s'.  Carrying on...", 
+            pm_message("WARNING: couldn't open file '%s'.  Carrying on...",
                        outfilename);
         else {
             pbm_writepbminit(out, 160, 160, FALSE);
@@ -171,3 +171,6 @@ main(int argc, char ** argv) {
     }
     return 0;
 }
+
+
+
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c
index f9655fce..56462768 100644
--- a/converter/pbm/g3topbm.c
+++ b/converter/pbm/g3topbm.c
@@ -249,6 +249,7 @@ readBitAndDetectEol(struct BitStream * const bitStreamP,
 }
 
 
+
 static void
 initBitStream(struct BitStream * const bitStreamP,
               FILE *             const fileP,
diff --git a/converter/pbm/macp.h b/converter/pbm/macp.h
index d00dc5c9..dcd96af9 100644
--- a/converter/pbm/macp.h
+++ b/converter/pbm/macp.h
@@ -6,11 +6,11 @@
 #ifndef MACP_H_INCLUDED
 #define MACP_H_INCLUDED
 
-#define	MACBIN_HEAD_LEN	128
-#define	MACP_HEAD_LEN	512
-#define	MACP_ROWS	720
-#define	MACP_COLCHARS	72
-#define MACP_COLS	((MACP_COLCHARS) * 8)
-#define MACP_BYTES	((MACP_COLCHARS) * (MACP_ROWS))
+#define MACBIN_HEAD_LEN 128
+#define MACP_HEAD_LEN   512
+#define MACP_ROWS       720
+#define MACP_COLCHARS   72
+#define MACP_COLS       ((MACP_COLCHARS) * 8)
+#define MACP_BYTES      ((MACP_COLCHARS) * (MACP_ROWS))
 
 #endif
diff --git a/converter/pbm/macptopbm.c b/converter/pbm/macptopbm.c
index db628b6c..b5dbcbad 100644
--- a/converter/pbm/macptopbm.c
+++ b/converter/pbm/macptopbm.c
@@ -133,7 +133,6 @@ scanMacBinaryHeader( const unsigned char * rBuff ) {
 
 
 
-
 static void
 skipHeader( FILE * const ifP ) {
 /*--------------------------------------------------------------------------
@@ -227,7 +226,6 @@ readChar( FILE * const ifP ) {
 
 
 
-
 static void
 ReadMacPaintFile( FILE *  const ifP,
                   int  * outOfSyncP,
@@ -291,6 +289,7 @@ ReadMacPaintFile( FILE *  const ifP,
 }
 
 
+
 int
 main( int argc, char * argv[])  {
 
@@ -354,3 +353,6 @@ main( int argc, char * argv[])  {
     pm_close( stdout );
     exit( 0 );
 }
+
+
+
diff --git a/converter/pbm/mrftopbm.c b/converter/pbm/mrftopbm.c
index 32f36ef3..07cf0ed2 100644
--- a/converter/pbm/mrftopbm.c
+++ b/converter/pbm/mrftopbm.c
@@ -20,15 +20,15 @@ static int bitbox;
 static int bitsleft;
 
 
-static void 
+static void
 bit_init(void) {
-    bitbox=0; 
+    bitbox=0;
     bitsleft=0;
 }
 
 
 
-static int 
+static int
 bit_input(FILE * const in) {
     if (bitsleft == 0)   {
         int rc;
@@ -45,7 +45,7 @@ bit_input(FILE * const in) {
 
 
 
-static void 
+static void
 doSquare(FILE *          const ifP,
          unsigned char * const image,
          unsigned int    const ulCol,
@@ -60,7 +60,7 @@ doSquare(FILE *          const ifP,
    image[], which is a concatenation of rows 'imageWidth' pixels wide, one
    byte per pixel.
 -----------------------------------------------------------------------------*/
-    if (size == 1 || bit_input(ifP)) { 
+    if (size == 1 || bit_input(ifP)) {
         /* It's all black or all white.  Next bit says which. */
 
         unsigned int const c = bit_input(ifP);
@@ -100,7 +100,7 @@ writeOutput(FILE *                const ofP,
             int                   const cols,
             int                   const rows,
             const unsigned char * const image) {
-            
+
     /* w64 is units-of-64-bits width */
     unsigned int const w64 = (cols+63)/64;
 
@@ -113,9 +113,9 @@ writeOutput(FILE *                const ofP,
 
     for (row = 0; row < rows; ++row) {
         unsigned int col;
-     
+
         for (col = 0; col < cols; ++col)
-            bitrow[col] = 
+            bitrow[col] =
                 (image[row * (w64*64) + col] == 1) ? PBM_WHITE : PBM_BLACK;
 
         pbm_writepbmrow(ofP, bitrow, cols, FALSE);
@@ -173,7 +173,7 @@ readMrfImage(FILE *           const ifP,
     image = calloc(w64*h64*64*64, 1);
     if (image == NULL)
         pm_error("Unable to get memory for raster");
-                 
+
     /* now recursively input squares. */
 
     bit_init();
@@ -191,7 +191,7 @@ readMrfImage(FILE *           const ifP,
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
 
     FILE *ifP;
@@ -213,7 +213,7 @@ main(int argc, char *argv[]) {
         pm_error("Too many arguments: %d.  Only argument is input file",
                  argc-1);
 
-    if (argc-1 == 1) 
+    if (argc-1 == 1)
         ifP = pm_openr(argv[1]);
     else
         ifP = stdin;
@@ -221,9 +221,9 @@ main(int argc, char *argv[]) {
     ofP = stdout;
 
     readMrfImage(ifP, expandAll, &image, &cols, &rows);
-    
+
     pm_close(ifP);
-    
+
     writeOutput(ofP, cols, rows, image);
 
     free(image);
@@ -233,6 +233,3 @@ main(int argc, char *argv[]) {
 
 
 
-
-
-
diff --git a/converter/pbm/pbmto10x.c b/converter/pbm/pbmto10x.c
index d040b3ed..99f35847 100644
--- a/converter/pbm/pbmto10x.c
+++ b/converter/pbm/pbmto10x.c
@@ -23,8 +23,8 @@
 
 
 static void
-outstripe(char * const stripe, 
-          char * const sP, 
+outstripe(char * const stripe,
+          char * const sP,
           int    const reschar) {
 
     char * p;
@@ -32,7 +32,7 @@ outstripe(char * const stripe,
     p = sP;  /* initial value */
 
     /* scan backwards, removing empty columns */
-    while (p != stripe) 
+    while (p != stripe)
         if (*--p != 0) {
             ++p;
             break;
@@ -199,7 +199,7 @@ main(int argc, const char ** argv) {
         fname = argv[1];
     else
         fname = "-";
-    
+
     ifP = pm_openr(fname);
 
     pbm_readpbminit(ifP, &cols, &rows, &format);
diff --git a/converter/pbm/pbmtoascii.c b/converter/pbm/pbmtoascii.c
index 0305a47b..634bea67 100644
--- a/converter/pbm/pbmtoascii.c
+++ b/converter/pbm/pbmtoascii.c
@@ -272,7 +272,7 @@ main(int argc, const char ** argv) {
     }
     else
         ifP = stdin;
-    
+
     if ( argn != argc )
         pm_usage( usage );
 
@@ -282,3 +282,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoatk.c b/converter/pbm/pbmtoatk.c
index 5f2b625c..d58d7c7d 100644
--- a/converter/pbm/pbmtoatk.c
+++ b/converter/pbm/pbmtoatk.c
@@ -178,3 +178,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtobbnbg.c b/converter/pbm/pbmtobbnbg.c
index e97ef4f2..f9191a49 100644
--- a/converter/pbm/pbmtobbnbg.c
+++ b/converter/pbm/pbmtobbnbg.c
@@ -9,7 +9,7 @@
 ** documentation.  This software is provided "as is" without express or
 ** implied warranty.
 */
-  
+
 /*
 ** Changed to take advantage of negative Packed Pixed Data values and
 ** supply ANSI-standard string terminator.  Paul Milazzo, 28 May 1990.
@@ -17,7 +17,7 @@
 
 #include "pbm.h"
 
-static void write16 ARGS(( unsigned int	));
+static void write16 ARGS(( unsigned int ));
 
 static int nco;
 
@@ -72,10 +72,10 @@ char **argv;
      { if (bitrow[i]==PBM_BLACK) sixteen |= mask;
        mask >>= 1;
        if (mask == 0)
-	{ mask = 0x8000;
-	  write16(sixteen);
-	  sixteen = 0;
-	}
+        { mask = 0x8000;
+          write16(sixteen);
+          sixteen = 0;
+        }
      }
     if (mask != 0x8000)
      { write16(sixteen);
@@ -85,6 +85,8 @@ char **argv;
  exit(0);
 }
 
+
+
 #ifdef POSITIVE_VALUES_ONLY
 static void
 write16(sixteen)
@@ -113,40 +115,40 @@ unsigned int sixteen;
  */
 static void
 write16 (word)
-unsigned int	word;
+unsigned int    word;
 {
-    int		high;
-    int		mid;
-    int		low;
-    int		signChar;
+    int         high;
+    int         mid;
+    int         low;
+    int         signChar;
 
     if (nco > 75) {
-	putchar ('\n');
-	nco = 0;
+        putchar ('\n');
+        nco = 0;
     }
 
     if (word > 0x7fff) {
-	word = (unsigned int) (0x10000L - (long) word);
-	signChar = ' ';
+        word = (unsigned int) (0x10000L - (long) word);
+        signChar = ' ';
     }
     else
-	signChar = '0';
+        signChar = '0';
 
     high = (word >> 10) + '@';
-    mid	= ((word & 0x3f0) >> 4) + '@';
-    low	= (word & 0xf) + signChar;
+    mid = ((word & 0x3f0) >> 4) + '@';
+    low = (word & 0xf) + signChar;
 
     if (high != '@') {
-	printf ("%c%c%c", high, mid, low);
-	nco += 3;
+        printf ("%c%c%c", high, mid, low);
+        nco += 3;
     }
     else if (mid != '@') {
-	printf ("%c%c", mid, low);
-	nco += 2;
+        printf ("%c%c", mid, low);
+        nco += 2;
     }
     else {
-	putchar (low);
-	nco++;
+        putchar (low);
+        nco++;
     }
 }
 #endif
diff --git a/converter/pbm/pbmtocis.c b/converter/pbm/pbmtocis.c
index 9bb42c56..c7a29055 100644
--- a/converter/pbm/pbmtocis.c
+++ b/converter/pbm/pbmtocis.c
@@ -42,6 +42,8 @@ static void syntax(const char *prog)
          );
 }
 
+
+
 int main(int argc, const char **argv)
 {
     FILE *ofP = stdout;
@@ -86,7 +88,7 @@ int main(int argc, const char **argv)
                 pm_keymatch(argv[n], "-W", 2) ||
                 pm_keymatch(argv[n], "--whitebg", 9))
             {
-                bg = PBM_WHITE; 
+                bg = PBM_WHITE;
                 continue;
             }
             if (argv[n][0] == '-' && argv[n][1] != 0)
@@ -126,7 +128,7 @@ int main(int argc, const char **argv)
     run = 0;
     while (y < outh)
     {
-        if (x < width && y < height)    
+        if (x < width && y < height)
         {
             cell = bits[y][x];
             if (inverse) cell ^= (PBM_BLACK ^ PBM_WHITE);
@@ -137,11 +139,11 @@ int main(int argc, const char **argv)
         {
             ++run;
             if (run > MAXRUNLENGTH)
-            {       
+            {
                 fputc(0x20 + MAXRUNLENGTH, ofP);
                 fputc(0x20, ofP);
                 run -= MAXRUNLENGTH;
-            }   
+            }
         }
         else    /* change */
         {
@@ -166,5 +168,8 @@ int main(int argc, const char **argv)
     fputc(0x47, ofP);
     fputc(0x4E, ofP);
     pm_close(ifP);
-    return 0;   
+    return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtocmuwm.c b/converter/pbm/pbmtocmuwm.c
index 983ea491..f166b5ba 100644
--- a/converter/pbm/pbmtocmuwm.c
+++ b/converter/pbm/pbmtocmuwm.c
@@ -67,18 +67,18 @@ main(int argc,
         inputFileName = argv[1];
     else
         inputFileName = "-";
-    
+
     ifP = pm_openr(inputFileName);
 
     pbm_readpbminit(ifP, &cols, &rows, &format);
     bitrow = pbm_allocrow_packed(cols);
 
     putinit(rows, cols);
-    
-    /* Convert PBM raster data to CMUWM and write */ 
+
+    /* Convert PBM raster data to CMUWM and write */
     for (row = 0; row < rows; ++row) {
         unsigned int const bytesPerRow = pbm_packed_bytes(cols);
-        unsigned char const padding = 
+        unsigned char const padding =
             (cols % 8 == 0) ? 0x00 : ((unsigned char) ~0 >> (cols % 8));
 
         unsigned int i;
@@ -95,7 +95,7 @@ main(int argc,
             bitrow[i] = ~bitrow[i];
 
         bitrow[bytesPerRow-1] |= padding;  /* Set row end pad bits */
-        
+
         bytesWritten = fwrite(bitrow, 1, bytesPerRow, stdout);
         if (bytesWritten != bytesPerRow)
             pm_error("fwrite() failed to write CMU window manager bitmap");
@@ -104,3 +104,6 @@ main(int argc,
     pm_close(ifP);
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtodjvurle.c b/converter/pbm/pbmtodjvurle.c
index 83e99ec4..598abfbb 100644
--- a/converter/pbm/pbmtodjvurle.c
+++ b/converter/pbm/pbmtodjvurle.c
@@ -1,7 +1,7 @@
 /*
    Convert a PBM image into the DjVu Bitonal RLE format
    described in the csepdjvu(1) documentation
-  
+
    Copyright (c) 2004 Scott Pakin <scott+pbm@pakin.org>
 
    All rights reserved.
@@ -9,7 +9,7 @@
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
-   
+
    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright
@@ -17,7 +17,7 @@
       documentation and/or other materials provided with the distribution.
    3. The name of the author may not be used to endorse or promote products
       derived from this software without specific prior written permission.
-   
+
    THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -48,8 +48,9 @@ writebyte(FILE *        const ofP,
 }
 
 
+
 /* Write a run length to the RLE file. */
-static void 
+static void
 write_rle(FILE *   const rlefile,
           uint32_t const tallyArg) {
 
@@ -83,7 +84,7 @@ write_rle(FILE *   const rlefile,
 
 
 
-int 
+int
 main (int argc, const char * argv[]) {
 
     FILE * const rlefile = stdout; /* Generated Bitonal RLE file */
@@ -144,3 +145,6 @@ main (int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoepsi.c b/converter/pbm/pbmtoepsi.c
index 87985a1f..7ffd6103 100644
--- a/converter/pbm/pbmtoepsi.c
+++ b/converter/pbm/pbmtoepsi.c
@@ -45,7 +45,7 @@ struct cmdlineInfo {
 
 
 static void
-parseDpi(char *         const dpiOpt, 
+parseDpi(char *         const dpiOpt,
          unsigned int * const dpiXP,
          unsigned int * const dpiYP) {
 
@@ -53,7 +53,7 @@ parseDpi(char *         const dpiOpt,
     unsigned int dpiX, dpiY;
 
     dpiX = strtol(dpiOpt, &dpistr2, 10);
-    if (dpistr2 == dpiOpt) 
+    if (dpistr2 == dpiOpt)
         pm_error("Invalid value for -dpi: '%s'.  Must be either number "
                  "or NxN ", dpiOpt);
     else {
@@ -64,7 +64,7 @@ parseDpi(char *         const dpiOpt,
             char * dpistr3;
 
             dpistr2++;  /* Move past 'x' */
-            dpiY = strtol(dpistr2, &dpistr3, 10);        
+            dpiY = strtol(dpistr2, &dpistr3, 10);
             if (dpistr3 != dpistr2 && *dpistr3 == '\0') {
                 *dpiXP = dpiX;
                 *dpiYP = dpiY;
@@ -77,6 +77,7 @@ parseDpi(char *         const dpiOpt,
 }
 
 
+
 static void
 parseCommandLine(int argc, const char ** const argv,
                  struct cmdlineInfo * const cmdlineP) {
@@ -105,17 +106,17 @@ parseCommandLine(int argc, const char ** const argv,
 
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
-    
+
 
     if (dpiOptSpec)
         parseDpi(dpiOpt, &cmdlineP->dpiX, &cmdlineP->dpiY);
     else
         cmdlineP->dpiX = cmdlineP->dpiY = 72;
-    
+
     if ((argc-1) > 1)
         pm_error("Too many arguments (%d).  Only argument is input file name",
                  argc-1);
-    
+
     if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else
@@ -125,7 +126,7 @@ parseCommandLine(int argc, const char ** const argv,
 
 
 static void
-findPrincipalImage(bit **         const bits, 
+findPrincipalImage(bit **         const bits,
                    unsigned int   const rows,
                    unsigned int   const cols,
                    unsigned int * const topP,
@@ -151,25 +152,25 @@ findPrincipalImage(bit **         const bits,
     bottom = 0;
     left   = cols;
     right  = 0;
- 
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         for (col = 0; col < cols; ++col) {
             if (bits[row][col] == PBM_BLACK) {
-                if (row < top) 
+                if (row < top)
                     top = row;
-                if (row > bottom) 
+                if (row > bottom)
                     bottom = row;
-                if (col < left) 
+                if (col < left)
                     left = col;
-                if (col > right) 
+                if (col > right)
                     right = col;
             }
         }
     }
 
     if (top > bottom) {
-        /* No black pixels encountered */ 
+        /* No black pixels encountered */
         pm_message("Blank page");
         top    = 0;
         left   = 0;
@@ -194,8 +195,8 @@ outputBoundingBox(int const top, int const bottom,
     float const xScale = 72.0 / dpiX;
     float const yScale = 72.0 / dpiY;
 
-    printf("%%%%BoundingBox: %d %d %d %d\n", 
-           ROUND(left*xScale),  ROUND((rows - bottom)*yScale), 
+    printf("%%%%BoundingBox: %d %d %d %d\n",
+           ROUND(left*xScale),  ROUND((rows - bottom)*yScale),
            ROUND(right*xScale), ROUND((rows - top)*yScale));
 }
 
@@ -244,7 +245,7 @@ main(int argc, const char * argv[]) {
         */
 
     pm_proginit(&argc, argv);
-    
+
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFileName);
@@ -255,12 +256,12 @@ main(int argc, const char * argv[]) {
 
     printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
 
-    outputBoundingBox(top, bottom, left, right, rows, 
+    outputBoundingBox(top, bottom, left, right, rows,
                       cmdline.dpiX, cmdline.dpiY);
 
     if (!cmdline.bbonly) {
         int row;
-        printf("%%%%BeginPreview: %d %d 1 %d\n", 
+        printf("%%%%BeginPreview: %d %d 1 %d\n",
                right - left + 1, bottom - top + 1, bottom - top + 1);
 
         for (row = top; row <= bottom; row++) {
@@ -274,7 +275,7 @@ main(int argc, const char * argv[]) {
                 if (outChars == 72) {
                     printf("\n%% ");
                     outChars = 2;
-                }  
+                }
 
                 printf("%02x", eightPixels(bits, row, col, cols));
                 outChars += 2;
@@ -287,3 +288,6 @@ main(int argc, const char * argv[]) {
     }
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoepson.c b/converter/pbm/pbmtoepson.c
index 122a438f..69742368 100644
--- a/converter/pbm/pbmtoepson.c
+++ b/converter/pbm/pbmtoepson.c
@@ -1,7 +1,7 @@
 /* pbmtoeps.c - read a PBM image and produce Epson graphics
 **
 ** Copyright (C) 1990 by John Tiller (tiller@galois.msfc.nasa.gov)
-**			 and Jef Poskanzer.
+**                       and Jef Poskanzer.
 **
 ** Permission to use, copy, modify, and distribute this software and its
 ** documentation for any purpose and without fee is hereby granted, provided
@@ -42,12 +42,12 @@ struct CmdlineInfo {
 
 
 static void
-parseCommandLine(int                  argc, 
+parseCommandLine(int                  argc,
                  const char **        argv,
                  struct CmdlineInfo * cmdlineP ) {
 /*----------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -107,7 +107,7 @@ parseCommandLine(int                  argc,
                      "Only recognized values are 'escp9' and 'escp'",
                      protocol);
     }
-    
+
     if (adjacentSpec && nonadjacentSpec)
         pm_error("You can't specify both -adjacent and -nonadjacent");
     else if (adjacentSpec)
@@ -143,7 +143,7 @@ lineWidth(const bit ** const stripeBits,
 -----------------------------------------------------------------------------*/
     unsigned int col;
     unsigned int endSoFar;
-    
+
     endSoFar = 0;
 
     for (col = 0; col < cols; ++ col) {
@@ -177,14 +177,14 @@ printStripe(const bit ** const stripeBits,
 
     /* Print header of Select Bit Image command */
     printf("%c%c%c%c%c", esc, '*', m, cols % 256, cols / 256);
-    
+
     /* Print the data part of the Select Bit Image command */
     for (col = 0; col < cols; ++col) {
         unsigned int stripeRow;
         int val;
-        
+
         val = 0;
-        for (stripeRow = 0; stripeRow < stripeRows; ++stripeRow) 
+        for (stripeRow = 0; stripeRow < stripeRows; ++stripeRow)
             if (stripeBits[stripeRow][col] == PBM_BLACK)
                 val |= (1 << (8-1-stripeRow));
         putchar(val);
@@ -213,7 +213,7 @@ computeM(enum epsonProtocol const protocol,
             }
         }
         break;
-    case 60: 
+    case 60:
         if (adjacence == ADJACENT_NO)
             pm_error("You can't print at %u dpi "
                      "with adjacent dot printing", dpi);
@@ -236,7 +236,7 @@ computeM(enum epsonProtocol const protocol,
         break;
     case 72:
         if (protocol != ESCP9)
-            pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", 
+            pm_error("%u dpi is possible only with the ESC/P 9-pin protocol",
                      dpi);
         if (adjacence == ADJACENT_NO)
             pm_error("You can't print at %u dpi "
@@ -251,7 +251,7 @@ computeM(enum epsonProtocol const protocol,
         break;
     case 144:
         if (protocol != ESCP9)
-            pm_error("%u dpi is possible only with the ESC/P 9-pin protocol", 
+            pm_error("%u dpi is possible only with the ESC/P 9-pin protocol",
                      dpi);
         if (adjacence == ADJACENT_NO)
             pm_error("You can't print at %u dpi "
@@ -273,13 +273,13 @@ convertToEpson(const bit **       const bits,
                enum epsonProtocol const protocol,
                unsigned int       const dpi,
                enum adjacence     const adjacence) {
-    
+
     unsigned int const rowsPerStripe = 8;
     unsigned int const stripeCt = (rows + rowsPerStripe-1) / rowsPerStripe;
 
     unsigned int stripe;
     char m;
-    
+
     computeM(protocol, dpi, adjacence, &m);
 
     /* Change line spacing to 8/72 inches. */
@@ -292,10 +292,10 @@ convertToEpson(const bit **       const bits,
 
     for (stripe = 0; stripe < stripeCt; ++stripe) {
         const bit ** const stripeBits = &bits[stripe*rowsPerStripe];
-        unsigned int const stripeRows = 
+        unsigned int const stripeRows =
             MIN(rowsPerStripe, rows - stripe * rowsPerStripe);
             /* Number of rows in this stripe (8 for all but bottom stripe) */
-        
+
         unsigned int const endcol = lineWidth(stripeBits, cols, stripeRows);
             /* Column where right margin (contiguous white area at right
                end of stripe) begins.  Zero if entire stripe is white.
@@ -332,10 +332,13 @@ main(int argc, const char ** argv) {
 
     pm_close(ifP);
 
-    convertToEpson(bits, cols, rows, 
+    convertToEpson(bits, cols, rows,
                    cmdline.protocol, cmdline.dpi, cmdline.adjacence);
 
     pbm_freearray(bits, rows);
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoescp2.c b/converter/pbm/pbmtoescp2.c
index 942ecec9..54a77e44 100644
--- a/converter/pbm/pbmtoescp2.c
+++ b/converter/pbm/pbmtoescp2.c
@@ -245,3 +245,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtog3.c b/converter/pbm/pbmtog3.c
index f034b466..48de8885 100644
--- a/converter/pbm/pbmtog3.c
+++ b/converter/pbm/pbmtog3.c
@@ -145,7 +145,7 @@ flushBuffer(struct OutStream * const outP) {
         outbytes = pm_bigendFromUint32(
                    buffer.intBuffer << (fullBuffer - buffer.bitCount));
         if (outP->reverseBits)
-    	reversebuffer((unsigned char *)&outbytes, bytesToWrite);
+        reversebuffer((unsigned char *)&outbytes, bytesToWrite);
         rc = fwrite((unsigned char *)&outbytes, 1, bytesToWrite, outP->fp);
         if (rc != bytesToWrite)
             pm_error("Output error");
@@ -153,6 +153,7 @@ flushBuffer(struct OutStream * const outP) {
 }
 
 
+
 #if 1==0
 static void
 putbitsDump(struct OutStream * const outP,
diff --git a/converter/pbm/pbmtogem.c b/converter/pbm/pbmtogem.c
index 4fd30e92..64bcb761 100644
--- a/converter/pbm/pbmtogem.c
+++ b/converter/pbm/pbmtogem.c
@@ -32,7 +32,7 @@
 *
 *  Deficiencies:
 *  Compression of repeated scanlines not added
-*  
+*
 *       Johann Haider (jh@fortec.tuwien.ac.at)
 *
 * 94/01/31 Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de)
@@ -85,6 +85,8 @@ putinit (int const rows, int const cols)
   linerepeat = -1;
 }
 
+
+
 static void
 putitem( )
     {
@@ -119,6 +121,7 @@ putstring ( unsigned char *p, int n)
 }
 
 
+
 static void
 flushrow( )
     {
@@ -173,7 +176,7 @@ flushrow( )
                 p++;
                 col--;
             }
-    }           
+    }
     if (p > outp)
          putstring (outp, p-outp);
     if (ferror (stdout))
@@ -181,6 +184,7 @@ flushrow( )
 }
 
 
+
 static void
 putrow( )
 {
@@ -203,6 +207,7 @@ putrow( )
 }
 
 
+
 int
 main( int argc, char* argv[])
     {
@@ -246,3 +251,6 @@ main( int argc, char* argv[])
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/pbm/pbmtoibm23xx.c b/converter/pbm/pbmtoibm23xx.c
index 3f1f9679..86103ba6 100644
--- a/converter/pbm/pbmtoibm23xx.c
+++ b/converter/pbm/pbmtoibm23xx.c
@@ -120,7 +120,7 @@ parseCommandLine(int argc, char ** const argv,
 
 
 /* Read all pbm images from a filehandle and print them */
-static void 
+static void
 process_handle(FILE *        const fh,
                unsigned char const graph_mode,
                unsigned int  const passes) {
@@ -155,7 +155,7 @@ process_handle(FILE *        const fh,
             for(bitline = 0; bitline < 8; ++bitline)
                 for(pass = 0; pass < passes; ++pass)
                     /* don't read beyond the end of the image if
-                       height is not a multiple of passes 
+                       height is not a multiple of passes
                     */
                     if(y + bitline * passes + pass < rows) {
                         pbm_readpbmrow(fh, row, cols, format);
@@ -188,7 +188,7 @@ process_handle(FILE *        const fh,
 
 
 
-int 
+int
 main(int argc,char **argv) {
 
   struct cmdlineInfo cmdline;
@@ -212,3 +212,6 @@ main(int argc,char **argv) {
 
   return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoln03.c b/converter/pbm/pbmtoln03.c
index 235429cd..cf1f7959 100644
--- a/converter/pbm/pbmtoln03.c
+++ b/converter/pbm/pbmtoln03.c
@@ -268,3 +268,4 @@ main (int argc, char **argv) {
 }
 
 
+
diff --git a/converter/pbm/pbmtolps.c b/converter/pbm/pbmtolps.c
index d974fcb2..2c6b01a0 100644
--- a/converter/pbm/pbmtolps.c
+++ b/converter/pbm/pbmtolps.c
@@ -251,3 +251,6 @@ main(int argc, const char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtomacp.c b/converter/pbm/pbmtomacp.c
index 4897e6d0..5fa54ad6 100644
--- a/converter/pbm/pbmtomacp.c
+++ b/converter/pbm/pbmtomacp.c
@@ -441,3 +441,5 @@ main(int argc, const char *argv[]) {
     return 0;
 }
 
+
+
diff --git a/converter/pbm/pbmtomatrixorbital.c b/converter/pbm/pbmtomatrixorbital.c
index 41f8e260..f91fd5ff 100644
--- a/converter/pbm/pbmtomatrixorbital.c
+++ b/converter/pbm/pbmtomatrixorbital.c
@@ -14,7 +14,7 @@
 
 
 static void
-generateMo(FILE *       const ofP, 
+generateMo(FILE *       const ofP,
            bit **       const bits,
            unsigned int const cols,
            unsigned int const rows) {
@@ -28,7 +28,7 @@ generateMo(FILE *       const ofP,
         unsigned int row;
         unsigned int outbitpos;
         unsigned char outchar;
-        
+
         outbitpos = 0;  /* Start at 1st bit of 1st output byte */
 
         for (row = 0; row < rows; ++row) {
@@ -38,7 +38,7 @@ generateMo(FILE *       const ofP,
 
             outchar |= bits[row][col] << outbitpos;
 
-            if (outbitpos == 7) 
+            if (outbitpos == 7)
                 /* We filled up a byte.  Output it. */
                 fputc(outchar, ofP);
 
@@ -65,13 +65,13 @@ main(int argc, const char ** argv) {
     if (argc-1 > 1)
         pm_error("Too many arguments (%u).  The only valid argument is an "
                  "input file name.", argc-1);
-    else if (argc-1 == 1) 
+    else if (argc-1 == 1)
         inputFilename = argv[1];
     else
         inputFilename = "-";
 
     ifP = pm_openr(inputFilename);
-    
+
     bits = pbm_readpbm(ifP, &cols, &rows);
 
     if (rows > 255)
@@ -80,7 +80,7 @@ main(int argc, const char ** argv) {
         pm_error("Image is too wide:  %u cols.  Max width: 255 cols", cols);
 
     generateMo(stdout, bits, cols, rows);
-    
+
     pm_close(ifP);
 
     pbm_freearray(bits, rows);
diff --git a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c
index a39cf1a7..2ed862fc 100644
--- a/converter/pbm/pbmtomda.c
+++ b/converter/pbm/pbmtomda.c
@@ -1,4 +1,3 @@
-
 /***************************************************************************
 
     PBMTOMDA: Convert PBM to Microdesign area
@@ -106,6 +105,7 @@ encode(bit ** const bits,
 }
 
 
+
 static void
 doTranslation(bit **       const bits,
               unsigned int const nOutCols,
diff --git a/converter/pbm/pbmtomrf.c b/converter/pbm/pbmtomrf.c
index e7b7fcc9..a9243561 100644
--- a/converter/pbm/pbmtomrf.c
+++ b/converter/pbm/pbmtomrf.c
@@ -23,18 +23,18 @@ typedef struct bitOut {
 
 
 
-static void 
+static void
 bit_init(struct bitOut * const bitOutP,
          FILE *          const ofP) {
 
-    bitOutP->bitbox = 0; 
+    bitOutP->bitbox = 0;
     bitOutP->bitsleft = 8;
     bitOutP->fileP = ofP;
 }
 
 
 
-static void 
+static void
 bit_output(struct bitOut * const bitOutP,
            int             const bit) {
 
@@ -49,7 +49,7 @@ bit_output(struct bitOut * const bitOutP,
 
 
 
-static void 
+static void
 bit_flush(struct bitOut * const bitOutP) {
     /* there are never 0 bits left outside of bit_output, but
      * if 8 bits are left here there's nothing to flush, so
@@ -86,7 +86,7 @@ determineBlackWhiteOrMix(const unsigned char * const image,
 
             t += image[rowOfImage * imageWidth + colOfImage];
         }
-    }        
+    }
     /* if the total's 0, it's black. if it's size*size, it's white. */
     if (t == 0) {
         *oneColorP = TRUE;
@@ -100,7 +100,7 @@ determineBlackWhiteOrMix(const unsigned char * const image,
 
 
 
-static void 
+static void
 doSquare(bitOut *              const bitOutP,
          const unsigned char * const image,
          unsigned int          const ulCol,
@@ -148,7 +148,7 @@ doSquare(bitOut *              const bitOutP,
         }
     }
 }
-    
+
 
 
 static void
@@ -186,7 +186,7 @@ fiddleBottomEdge(unsigned char * const image,
                  unsigned int    const pw,
                  unsigned int    const ph,
                  bool *          const flippedP) {
-    
+
     unsigned int col;
     unsigned int t;
 
@@ -207,7 +207,6 @@ fiddleBottomEdge(unsigned char * const image,
 
 
 
-
 static void
 fiddleBottomRightCorner(unsigned char * const image,
                         unsigned int    const w,
@@ -218,7 +217,7 @@ fiddleBottomRightCorner(unsigned char * const image,
 
     for (row = h; row < ph; ++row) {
         unsigned int col;
-        
+
         for (col = w; col < pw; ++col)
                     image[row*pw + col] = 1;
     }
@@ -226,7 +225,7 @@ fiddleBottomRightCorner(unsigned char * const image,
 
 
 
-static void 
+static void
 fiddleEdges(unsigned char * const image,
             int             const cols,
             int             const rows) {
@@ -247,9 +246,9 @@ fiddleEdges(unsigned char * const image,
          * So, all we do is flip the runoff area of an edge to white
          * if more than half of the pixels on that edge are
          * white. Then for the bottom-right runoff square (if there is
-         * one), we flip it if we flipped both edges.  
+         * one), we flip it if we flipped both edges.
          */
-        
+
     /* w64 is units-of-64-bits width, h64 same for height */
     unsigned int const w64 = (cols + 63) / 64;
     unsigned int const h64 = (rows + 63) / 64;
@@ -259,28 +258,28 @@ fiddleEdges(unsigned char * const image,
 
     bool flippedRight, flippedBottom;
 
-    if (cols % 64 != 0) 
+    if (cols % 64 != 0)
         fiddleRightEdge(image, cols, rows, pw, &flippedRight);
     else
         flippedRight = FALSE;
 
-    if (rows % 64 != 0) 
+    if (rows % 64 != 0)
         fiddleBottomEdge(image, cols, rows, pw, ph, &flippedBottom);
     else
         flippedBottom = FALSE;
 
-    if (flippedRight && flippedBottom) 
+    if (flippedRight && flippedBottom)
         fiddleBottomRightCorner(image, cols, rows, pw, ph);
 }
 
 
 
 static void
-readPbmImage(FILE *           const ifP, 
+readPbmImage(FILE *           const ifP,
              unsigned char ** const imageP,
              int *            const colsP,
              int *            const rowsP) {
-    
+
 
     /* w64 is units-of-64-bits width, h64 same for height */
     unsigned int w64, h64;
@@ -289,7 +288,7 @@ readPbmImage(FILE *           const ifP,
     int cols, rows, format;
     unsigned int row;
     bit * bitrow;
-    
+
     pbm_readpbminit(ifP, &cols, &rows, &format);
 
     w64 = (cols + 63) / 64;
@@ -302,7 +301,7 @@ readPbmImage(FILE *           const ifP,
     image = calloc(w64*h64*64*64, 1);
     if (image == NULL)
         pm_error("Unable to get memory for raster");
-                 
+
     /* get bytemap image rounded up into mod 64x64 squares */
 
     bitrow = pbm_allocrow(cols);
@@ -324,7 +323,7 @@ readPbmImage(FILE *           const ifP,
 
 
 static void
-outputMrf(FILE *          const ofP, 
+outputMrf(FILE *          const ofP,
           unsigned char * const image,
           unsigned int    const cols,
           unsigned int    const rows) {
@@ -340,7 +339,7 @@ outputMrf(FILE *          const ofP,
     fprintf(ofP, "%c%c%c%c", cols >> 24, cols >> 16, cols >> 8, cols >> 0);
     fprintf(ofP, "%c%c%c%c", rows >> 24, rows >> 16, rows >> 8, rows >> 0);
     fputc(0, ofP);   /* option byte, unused for now */
-    
+
     /* now recursively check squares. */
 
     bit_init(&bitOut, ofP);
@@ -355,18 +354,18 @@ outputMrf(FILE *          const ofP,
 
 
 
-int 
+int
 main(int argc,char *argv[]) {
 
     FILE * ifP;
     FILE * ofP;
     unsigned char *image;
     int rows, cols;
-    
+
     pbm_init(&argc, argv);
 
     if (argc-1 > 1)
-        pm_error("Too many arguments: %d.  Only argument is input file", 
+        pm_error("Too many arguments: %d.  Only argument is input file",
                  argc-1);
 
     if (argc-1 == 1)
@@ -375,7 +374,7 @@ main(int argc,char *argv[]) {
         ifP = stdin;
 
     ofP = stdout;
- 
+
     readPbmImage(ifP, &image, &cols, &rows);
 
     pm_close(ifP);
@@ -395,4 +394,3 @@ main(int argc,char *argv[]) {
 
 
 
-
diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c
index 4604064a..7bf51368 100644
--- a/converter/pbm/pbmtonokia.c
+++ b/converter/pbm/pbmtonokia.c
@@ -168,7 +168,6 @@ validateSize(unsigned int const cols,
 
 
 
-
 static void
 convertToHexNol(bit **       const image,
                 unsigned int const cols,
@@ -236,7 +235,6 @@ convertToHexNgg(bit **       const image,
 
 
 
-
 static void
 convertToHexNpm(bit **       const image,
                 unsigned int const cols,
@@ -337,7 +335,6 @@ convertToNol(bit **       const image,
 
 
 
-
 static void
 convertToNgg(bit **       const image,
              unsigned int const cols,
diff --git a/converter/pbm/pbmtopi3.c b/converter/pbm/pbmtopi3.c
index 791bcb50..35e73ca3 100644
--- a/converter/pbm/pbmtopi3.c
+++ b/converter/pbm/pbmtopi3.c
@@ -67,7 +67,7 @@ main(int argc, const char ** argv) {
     inColByteCt = pbm_packed_bytes(inCols);
 
     bitrow = pbm_allocrow_packed(MAX(outCols, inCols));
-    
+
     /* Add padding to round cols up to 640 */
     for (i = inColByteCt; i < outColByteCt; ++i)
         bitrow[i] = 0x00;
@@ -96,3 +96,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoplot.c b/converter/pbm/pbmtoplot.c
index 8c9075b2..db897bd0 100644
--- a/converter/pbm/pbmtoplot.c
+++ b/converter/pbm/pbmtoplot.c
@@ -30,13 +30,13 @@ main( argc, argv )
     FILE* ifp;
     register bit** bits;
     register int row, col, scol;
-    int	rows, cols;
+    int rows, cols;
 
 
     pbm_init( &argc, argv );
 
     if ( argc > 2 )
-	pm_usage( "[pbmfile]" );
+        pm_usage( "[pbmfile]" );
 
     ifp = (argc == 2) ? pm_openr( argv[1] ) : stdin;
 
@@ -50,27 +50,30 @@ main( argc, argv )
     puttwo( rows - 1 );
     puttwo( cols - 1 );
     for ( row = 0; row < rows; ++row )
-	{
-	for ( col = 0; col < cols; ++col )
-	    {
-	    if ( bits[row][col] == PBM_WHITE )
-		continue;
-	    scol = col;
-	    while ( ++col < cols && bits[row][col] == PBM_BLACK )
-		; /* nothing */
-	    --col;
-	    if ( col == scol )
-		(void) putchar( 'p' );
-	    else
-		{
-		(void) putchar( 'l' );
-		puttwo( scol );
-		puttwo( rows - 1 - row );
-		}
-	    puttwo( col );
-	    puttwo( rows - 1 - row );
-	    }
-	}
+        {
+        for ( col = 0; col < cols; ++col )
+            {
+            if ( bits[row][col] == PBM_WHITE )
+                continue;
+            scol = col;
+            while ( ++col < cols && bits[row][col] == PBM_BLACK )
+                ; /* nothing */
+            --col;
+            if ( col == scol )
+                (void) putchar( 'p' );
+            else
+                {
+                (void) putchar( 'l' );
+                puttwo( scol );
+                puttwo( rows - 1 - row );
+                }
+            puttwo( col );
+            puttwo( rows - 1 - row );
+            }
+        }
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/pbm/pbmtoppa/cutswath.c b/converter/pbm/pbmtoppa/cutswath.c
index d3f15c03..bc7139b9 100644
--- a/converter/pbm/pbmtoppa/cutswath.c
+++ b/converter/pbm/pbmtoppa/cutswath.c
@@ -12,6 +12,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "mallocvar.h"
+#include "pm.h"
+
 #include "ppa.h"
 #include "ppapbm.h"
 #include "cutswath.h"
@@ -20,343 +23,321 @@ extern int Width;
 extern int Height;
 extern int Pwidth;
 
-/* sweep_data->direction must be set already */
-/* Upon successful completion, sweep_data->image_data and
-   sweep_data->nozzle_data have been set to pointers which this routine
-   malloc()'d. */
-/* Upon successful completion, all members of *sweep_data have been set
-   except direction, vertical_pos, and next. */
-/* Returns: 0 if unsuccessful
+
+
+int
+cut_pbm_swath(pbm_stat *       const pbmP,
+              ppa_stat *       const prnP,
+              int              const maxlines,
+              ppa_sweep_data * const sweepDataP) {
+/*----------------------------------------------------------------------------
+   sweepDataP->direction must be set already
+
+   Upon successful completion, sweepDataP->image_data and
+   sweepDataP->nozzle_data have been set to pointers which this routine
+   malloc()'d.
+
+   Upon successful completion, all members of *sweepDataP have been set
+   except direction, vertical_pos, and next.
+
+   Returns: 0 if unsuccessful
             1 if successful, but with non-printing result (end of page)
-            2 if successful, with printing result */
-int 
-cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_data)
-{
-  unsigned char *data, *ppa, *place, *maxplace;
-  int p_width, width8, p_width8;
-  int i, j, left, right, got_nonblank, numlines;
-  int horzpos, hp2;
-  int shift;
-  ppa_nozzle_data nozzles[2];
-
-  ppa = NULL;
-
-  /* shift = 6 if DPI==300  */
-  /* shift = 12 if DPI==600 */ 
-  shift = ( prn->DPI == 300 ? 6:12 ) ;
-  
-  /* safeguard against the user freeing these */
-  sweep_data->image_data  = NULL;
-  sweep_data->nozzle_data = NULL;
-
-  /* read the data from the input file */
-  width8 = (pbm->width + 7) / 8;
- 
-/* 
-  fprintf(stderr,"cutswath(): width=%u\n",pbm->width);
-  fprintf(stderr,"cutswath(): height=%u\n",pbm->height);
-*/
-
-  if ((data=malloc(width8*maxlines)) == NULL)
-  {
-    fprintf(stderr,"cutswath(): could not malloc data storage\n");
-    return 0;
-  }
-
-  /* ignore lines that are above the upper margin */
-  while(pbm->current_line < prn->top_margin)
-    if(!pbm_readline(pbm,data))
-    {
-      fprintf(stderr,"cutswath(): A-could not read top margin\n");
-      free (data); data=NULL;
-      return 0;
+            2 if successful, with printing result
+-----------------------------------------------------------------------------*/
+    int const shift = prnP->DPI == 300 ? 6 : /* DPI=600 */ 12;
+
+    unsigned char *data, *ppa, *place, *maxplace;
+    int pWidth, width8, pWidth8;
+    int i, left, right, gotNonblank, numlines;
+    int horzpos, hp2;
+    ppa_nozzle_data nozzles[2];
+
+    ppa = NULL;
+
+    /* Safeguard against the user freeing these */
+    sweepDataP->image_data  = NULL;
+    sweepDataP->nozzle_data = NULL;
+
+    /* Read the data from the input file */
+    width8 = (pbmP->width + 7) / 8;
+
+    MALLOCARRAY(data, width8 * maxlines);
+    if (!data) {
+        pm_message("could not malloc data storage");
+        return 0;
+    }
+
+    /* Ignore lines that are above the upper margin */
+    while (pbmP->current_line < prnP->top_margin) {
+        if (!pbm_readline(pbmP, data)) {
+            pm_message("could not read top margin");
+            free(data); data=NULL;
+            return 0;
+        }
+    }
+
+    /* Eat all lines that are below the lower margin */
+    if (pbmP->current_line >= Height - prnP->bottom_margin) {
+        while (pbmP->current_line < pbmP->height) {
+            if (!pbm_readline(pbmP, data)) {
+                pm_message("could not clear bottom margin");
+                free(data); data=NULL;
+                return 0;
+            }
+        }
+        free(data); data=NULL;
+        return 1;
     }
 
-  /* eat all lines that are below the lower margin */
-  if(pbm->current_line >= Height - prn->bottom_margin)
-  {
-    while(pbm->current_line < pbm->height)
-      if(!pbm_readline(pbm,data))
-      {
-	fprintf(stderr,"cutswath(): could not clear bottom margin\n");
-	free (data); data=NULL;
-	return 0;
-      }
-    free (data); data=NULL;
-    return 1;
-  }
-
-  left = Pwidth-prn->right_margin/8;
-  right = prn->left_margin/8;
-
-  /* eat all beginning blank lines and then up to maxlines or lower margin */
-  got_nonblank=numlines=0;
-  while( (pbm->current_line < Height-prn->bottom_margin) &&
-	 (numlines < maxlines) )
-  {
-    if(!pbm_readline(pbm,data+width8*numlines))
-    {
-      fprintf(stderr,"cutswath(): B-could not read next line\n");
-      free (data); data=NULL;
-      return 0;
+    left  = Pwidth - prnP->right_margin / 8;
+    right = prnP->left_margin / 8;
+
+    /* Eat all beginning blank lines and then up to maxlines or lower margin */
+    gotNonblank = numlines = 0;
+    while ((pbmP->current_line < Height-prnP->bottom_margin) &&
+           (numlines < maxlines)) {
+        if (!pbm_readline(pbmP, data + width8 * numlines)) {
+            pm_message("could not read next line");
+            free(data); data=NULL;
+            return 0;
+        }
+        if (!gotNonblank) {
+            unsigned int j;
+            for (j = prnP->left_margin / 8; j < left; ++j) {
+                if (data[j]) {
+                  left = j;
+                  gotNonblank=1;
+                  break;
+                }
+            }
+        }
+        if (gotNonblank) {
+            int newleft, newright;
+            unsigned int i;
+
+            /* Find left-most nonblank */
+            for (i = prnP->left_margin / 8, newleft = left; i < left; ++i) {
+                if (data[width8 * numlines + i]) {
+                    newleft = i;
+                    break;
+                }
+            }
+            /* Find right-most nonblank */
+            for (i = Pwidth - prnP->right_margin / 8 - 1, newright = right;
+                 i >= right;
+                 --i) {
+              if (data[width8 * numlines + i]) {
+                  newright = i;
+                  break;
+              }
+            }
+            ++numlines;
+
+            if (newright < newleft) {
+                pm_message("Ack! newleft=%d, newright=%d, left=%d, right=%d",
+                           newleft, newright, left, right);
+                free(data); data=NULL;
+                return 0;
+            }
+
+            /* If the next line might push us over the buffer size, stop here!
+               ignore this test for the 720 right now.  Will add better
+               size-guessing for compressed data in the near future!
+            */
+            if (numlines % 2 == 1 && prnP->version != HP720) {
+                int l = newleft;
+                int r = newright;
+                int w;
+
+                --l;
+                r += 2;
+                l *= 8;
+                r *= 8;
+                w = r-l;
+                w = (w + 7) / 8;
+
+                if ((w + 2 * shift) * numlines > prnP->bufsize) {
+                    --numlines;
+                    pbm_unreadline(pbmP, data + width8 * numlines);
+                    break;
+                } else {
+                    left  = newleft;
+                    right = newright;
+                }
+            } else {
+                left  = newleft;
+                right = newright;
+            }
+        }
     }
-    if(!got_nonblank)
-      for(j=prn->left_margin/8; j<left; j++)
-	if(data[j])
-	{
-	  left = j;
-	  got_nonblank=1;
-	  break;
-	}
-    if(got_nonblank)
-      {
-	int newleft = left, newright = right;
-
-	/* find left-most nonblank */
-	for (i = prn->left_margin/8; i < left; i++)
-	  if (data[width8*numlines+i])
-	    {
-	      newleft = i;
-	      break;
-	    }
-	/* find right-most nonblank */
-	for (i = Pwidth-prn->right_margin/8-1; i >= right; i--)
-	  if (data[width8*numlines+i])
-	    {
-	      newright = i;
-	      break;
-	    }
-	numlines++;
-
-	if (newright < newleft)
-	  {
-	    fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n",
-		     newleft, newright, left, right);
-	    free (data); data=NULL;
-	    return 0;
-	  }
-
-	/* if the next line might push us over the buffer size, stop here! */
-	/* ignore this test for the 720 right now.  Will add better */
-	/* size-guessing for compressed data in the near future! */
-	if (numlines % 2 == 1 && prn->version != HP720)
-	  {
-	    int l = newleft, r = newright, w;
-	    
-	    l--;
-	    r+=2;
-	    l*=8;
-	    r*=8;
-	    w = r-l;
-	    w = (w+7)/8;
-	    
-	    if ((w+2*shift)*numlines > prn->bufsize)
-	      {
-		numlines--;
-		pbm_unreadline (pbm, data+width8*numlines);
-		break;
-	      }
-	    else
-	      {
-		left = newleft;
-		right = newright;
-	      }
-	  }
-	else
-	  {
-	    left = newleft;
-	    right = newright;
-	  }
-      }
-  }
-
-  if(!got_nonblank)
-  {
-    /* eat all lines that are below the lower margin */
-    if(pbm->current_line >= Height - prn->bottom_margin)
-    {
-      while(pbm->current_line < pbm->height)
-	if(!pbm_readline(pbm,data))
-	{
-	  fprintf(stderr,"cutswath(): could not clear bottom margin\n");
-	  free (data); data=NULL;
-	  return 0;
-	}
-      free (data); data=NULL;
-      return 1;
+
+    if (!gotNonblank) {
+        /* Eat all lines that are below the lower margin */
+        if (pbmP->current_line >= Height - prnP->bottom_margin) {
+            while (pbmP->current_line < pbmP->height) {
+                if (!pbm_readline(pbmP, data)) {
+                    pm_message("could not clear bottom margin");
+                    free(data); data = NULL;
+                    return 0;
+                }
+            }
+            free(data); data = NULL;
+            return 1;
+        }
+        free(data); data = NULL;
+        return 0; /* error, since didn't get to lower margin, yet blank */
     }
-    free (data); data=NULL;
-    return 0; /* error, since didn't get to lower margin, yet blank */
-  }
-
-  /* make sure numlines is even and >= 2 (b/c we have to pass the printer 
-     HALF of the number of pins used */
-  if (numlines == 1)
-    {
-      /* there's no way that we only have 1 line and not enough memory, so
-	 we're safe to increase numlines here.  Also, the bottom margin should
-	 be > 0 so we have some lines to read */
-      if(!pbm_readline(pbm,data+width8*numlines))
-	{
-	  fprintf(stderr,"cutswath(): C-could not read next line\n");
-	  free (data); data=NULL;
-	  return 0;
-	}
-      numlines++;
+
+    /* Make sure numlines is even and >= 2 (b/c we have to pass the printer
+       HALF of the number of pins used
+    */
+    if (numlines == 1) {
+        /* There's no way that we only have 1 line and not enough memory, so
+           we're safe to increase numlines here.  Also, the bottom margin
+           should be > 0 so we have some lines to read
+        */
+        if (!pbm_readline(pbmP, data + width8 * numlines)) {
+            pm_message("could not read next line");
+            free(data); data = NULL;
+            return 0;
+        }
+        ++numlines;
     }
-  if (numlines % 2 == 1)
-    {
-      /* decrease instead of increasing so we don't max out the buffer */
-      numlines--;
-      pbm_unreadline (pbm, data+width8*numlines);
+    if (numlines % 2 == 1) {
+      /* Decrease instead of increasing so we don't max out the buffer */
+        --numlines;
+        pbm_unreadline(pbmP, data + width8 * numlines);
     }
 
-  /* calculate vertical position */
-  sweep_data->vertical_pos = pbm->current_line;
+    sweepDataP->vertical_pos = pbmP->current_line;
 
-  /* change sweep params */
-  left--;
-  right+=2;
-  left *= 8;
-  right *= 8;
+    /* Change sweep params */
+    left  -= 1;
+    right += 2;
+    left  *= 8;
+    right *= 8;
 
-  /* construct the sweep data */
-  p_width = right - left;
-  p_width8 = (p_width + 7) / 8;
+    /* Construct the sweep data */
+    pWidth = right - left;
+    pWidth8 = (pWidth + 7) / 8;
 
-  if ((ppa = malloc ((p_width8+2*shift) * numlines)) == NULL)
-    {
-      fprintf(stderr,"cutswath(): could not malloc ppa storage\n");
-      free (data); data=NULL;
-      return 0;
+    MALLOCARRAY(ppa, (pWidth8 + 2 * shift) * numlines);
+    if (!ppa) {
+        pm_message("could not malloc ppa storage");
+        free(data); data = NULL;
+        return 0;
     }
 
-  place = ppa;
-
-  /* place 0's in the first 12 columns */
-  memset (place, 0, numlines/2 * shift);
-  place += numlines/2 * shift;
-
-
-  if(sweep_data->direction == right_to_left)  /* right-to-left */
-  {
-    for (i = p_width8+shift-1; i >= 0; i--)
-    {
-      if (i >= shift)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[j*2*width8 + i + left/8-shift];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-
-      if (i < p_width8)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[(j*2+1)*width8 + i + left/8];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-    }
-  }
-  else /* sweep_data->direction == left_to_right */
-  {
-    for (i = 0; i < p_width8+shift; i++)
-    {
-      if (i < p_width8)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[(j*2+1)*width8 + i + left/8];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
-
-      if (i >= shift)
-      {
-	for (j = 0; j < numlines/2; j++)
-	  *place++ = data[j*2*width8 + i + left/8 - shift];
-      }
-      else
-      {
-	memset (place, 0, numlines/2);
-	place += numlines/2;
-      }
+    place = ppa;
+
+    /* Place 0's in the first 12 columns */
+    memset(place, 0, numlines/2 * shift);
+    place += numlines/2 * shift;
+
+    if (sweepDataP->direction == right_to_left) { /* right-to-left */
+        int i;
+
+        for (i = pWidth8 + shift - 1; i >= 0; --i) {
+            if (i >= shift) {
+                unsigned int j;
+
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[j * 2 * width8 + i + left / 8 - shift];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+
+            if (i < pWidth8) {
+                unsigned int j;
+
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[(j * 2 + 1) * width8 + i + left / 8];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+        }
+    } else {
+        /* sweep_data->direction == left_to_right */
+        unsigned int i;
+        for (i = 0; i < pWidth8 + shift; ++i) {
+            if (i < pWidth8) {
+                unsigned int j;
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[(j * 2 + 1) * width8 + i + left / 8];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+
+            if (i >= shift) {
+                unsigned int j;
+                for (j = 0; j < numlines/2; ++j)
+                    *place++ = data[j * 2 * width8 + i + left / 8 - shift];
+            } else {
+                memset(place, 0, numlines/2);
+                place += numlines/2;
+            }
+        }
     }
-  }
-
-  /* done with data */
-  free (data); data=NULL;
-
-  /* place 0's in the last 12 columns */
-  memset (place, 0, numlines/2 * shift);
-  place += numlines/2 * shift;
-  maxplace = place;
-
-  /* create sweep data */
-  sweep_data->image_data = ppa;
-  sweep_data->data_size = maxplace-ppa;
-  sweep_data->in_color = False;
-
-  /*
-  horzpos = left*600/prn->DPI + (sweep_data->direction==left_to_right ? 0*600/prn->DPI : 0);
-  */
-  horzpos = left * 600/prn->DPI;
-
-  hp2 = horzpos + ( p_width8 + 2*shift )*8 * 600/prn->DPI;
-  
- 
-  sweep_data->left_margin = horzpos;
-  sweep_data->right_margin = hp2 + prn->marg_diff;
-
-  
-  for (i = 0; i < 2; i++)
-  {
-    nozzles[i].DPI = prn->DPI;
-        
-    nozzles[i].pins_used_d2 = numlines/2;
-    nozzles[i].unused_pins_p1 = 301-numlines;
-    nozzles[i].first_pin = 1;
-    if (i == 0)
-    {
-      nozzles[i].left_margin = horzpos + prn->marg_diff;
-      nozzles[i].right_margin = hp2 + prn->marg_diff;
-      if(sweep_data->direction == right_to_left)
-       /* 0 */
-	nozzles[i].nozzle_delay=prn->right_to_left_delay[0];
-      else
-       /* 6 */
-	nozzles[i].nozzle_delay=prn->left_to_right_delay[0];
-    }
-    else
-    {
-      nozzles[i].left_margin = horzpos;
-      nozzles[i].right_margin = hp2;
-      if(sweep_data->direction == right_to_left)
-       /* 2 */
-	nozzles[i].nozzle_delay=prn->right_to_left_delay[1];
-      else
-       /* 0 */
-	nozzles[i].nozzle_delay=prn->left_to_right_delay[1];
 
+    /* Done with data */
+    free(data); data=NULL;
+
+    /* Place 0's in the last 12 columns */
+    memset(place, 0, numlines/2 * shift);
+    place += numlines/2 * shift;
+    maxplace = place;
+
+    /* Create sweep data */
+    sweepDataP->image_data = ppa;
+    sweepDataP->data_size  = maxplace-ppa;
+    sweepDataP->in_color   = False;
+
+    /*
+      horzpos = left*600/prn->DPI + (sweep_data->direction==left_to_right ? 0*600/prn->DPI : 0);
+    */
+    horzpos = left * 600 / prnP->DPI;
+
+    hp2 = horzpos + (pWidth8 + 2 * shift) * 8 * 600 /prnP->DPI;
+
+    sweepDataP->left_margin  = horzpos;
+    sweepDataP->right_margin = hp2 + prnP->marg_diff;
+
+    for (i = 0; i < 2; ++i) {
+        nozzles[i].DPI = prnP->DPI;
+
+        nozzles[i].pins_used_d2 = numlines/2;
+        nozzles[i].unused_pins_p1 = 301 - numlines;
+        nozzles[i].first_pin = 1;
+
+        if (i == 0) {
+            nozzles[i].left_margin  = horzpos + prnP->marg_diff;
+            nozzles[i].right_margin = hp2 + prnP->marg_diff;
+            if (sweepDataP->direction == right_to_left)  /* 0 */
+
+                nozzles[i].nozzle_delay = prnP->right_to_left_delay[0];
+            else  /* 6 */
+                nozzles[i].nozzle_delay = prnP->left_to_right_delay[0];
+        } else {
+            nozzles[i].left_margin  = horzpos;
+            nozzles[i].right_margin = hp2;
+
+            if (sweepDataP->direction == right_to_left)  /* 2 */
+                nozzles[i].nozzle_delay = prnP->right_to_left_delay[1];
+            else  /* 0 */
+                nozzles[i].nozzle_delay = prnP->left_to_right_delay[1];
+        }
     }
-  }
 
-  sweep_data->nozzle_data_size = 2;
-  sweep_data->nozzle_data = malloc(sizeof(nozzles));
-  if(sweep_data->nozzle_data == NULL)
-    return 0;
-  memcpy(sweep_data->nozzle_data,nozzles,sizeof(nozzles));
+    sweepDataP->nozzle_data_size = 2;
+    MALLOCARRAY_NOFAIL(sweepDataP->nozzle_data, 2);
+    sweepDataP->nozzle_data[0] = nozzles[0];
+    sweepDataP->nozzle_data[1] = nozzles[1];
 
-  return 2;
+    return 2;
 }
 
 
+
diff --git a/converter/pbm/pbmtoppa/cutswath.h b/converter/pbm/pbmtoppa/cutswath.h
index 430558de..347510cf 100644
--- a/converter/pbm/pbmtoppa/cutswath.h
+++ b/converter/pbm/pbmtoppa/cutswath.h
@@ -1,4 +1,4 @@
-int 
+int
 cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,
               ppa_sweep_data* sweep_data);
 
diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
index ae36e0d2..403ca95c 100644
--- a/converter/pbm/pbmtoppa/pbm.c
+++ b/converter/pbm/pbmtoppa/pbm.c
@@ -15,8 +15,11 @@
 
 #include "pm.h"
 #include "nstring.h"
+
 #include "ppapbm.h"
 
+
+
 int
 make_pbm_stat(pbm_stat * const pbmStatP,
               FILE *     const ifP) {
@@ -61,15 +64,15 @@ make_pbm_stat(pbm_stat * const pbmStatP,
                     if (pbmStatP->width < 0) {
                         pm_message("Image has negative width");
                         retval = 0;
-                    } else if (pbmStatP->width > INT_MAX/2) {
-                        pm_message("Uncomputeably large width: %d",
+                    } else if (pbmStatP->width > INT_MAX/2 - 10) {
+                        pm_message("Uncomputably large width: %d",
                                    pbmStatP->width);
                         retval = 0;
                     } else if (pbmStatP->height < 0) {
                         pm_message("Image has negative height");
                         retval = 0;
-                    } else if (pbmStatP->height > INT_MAX/2) {
-                        pm_message("Uncomputeably large height: %d",
+                    } else if (pbmStatP->height > INT_MAX/2 - 10) {
+                        pm_message("Uncomputably large height: %d",
                                    pbmStatP->height);
                         retval = 0;
                     } else
@@ -193,3 +196,4 @@ pbm_unreadline(pbm_stat * const pbmStatP,
 }
 
 
+
diff --git a/converter/pbm/pbmtoppa/ppa.c b/converter/pbm/pbmtoppa/ppa.c
index 69e7bb79..0f75aa1e 100644
--- a/converter/pbm/pbmtoppa/ppa.c
+++ b/converter/pbm/pbmtoppa/ppa.c
@@ -31,7 +31,7 @@
   (*): responses, autostatus, and pacing are communicated from the printer to
        the computer, and may be safely ignored.
 */
-static void 
+static void
 vlink_put(FILE *fptr, int channel, int length, void *data)
 {
   fputc ('$', fptr);
@@ -40,6 +40,8 @@ vlink_put(FILE *fptr, int channel, int length, void *data)
   fwrite (data, length, 1, fptr);
 }
 
+
+
 /*
   SCP packet structure:
 
@@ -60,9 +62,9 @@ vlink_put(FILE *fptr, int channel, int length, void *data)
        19       1     Handle Media
        18       1     Print Sweep
 */
-static void 
+static void
 scp_put(FILE *fptr, int comspec, int comref, int priority,
-	     int length, void *data)
+             int length, void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -79,6 +81,7 @@ scp_put(FILE *fptr, int comspec, int comref, int priority,
 }
 
 
+
 /*
   SCP2 packet structure:
 
@@ -101,10 +104,10 @@ scp_put(FILE *fptr, int comspec, int comref, int priority,
      0x181      1     Handle Media
      0x180      1     Print Sweep
 */
-static void 
+static void
 scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
-	      unsigned char priority,unsigned short comref,unsigned data_len,
-	      void *data)
+              unsigned char priority,unsigned short comref,unsigned data_len,
+              void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -128,6 +131,7 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
 }
 
 
+
 /*
   SCP3 packet structure:
 
@@ -152,10 +156,10 @@ scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
      0x181      1     Handle Media
      0x180      1     Print Sweep
 */
-static void 
+static void
 scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
-	      unsigned char priority,unsigned short comref,unsigned data_len,
-	      void *data)
+              unsigned char priority,unsigned short comref,unsigned data_len,
+              void *data)
 {
   /* encapsulate the vlink_put call in here, to avoid a memcpy */
   fputc ('$', fptr);
@@ -179,6 +183,7 @@ scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16,
 }
 
 
+
 void ppa_init_job(ppa_stat* prn)
 {
   unsigned char init1[8] = { 0x00, 0x00, 0x01, 0xf4, 0x01, 0x00, 0x00, 0x00 };
@@ -211,6 +216,8 @@ void ppa_init_job(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_end_print(ppa_stat* prn)
 {
   unsigned char pageA[4] = { 0x05, 0x01, 0x03, 0x84 };
@@ -219,12 +226,14 @@ void ppa_end_print(ppa_stat* prn)
     scp3_put (prn->fptr, 0x0181, sizeof(pageA), 7, 2, 0, pageA);
 }
 
+
+
 void ppa_init_page(ppa_stat* prn)
 {
   unsigned char pageA[16] = {0x28, 0x2d, 0x00, 0x41, 0x29, 0x2e, 0x00, 0x42,
-			     0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 };
+                             0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 };
   unsigned char pageB[16] = {0x28, 0x2d, 0x00, 0x41, 0x2d, 0x32, 0x00, 0x46,
-			     0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 };
+                             0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 };
 
   switch(prn->version)
   {
@@ -242,6 +251,8 @@ void ppa_init_page(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_load_page(ppa_stat* prn)
 {
   unsigned char loadA[4] = {0x01, 0x01, 0x09, 0x60 };
@@ -264,6 +275,8 @@ void ppa_load_page(ppa_stat* prn)
   }
 }
 
+
+
 void ppa_eject_page(ppa_stat* prn)
 {
   unsigned char loadA[4] = {0x02, 0x01, 0x09, 0x60 };
@@ -288,8 +301,8 @@ void ppa_eject_page(ppa_stat* prn)
 
 
 
-static int 
-compress(unsigned char *in, int num_lines_d2, int final_len, 
+static int
+compress(unsigned char *in, int num_lines_d2, int final_len,
              unsigned char *iout)
 {
   unsigned char* out = iout;
@@ -301,89 +314,91 @@ compress(unsigned char *in, int num_lines_d2, int final_len,
       /* Find the size of duplicate values */
       int dup_len = 0;
       while ((i + dup_len < len)
-	     && (in[i + dup_len] == in[i])) {
-	dup_len++;
+             && (in[i + dup_len] == in[i])) {
+        dup_len++;
       }
       /* See if we have enough zeros to be worth compressing. */
       /* I figure one is enough. */
       if ((dup_len >= 1) && (in[i] == 0)) {
-	/* Output run of zeros. */
-	while (dup_len >= 128) {
-	  /* Max is 128 */
-	  *out++ = 0x00;
-	  i += 128;
-	  dup_len -= 128;
-	}
-	if (dup_len >= 1)
-	{
-	  *out++ = dup_len;
-	  i += dup_len;
-	}
-	/* See if we have enough non-zeros to be worth compressing. */
-	/* Here two should be enough. */
+        /* Output run of zeros. */
+        while (dup_len >= 128) {
+          /* Max is 128 */
+          *out++ = 0x00;
+          i += 128;
+          dup_len -= 128;
+        }
+        if (dup_len >= 1)
+        {
+          *out++ = dup_len;
+          i += dup_len;
+        }
+        /* See if we have enough non-zeros to be worth compressing. */
+        /* Here two should be enough. */
       }
       else if (dup_len >= 2)
       {
-	/* Output run of duplicates. */
-	while (dup_len >= 64) {
-	  /* Max is 64 */
-	  *out++ = 0x80;
-	  *out++ = in[i];
-	  i += 64;
-	  dup_len -= 64;
-	}
-	if (dup_len >= 2)
-	{
-	  *out++ = dup_len + 0x80;
-	  *out++ = in[i];
-	  i += dup_len;
-	}
+        /* Output run of duplicates. */
+        while (dup_len >= 64) {
+          /* Max is 64 */
+          *out++ = 0x80;
+          *out++ = in[i];
+          i += 64;
+          dup_len -= 64;
+        }
+        if (dup_len >= 2)
+        {
+          *out++ = dup_len + 0x80;
+          *out++ = in[i];
+          i += dup_len;
+        }
       }
       else
       {
-	/* Look for two zeros, or three duplicates to end literal run. */
-	/* Note this is one more than the number to start a run. */
-	int lit_len = -1;
-	int add_more = 1;
-	while (add_more) {
-	  lit_len++;
-	  if (i + lit_len == len) add_more = 0;
-	  /* Always add more if we are near the very end. */
-	  if (i + lit_len < len - 3) {
-	    char a = in[i + lit_len + 0];
-	    char b = in[i + lit_len + 1];
-	    char c = in[i + lit_len + 2];
-	    /* See if there are enough zeros */
-	    if ((a == b) && (b == 0)) add_more = 0;
-	    /* See if there are enough duplicates */
-	    if ((a == b) && (b == c)) add_more = 0;
-	  }
-	}
-	/* Output run of literals. */
-	while (lit_len >= 64) {
-	  /* Max is 64 */
-	  int j;
-	  *out++ = 0xc0;
-	  for (j = i; j < i + 64; j++) {
-	    *out++ = in[j];
-	  }
-	  i += 64;
-	  lit_len -= 64;
-	} 
-	if (lit_len) {
-	  int j;
-	  *out++ = lit_len + 0xc0;
-	  for (j = i; j < i + lit_len; j++) {
-	    *out++ = in[j];
-	  }
-	  i += lit_len;
-	}
+        /* Look for two zeros, or three duplicates to end literal run. */
+        /* Note this is one more than the number to start a run. */
+        int lit_len = -1;
+        int add_more = 1;
+        while (add_more) {
+          lit_len++;
+          if (i + lit_len == len) add_more = 0;
+          /* Always add more if we are near the very end. */
+          if (i + lit_len < len - 3) {
+            char a = in[i + lit_len + 0];
+            char b = in[i + lit_len + 1];
+            char c = in[i + lit_len + 2];
+            /* See if there are enough zeros */
+            if ((a == b) && (b == 0)) add_more = 0;
+            /* See if there are enough duplicates */
+            if ((a == b) && (b == c)) add_more = 0;
+          }
+        }
+        /* Output run of literals. */
+        while (lit_len >= 64) {
+          /* Max is 64 */
+          int j;
+          *out++ = 0xc0;
+          for (j = i; j < i + 64; j++) {
+            *out++ = in[j];
+          }
+          i += 64;
+          lit_len -= 64;
+        }
+        if (lit_len) {
+          int j;
+          *out++ = lit_len + 0xc0;
+          for (j = i; j < i + lit_len; j++) {
+            *out++ = in[j];
+          }
+          i += lit_len;
+        }
       }
     }
   }
   return out-iout;
 }
 
+
+
 static void __inline__ place_2bytes(int x,unsigned char* y)
 { y[0]=x>>8; y[1]=x; }
 static void __inline__ place_4bytes(int x,unsigned char* y)
@@ -519,9 +534,13 @@ void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data)
 }
 
 
+
 void ppa_print_sweeps(ppa_stat* prn,ppa_sweep_data* data)
 {
   ppa_sweep_data* current_sweep;
   for(current_sweep=data; current_sweep; current_sweep=current_sweep->next)
     ppa_print_sweep(prn,current_sweep);
 }
+
+
+
diff --git a/converter/pbm/pbmtoppa/ppa.h b/converter/pbm/pbmtoppa/ppa.h
index 1c7e6f18..cfa18c11 100644
--- a/converter/pbm/pbmtoppa/ppa.h
+++ b/converter/pbm/pbmtoppa/ppa.h
@@ -32,7 +32,7 @@ typedef struct
 } ppa_stat;
 
 typedef struct
-{ 
+{
   int DPI;
   int right;
   int left;
diff --git a/converter/pbm/pbmtoppa/ppapbm.h b/converter/pbm/pbmtoppa/ppapbm.h
index 1ffc093b..10ef4233 100644
--- a/converter/pbm/pbmtoppa/ppapbm.h
+++ b/converter/pbm/pbmtoppa/ppapbm.h
@@ -22,7 +22,7 @@ typedef struct
 } pbm_stat;
 
 int make_pbm_stat(pbm_stat*,FILE*);
-int pbm_readline(pbm_stat*,unsigned char*); 
+int pbm_readline(pbm_stat*,unsigned char*);
   /* reads a single line into char* */
 void pbm_unreadline(pbm_stat*,void*); /* pushes a single line back */
 
diff --git a/converter/pbm/pbmtopsg3.c b/converter/pbm/pbmtopsg3.c
index 8163b70a..c3bb636d 100644
--- a/converter/pbm/pbmtopsg3.c
+++ b/converter/pbm/pbmtopsg3.c
@@ -1,20 +1,20 @@
 /* pbmtopsg3
 
    Reads a series of PBM images and writes a Postscript program
-   containing these images as individual pages with Fax-G3 
+   containing these images as individual pages with Fax-G3
    (CCITT-Fiter) compression. (Useful for combining scanned pages into
    a comfortably printable document.)
 
-   Copyright (C) 2001 Kristof Koehler 
+   Copyright (C) 2001 Kristof Koehler
        <kristof@fachschaft.physik.uni-karlsruhe.de>
 
    Netpbm adaptation by Bryan Henderson June 2001.
- 
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
- 
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -55,7 +55,7 @@ parseCommandLine(int argc, char ** argv,
 
     OPTENT3(0, "dpi",      OPT_FLOAT,  &dpiOpt,   &dpiSpec,   0);
     OPTENT3(0, "title",    OPT_STRING, &titleOpt, &titleSpec, 0);
-    
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;
     opt.allowNegNum = FALSE;
@@ -75,67 +75,71 @@ parseCommandLine(int argc, char ** argv,
     cmdlineP->title = titleSpec ? titleOpt : NULL;
 }
 
-    
 
-static void 
+
+static void
 write85 ( unsigned int bits, int *col )
 {
-	char buf[5] ;
-	if ( bits == 0 ) {
-		fputc ( 'z', stdout ) ;
-		*col += 1 ;
-	} else {
-		buf[4] = bits % 85 + '!' ;
-		bits /= 85 ;
-		buf[3] = bits % 85 + '!' ;
-		bits /= 85 ;
-		buf[2] = bits % 85 + '!' ;
-		bits /= 85 ;
-		buf[1] = bits % 85 + '!' ;
-		bits /= 85 ;
-		buf[0] = bits % 85 + '!' ;
-		fwrite ( buf, 1, 5, stdout ) ;
-		*col += 5 ;
-	}
-	if ( *col > 70 ) {
-		printf ( "\n" ) ;
-		*col = 0 ;
-	}
+        char buf[5] ;
+        if ( bits == 0 ) {
+                fputc ( 'z', stdout ) ;
+                *col += 1 ;
+        } else {
+                buf[4] = bits % 85 + '!' ;
+                bits /= 85 ;
+                buf[3] = bits % 85 + '!' ;
+                bits /= 85 ;
+                buf[2] = bits % 85 + '!' ;
+                bits /= 85 ;
+                buf[1] = bits % 85 + '!' ;
+                bits /= 85 ;
+                buf[0] = bits % 85 + '!' ;
+                fwrite ( buf, 1, 5, stdout ) ;
+                *col += 5 ;
+        }
+        if ( *col > 70 ) {
+                printf ( "\n" ) ;
+                *col = 0 ;
+        }
 }
 
 
-static void 
+
+static void
 writebits ( unsigned int *outbits, int *outbitsidx, int *col,
             unsigned int bits, int n )
 {
-	int k, m ;
-	unsigned int usedbits ;
-	while ( n > 0 ) {
-		if ( *outbitsidx == 0 )
-			*outbits = 0 ;
-		k = 32 - *outbitsidx ;
-		m = n > k ? k : n ;
-		usedbits = (bits >> (n-m)) & ((1<<m)-1) ;
-		*outbits |= usedbits << (k-m) ;
-		*outbitsidx += m ;
-		n -= m ;
-		if ( *outbitsidx == 32 ) {
-			write85 ( *outbits, col ) ;
-			*outbitsidx = 0 ;
-		}
-	}
+        int k, m ;
+        unsigned int usedbits ;
+        while ( n > 0 ) {
+                if ( *outbitsidx == 0 )
+                        *outbits = 0 ;
+                k = 32 - *outbitsidx ;
+                m = n > k ? k : n ;
+                usedbits = (bits >> (n-m)) & ((1<<m)-1) ;
+                *outbits |= usedbits << (k-m) ;
+                *outbitsidx += m ;
+                n -= m ;
+                if ( *outbitsidx == 32 ) {
+                        write85 ( *outbits, col ) ;
+                        *outbitsidx = 0 ;
+                }
+        }
 }
 
 
-static void 
+
+static void
 flushbits ( unsigned int *outbits, int *outbitsidx, int *col )
 {
-	if ( *outbitsidx > 0 ) {
-		write85 ( *outbits, col ) ;
-		*outbitsidx = 0 ;
-	}
+        if ( *outbitsidx > 0 ) {
+                write85 ( *outbits, col ) ;
+                *outbitsidx = 0 ;
+        }
 }
 
+
+
 struct { unsigned int b, l ; } makeup[40][2] = {
     { { 0x001b, 5 } /*         11011 */ , { 0x000f,10 } /*    0000001111 */  },
     { { 0x0012, 5 } /*         10010 */ , { 0x00c8,12 } /*  000011001000 */  },
@@ -243,7 +247,7 @@ struct { unsigned int b, l ; } term[64][2] = {
     { { 0x004b, 8 } /*      01001011 */ , { 0x002c,12 } /*  000000101100 */  },
     { { 0x0032, 8 } /*      00110010 */ , { 0x005a,12 } /*  000001011010 */  },
     { { 0x0033, 8 } /*      00110011 */ , { 0x0066,12 } /*  000001100110 */  },
-    { { 0x0034, 8 } /*      00110100 */ , { 0x0067,12 } /*  000001100111 */  } 
+    { { 0x0034, 8 } /*      00110100 */ , { 0x0067,12 } /*  000001100111 */  }
 } ;
 
 
@@ -251,16 +255,16 @@ static void
 writelength ( unsigned int *outbits, int *outbitsidx, int *col,
               int bit, int length )
 {
-	while ( length >= 64 ) {
-		int m = length / 64 ;
-		if ( m > 40 )
-			m = 40 ;
-		writebits ( outbits, outbitsidx, col,
-			    makeup[m-1][bit].b, makeup[m-1][bit].l ) ;
-		length -= 64*m ;
-	}
-	writebits ( outbits, outbitsidx, col,
-		    term[length][bit].b, term[length][bit].l ) ;
+        while ( length >= 64 ) {
+                int m = length / 64 ;
+                if ( m > 40 )
+                        m = 40 ;
+                writebits ( outbits, outbitsidx, col,
+                            makeup[m-1][bit].b, makeup[m-1][bit].l ) ;
+                length -= 64*m ;
+        }
+        writebits ( outbits, outbitsidx, col,
+                    term[length][bit].b, term[length][bit].l ) ;
 }
 
 
@@ -277,9 +281,9 @@ doPage(FILE *       const ifP,
     int outbitsidx, col ;
 
     pbm_readpbminit(ifP, &cols, &rows, &format);
-        
+
     bitrow = pbm_allocrow(cols);
-        
+
     pm_message("[%u]\n", pageNum);
 
     printf ("%%%%Page: %u %u\n", pageNum, pageNum);
@@ -288,16 +292,16 @@ doPage(FILE *       const ifP,
             "  << /Columns %u /Rows %u /EndOfBlock false >> "
                 "/CCITTFaxDecode filter\n"
             "  image } exec\n",
-            cols, rows, dpi/72.0, -dpi/72.0, rows, 
+            cols, rows, dpi/72.0, -dpi/72.0, rows,
             cols, rows) ;
-        
+
     outbitsidx = col = 0 ;
     for (row = 0 ; row < rows; ++row) {
         int lastbit, cnt ;
         unsigned int j;
 
         pbm_readpbmrow(ifP, bitrow, cols, format);
-            
+
         lastbit = cnt = 0 ;
         for (j = 0; j < cols; ++j) {
             if (bitrow[j] != lastbit) {
@@ -309,7 +313,7 @@ doPage(FILE *       const ifP,
         }
         writelength(&outbits, &outbitsidx, &col, lastbit, cnt);
     }
-        
+
     flushbits(&outbits, &outbitsidx, &col) ;
     printf("~>\nshowpage\n") ;
 
@@ -318,7 +322,7 @@ doPage(FILE *       const ifP,
 
 
 
-static void 
+static void
 doPages(FILE *         const ifP,
         unsigned int * const pagesP,
         double         const dpi) {
@@ -345,7 +349,7 @@ main(int    argc,
 
     FILE *ifP;
     unsigned int pages;
-    
+
     struct cmdline_info cmdline;
 
     pbm_init(&argc, argv);
@@ -360,7 +364,7 @@ main(int    argc,
     printf ("%%%%Creator: pbmtopsg3, Copyright (C) 2001 Kristof Koehler\n"
             "%%%%Pages: (atend)\n"
             "%%%%EndComments\n") ;
-    
+
     doPages(ifP, &pages, cmdline.dpi);
 
     printf ("%%%%Trailer\n"
@@ -370,6 +374,9 @@ main(int    argc,
 
     pm_close(ifP);
     pm_close(stdout);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pbmtoptx.c b/converter/pbm/pbmtoptx.c
index 69f1707a..b9d4b756 100644
--- a/converter/pbm/pbmtoptx.c
+++ b/converter/pbm/pbmtoptx.c
@@ -87,3 +87,4 @@ main(int argc, const char ** argv)  {
 }
 
 
+
diff --git a/converter/pbm/pbmtosunicon.c b/converter/pbm/pbmtosunicon.c
index 95deab7c..af5cff91 100644
--- a/converter/pbm/pbmtosunicon.c
+++ b/converter/pbm/pbmtosunicon.c
@@ -42,7 +42,7 @@ putitem(uint16_t const item) {
     if (ip.itemCnt == 8 ) {
         /* Buffer is full.  Write out one line. */
         int rc;
-    
+
         rc = fprintf(ip.putFp,
                      "\t0x%04x,0x%04x,0x%04x,0x%04x,"
                      "0x%04x,0x%04x,0x%04x,0x%04x,\n",
@@ -50,9 +50,9 @@ putitem(uint16_t const item) {
                      ip.itemBuff[2], ip.itemBuff[3],
                      ip.itemBuff[4], ip.itemBuff[5],
                      ip.itemBuff[6], ip.itemBuff[7]);
-        if (rc < 0)        
+        if (rc < 0)
            pm_error("fprintf() failed to write Icon bitmap");
-           
+
         ip.itemCnt = 0;
     }
     ip.itemBuff[ip.itemCnt++] = item & 0xffff;
@@ -71,10 +71,10 @@ putterm(void) {
         rc = fprintf(ip.putFp, "%s0x%04x%c", i == 0  ? "\t" : "",
                      ip.itemBuff[i],
                      i == ip.itemCnt - 1 ? '\n' : ',');
-        if (rc < 0)        
+        if (rc < 0)
             pm_error("fprintf() failed to write Icon bitmap");
     }
-}     
+}
 
 
 
@@ -89,7 +89,7 @@ writeIconHeader(FILE *       const ofP,
                  "/* Format_version=1, Width=%u, Height=%u", width, height);
     if (rc < 0)
         pm_error("fprintf() failed to write Icon header");
-        
+
     rc = fprintf(ofP, ", Depth=1, Valid_bits_per_item=16\n */\n");
     if (rc < 0)
         pm_error("fprintf() failed to write Icon header");
@@ -123,7 +123,7 @@ writeIcon(FILE *       const ifP,
 
         for (itemSeq = 0; itemSeq < items; ++itemSeq) {
             /* Read bits from bitrow, send to format & print function. */
-            
+
             putitem((bitrow[itemSeq*2]<<8) + bitrow[itemSeq*2+1]);
         }
     }
@@ -151,7 +151,7 @@ main(int argc,
         inputFileName = argv[1];
     else
         inputFileName = "-";
-    
+
     ifP = pm_openr(inputFileName);
 
     pbm_readpbminit(ifP, &cols, &rows, &format);
@@ -163,3 +163,5 @@ main(int argc,
     return 0;
 }
 
+
+
diff --git a/converter/pbm/pbmtowbmp.c b/converter/pbm/pbmtowbmp.c
index 2907fd68..e1b2b146 100644
--- a/converter/pbm/pbmtowbmp.c
+++ b/converter/pbm/pbmtowbmp.c
@@ -1,9 +1,9 @@
 /* pbmtowbmp.c - convert a portable bitmap to a Wireless Bitmap file
 
-   This is derived for Netpbm from the pbmwbmp package from 
+   This is derived for Netpbm from the pbmwbmp package from
    <http://www.looplab.com/wap/tools> on 2000.06.06.
-   
-   The specifications for the wbmp format are part of the Wireless 
+
+   The specifications for the wbmp format are part of the Wireless
    Application Environment specification at
    <http://www.wapforum.org/what/technical.htm>.
 
@@ -19,7 +19,7 @@
 
 #include "pbm.h"
 
-static void 
+static void
 outputint(int i) {
   int c = 1;
   while(i & 0x7f << 7*c) c++;
@@ -29,7 +29,7 @@ outputint(int i) {
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
   FILE *f;
   bit **image;
@@ -58,13 +58,15 @@ main(int argc, char *argv[]) {
     for(col = 0; col < cols; col++) {
       if(image[row][col] == PBM_WHITE) c = c | (1 << (7-p));
       if(++p == 8) {
-	putchar(c);
-	p = c = 0;
+        putchar(c);
+        p = c = 0;
       }
     }
     if(p) putchar(c);
   }
-  
+
   return 0;
 }
 
+
+
diff --git a/converter/pbm/pbmtoybm.c b/converter/pbm/pbmtoybm.c
index 27ce6cb1..7281866c 100644
--- a/converter/pbm/pbmtoybm.c
+++ b/converter/pbm/pbmtoybm.c
@@ -66,7 +66,7 @@ main(int argc, const char *argv[]) {
         pm_error("Input image is too large.");
 
     bitrow = pbm_allocrow_packed(cols + 8);
-    
+
     putinit(cols, rows);
 
     bitrow[pbm_packed_bytes(cols + 8) - 1] = 0x00;
@@ -95,3 +95,4 @@ main(int argc, const char *argv[]) {
 }
 
 
+
diff --git a/converter/pbm/pbmtozinc.c b/converter/pbm/pbmtozinc.c
index a89b8c9f..3bf3acd0 100644
--- a/converter/pbm/pbmtozinc.c
+++ b/converter/pbm/pbmtozinc.c
@@ -182,3 +182,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pi3topbm.c b/converter/pbm/pi3topbm.c
index 17b07d6f..82665f6c 100644
--- a/converter/pbm/pi3topbm.c
+++ b/converter/pbm/pi3topbm.c
@@ -40,13 +40,13 @@ struct CmdlineInfo {
 
 
 
-static void 
-parseCommandLine(int argc, 
-                 const char ** argv, 
+static void
+parseCommandLine(int argc,
+                 const char ** argv,
                  struct CmdlineInfo * const cmdlineP) {
 /* --------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -58,12 +58,12 @@ parseCommandLine(int argc,
     optStruct3 opt;
         /* Instructions to pm_optParseOptions3 on how to parse our options. */
     unsigned int option_def_index;
-  
+
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3(0, "debug",    OPT_FLAG,    NULL,       &cmdlineP->debug,       0);
-  
+
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;   /* We have no parms that are negative numbers */
@@ -71,7 +71,7 @@ parseCommandLine(int argc,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (argc-1 < 1) 
+    if (argc-1 < 1)
         cmdlineP->inputFileName = "-";
     else {
         cmdlineP->inputFileName = argv[1];
@@ -166,3 +166,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
index 49e15c49..c45af082 100644
--- a/converter/pbm/pktopbm.c
+++ b/converter/pbm/pktopbm.c
@@ -454,7 +454,7 @@ readCharacterHeader(int *          const carP,
     if (packetLength < 0)
         pm_error("Invalid character header - negative packet length");
     if (packetLength > UINT_MAX - pkLoc)
-        pm_error("Invalid character header - excessive packet lenght");
+        pm_error("Invalid character header - excessive packet length");
 
     *endOfPacketP = packetLength + pkLoc;
 
diff --git a/converter/pbm/wbmptopbm.c b/converter/pbm/wbmptopbm.c
index a3ce7ec3..3b941fcb 100644
--- a/converter/pbm/wbmptopbm.c
+++ b/converter/pbm/wbmptopbm.c
@@ -1,9 +1,9 @@
 /* wbmptopbm.c - convert a wbmp file to a portable bitmap
 
-   This is derived for Netpbm from the pbmwbmp package from 
+   This is derived for Netpbm from the pbmwbmp package from
    <http://www.looplab.com/wap/tools> on 2000.06.06.
-   
-   The specifications for the wbmp format are part of the Wireless 
+
+   The specifications for the wbmp format are part of the Wireless
    Application Environment specification at
    <http://www.wapforum.org/what/technical.htm>.
 
@@ -19,7 +19,7 @@
 
 #include "pbm.h"
 
-static int 
+static int
 readc(FILE *f) {
   int c = fgetc(f);
   if(c == EOF) pm_error("EOF / read error");
@@ -28,7 +28,7 @@ readc(FILE *f) {
 
 
 
-static int 
+static int
 readint(FILE *f) {
   int c=0, pos=0, sum=0;
   do {
@@ -40,7 +40,7 @@ readint(FILE *f) {
 
 
 
-static void 
+static void
 readheader(int h, FILE *f) {
   int c,i;
   switch(h & 0x60) {
@@ -81,7 +81,7 @@ readwbmp(FILE *f, int *cols, int *rows) {
     for(j=0; j<row; j++) {
       c=readc(f);
       for(k=0; k<8 && j*8+k<*cols; k++) {
-	image[i][j*8+k] = c & (0x80 >> k) ? PBM_WHITE : PBM_BLACK;
+        image[i][j*8+k] = c & (0x80 >> k) ? PBM_WHITE : PBM_BLACK;
       }
     }
   }
@@ -90,7 +90,7 @@ readwbmp(FILE *f, int *cols, int *rows) {
 
 
 
-int 
+int
 main(int argc, char *argv[]) {
   FILE *f;
   bit **image;
@@ -110,3 +110,5 @@ main(int argc, char *argv[]) {
   return 0;
 }
 
+
+
diff --git a/converter/pbm/xbmtopbm.c b/converter/pbm/xbmtopbm.c
index 1f5384ed..d3595ca1 100644
--- a/converter/pbm/xbmtopbm.c
+++ b/converter/pbm/xbmtopbm.c
@@ -384,6 +384,8 @@ main(int    argc,
     return 0;
 }
 
+
+
 /*  CHANGE HISTORY:
 
   99.09.08 bryanh    Recognize "static unsigned char" declaration.
diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c
index 78eb79f2..13210e43 100644
--- a/converter/pbm/ybmtopbm.c
+++ b/converter/pbm/ybmtopbm.c
@@ -116,3 +116,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/asciitopgm.c b/converter/pgm/asciitopgm.c
index f4179de8..d8bc263b 100644
--- a/converter/pgm/asciitopgm.c
+++ b/converter/pgm/asciitopgm.c
@@ -124,7 +124,7 @@ convertAsciiToPgm(FILE *         const ifP,
         else {
             if (beginningOfLine) {
                 if (c == '+') {
-                    /* + at start of line means rest of line 
+                    /* + at start of line means rest of line
                        overstrikes previous
                     */
                     c = getc(ifP);
@@ -192,7 +192,7 @@ main(int argc, const char ** argv) {
     rows = 0;  /* initial value */
     cols = 0;  /* initial value */
     divisor = 1; /* initial value */
-    
+
     argn = 1;
 
     if ( argc < 3 || argc > 6 )
@@ -246,3 +246,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/bioradtopgm.c b/converter/pgm/bioradtopgm.c
index e0bc3584..471709c1 100644
--- a/converter/pgm/bioradtopgm.c
+++ b/converter/pgm/bioradtopgm.c
@@ -44,32 +44,32 @@ main( argc, argv )
 
     while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
     {
-	if ( ISDIGIT( argv[argn][1] ))
-	{
-	    image_num = atoi( (argv[argn]+1) );
-	}
-	else
-	    pm_usage( usage );
-	++argn;
+        if ( ISDIGIT( argv[argn][1] ))
+        {
+            image_num = atoi( (argv[argn]+1) );
+        }
+        else
+            pm_usage( usage );
+        ++argn;
     }
 
     if ( argn < argc )
-	{
-	ifp = pm_openr( argv[argn] );
-	++argn;
-	}
+        {
+        ifp = pm_openr( argv[argn] );
+        ++argn;
+        }
     else
-	ifp = stdin;
+        ifp = stdin;
 
     if ( argn != argc )
-	pm_usage( usage );
+        pm_usage( usage );
 
     for ( i = 0; i < BIORAD_HEADER_LENGTH; ++i )
     {
-	val = getc( ifp );
-	if ( val == EOF )
-	    pm_error( "EOF / read error" );
-	buf[ i ] = val;
+        val = getc( ifp );
+        if ( val == EOF )
+            pm_error( "EOF / read error" );
+        buf[ i ] = val;
     }
 
     cols = BYTE_TO_WORD(buf[0], buf[1]);
@@ -79,74 +79,77 @@ main( argc, argv )
     check_word = BYTE_TO_WORD(buf[54], buf[55]);
 
     if ( check_word != 12345 )
-	pm_error( "Not a Biorad file" );
+        pm_error( "Not a Biorad file" );
 
     if ( cols <= 0 )
-	pm_error( "Strange image size, cols = %d", cols);
+        pm_error( "Strange image size, cols = %d", cols);
 
     if ( rows <= 0 )
-	pm_error( "Strange image size, rows = %d", rows);
+        pm_error( "Strange image size, rows = %d", rows);
 
     if ( image_count <= 0 )
-	pm_error( "Number of images in file is %d", image_count);
+        pm_error( "Number of images in file is %d", image_count);
 
     if ( byte_word )
-	maxval = 255;
+        maxval = 255;
     else
     {
-	maxval = 65535;   /* Perhaps this should be something else */
+        maxval = 65535;   /* Perhaps this should be something else */
 
     }
 
     pm_message( "Image size: %d cols, %d rows", cols, rows);
     pm_message( "%s",
-	       (byte_word) ? "Byte image (8 bits)" : "Word image (16 bits)");
+               (byte_word) ? "Byte image (8 bits)" : "Word image (16 bits)");
 
     if ( image_num < 0 )
-	pm_message( "Input contains %d image%c",
-		   image_count, (image_count > 1) ? 's' : '\0');
+        pm_message( "Input contains %d image%c",
+                   image_count, (image_count > 1) ? 's' : '\0');
     else
     {
-	if ( image_num >= image_count )
-	    pm_error( "Cannot extract image %d, input contains only %d image%s",
-		     image_num, image_count, (image_count > 1) ? "s" : "" );
-	for ( i = (byte_word) ? image_num : image_num*2 ; i > 0 ; --i ) {
-	    for ( row = 0; row < rows; ++row)
-		for ( col = 0; col < cols; ++col )
-		{
-		    val = getc( ifp );
-		    if ( val == EOF ) {
-			pm_error( "EOF / read error" );
-		    }
-		}
-	}
-
-	pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
-	grayrow = pgm_allocrow( cols );
-
-	for ( row = 0; row < rows; ++row)
-	{
-	    for ( col = 0, gP = grayrow; col < cols; ++col )
-	    {
-		val = getc( ifp );
-		if ( val == EOF )
-		    pm_error( "EOF / read error" );
-		if (byte_word)
-		    *gP++ = val;
-		else
-		{
-		    val2 = getc( ifp );
-		    if ( val2 == EOF )
-			pm_error( "EOF / read error" );
-		    *gP++ = BYTE_TO_WORD(val, val2);
-		}
-	    }
-	    pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 );
-	}
-
-	pm_close( ifp );
-	pm_close( stdout );
+        if ( image_num >= image_count )
+            pm_error( "Cannot extract image %d, input contains only %d image%s",
+                     image_num, image_count, (image_count > 1) ? "s" : "" );
+        for ( i = (byte_word) ? image_num : image_num*2 ; i > 0 ; --i ) {
+            for ( row = 0; row < rows; ++row)
+                for ( col = 0; col < cols; ++col )
+                {
+                    val = getc( ifp );
+                    if ( val == EOF ) {
+                        pm_error( "EOF / read error" );
+                    }
+                }
+        }
+
+        pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
+        grayrow = pgm_allocrow( cols );
+
+        for ( row = 0; row < rows; ++row)
+        {
+            for ( col = 0, gP = grayrow; col < cols; ++col )
+            {
+                val = getc( ifp );
+                if ( val == EOF )
+                    pm_error( "EOF / read error" );
+                if (byte_word)
+                    *gP++ = val;
+                else
+                {
+                    val2 = getc( ifp );
+                    if ( val2 == EOF )
+                        pm_error( "EOF / read error" );
+                    *gP++ = BYTE_TO_WORD(val, val2);
+                }
+            }
+            pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 );
+        }
+
+        pm_close( ifp );
+        pm_close( stdout );
 
     }
     exit( 0 );
 }
+
+
+
diff --git a/converter/pgm/fstopgm.c b/converter/pgm/fstopgm.c
index 1f574604..63ccb3c5 100644
--- a/converter/pgm/fstopgm.c
+++ b/converter/pgm/fstopgm.c
@@ -47,7 +47,7 @@ warnNonsquarePixels(unsigned int const cols,
                     unsigned int const xcols,
                     unsigned int const rows,
                     unsigned int const xrows) {
-    
+
     const char * const baseMsg = "warning, non-square pixels";
 
     if (pm_have_float_format()) {
@@ -57,7 +57,7 @@ warnNonsquarePixels(unsigned int const cols,
         pm_message("%s; to fix do a 'pamscale -%cscale %g'",
                    baseMsg,
                    rowratio > colratio ? 'y' : 'x',
-                   rowratio > colratio ? 
+                   rowratio > colratio ?
                    rowratio / colratio : colratio / rowratio);
     } else
         pm_message("%s", baseMsg);
@@ -153,3 +153,5 @@ main(int argc, const char ** argv) {
     return 0;
 }
 
+
+
diff --git a/converter/pgm/hipstopgm.c b/converter/pgm/hipstopgm.c
index 2f5956e1..17048ce7 100644
--- a/converter/pgm/hipstopgm.c
+++ b/converter/pgm/hipstopgm.c
@@ -16,21 +16,21 @@
 #include "pgm.h"
 
 struct HIPS_Header {
-    char* orig_name;	/* An indication of the originator of this sequence. */
-    char* seq_name;	/* The sequence name. */
-    int num_frame;	/* The number of frames in this sequence. */
-    char* orig_date;	/* The date the sequence was originated. */
-    int rows;		/* The number of rows in each image, the height. */
-    int cols;		/* The number of columns in each image, the width. */
-    int bits_per_pixel;	/* The number of significant bits per pixel. */
-    int bit_packing;	/* Nonzero if the bits were packed such as to
+    char* orig_name;    /* An indication of the originator of this sequence. */
+    char* seq_name;     /* The sequence name. */
+    int num_frame;      /* The number of frames in this sequence. */
+    char* orig_date;    /* The date the sequence was originated. */
+    int rows;           /* The number of rows in each image, the height. */
+    int cols;           /* The number of columns in each image, the width. */
+    int bits_per_pixel; /* The number of significant bits per pixel. */
+    int bit_packing;    /* Nonzero if the bits were packed such as to
                            eliminate any unused bits resulting from a
                            bits_per_pixel value which was not an even
                            multiple of eight. */
-    int pixel_format;	/* An indication of the format of each pixel. */
-    char* seq_history;	/* A description of the sequence of transformations
+    int pixel_format;   /* An indication of the format of each pixel. */
+    char* seq_history;  /* A description of the sequence of transformations
                            leading up to the current image. */
-    char* seq_desc;	/* A free form description of the contents of the
+    char* seq_desc;     /* A free form description of the contents of the
                        sequence. */
 };
 #define HIPS_PFBYTE 0
@@ -52,7 +52,6 @@ read_line(FILE * const fd,
 
 
 
-
 static void
 read_hips_header( fd, hP )
     FILE* fd;
@@ -95,9 +94,9 @@ read_hips_header( fd, hP )
 
     /* Now read and toss lines until we get one with just a period. */
     do
-	{
+        {
         read_line( fd, buf, 5000 );
-	}
+        }
     while ( !streq( buf, ".\n" ) );
 }
 
@@ -121,10 +120,10 @@ main(int argc, char * argv[]) {
     argn = 1;
 
     if ( argn < argc )
-	{
+        {
         ifp = pm_openr( argv[argn] );
         argn++;
-	}
+        }
     else
         ifp = stdin;
 
@@ -137,8 +136,8 @@ main(int argc, char * argv[]) {
     rows = h.rows * h.num_frame;
 
     switch ( h.pixel_format )
-	{
-	case HIPS_PFBYTE:
+        {
+        case HIPS_PFBYTE:
         if ( h.bits_per_pixel != 8 )
             pm_error(
                 "can't handle unusual bits_per_pixel %d", h.bits_per_pixel );
@@ -147,16 +146,16 @@ main(int argc, char * argv[]) {
         maxval = 255;
         break;
 
-	default:
+        default:
         pm_error( "unknown pixel format %d", h.pixel_format );
-	}
+        }
 
     pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
     grayrow = pgm_allocrow( cols );
     for ( row = 0; row < rows; row++)
-	{
+        {
         for ( col = 0, gP = grayrow; col < cols; col++, gP++ )
-	    {
+            {
             int ich;
 
             switch ( h.pixel_format )
@@ -171,11 +170,14 @@ main(int argc, char * argv[]) {
             default:
                 pm_error( "can't happen" );
             }
-	    }
+            }
         pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 );
-	}
+        }
     pm_close( ifp );
     pm_close( stdout );
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
index 03bcb512..29f280f3 100644
--- a/converter/pgm/lispmtopgm.c
+++ b/converter/pgm/lispmtopgm.c
@@ -182,3 +182,5 @@ main(int argc, const char ** argv) {
     exit(0);
 }
 
+
+
diff --git a/converter/pgm/pgmtofs.c b/converter/pgm/pgmtofs.c
index 53a2e7b3..8780b35a 100644
--- a/converter/pgm/pgmtofs.c
+++ b/converter/pgm/pgmtofs.c
@@ -35,14 +35,14 @@ main( argc, argv )
     argn = 1;
 
     if ( argn < argc )
-	{
+        {
         ifp = pm_openr( argv[argn] );
         ++argn;
-	}
+        }
     else
-	{
+        {
         ifp = stdin;
-	}
+        }
 
     if ( argn != argc )
         pm_usage( usage );
@@ -60,19 +60,19 @@ main( argc, argv )
         pm_error(
             "maxval of %d is too large for FaceSaver(tm)", maxval );
     nmaxval = pm_bitstomaxval( bps );
-    
+
     /* Compute padding to round cols * bps up to the nearest multiple of 8. */
     padright = ( ( cols * bps + 7 ) / 8 ) * 8 - cols * bps;
 
     putinit( cols, rows, bps );
     for ( row = rows - 1; row >= 0; --row )
-	{
+        {
         for ( col = 0, gP = grays[row]; col < cols; ++col, ++gP )
-	    {
+            {
             if ( maxval != nmaxval )
                 *gP = (int) *gP * nmaxval / maxval;
             putgray( *gP );
-	    }
+            }
         for ( col = 0; col < padright; ++col )
             putgray( 0 );
     }
@@ -83,6 +83,7 @@ main( argc, argv )
 }
 
 
+
 static int bitspersample, item, bitsperitem, bitshift, itemsperline, items;
 
 static void
@@ -109,16 +110,18 @@ putinit( cols, rows, bps )
     bitshift = 8 - bitspersample;
 }
 
+
+
 static void
 putitem( )
 {
     const char* const hexits = "0123456789abcdef";
 
     if ( itemsperline == 30 )
-	{
+        {
         putchar( '\n' );
         itemsperline = 0;
-	}
+        }
     putchar( hexits[item >> 4] );
     putchar( hexits[item & 15] );
     ++itemsperline;
@@ -128,6 +131,8 @@ putitem( )
     bitshift = 8 - bitspersample;
 }
 
+
+
 static void
 putgray( gray g )
 {
@@ -138,6 +143,8 @@ putgray( gray g )
     bitshift -= bitspersample;
 }
 
+
+
 static void
 putrest( )
 {
@@ -145,3 +152,6 @@ putrest( )
         putitem( );
     printf( "\n" );
 }
+
+
+
diff --git a/converter/pgm/pgmtolispm.c b/converter/pgm/pgmtolispm.c
index 7d931fb3..4309228e 100644
--- a/converter/pgm/pgmtolispm.c
+++ b/converter/pgm/pgmtolispm.c
@@ -1,4 +1,4 @@
-/* pgmtolispm.c - read a pgm and write a file acceptable to the 
+/* pgmtolispm.c - read a pgm and write a file acceptable to the
 ** tv:read-bit-array-file function of TI Explorer and Symbolics Lisp Machines.
 **
 ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer.
@@ -12,7 +12,7 @@
 **
 **   When one writes a multi-plane bitmap with tv:write-bit-array-file, it is
 **   usually a color image; but a color map is not written in the file, so we
-**   treat this as a graymap instead.  To convert a color image to Lispm 
+**   treat this as a graymap instead.  To convert a color image to Lispm
 **   format, you must convert it to a pgm, and hand-edit a color map...  Ick.
 **
 ** Feb 2010 afu
@@ -37,7 +37,7 @@ depth_to_word_size(unsigned int const depth) {
     /* out with a depth of 5, it really has a depth of 8, and  */
     /* is stored that way in the file.                         */
 
-    unsigned int const wordSize = 
+    unsigned int const wordSize =
         depth ==  1 ?  1 :
         depth ==  2 ?  2 :
         depth <=  4 ?  4 :
@@ -178,3 +178,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/pgmtopgm.c b/converter/pgm/pgmtopgm.c
index 250bb4dc..71b12754 100644
--- a/converter/pgm/pgmtopgm.c
+++ b/converter/pgm/pgmtopgm.c
@@ -20,9 +20,9 @@ main(int argc, char *argv[]) {
     gray maxval;
     int row;
     gray * grayrow;
-    
+
     pgm_init(&argc, argv);
-    
+
     if (argc-1 != 0)
         pm_error("Program takes no arguments.  Input is from Standard Input");
 
@@ -42,3 +42,6 @@ main(int argc, char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/pgmtosbig.c b/converter/pgm/pgmtosbig.c
index 0a302dd8..cdc867cb 100644
--- a/converter/pgm/pgmtosbig.c
+++ b/converter/pgm/pgmtosbig.c
@@ -128,3 +128,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/pgmtost4.c b/converter/pgm/pgmtost4.c
index fa101ac9..aa691464 100644
--- a/converter/pgm/pgmtost4.c
+++ b/converter/pgm/pgmtost4.c
@@ -76,7 +76,7 @@ main(int argc, const char * argv[]) {
     if (inpam.width != st4Width)
         pm_error("Image is wrong width for ST-4 SBIG: %u pixels.  "
                  "Must be %u", inpam.width, st4Width);
-    
+
     /* Really, we should just scale to maxval 255.  There are library routines
        for that, but we're too lazy even for that, since nobody is really
        going to use this program.
@@ -102,3 +102,6 @@ main(int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/pgm/psidtopgm.c b/converter/pgm/psidtopgm.c
index 99ce3710..58e84855 100644
--- a/converter/pgm/psidtopgm.c
+++ b/converter/pgm/psidtopgm.c
@@ -132,3 +132,4 @@ main(int           argc,
 }
 
 
+
diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c
index 7833cb62..8b28f740 100644
--- a/converter/pgm/sbigtopgm.c
+++ b/converter/pgm/sbigtopgm.c
@@ -53,13 +53,13 @@ parseCommandLine(int argc, const char ** argv,
     unsigned int option_def_index;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
-    
+
     OPTENTINIT;
 
     opt.opt_table     = option_def;
     opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */
     opt.allowNegNum   = FALSE; /* We have no parms that are negative numbers */
-    
+
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others */
 
@@ -208,7 +208,7 @@ readSbigHeader(FILE *              const ifP,
                 *ep = ' ';
             }
         }
-        
+
         looseCanon(cursor);
             /* Convert from standard SBIG to an internal format */
 
@@ -270,7 +270,7 @@ writeRaster(FILE *            const ifP,
             unsigned short rowlen;        /* Compressed row length */
 
             pm_readlittleshortu(ifP, &rowlen);
-            
+
             /*  If compression results in a row length >= the uncompressed
                 row length, that row is output uncompressed.  We detect this
                 by observing that the compressed row length is equal to
diff --git a/converter/pgm/spottopgm.c b/converter/pgm/spottopgm.c
index 59240ba8..26801cb2 100644
--- a/converter/pgm/spottopgm.c
+++ b/converter/pgm/spottopgm.c
@@ -37,7 +37,7 @@ static int Colbool = 0;        /* 1 if color */
  * requested by the user (i.e 1, 2 or 3). I could create a ppm file
  * but I couldn't be bothered with the rearranging of the data.
  */
-static int 
+static int
 get_image(long length)
 {
     int cnt;
@@ -72,7 +72,7 @@ get_image(long length)
             pm_error ("seek error");
         if (pm_readbiglong (spotfile, &numpixels) == -1)
             pm_error ("EOF / read error reading line ender");
-    
+
         /* Determine the picture size */
         Bufptr = &linebuf[Firstcol];
         if (Lastcol == 0 || Lastcol > numpixels)
@@ -95,7 +95,7 @@ get_image(long length)
     fprintf(stderr,
             "Line %4d, %3d, %3d, time %4d, l/r "
             "pixmar %4d %4d len %d pixnum %d\n",
-            linehdr.linenum, linehdr.recseq, 
+            linehdr.linenum, linehdr.recseq,
             linehdr.spectseq, linehdr.linetime,
             linehdr.leftpixmar, linehdr.rightpixmar, length, numpixels);
 #endif
@@ -116,7 +116,7 @@ get_image(long length)
  *  element 9 == S --> sequential (i.e only one color here)
  *  element 9 == I --> interleaved (1 or more colors)
  */
-static int 
+static int
 get_imghdr(int length)
 {
     struct Imghdr
@@ -145,7 +145,7 @@ get_imghdr(int length)
 
 #ifdef DEBUG
     fprintf(stderr, "Dummy str is >%s<\n", header.dummy1);
-    fprintf(stderr, "Imghdr str is >%s<, col %d\n", 
+    fprintf(stderr, "Imghdr str is >%s<, col %d\n",
             header.description, Colbool);
 #endif
     /* Return the amount to fseek */
@@ -153,6 +153,7 @@ get_imghdr(int length)
 }
 
 
+
 static void
 usage()
 {
@@ -162,6 +163,8 @@ usage()
     exit(1);
 }
 
+
+
 int
 main(int argc, char *argv[])
 {
@@ -176,7 +179,7 @@ main(int argc, char *argv[])
     } arecord;
 
     pgm_init( &argc, argv );
-   
+
     switch (argc)
     {
     case 7:
@@ -219,7 +222,7 @@ main(int argc, char *argv[])
             arecord.length = get_imghdr(arecord.length);
 #ifdef DEBUG
         else
-            fprintf(stderr, 
+            fprintf(stderr,
                     "Rcrd %3d, type %03o, stype %03o %03o %03o, length %d\n",
                     arecord.record, arecord.type, arecord.sub1, arecord.sub2,
                     (int) arecord.sub3 & 0xff, arecord.length);
@@ -229,3 +232,6 @@ main(int argc, char *argv[])
     }
     exit (0);
 }
+
+
+
diff --git a/converter/pgm/st4topgm.c b/converter/pgm/st4topgm.c
index 791184b7..89ec930d 100644
--- a/converter/pgm/st4topgm.c
+++ b/converter/pgm/st4topgm.c
@@ -56,6 +56,7 @@ validateFileSize(FILE * const ifP) {
 }
 
 
+
 static void
 writeRaster(FILE *       const ifP,
             struct pam * const pamP) {
@@ -188,15 +189,15 @@ readFooter(FILE *             const ifP,
 static void
 reportFooter(struct St4Footer const footer) {
 
-	pm_message("Comment:                 %s", footer.comment);
+        pm_message("Comment:                 %s", footer.comment);
 
-	pm_message("Exposure time (1/100 s): %s", footer.exposureTime);
+        pm_message("Exposure time (1/100 s): %s", footer.exposureTime);
 
-	pm_message("Focal length (in):       %s", footer.focalLength);
+        pm_message("Focal length (in):       %s", footer.focalLength);
 
-	pm_message("Aperture area (sq in):   %s", footer.apertureArea);
+        pm_message("Aperture area (sq in):   %s", footer.apertureArea);
 
-	pm_message("Calibration factor:      %s", footer.calibrationFactor);
+        pm_message("Calibration factor:      %s", footer.calibrationFactor);
 }
 
 
@@ -219,7 +220,7 @@ main(int argc, const char **argv) {
             pm_error("Too many arguments: %u.  "
                      "The only possible argument is the "
                      "optional input file name", argc-1);
-    }        
+    }
 
     /* We check the file size to catch the common problem of the input not
        being valid ST-4 SBIG input.  Unlike most formats, this one does not
@@ -258,3 +259,4 @@ main(int argc, const char **argv) {
 }
 
 
+
diff --git a/converter/ppm/411toppm.c b/converter/ppm/411toppm.c
index eb2372a5..a50e5145 100644
--- a/converter/ppm/411toppm.c
+++ b/converter/ppm/411toppm.c
@@ -105,7 +105,7 @@ parseCommandLine(int argc, const char ** argv,
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
-    
+
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
@@ -182,7 +182,7 @@ YUVtoPPM(FILE  * const ifP,
         r = CHOP((int)(tempR >> 16));
         g = CHOP((int)(tempG >> 16));
         b = CHOP((int)(tempB >> 16));
-        
+
         PPM_ASSIGN(pixrow[col], r, g, b);
     }
 }
@@ -225,6 +225,8 @@ main(int argc, const char **argv) {
     return 0;
 }
 
+
+
 /*
    By default a .411 file is width=64, height=48, 4608 bytes.
    There is no header.
diff --git a/converter/ppm/autocad.h b/converter/ppm/autocad.h
index 3005782b..ef82cf6f 100644
--- a/converter/ppm/autocad.h
+++ b/converter/ppm/autocad.h
@@ -56,7 +56,7 @@ static unsigned char acadcol[256][3] = {
     {76, 38, 66}, {38, 0, 28}, {38, 19, 33}, {255, 0, 127}, {255, 127, 191},
     {165, 0, 82}, {165, 82, 124}, {127, 0, 63}, {127, 63, 95}, {76, 0, 38},
     {76, 38, 57}, {38, 0, 19}, {38, 19, 28}, {255, 0, 63}, {255, 127, 159},
-    {165, 0, 41}, {165, 82, 103}, {127, 0, 31}, {127, 63, 79},	{76, 0, 19},
+    {165, 0, 41}, {165, 82, 103}, {127, 0, 31}, {127, 63, 79},  {76, 0, 19},
     {76, 38, 47}, {38, 0, 9}, {38, 19, 23}, {84, 84, 84}, {118, 118, 118},
     {152, 152, 152}, {186, 186, 186}, {220, 220, 220}, {255, 255, 255}
 };
diff --git a/converter/ppm/eyuvtoppm.c b/converter/ppm/eyuvtoppm.c
index 910a125b..3ec29268 100644
--- a/converter/ppm/eyuvtoppm.c
+++ b/converter/ppm/eyuvtoppm.c
@@ -1,6 +1,6 @@
 /* Bryan got this from mm.ftp-cs.berkeley.edu from the package
-   mpeg-encode-1.5b-src under the name eyuvtoppm.c on March 30, 2000.  
-   The file was dated April 14, 1995.  
+   mpeg-encode-1.5b-src under the name eyuvtoppm.c on March 30, 2000.
+   The file was dated April 14, 1995.
 
    Bryan rewrote the program entirely to match Netpbm coding style,
    use the Netpbm libraries and also to output to stdout and ignore
@@ -70,7 +70,7 @@ parseCommandLine(int argc, char ** argv,
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3('w', "width",     OPT_UINT,  &cmdlineP->width,   NULL,         0);
     OPTENT3('h', "height",    OPT_UINT,  &cmdlineP->height,  NULL,         0);
-    
+
     /* DEFAULTS */
     cmdlineP->width = 352;
     cmdlineP->height = 240;
@@ -93,7 +93,7 @@ parseCommandLine(int argc, char ** argv,
                  "You specified %u.", cmdlineP->height);
 
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFileName = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -106,7 +106,7 @@ parseCommandLine(int argc, char ** argv,
 
 
 
-static uint8 ** 
+static uint8 **
 allocUint8Array(unsigned int const cols,
                 unsigned int const rows) {
 
@@ -129,7 +129,7 @@ allocUint8Array(unsigned int const cols,
 
 
 
-static void 
+static void
 freeUint8Array(uint8 **     const array,
                unsigned int const rows) {
 
@@ -162,28 +162,28 @@ freeStorage(unsigned int const rows,
             uint8 **     const orig_y,
             uint8 **     const orig_cb,
             uint8 **     const orig_cr) {
-    
-    freeUint8Array(orig_y,  rows); 
-    freeUint8Array(orig_cb, rows); 
+
+    freeUint8Array(orig_y,  rows);
+    freeUint8Array(orig_cb, rows);
     freeUint8Array(orig_cr, rows);
 
 }
 
 
 
-static void 
+static void
 YUVtoPPM(FILE *       const ofP,
          unsigned int const cols,
          unsigned int const rows,
          uint8 **     const orig_y,
          uint8 **     const orig_cb,
-         uint8 **     const orig_cr) { 
+         uint8 **     const orig_cr) {
 /*----------------------------------------------------------------------------
    Convert the YUV image in arrays orig_y[][], orig_cb[][], and orig_cr[][]
    to a PPM image and write it to file *ofP.
 -----------------------------------------------------------------------------*/
     pixel * const pixrow = ppm_allocrow(cols);
-    
+
     unsigned int row;
 
     ppm_writeppminit(ofP, cols, rows, 255, FALSE);
@@ -202,11 +202,11 @@ YUVtoPPM(FILE *       const ofP,
             tempR = 104635*v + 76310*y;
             tempG = -25690*u + -53294*v + 76310*y;
             tempB = 132278*u + 76310*y;
-            
+
             r = CHOP((int)(tempR >> 16));
             g = CHOP((int)(tempG >> 16));
             b = CHOP((int)(tempB >> 16));
-            
+
             PPM_ASSIGN(pixrow[col], r, g, b);
         }
         ppm_writeppmrow(stdout, pixrow, cols, 255, FALSE);
@@ -216,12 +216,12 @@ YUVtoPPM(FILE *       const ofP,
 
 
 
-static void 
+static void
 ReadYUV(FILE *       const ifP,
         unsigned int const cols,
         unsigned int const rows,
-        uint8 **     const orig_y, 
-        uint8 **     const orig_cb, 
+        uint8 **     const orig_y,
+        uint8 **     const orig_cb,
         uint8 **     const orig_cr,
         bool *       const eofP) {
 
@@ -240,7 +240,7 @@ ReadYUV(FILE *       const ifP,
         if (bytesRead != cols)
             eof = true;
     }
-        
+
     for (row = 0; row < rows / 2 && !eof; ++row) {  /* U */
         size_t bytesRead;
 
@@ -249,7 +249,7 @@ ReadYUV(FILE *       const ifP,
         if (bytesRead != cols / 2)
             eof = true;
     }
-        
+
     for (row = 0; row < rows / 2 && !eof; ++row) { /* V */
         size_t bytesRead;
 
@@ -297,7 +297,7 @@ main(int argc, const char **argv) {
 
     for (frameSeq = 0, eof = false; !eof; ++frameSeq) {
 
-        ReadYUV(ifP, cmdline.width, cmdline.height, 
+        ReadYUV(ifP, cmdline.width, cmdline.height,
                 orig_y, orig_cb, orig_cr, &eof);
 
         if (!eof) {
@@ -317,3 +317,4 @@ main(int argc, const char **argv) {
 }
 
 
+
diff --git a/converter/ppm/gouldtoppm.c b/converter/ppm/gouldtoppm.c
index 5db7c51a..6cc7726c 100644
--- a/converter/ppm/gouldtoppm.c
+++ b/converter/ppm/gouldtoppm.c
@@ -22,101 +22,106 @@ main( argc, argv )
 int argc;
 char *argv[];
 {
-	FILE *ifp;
-	pixel *pixrow;
+        FILE *ifp;
+        pixel *pixrow;
 
-	unsigned long cols, nlines, bytesperline, bitsperpixel, NB, x, y;
-	unsigned char pbuffer[4];
+        unsigned long cols, nlines, bytesperline, bitsperpixel, NB, x, y;
+        unsigned char pbuffer[4];
 
-	int color_type;
+        int color_type;
 
 
-	ppm_init( &argc, argv );
+        ppm_init( &argc, argv );
 
-	if ( argc > 2 )
-		pm_usage( "[gouldfile]" );
+        if ( argc > 2 )
+                pm_usage( "[gouldfile]" );
 
-	if ( argc == 2 )
-		ifp = pm_openr( argv[1] );
-	else
-		ifp = stdin;
+        if ( argc == 2 )
+                ifp = pm_openr( argv[1] );
+        else
+                ifp = stdin;
 
-	getgouldheader( ifp, &cols, &nlines, &bytesperline, &bitsperpixel, &NB);
+        getgouldheader( ifp, &cols, &nlines, &bytesperline, &bitsperpixel, &NB);
 
-	ppm_writeppminit(stdout, cols, nlines, MAXVAL, 0);
+        ppm_writeppminit(stdout, cols, nlines, MAXVAL, 0);
 
-	color_type = bitsperpixel/8;
-	if (color_type == 0) color_type = NB;
+        color_type = bitsperpixel/8;
+        if (color_type == 0) color_type = NB;
 
-	pixrow = ppm_allocrow(cols);
+        pixrow = ppm_allocrow(cols);
 
-	for (y = 0; y < nlines; ++y)
-	{
-		for (x = 0; x < cols; ++x)
-		{
-			switch (color_type)
-			{
-			case 0:
-				pm_error("incorrect color type" );
+        for (y = 0; y < nlines; ++y)
+        {
+                for (x = 0; x < cols; ++x)
+                {
+                        switch (color_type)
+                        {
+                        case 0:
+                                pm_error("incorrect color type" );
 
-			case 1:
-				fread(pbuffer, 1, 1, ifp);
-				PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[0], pbuffer[0]);
-				break;
+                        case 1:
+                                fread(pbuffer, 1, 1, ifp);
+                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[0], pbuffer[0]);
+                                break;
 
-			case 2:
-				fread(pbuffer, 2, 1, ifp);
-				PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[1]);
-				break;
+                        case 2:
+                                fread(pbuffer, 2, 1, ifp);
+                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[1]);
+                                break;
 
-			case 3:
-				fread(pbuffer, 3, 1, ifp);
-				PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
-				break;
+                        case 3:
+                                fread(pbuffer, 3, 1, ifp);
+                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
+                                break;
 
-			default :
-				fread(pbuffer, 3, 1, ifp);
-				PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
-				break;
+                        default :
+                                fread(pbuffer, 3, 1, ifp);
+                                PPM_ASSIGN( pixrow[x], pbuffer[0], pbuffer[1], pbuffer[2]);
+                                break;
 
-			} /* switch */
-		}
-		ppm_writeppmrow(stdout, pixrow, cols, MAXVAL, 0);
-	}
+                        } /* switch */
+                }
+                ppm_writeppmrow(stdout, pixrow, cols, MAXVAL, 0);
+        }
 
-	pm_close(ifp);
-	pm_close(stdout);
+        pm_close(ifp);
+        pm_close(stdout);
 
-	exit(0);
+        exit(0);
 }
 
+
+
 static void
 getgouldheader( infile, cols, nlines, bytesperline, bitsperpixel, NB)
 FILE *infile;
 unsigned long *cols, *nlines, *bytesperline, *bitsperpixel, *NB;
 {
-	unsigned long nlines_new, bytesperline_new, numheaderrec;
-	unsigned char headerblk[512];
-	int i;
-
-	if (fread(headerblk, 512, 1, infile) == 0)
-		pm_error("cannot read gould header" );
-
-	*nlines       = (headerblk[3]<<8) | headerblk[2];
-	*bytesperline = (headerblk[5]<<8) | headerblk[4];
-	*bitsperpixel = (headerblk[7]<<8) | headerblk[6];
-	numheaderrec  = (headerblk[9]<<8) | headerblk[8];
-	nlines_new    = (headerblk[15]<<24)| (headerblk[14]<<16) | (headerblk[13]<<8) | (headerblk[12]);
-	bytesperline_new = (headerblk[19]<<24)| (headerblk[18]<<16) | (headerblk[17]<<8) | (headerblk[16]);
-	*NB           = (headerblk[23]<<24)| (headerblk[22]<<16) | (headerblk[21]<<8) | (headerblk[20]);
-
-	if (numheaderrec > 1)
-		for (i = 1 ; i <numheaderrec; ++i)
-			if (fread(headerblk, 512, 1, infile) == 0)
-				pm_error("cannot read gould header(2nd)" );
-
-	if (*nlines==0) *nlines=nlines_new;
-	if (*bytesperline==0) *bytesperline=bytesperline_new;
-
-	*cols = (*bytesperline)*8 / (*bitsperpixel);
+        unsigned long nlines_new, bytesperline_new, numheaderrec;
+        unsigned char headerblk[512];
+        int i;
+
+        if (fread(headerblk, 512, 1, infile) == 0)
+                pm_error("cannot read gould header" );
+
+        *nlines       = (headerblk[3]<<8) | headerblk[2];
+        *bytesperline = (headerblk[5]<<8) | headerblk[4];
+        *bitsperpixel = (headerblk[7]<<8) | headerblk[6];
+        numheaderrec  = (headerblk[9]<<8) | headerblk[8];
+        nlines_new    = (headerblk[15]<<24)| (headerblk[14]<<16) | (headerblk[13]<<8) | (headerblk[12]);
+        bytesperline_new = (headerblk[19]<<24)| (headerblk[18]<<16) | (headerblk[17]<<8) | (headerblk[16]);
+        *NB           = (headerblk[23]<<24)| (headerblk[22]<<16) | (headerblk[21]<<8) | (headerblk[20]);
+
+        if (numheaderrec > 1)
+                for (i = 1 ; i <numheaderrec; ++i)
+                        if (fread(headerblk, 512, 1, infile) == 0)
+                                pm_error("cannot read gould header(2nd)" );
+
+        if (*nlines==0) *nlines=nlines_new;
+        if (*bytesperline==0) *bytesperline=bytesperline_new;
+
+        *cols = (*bytesperline)*8 / (*bitsperpixel);
 }
+
+
+
diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
index 1b66c0b3..8a8cf9f3 100644
--- a/converter/ppm/ilbmtoppm.c
+++ b/converter/ppm/ilbmtoppm.c
@@ -112,6 +112,7 @@ ID2string(IFF_ID const id) {
 }
 
 
+
 /****************************************************************************
  Memory allocation
  ****************************************************************************/
@@ -154,6 +155,7 @@ alloc_rawrow(unsigned int const cols) {
 }
 
 
+
 /****************************************************************************
  Basic I/O functions
  ****************************************************************************/
@@ -207,6 +209,8 @@ get_byte(FILE *          const ifP,
     return (unsigned char) i;
 }
 
+
+
 static long
 get_big_long(FILE *          const ifP,
              IFF_ID          const iffid,
@@ -540,6 +544,7 @@ read_bmhd(FILE *        const ifP,
 }
 
 
+
 /****************************************************************************
  ILBM functions
  ****************************************************************************/
@@ -594,6 +599,7 @@ read_ilbm_plane(FILE *          const ifP,
 }
 
 
+
 static const unsigned char bit_mask[] = {1, 2, 4, 8, 16, 32, 64, 128};
 
 static void
@@ -637,6 +643,7 @@ decodeRow(FILE *          const ifP,
 }
 
 
+
 static void
 decodeMask(FILE *          const ifP,
            unsigned long * const remainingChunksizeP,
@@ -699,6 +706,7 @@ decodeMask(FILE *          const ifP,
 }
 
 
+
 /****************************************************************************
  Multipalette handling
  ****************************************************************************/
@@ -1609,6 +1617,8 @@ rgbn_to_ppm(FILE *         const ifP,
     chunk_end(ifP, ID_BODY, remainingChunksize);
 }
 
+
+
 /****************************************************************************
  Multipalette chunk reader
 
@@ -1782,6 +1792,7 @@ PCHG_Decompress(PCHGHeader *     const PCHG,
 }
 
 
+
 static void
 PCHG_ConvertSmall(PCHGHeader *    const pchgP,
                   ColorMap *      const cmapP,
diff --git a/converter/ppm/leaftoppm.c b/converter/ppm/leaftoppm.c
index 61c19c1e..0dcc1255 100644
--- a/converter/ppm/leaftoppm.c
+++ b/converter/ppm/leaftoppm.c
@@ -10,7 +10,7 @@
  * implied warranty.
  *
  * known problems: doesn't do compressed ileaf images.
- * 
+ *
  */
 
 #include <stdio.h>
@@ -20,11 +20,11 @@
 #define LEAF_MAXVAL 255
 
 static void
-leaf_init(FILE *  const fp, 
+leaf_init(FILE *  const fp,
           int *   const colsP,
-          int *   const rowsP, 
-          int *   const depthP, 
-          int *   const ncolorsP, 
+          int *   const rowsP,
+          int *   const depthP,
+          int *   const ncolorsP,
           pixel * const colors) {
 
     unsigned char buf[256];
@@ -34,41 +34,41 @@ leaf_init(FILE *  const fp,
     short rows;
     short depth;
     long magic;
-    
+
     pm_readbiglong(fp, &magic);
     if ((uint32_t)magic != 0x894f5053)
         pm_error("Bad magic number.  First 4 bytes should be "
                  "0x894f5053 but are instead 0x%08x", (unsigned)magic);
-    
+
     /* version =   2 bytes
-       hres =      2 
+       hres =      2
        vres =      2
        unique id = 4
        offset x =  2
        offset y =  2
-       TOTAL    =  14 bytes 
+       TOTAL    =  14 bytes
     */
-    
+
     pm_readbigshort(fp, &version);
 
     if (fread(buf, 1, 12, fp) != 12)
         pm_error("bad header, short file?");
-    
+
     pm_readbigshort(fp, &cols);
     *colsP = cols;
     pm_readbigshort(fp, &rows);
     *rowsP = rows;
     pm_readbigshort(fp, &depth);
     *depthP = depth;
-    
+
     if ((compressed = fgetc(fp)) != 0)
         pm_error("Can't do compressed images.");
 
     if ((*depthP == 1) && (version < 4)) {
-        fgetc(fp); 
+        fgetc(fp);
         *ncolorsP = 0;
     } else if ((*depthP == 8) && (version < 4)) {
-        fgetc(fp); 
+        fgetc(fp);
         *ncolorsP = 0;
     } else {
         long format;
@@ -121,19 +121,19 @@ main(int argc, char * argv[]) {
     pixel colormap[MAXCOLORS];
     int rows, cols, row, col, depth, ncolors;
 
-    
+
     ppm_init(&argc, argv);
-    
+
     if (argc-1 > 1)
         pm_error("Too many arguments.  Only argument is ileaf file name");
-    
+
     if (argc-1 == 1)
         ifd = pm_openr(argv[1]);
     else
         ifd = stdin;
-    
+
     leaf_init(ifd, &cols, &rows, &depth, &ncolors, colormap);
-    
+
     if ((depth == 8) && (ncolors == 0)) {
         /* gray image */
         gray * grayrow;
@@ -177,7 +177,7 @@ main(int argc, char * argv[]) {
 
         ppm_writeppminit(stdout, cols, rows, (pixval) maxval, 0);
         pixrow = ppm_allocrow( cols );
-    
+
         for (row = 0; row < rows; ++row) {
             for (col = 0; col < cols; ++col)
                 pixrow[col] = colormap[fgetc(ifd)];
@@ -190,18 +190,18 @@ main(int argc, char * argv[]) {
         /* mono image */
         bit *bitrow;
         unsigned int row;
-        
+
         pbm_writepbminit(stdout, cols, rows, 0);
         bitrow = pbm_allocrow(cols);
-    
+
         for (row = 0; row < rows; ++row) {
             unsigned char bits;
             bits = 0x00;  /* initial value */
             for (col = 0; col < cols; ++col) {
                 int const shift = col % 8;
-                if (shift == 0) 
+                if (shift == 0)
                     bits = (unsigned char) fgetc(ifd);
-                bitrow[col] = (bits & (unsigned char)(0x01 << (7 - shift))) ? 
+                bitrow[col] = (bits & (unsigned char)(0x01 << (7 - shift))) ?
                     PBM_WHITE : PBM_BLACK;
             }
             if ((cols % 16) && (cols % 16) <= 8)
@@ -211,6 +211,9 @@ main(int argc, char * argv[]) {
         pbm_freerow(bitrow);
     }
     pm_close(ifd);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/ppm/mitsu.h b/converter/ppm/mitsu.h
index bca4fbdf..b0ae9aa5 100644
--- a/converter/ppm/mitsu.h
+++ b/converter/ppm/mitsu.h
@@ -10,19 +10,30 @@
 #define A_MAXROWS   1350
 #define AS_MAXROWS  1650
 
+/* To use the macros in this file that generate Mitsu output, define a
+   function named 'cmd' that outputs a character.  Like this:
+
+    static void
+    cmd(char const arg) {
+
+        fputc(arg, stdout);
+    }
+*/
+
 #define ONLINE         cmd('\021')
 #define CLRMEM         cmd('\033'), cmd('Z')
 
-struct mediasize {
-        char size;
-        int  maxcols, maxrows;
+struct Mediasize {
+    char         size;
+    unsigned int maxcols;
+    unsigned int maxrows;
 };
 
-const struct mediasize MSize_User={' ',1184,1350};
-const struct mediasize MSize_A4  ={'0',1184,1452};
-const struct mediasize MSize_A   ={'1',1216,1350};
-const struct mediasize MSize_A4S ={'2',1184,1754};
-const struct mediasize MSize_AS  ={'3',1216,1650};
+static struct Mediasize const MSize_User={' ',1184,1350};
+static struct Mediasize const MSize_A4  ={'0',1184,1452};
+static struct Mediasize const MSize_A   ={'1',1216,1350};
+static struct Mediasize const MSize_A4S ={'2',1184,1754};
+static struct Mediasize const MSize_AS  ={'3',1216,1650};
 #define MEDIASIZE(chr) cmd('\033'), cmd('#'), cmd('P'), cmd((chr).size)
 
 #define HENLARGE(enl)  cmd('\033'), cmd('&'), cmd('P'), cmd(enl), cmd('\001')
diff --git a/converter/ppm/mtvtoppm.c b/converter/ppm/mtvtoppm.c
index e8558632..42f99428 100644
--- a/converter/ppm/mtvtoppm.c
+++ b/converter/ppm/mtvtoppm.c
@@ -30,39 +30,42 @@ main( argc, argv )
     ppm_init( &argc, argv );
 
     if ( argc > 2 )
-	pm_usage( "[mtvfile]" );
+        pm_usage( "[mtvfile]" );
 
     if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+        ifp = pm_openr( argv[1] );
     else
-	ifp = stdin;
+        ifp = stdin;
 
     /* Read in the MTV file.  First the header. */
     if ( fgets( line, MAXLINE, ifp ) == NULL )
-	pm_error( "unable to read MTV file header" );
+        pm_error( "unable to read MTV file header" );
     if ( sscanf( line, "%d%d", &cols, &rows ) != 2 )
-	pm_error( "unable to parse MTV file header" );
+        pm_error( "unable to parse MTV file header" );
 
     if ( cols <= 0 || rows <= 0 )
-	pm_error( "invalid size: %d %d", cols, rows );
+        pm_error( "invalid size: %d %d", cols, rows );
     maxval = 255;
 
     ppm_writeppminit( stdout, cols, rows, maxval, 0 );
     pixelrow = ppm_allocrow( cols );
 
     for ( row = 0; row < rows; row++ )
-	{
-	for ( col = 0, pP = pixelrow; col < cols; col++, pP++ )
-	    {
-	    if ( fread( buf, sizeof(buf), 1, ifp ) != 1 )
-		pm_error( "EOF / read error" );
-	    PPM_ASSIGN( *pP, buf[0], buf[1], buf[2] );
-	    }
-	ppm_writeppmrow( stdout, pixelrow, cols, maxval, 0 );
-	}
+        {
+        for ( col = 0, pP = pixelrow; col < cols; col++, pP++ )
+            {
+            if ( fread( buf, sizeof(buf), 1, ifp ) != 1 )
+                pm_error( "EOF / read error" );
+            PPM_ASSIGN( *pP, buf[0], buf[1], buf[2] );
+            }
+        ppm_writeppmrow( stdout, pixelrow, cols, maxval, 0 );
+        }
 
     pm_close( ifp );
     pm_close( stdout );
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/neotoppm.c b/converter/ppm/neotoppm.c
index d8cf2918..6ce5ef43 100644
--- a/converter/ppm/neotoppm.c
+++ b/converter/ppm/neotoppm.c
@@ -57,7 +57,7 @@ main( int argc, char * argv[] ) {
         /* Read the palette. */
         for ( i = 0; i < 16; ++i ) {
             short j;
-            
+
             pm_readbigshort (ifp, &j);
             PPM_ASSIGN( pal[i],
                         ( j & 0x700 ) >> 8,
@@ -102,3 +102,6 @@ main( int argc, char * argv[] ) {
 
     exit( 0 );
 }
+
+
+
diff --git a/converter/ppm/pc1toppm.c b/converter/ppm/pc1toppm.c
index ec6678a4..45d09faa 100644
--- a/converter/ppm/pc1toppm.c
+++ b/converter/ppm/pc1toppm.c
@@ -13,7 +13,7 @@
  documentation.  This software is provided "as is" without express or
  implied warranty.
 
- Algorithm for PC1 compression from "gimp-degas" GIMP plugin 
+ Algorithm for PC1 compression from "gimp-degas" GIMP plugin
  by Markus F.X.J. Oberhumer
 
 */
@@ -39,7 +39,7 @@ unsigned int const colsPerBlock = 16;
 
 
 static void
-readPalette(FILE *   const ifP, 
+readPalette(FILE *   const ifP,
             pixel (* const palP)[]) {
 
     /* Read the palette. */
@@ -78,7 +78,7 @@ processStretch(unsigned int     const countbyte,
         }
     } else {
         /* next byte repeated 257-countbyte times */
-                
+
         unsigned char const duplicated_color = getc(ifP);
         unsigned int  const count = 257 - countbyte;
         unsigned int i;
@@ -121,8 +121,8 @@ readPc1(FILE * const ifP,
             unsigned int const countbyte = getc(ifP);
 
             processStretch(countbyte, ifP, &col, &bufferCursor);
-	    }
-	}
+            }
+        }
 }
 
 
@@ -130,7 +130,7 @@ readPc1(FILE * const ifP,
 static void
 reInterleave(unsigned char     const buffer[],
              unsigned short (* const screenP)[]) {
-    
+
     /* The buffer is in one plane for each line, to optimize packing */
     /* Re-interleave to match the Atari screen layout                */
 
@@ -142,10 +142,10 @@ reInterleave(unsigned char     const buffer[],
         for (block = 0; block < BLOCKS; ++block) {
             unsigned int plane;
             for (plane = 0; plane < planes; ++plane) {
-                unsigned int const blockIndex = 
+                unsigned int const blockIndex =
                     row*ROWBYTES + plane*PLANEBYTES + block*BLOCKBYTES;
 
-                screen[row*ROWSHORTS + block*BLOCKSHORTS + plane] = 
+                screen[row*ROWSHORTS + block*BLOCKSHORTS + plane] =
                     (buffer[blockIndex+0] << 8) + (buffer[blockIndex+1]);
             }
         }
@@ -202,9 +202,9 @@ main(int argc, char ** argv) {
     const char * inputFilename;
     FILE* ifP;
     pixel palette[16];  /* Degas palette */
-    static unsigned short screen[32000/2];   
+    static unsigned short screen[32000/2];
         /* simulates the Atari's video RAM */
-    static unsigned char buffer[32000];   
+    static unsigned char buffer[32000];
         /* simulates the Atari's video RAM */
 
     ppm_init(&argc, argv);
@@ -231,3 +231,6 @@ main(int argc, char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/pi1toppm.c b/converter/ppm/pi1toppm.c
index 69b99863..9a07f535 100644
--- a/converter/ppm/pi1toppm.c
+++ b/converter/ppm/pi1toppm.c
@@ -90,3 +90,6 @@ main( argc, argv )
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
index ec701cfc..8ca553bd 100644
--- a/converter/ppm/picttoppm.c
+++ b/converter/ppm/picttoppm.c
@@ -339,6 +339,7 @@ allocateRaster(struct Raster * const rasterP,
 }
 
 
+
 static void
 freeRaster(struct Raster const raster) {
 
@@ -346,6 +347,7 @@ freeRaster(struct Raster const raster) {
 }
 
 
+
 struct BlitInfo {
     struct Rect       srcRect;
     struct Rect       srcBounds;
@@ -763,6 +765,7 @@ skipPolyOrRegion(FILE *          const ifP,
 }
 
 
+
 #define NA (0)
 
 #define FNT_BOLD    (1)
@@ -969,6 +972,7 @@ rectequal(const struct Rect * const comparand,
 }
 
 
+
 static int
 rectheight(const struct Rect * const r) {
 
@@ -2719,6 +2723,7 @@ interpretCompressedLine(unsigned char * const linebuf,
 }
 
 
+
 /* There is some confusion about when, in PICT, a line length is one byte and
   when it is two.  An Apple document says it is two bytes when the number of
   pixels in the row, padded, is > 250.  Ppmtopict generated PICTs that way
@@ -3194,6 +3199,8 @@ drawPen(struct Canvas * const canvasP,
     drawPenRect(canvasP, &clippedPenrect);
 }
 
+
+
 /*
  * Digital Line Drawing
  * by Paul Heckbert
diff --git a/converter/ppm/ppmtoacad.c b/converter/ppm/ppmtoacad.c
index b5ee4d65..4f4dc5dd 100644
--- a/converter/ppm/ppmtoacad.c
+++ b/converter/ppm/ppmtoacad.c
@@ -108,33 +108,33 @@ static void outrun(color, ysize, y, xstart, xend)
                 stdout, (int) ((xend + 1) * aspect + 0.4999));
             (void) pm_writelittleshort(stdout, yb - yspan);
         } else {
-            (void) pm_writelittleshort(stdout, (short) 0xFD00); 
+            (void) pm_writelittleshort(stdout, (short) 0xFD00);
               /* Solid fill header */
-            (void) pm_writelittleshort(stdout, 4);      
+            (void) pm_writelittleshort(stdout, 4);
               /* Vertices to follow */
             (void) pm_writelittleshort(stdout, -2);     /* Fill type */
 
-            (void) pm_writelittleshort(stdout, (short)0xFD00); 
+            (void) pm_writelittleshort(stdout, (short)0xFD00);
               /* Solid fill vertex */
             (void) pm_writelittleshort(stdout, xstart);
             (void) pm_writelittleshort(stdout, yb);
 
-            (void) pm_writelittleshort(stdout, (short) 0xFD00); 
+            (void) pm_writelittleshort(stdout, (short) 0xFD00);
               /* Solid fill vertex */
             (void) pm_writelittleshort(stdout, xend + 1);
             (void) pm_writelittleshort(stdout, yb);
 
-            (void) pm_writelittleshort(stdout, (short) 0xFD00); 
+            (void) pm_writelittleshort(stdout, (short) 0xFD00);
               /* Solid fill vertex */
             (void) pm_writelittleshort(stdout, xend + 1);
             (void) pm_writelittleshort(stdout, yb - yspan);
 
-            (void) pm_writelittleshort(stdout, (short) 0xFD00); 
+            (void) pm_writelittleshort(stdout, (short) 0xFD00);
               /* Solid fill vertex */
             (void) pm_writelittleshort(stdout, xstart);
             (void) pm_writelittleshort(stdout, yb - yspan);
 
-            (void) pm_writelittleshort(stdout, (short) 0xFD00); 
+            (void) pm_writelittleshort(stdout, (short) 0xFD00);
               /* Solid fill trailer */
             (void) pm_writelittleshort(stdout, 4); /* Vertices that precede */
             (void) pm_writelittleshort(stdout, -2);     /* Fill type */
@@ -147,6 +147,8 @@ static void outrun(color, ysize, y, xstart, xend)
     }
 }
 
+
+
 /*  SLIDEOUT  --  Write an AutoCAD slide.  */
 
 static void slideout(xdots, ydots, ncolors, red, green, blue)
@@ -253,12 +255,14 @@ static void slideout(xdots, ydots, ncolors, red, green, blue)
     if (dxbmode) {
         putchar(0);                   /* DXB end sentinel */
     } else {
-        (void) pm_writelittleshort(stdout, (short) 0xFC00); 
+        (void) pm_writelittleshort(stdout, (short) 0xFC00);
           /* End of file marker */
     }
     pm_freerow((char *) acadmap);
 }
 
+
+
 /*  Main program.  */
 
 int main(argc, argv)
@@ -391,3 +395,6 @@ int main(argc, argv)
     pm_freerow((char *) Blue);
     exit(0);
 }
+
+
+
diff --git a/converter/ppm/ppmtoapplevol.c b/converter/ppm/ppmtoapplevol.c
index 1e979de9..50c85dc6 100644
--- a/converter/ppm/ppmtoapplevol.c
+++ b/converter/ppm/ppmtoapplevol.c
@@ -97,3 +97,6 @@ main (int argc, const char * argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtoarbtxt.c b/converter/ppm/ppmtoarbtxt.c
index 6d4c6eac..cb2c388b 100644
--- a/converter/ppm/ppmtoarbtxt.c
+++ b/converter/ppm/ppmtoarbtxt.c
@@ -69,11 +69,11 @@ parseCommandLine(int argc, const char ** argv,
     unsigned int hdSpec, tlSpec;
 
     unsigned int option_def_index;
-    
+
     MALLOCARRAY(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0,   "hd",   OPT_STRING, &cmdlineP->hd, 
+    OPTENT3(0,   "hd",   OPT_STRING, &cmdlineP->hd,
             &hdSpec,             0);
     OPTENT3(0,   "tl",   OPT_STRING, &cmdlineP->tl,
             &tlSpec,             0);
@@ -113,7 +113,6 @@ parseCommandLine(int argc, const char ** argv,
 
 
 
-
 typedef enum {
 /* The types of object we handle */
     BDATA, IRED, IGREEN, IBLUE, ILUM, FRED, FGREEN, FBLUE, FLUM,
@@ -134,7 +133,7 @@ typedef union {
         char * bdat;   /* Binary data (text with newlines etc.) */
         unsigned int ndat;
     } binData;
-    
+
     struct Icdat {
         char icformat[MAXFORMAT+1];  /* Integer colors */
         unsigned int icolmin, icolmax;
@@ -144,7 +143,7 @@ typedef union {
         char fcformat[MAXFORMAT+1];  /* Float colors */
         double fcolmin, fcolmax;
     } fcolData;
-    
+
     struct Idat {
         char iformat[MAXFORMAT+1];   /* Integer data */
     } iData;
@@ -152,7 +151,7 @@ typedef union {
 
 
 /* Each object has a type and some data */
-typedef struct { 
+typedef struct {
     SkeletonObjectType objType;
     SkeletonObjectData odata;
 } SkeletonObject;
@@ -187,11 +186,11 @@ dumpSkeleton(SkeletonObject ** const skeletonPList,
 static void
 dumpAllSkeleton(SkeletonObject ** const bodySkeletonPList,
                 unsigned int      const bodyNskl,
-                SkeletonObject ** const headSkeletonPList, 
+                SkeletonObject ** const headSkeletonPList,
                 unsigned int      const headNskl,
                 SkeletonObject ** const tailSkeletonPList,
                 unsigned int      const tailNskl) {
-    
+
     pm_message("Body skeleton:");
     dumpSkeleton(bodySkeletonPList, bodyNskl);
 
@@ -240,7 +239,7 @@ writeFcol(FILE *           const ofP,
           double           const value) {
 
     struct Fcdat * const fcdataP = &objectP->odata.fcolData;
-    
+
     fprintf(ofP, fcdataP->fcformat,
             (double)
             (fcdataP->fcolmin
@@ -255,7 +254,7 @@ writeIdat(FILE *           const ofP,
           unsigned int     const value) {
 
     struct Idat * const idataP = &objectP->odata.iData;
-    
+
     fprintf(ofP, idataP->iformat, value);
 }
 
@@ -272,7 +271,7 @@ writeText(FILE *            const ofP,
           double            const red,
           double            const green,
           double            const blue) {
-    
+
     unsigned int i;
 
     for (i = 0; i < nObj; ++i) {
@@ -352,6 +351,7 @@ objClass(SkeletonObjectType const objType) {
 }
 
 
+
 /*----------------------------------------------------------------------------
   Format string validation
 
@@ -366,7 +366,7 @@ objClass(SkeletonObjectType const objType) {
 
   Documentation for parse_printf_format() is usually available in texinfo
   format on GNU/Linux systems.  As of Dec. 2014 there is no official man page.
-  
+
   Online documentation is available from:
   https://
   www.gnu.org/software/libc/manual/html_node/Parsing-a-Template-String.html
@@ -379,7 +379,7 @@ validateParsePrintfFlag(int                const printfConversion,
                         const char **      const errorP) {
 /*----------------------------------------------------------------------------
   Assuming 'printfConversion' is the value reported by parse_printf_format()
-  as the type of argument a format string requires, 
+  as the type of argument a format string requires,
   return an explanation of how it is incompatible with 'ctyp' as
   *errorP -- return null string if it is compatible.
 -----------------------------------------------------------------------------*/
@@ -403,7 +403,7 @@ validateParsePrintfFlag(int                const printfConversion,
     default:
         switch (printfConversion & ~PA_FLAG_MASK) {
         case PA_CHAR:
-            pm_message("Warning: char type conversion."); 
+            pm_message("Warning: char type conversion.");
         case PA_INT:
             if(objClass(ctyp) == OBJTYP_ICOLOR ||
                objClass(ctyp) == OBJTYP_INT )
@@ -496,7 +496,7 @@ validateFormatOne(char               const typeSpecifier,
     case '0': case '1': case '2': case '3': case '4': case '5':
     case '6': case '7': case '8': case '9':
         break;
-        
+
     case 'c': case 'C':
         pm_message("Warning: char type conversion: %%%c.", typeSpecifier);
     case 'i': case 'd': case 'u': case 'o': case 'x': case 'X':
@@ -599,12 +599,12 @@ validateFormat(const char *       const format,
 
     if (error)
         pm_error("Invalid format string '%s'.  %s", format, error);
-}              
-               
+}
+
 
 
 static SkeletonObject *
-newBinDataObj(unsigned int const nDat, 
+newBinDataObj(unsigned int const nDat,
               const char * const bdat) {
 /*----------------------------------------------------------------------------
   Create a binary data object.
@@ -787,7 +787,7 @@ newFcSkelFromReplString(const char *       const fcolorObjstr,
         retval = NULL;
 
     return retval;
-} 
+}
 
 
 
@@ -805,7 +805,7 @@ newISkelFromReplString(const char *       const intObjstr,
     int nOdata;
 
     nOdata = sscanf(intObjstr, "%s", formstr);
-    
+
     if (nOdata == 1)
         retval = newIdataObj(objType, formstr);
     else if (nOdata == EOF) {
@@ -815,7 +815,7 @@ newISkelFromReplString(const char *       const intObjstr,
         retval = NULL;
 
     return retval;
-} 
+}
 
 
 
@@ -842,7 +842,7 @@ newSkeletonFromReplString(const char * const objstr) {
     int conversionCt;
     char s1[MAX_OBJ_BUF];    /* Dry read. */
     char s2[MAX_OBJ_BUF];    /* Extra tailing characters. */
-    float f1, f2;            /* Dry read. */ 
+    float f1, f2;            /* Dry read. */
 
     typstr[0] = '\0';  /* initial value */
 
@@ -905,7 +905,7 @@ readThroughCloseParen(FILE * const ifP,
             if (chr == ')') {
                 gotEscSeq = true;
                 objstr[i] = '\0';
-	        } else
+                } else
                 objstr[i] = chr;
         }
     }
@@ -942,7 +942,7 @@ SkeletonBuffer_add(SkeletonBuffer * const bufferP,
         pm_error("Too many skeletons.  Max = %u", bufferP->capacity);
 
     bufferP->skeletonPList[bufferP->nSkeleton++] = skeletonP;
-}                   
+}
 
 
 
@@ -1050,7 +1050,7 @@ readSkeletonFile(const char *      const filename,
         /* A buffer for accumulating skeleton objects */
     Buffer buffer;
         /* A buffer for accumulating binary (literal; unsubstituted) data, on
-           its way to becoming a binary skeleton object. 
+           its way to becoming a binary skeleton object.
         */
     bool eof;
     const char * error;
@@ -1135,7 +1135,7 @@ convertIt(FILE *            const ifP,
           FILE *            const ofP,
           SkeletonObject ** const bodySkeletonPList,
           unsigned int      const bodyNskl,
-          SkeletonObject ** const headSkeletonPList, 
+          SkeletonObject ** const headSkeletonPList,
           unsigned int      const headNskl,
           SkeletonObject ** const tailSkeletonPList,
           unsigned int      const tailNskl) {
@@ -1154,7 +1154,7 @@ convertIt(FILE *            const ifP,
     dmaxval = (double)maxval;
 
     /* Write header */
-    writeText(ofP, headNskl, headSkeletonPList, 
+    writeText(ofP, headNskl, headSkeletonPList,
               cols, rows , 0, 0, 0.0, 0.0, 0.0);
 
     /* Write raster */
@@ -1175,7 +1175,7 @@ convertIt(FILE *            const ifP,
     }
 
     /* Write trailer */
-    writeText(ofP, tailNskl, tailSkeletonPList, 
+    writeText(ofP, tailNskl, tailSkeletonPList,
               cols, rows, 0, 0, 0.0, 0.0, 0.0);
 }
 
@@ -1184,7 +1184,7 @@ convertIt(FILE *            const ifP,
 int
 main(int           argc,
      const char ** argv) {
-    
+
     struct CmdlineInfo cmdline;
 
     unsigned int headNskl, bodyNskl, tailNskl;
@@ -1240,3 +1240,4 @@ main(int           argc,
 }
 
 
+
diff --git a/converter/ppm/ppmtoascii.c b/converter/ppm/ppmtoascii.c
index 6b0b04d7..524bcd2c 100644
--- a/converter/ppm/ppmtoascii.c
+++ b/converter/ppm/ppmtoascii.c
@@ -164,7 +164,7 @@ ppmtoascii(pixel * const *    const pixels,
 
     for (row = 0; row < rows; row += cellHeight) {
         unsigned int col;
-        for (col = 0; col < cols; col += cellWidth)	{
+        for (col = 0; col < cols; col += cellWidth)     {
             unsigned int const sumthresh = cellWidth * cellHeight * 1.0 / 2;
 
             float sumr, sumg, sumb;
@@ -181,7 +181,7 @@ ppmtoascii(pixel * const *    const pixels,
                 for (subcol = 0; subcol < cellWidth; ++subcol) {
                     pixel color;
                     pixval value;
-                
+
                     if (row + subrow < rows && col + subcol < cols)
                         color = pixels[row + subrow][col + subcol];
                     else
@@ -225,7 +225,7 @@ main(int argc, const char ** argv) {
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
 
     pm_close(ifP);
@@ -234,3 +234,6 @@ main(int argc, const char ** argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtobmp.c b/converter/ppm/ppmtobmp.c
index 41cee482..8590c5ef 100644
--- a/converter/ppm/ppmtobmp.c
+++ b/converter/ppm/ppmtobmp.c
@@ -183,6 +183,7 @@ putLong(FILE * const fp, long const v) {
 }
 
 
+
 /*----------------------------------------------------------------------------
    BMP writing
 -----------------------------------------------------------------------------*/
diff --git a/converter/ppm/ppmtoeyuv.c b/converter/ppm/ppmtoeyuv.c
index c4cedcdf..0cfe9b13 100644
--- a/converter/ppm/ppmtoeyuv.c
+++ b/converter/ppm/ppmtoeyuv.c
@@ -66,7 +66,7 @@
 #include "ppm.h"
 #include "mallocvar.h"
 
-typedef	unsigned char uint8;
+typedef unsigned char uint8;
 
 /* Multiplication tables */
 
@@ -92,6 +92,8 @@ luminance(pixel const p) {
         ;
 }
 
+
+
 static __inline__ float
 chrominanceRed(pixel const p) {
     return mult5[PPM_GETR(p)]
@@ -100,6 +102,8 @@ chrominanceRed(pixel const p) {
         ;
 }
 
+
+
 static __inline__ float
 chrominanceBlue(pixel const p) {
     return mult16874[PPM_GETR(p)]
@@ -171,10 +175,10 @@ freeMultiplicationTables(void) {
  *
  * PPMtoYUV
  *
- *	convert PPM data into YUV data
- *	assumes that ydivisor = 1
+ *      convert PPM data into YUV data
+ *      assumes that ydivisor = 1
  *
- * RETURNS:	nothing
+ * RETURNS:     nothing
  *
  * SIDE EFFECTS:    none
  *
@@ -362,8 +366,8 @@ main(int argc, const char **argv) {
 
     eof = false;  /* EOF not yet encountered */
     lastMaxval = 0;  /* No previous maxval */
-    lastWidth = 0;	/* No previous width */
-    lastHeight = 0;	/* No previous height */
+    lastWidth = 0;      /* No previous width */
+    lastHeight = 0;     /* No previous height */
     orig_y = orig_cr = orig_cb = 0;
 
     while (!eof) {
diff --git a/converter/ppm/ppmtoicr.c b/converter/ppm/ppmtoicr.c
index 74ed4308..de21fc68 100644
--- a/converter/ppm/ppmtoicr.c
+++ b/converter/ppm/ppmtoicr.c
@@ -149,7 +149,6 @@ validateComputableSize(unsigned int const cols,
 
 
 
-
 static void
 makeIcrColormap(colorhist_vector const chv,
                 unsigned int     const colorCt,
@@ -290,6 +289,7 @@ windowNameFmFileName(const char * const fileName) {
 }
 
 
+
             int
 main(int argc, const char ** const argv) {
 
diff --git a/converter/ppm/ppmtoilbm.c b/converter/ppm/ppmtoilbm.c
index f9672733..c91315c3 100644
--- a/converter/ppm/ppmtoilbm.c
+++ b/converter/ppm/ppmtoilbm.c
@@ -344,6 +344,7 @@ writeTextChunks(void) {
 }
 
 
+
 static void
 writeCmap(pixel * const colormap,
           int     const colors,
@@ -2138,7 +2139,7 @@ main(int argc, char ** argv) {
         else
         if( pm_keymatch(argv[argn], "-nofloyd", 5) ||
             pm_keymatch(argv[argn], "-nofs", 5) )
-	    defunctArgs++;
+            defunctArgs++;
         else
         if( pm_keymatch(argv[argn], "-annotation", 3) ) {
             if( ++argn >= argc )
diff --git a/converter/ppm/ppmtoleaf.c b/converter/ppm/ppmtoleaf.c
index dcff0985..dc73dc48 100644
--- a/converter/ppm/ppmtoleaf.c
+++ b/converter/ppm/ppmtoleaf.c
@@ -11,7 +11,7 @@
  *
  * Known problems: pgms are not converted to leaf grayscales; they are
  * converted to 8-bit color images with all gray for colors.
- * 
+ *
  */
 
 #include <stdio.h>
@@ -31,7 +31,7 @@ static int
 colorstobpp(unsigned int const colors) {
 
     int bpp;
-    
+
     if (colors <= 2)
         bpp = 1;
     else if (colors <= 256)
@@ -49,15 +49,14 @@ GetPixel(int const x,
          int const y) {
 
     int color;
-    
+
     color = ppm_lookupcolor(cht, &pixels[y][x]);
-    
+
     return color;
 }
 
 
 
-
 static void
 leaf_writeimg(unsigned int const width,
               unsigned int const height,
@@ -70,52 +69,52 @@ leaf_writeimg(unsigned int const width,
     */
 
     /* NOTE: byte order in ileaf img file fmt is big-endian, always! */
-    
+
     /* magic */
     fputc(0x89, stdout);
     fputc(0x4f, stdout);
     fputc(0x50, stdout);
     fputc(0x53, stdout);
-    
+
     /* version 4 */
     fputc(0x00, stdout);
     fputc(0x04, stdout);
-    
+
     /* h resolution: pixels/inch: say 75=screen resolution */
     fputc(0x00, stdout);
     fputc(75, stdout);
-    
+
     /* v resolution: pixels/inch: say 75=screen resolution */
     fputc(0x00, stdout);
     fputc(75, stdout);
-    
+
     /* unique id, could be anything */
     fputc(0x01, stdout);
     fputc(0x02, stdout);
     fputc(0x03, stdout);
     fputc(0x04, stdout);
-    
+
     /* x offset, always zero */
     fputc(0x00, stdout);
     fputc(0x00, stdout);
-    
+
     /* y offset, always zero */
     fputc(0x00, stdout);
     fputc(0x00, stdout);
-    
+
     /* dimensions 64k x 64k max */
     fputc((unsigned char)((width >> 8) & 0x00ff), stdout);
     fputc((unsigned char)(width  & 0x00ff), stdout);
     fputc((unsigned char)((height >> 8) & 0x00ff), stdout);
     fputc((unsigned char)(height  & 0x00ff), stdout);
-    
+
     /* depth */
     fputc(0x00, stdout);
     fputc((unsigned char)depth, stdout);
-    
+
     /* compressed, 0=uncompressed, 1=compressed */
     fputc(0x00, stdout);
-    
+
     /* format, mono/gray = 0x20000000, RGB=0x29000000 */
     if (depth == 1)
         fputc(0x20, stdout);
@@ -125,7 +124,7 @@ leaf_writeimg(unsigned int const width,
     fputc(0x00, stdout);
     fputc(0x00, stdout);
     fputc(0x00, stdout);
-    
+
     /* colormap size */
     if (depth == 8) {
         unsigned int i;
@@ -139,10 +138,10 @@ leaf_writeimg(unsigned int const width,
             fputc((unsigned char) Green[i]*255/maxval, stdout);
         for (i = 0; i < 256; ++i)
             fputc((unsigned char) Blue[i]*255/maxval, stdout);
-    
+
         for (row=0; row < height; ++row) {
             unsigned int col;
-            for (col = 0; col < width; ++col) 
+            for (col = 0; col < width; ++col)
                 fputc(GetPixel(col, row), stdout);
             if ((width % 2) != 0)
                 fputc(0x00, stdout); /* pad to 2-bytes */
@@ -180,18 +179,18 @@ leaf_writeimg(unsigned int const width,
 
         fputc(0x00, stdout);
         fputc(0x00, stdout);
-        
+
         for (row = 0; row < height; ++row) {
             unsigned int col;
-            for (col = 0; col < width; ++col) 
+            for (col = 0; col < width; ++col)
                 fputc(pixels[row][col].r * 255 / maxval, stdout);
             if (width % 2 != 0)
                 fputc(0x00, stdout); /* pad to 2-bytes */
-            for (col = 0; col < width; ++col) 
+            for (col = 0; col < width; ++col)
                 fputc(pixels[row][col].g * 255 / maxval, stdout);
             if (width % 2 != 0)
                 fputc(0x00, stdout); /* pad to 2-bytes */
-            for (col = 0; col < width; ++col) 
+            for (col = 0; col < width; ++col)
                 fputc(pixels[row][col].b * 255 / maxval, stdout);
             if (width % 2 != 0)
                 fputc(0x00, stdout); /* pad to 2-bytes */
@@ -212,24 +211,24 @@ main(int argc, const char * argv[]) {
     pixval maxval;
     colorhist_vector chv;
     const char * const usage = "[ppmfile]";
-    
+
     pm_proginit(&argc, argv);
-    
+
     argn = 1;
-    
+
     if (argn < argc) {
         ifP = pm_openr(argv[argn]);
         argn++;
     } else
         ifP = stdin;
-    
+
     if (argn != argc)
         pm_usage(usage);
-    
+
     pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
-    
+
     pm_close(ifP);
-    
+
     /* Figure out the colormap. */
     pm_message("Computing colormap...");
     chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colors);
@@ -237,14 +236,14 @@ main(int argc, const char * argv[]) {
         unsigned int i;
 
         pm_message("... Done.  %u colors found.", colors);
-    
+
         for (i = 0; i < colors; ++i) {
             Red[i]   = (int) PPM_GETR( chv[i].color);
             Green[i] = (int) PPM_GETG( chv[i].color);
             Blue[i]  = (int) PPM_GETB( chv[i].color);
         }
         BitsPerPixel = colorstobpp(colors);
-    
+
         /* And make a hash table for fast lookup. */
         cht = ppm_colorhisttocolorhash(chv, colors);
         ppm_freecolorhist(chv);
@@ -252,8 +251,11 @@ main(int argc, const char * argv[]) {
         BitsPerPixel = 24;
         pm_message("  ... Done.  24-bit true color %u color image.", colors);
     }
-    
+
     leaf_writeimg(cols, rows, BitsPerPixel, colors, maxval);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
index 50b790d6..8fb7cddd 100644
--- a/converter/ppm/ppmtomitsu.c
+++ b/converter/ppm/ppmtomitsu.c
@@ -20,6 +20,7 @@
 ** implied warranty.
 */
 
+#include <stdbool.h>
 #include <assert.h>
 #include <string.h>
 #include <stdio.h>
@@ -35,28 +36,84 @@
 #define HASHSIZE 2048
 #define myhash(x) ((PPM_GETR(x)*3 + PPM_GETG(x)*5 + PPM_GETB(x)*7) % HASHSIZE)
 
-typedef struct hashinfo {
+typedef struct Hashinfo {
         pixel     color;
         long      flag;
-        struct hashinfo * next;
-} hashinfo;
+        struct Hashinfo * next;
+} Hashinfo;
 
-#define cmd(arg)           fputc((arg), stdout)
-#define datum(arg)         fputc((char)(arg), stdout)
-#define data(arg,num)      fwrite((arg), sizeof(char), (num), stdout)
+
+
+static struct Mediasize
+mediaSize(const char * const media,
+          bool         const dpi300) {
+
+    struct Mediasize medias;
+
+    if (TOUPPER(media[0]) == 'A') {
+        switch (TOUPPER(media[1])) {
+        case 'S':
+            medias = MSize_AS;
+            break;
+        case '4':
+            if (TOUPPER(media[2]) == 'S')
+                medias = MSize_A4S;
+            else
+                medias = MSize_A4;
+            break;
+        default:
+            medias = MSize_A;
+        }
+    } else
+        medias = MSize_User;
+
+    if (dpi300) {
+        medias.maxcols *= 2;
+        medias.maxrows *= 2;
+    }
+
+    return medias;
+}
 
 
 
 static void
-check_and_rotate(int              const cols,
-                 int              const rows,
-                 int              const enlarge,
-                 struct mediasize const medias) {
+cmd(char const arg) {
+
+    fputc(arg, stdout);
+}
+
+
+
+static void
+datum(unsigned char const arg) {
+
+    fputc(arg, stdout);
+}
+
+
+
+static void
+data(unsigned char * const arg,
+     size_t          const len) {
+
+    fwrite((unsigned char *)arg, 1, len, stdout);
+}
+
+
+
+static void
+checkAndRotate(int              const cols,
+               int              const rows,
+               int              const enlarge,
+               struct Mediasize const medias) {
 
     if (cols > rows) {
         ROTATEIMG(DOROTATE);                        /* rotate image */
         if (enlarge * rows > medias.maxcols || enlarge * cols > medias.maxrows)
-            pm_error("Image too large, MaxPixels = %u x %u",
+            pm_error("Image too large (%u x %u).  "
+                     "Size of output media: %u x %u",
+                     enlarge*rows, enlarge*cols,
                      medias.maxrows, medias.maxcols);
         HPIXELS(cols);
         VPIXELS(rows);
@@ -66,7 +123,9 @@ check_and_rotate(int              const cols,
     } else {
         ROTATEIMG(DONTROTATE);
         if (enlarge * rows > medias.maxrows || enlarge * cols > medias.maxcols)
-            pm_error("Image too large, MaxPixels = %u x %u",
+            pm_error("Image too large (%u x %u).  "
+                     "Size of output media: %u x %u",
+                     enlarge*rows, enlarge*cols,
                      medias.maxrows, medias.maxcols);
         HPIXELS(cols);
         VPIXELS(rows);
@@ -83,7 +142,7 @@ lineputinit(int              const cols,
             int              const sharpness,
             int              const enlarge,
             int              const copy,
-            struct mediasize const medias) {
+            struct Mediasize const medias) {
     ONLINE;
     CLRMEM;
     MEDIASIZE(medias);
@@ -132,7 +191,7 @@ lineputinit(int              const cols,
     default:
         SHARPNESS(SP_USER);
     }
-    check_and_rotate(cols, rows, enlarge, medias);
+    checkAndRotate(cols, rows, enlarge, medias);
     DATASTART;
 }
 
@@ -142,7 +201,7 @@ static void
 lookuptableinit(int              const sharpness,
                 int              const enlarge,
                 int              const copy,
-                struct mediasize const medias) {
+                struct Mediasize const medias) {
 
     ONLINE;
     CLRMEM;
@@ -200,10 +259,10 @@ static void
 lookuptabledata(int              const cols,
                 int              const rows,
                 int              const enlarge,
-                struct mediasize const medias) {
+                struct Mediasize const medias) {
 
     DONELOOKUPTABLE;
-    check_and_rotate(cols, rows, enlarge, medias);
+    checkAndRotate(cols, rows, enlarge, medias);
     DATASTART;
 }
 
@@ -215,7 +274,7 @@ frametransferinit(int              const cols,
                   int              const sharpness,
                   int              const enlarge,
                   int              const copy,
-                  struct mediasize const medias) {
+                  struct Mediasize const medias) {
 
     ONLINE;
     CLRMEM;
@@ -265,7 +324,7 @@ frametransferinit(int              const cols,
     default:
         SHARPNESS(SP_USER);
     }
-    check_and_rotate(cols, rows, enlarge, medias);
+    checkAndRotate(cols, rows, enlarge, medias);
 }
 
 
@@ -273,14 +332,14 @@ frametransferinit(int              const cols,
 static void
 doLookupTableColors(colorhist_vector const table,
                     unsigned int     const nColor,
-                    hashinfo *       const colorhashtable) {
+                    Hashinfo *       const colorhashtable) {
 
     unsigned int colval;
     for (colval = 0; colval < nColor; ++colval) {
-        struct hashinfo * const hashchain =
+        struct Hashinfo * const hashchain =
             &colorhashtable[myhash((table[colval]).color)];
 
-        struct hashinfo * hashrun;
+        struct Hashinfo * hashrun;
 
         cmd('$');
         datum(colval);
@@ -310,13 +369,13 @@ doLookupTableColors(colorhist_vector const table,
 static void
 doLookupTableGrays(colorhist_vector const table,
                    unsigned int     const nColor,
-                   hashinfo *       const colorhashtable) {
+                   Hashinfo *       const colorhashtable) {
 
     unsigned int colval;
     for (colval = 0; colval < nColor; ++colval) {
-        struct hashinfo * const hashchain =
+        struct Hashinfo * const hashchain =
             &colorhashtable[myhash((table[colval]).color)];
-        struct hashinfo * hashrun;
+        struct Hashinfo * hashrun;
 
         cmd('$');
         datum(colval);
@@ -352,8 +411,8 @@ generateLookupTable(colorhist_vector const table,
                     int              const sharpness,
                     int              const enlarge,
                     int              const copy,
-                    struct mediasize const medias,
-                    hashinfo **      const colorhashtableP) {
+                    struct Mediasize const medias,
+                    Hashinfo **      const colorhashtableP) {
 /*----------------------------------------------------------------------------
    Write to the output file the palette (color lookup table) indicated by
    'table' and generate a hash table to use with it: *colorhashtableP.
@@ -361,7 +420,7 @@ generateLookupTable(colorhist_vector const table,
    Also write the various properties 'sharpness', 'enlarge', 'copy', and
    'medias' to the output file.
 -----------------------------------------------------------------------------*/
-    hashinfo * colorhashtable;
+    Hashinfo * colorhashtable;
 
     lookuptableinit(sharpness, enlarge, copy, medias);
 
@@ -394,7 +453,7 @@ static void
 writeColormapRaster(pixel **         const pixels,
                     unsigned int     const cols,
                     unsigned int     const rows,
-                    hashinfo *       const colorhashtable) {
+                    Hashinfo *       const colorhashtable) {
 /*----------------------------------------------------------------------------
    Write a colormapped raster: write the pixels pixels[][] (dimensions cols x
    rows) as indices into the colormap (palette; lookup table) indicated by
@@ -407,9 +466,9 @@ writeColormapRaster(pixel **         const pixels,
 
         for (col = 0; col < cols; ++col) {
             pixel * const pixrow = pixels[row];
-            struct hashinfo * const hashchain =
+            struct Hashinfo * const hashchain =
                 &colorhashtable[myhash(pixrow[col])];
-            struct hashinfo * p;
+            struct Hashinfo * p;
 
             p = hashchain;
             while (!PPM_EQUAL((p->color), pixrow[col])) {
@@ -429,13 +488,13 @@ useLookupTable(pixel **         const pixels,
                int              const sharpness,
                int              const enlarge,
                int              const copy,
-               struct mediasize const medias,
+               struct Mediasize const medias,
                unsigned int     const cols,
                unsigned int     const rows,
                int              const format,
                unsigned int     const nColor) {
 
-    hashinfo * colorhashtable;
+    Hashinfo * colorhashtable;
 
     pm_message("found %u colors - using the lookuptable-method", nColor);
 
@@ -523,7 +582,7 @@ useNoLookupTable(pixel **         const pixels,
                  int              const sharpness,
                  int              const enlarge,
                  int              const copy,
-                 struct mediasize const medias,
+                 struct Mediasize const medias,
                  unsigned int     const cols,
                  unsigned int     const rows,
                  int              const format) {
@@ -553,7 +612,7 @@ doTiny(FILE *           const ifP,
        int              const sharpness,
        int              const enlarge,
        int              const copy,
-       struct mediasize const medias) {
+       struct Mediasize const medias) {
 
     pixel * pixelrow;
     unsigned char * redrow;
@@ -596,26 +655,28 @@ doTiny(FILE *           const ifP,
 
 
 int
-main(int argc, char * argv[]) {
-    FILE * ifP;
+main(int argc, const char ** argv) {
+
+    FILE *           ifP;
     int              argn;
     bool             dpi300;
+    bool             tiny;
     int              cols, rows, format;
     pixval           maxval;
-    int              sharpness, enlarge, copy, tiny;
-    struct mediasize medias;
+    int              sharpness, enlarge, copy;
+    struct Mediasize medias;
     char             media[16];
     const char * const usage = "[-sharpness <1-4>] [-enlarge <1-3>] [-media <a,a4,as,a4s>] [-copy <1-9>] [-tiny] [-dpi300] [ppmfile]";
 
-    ppm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
-    dpi300 = FALSE;
+    dpi300 = false;
     argn = 1;
     sharpness = 32;
     enlarge   = 1;
     copy      = 1;
     memset(media, '\0', 16);
-    tiny      = FALSE;
+    tiny      = false;
 
     /* check for flags */
     while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
@@ -648,9 +709,9 @@ main(int argc, char * argv[]) {
             pm_usage(usage);
         }
     else if (pm_keymatch(argv[argn], "-dpi300", 2))
-        dpi300 = TRUE;
+        dpi300 = true;
     else if (pm_keymatch(argv[argn], "-tiny", 2))
-        tiny = TRUE;
+        tiny = true;
     else
         pm_usage(usage);
     ++argn;
@@ -666,28 +727,7 @@ main(int argc, char * argv[]) {
     if (argn != argc)
         pm_usage(usage);
 
-    if (TOUPPER(media[0]) == 'A')
-        switch (TOUPPER(media[1])) {
-        case 'S':
-            medias = MSize_AS;
-            break;
-        case '4':
-            if(TOUPPER(media[2]) == 'S')
-                medias = MSize_A4S;
-            else {
-                medias = MSize_A4;
-            }
-            break;
-        default:
-            medias = MSize_A;
-        }
-    else
-        medias = MSize_User;
-
-    if (dpi300) {
-        medias.maxcols *= 2;
-        medias.maxrows *= 2;
-    }
+    medias = mediaSize(media, dpi300);
 
     ppm_readppminit(ifP, &cols, &rows, &maxval, &format);
 
@@ -721,3 +761,6 @@ main(int argc, char * argv[]) {
     pm_close(ifP);
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/bframe.c b/converter/ppm/ppmtompeg/bframe.c
index fb546cc0..8bce3e14 100644
--- a/converter/ppm/ppmtompeg/bframe.c
+++ b/converter/ppm/ppmtompeg/bframe.c
@@ -114,7 +114,6 @@ halfMotion(motion const motion) {
 
 
 
-
 /*===========================================================================*
  *
  *  compute the block resulting from motion compensation
@@ -439,7 +438,6 @@ MotionSufficient(MpegFrame *      const curr,
 
 
 
-
 struct stats {
     int IBlocks;
     int BBlocks;
@@ -1156,6 +1154,7 @@ SetBQScale(qB)
 }
 
 
+
 /*===========================================================================*
  *
  * GetBQScale
@@ -1174,6 +1173,7 @@ GetBQScale()
 }
 
 
+
 /*===========================================================================*
  *
  * ResetBFrameStats
@@ -1326,6 +1326,7 @@ ComputeBMotionLumBlock(MpegFrame * const prev,
 }
 
 
+
 /*===========================================================================*
  *
  *  estimate the seconds to compute a B-frame
@@ -1344,3 +1345,4 @@ EstimateSecondsPerBFrame() {
 }
 
 
+
diff --git a/converter/ppm/ppmtompeg/bitio.c b/converter/ppm/ppmtompeg/bitio.c
index 79c9f36f..b95f1ce1 100644
--- a/converter/ppm/ppmtompeg/bitio.c
+++ b/converter/ppm/ppmtompeg/bitio.c
@@ -133,6 +133,7 @@ Dump(BitBucket * const bbPtr) {
 }
 
 
+
 /*=====================*
  * EXPORTED PROCEDURES *
  *=====================*/
@@ -217,6 +218,7 @@ Bitio_Free(BitBucket * const bbPtr) {
 }
 
 
+
 /*===========================================================================*
  *
  * Bitio_Write
@@ -318,6 +320,7 @@ Bitio_Write(BitBucket * const bbPtr,
 }
 
 
+
 /*===========================================================================*
  *
  * Bitio_Flush
@@ -516,6 +519,7 @@ Bitio_WriteToSocket(BitBucket * const bbPtr,
 }
 
 
+
 /*===========================================================================*
  *
  * Bitio_BytePad
@@ -534,3 +538,6 @@ Bitio_BytePad(BitBucket * const bbPtr) {
         Bitio_Write(bbPtr, 0, lastPtrPtr->bitsleftcur % 8);
     }
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/block.c b/converter/ppm/ppmtompeg/block.c
index 23396b4c..db8dc277 100644
--- a/converter/ppm/ppmtompeg/block.c
+++ b/converter/ppm/ppmtompeg/block.c
@@ -42,6 +42,8 @@ halfVector(vector const v) {
     return half;
 }
 
+
+
 /*===========================*
  * COMPUTE DCT OF DIFFERENCE *
  *===========================*/
@@ -361,6 +363,7 @@ ComputeMotionLumBlock(MpegFrame * const prevFrame,
 }
 
 
+
 /*=======================*
  * BASIC ERROR FUNCTIONS *
  *=======================*/
@@ -691,6 +694,7 @@ AddMotionBlock(Block          block,
 }
 
 
+
 /*===========================================================================*
  *
  *  adds the motion-compensated B-frame block to the given block
@@ -734,6 +738,7 @@ AddBMotionBlock(Block          block,
 }
 
 
+
 /*===========================================================================*
  *
  *  copies the given block into the appropriate data area
@@ -764,6 +769,7 @@ BlockToData(uint8 ** const data,
 }
 
 
+
 /*===========================================================================*
  *
  *  copies data into appropriate blocks
@@ -834,6 +840,7 @@ BlockifyFrame(MpegFrame * const frameP) {
 }
 
 
+
 /*===========================================================================*
  *                                       *
  * UNUSED PROCEDURES                                 *
@@ -925,6 +932,7 @@ ComputeSubSampledMotionLumBlock(MpegFrame * const prevFrame,
 }
 
 
+
 /*===========================================================================*
  *
  *  return the MAD of the currentBlock and the motion-compensated block,
@@ -1021,6 +1029,7 @@ LumMotionErrorSubSampled(LumBlock    const currentBlock,
 }
 
 
+
 #endif /* UNUSED_PROCEDURES */
 /*
  * Copyright (c) 1995 The Regents of the University of California.
diff --git a/converter/ppm/ppmtompeg/bsearch.c b/converter/ppm/ppmtompeg/bsearch.c
index b825ef72..6d13ab34 100644
--- a/converter/ppm/ppmtompeg/bsearch.c
+++ b/converter/ppm/ppmtompeg/bsearch.c
@@ -116,6 +116,7 @@ SetBSearchAlg(const char * const alg) {
 }
 
 
+
 /*===========================================================================*
  *
  * BSearchName
@@ -256,6 +257,7 @@ FindBestMatchExhaust(const LumBlock * const blockP,
 }
 
 
+
 /*===========================================================================*
  *
  * FindBestMatchTwoLevel
@@ -587,6 +589,7 @@ FindBestMatchSubSample(const LumBlock * const blockP,
 }
 
 
+
 /*===========================================================================*
  *
  * FindBestMatch
@@ -775,6 +778,7 @@ BMotionSearchSimple(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  * BMotionSearchCross2
@@ -863,6 +867,7 @@ BMotionSearchCross2(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  * BMotionSearchExhaust
@@ -1027,6 +1032,7 @@ BMotionSearch(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *                                       *
  * UNUSED PROCEDURES                                 *
@@ -1085,4 +1091,5 @@ ValidBMotion(by, bx, mode, fmy, fmx, bmy, bmx)
 }
 
 
+
 #endif /* UNUSED_PROCEDURES */
diff --git a/converter/ppm/ppmtompeg/file.c b/converter/ppm/ppmtompeg/file.c
index b81e8077..bc097452 100644
--- a/converter/ppm/ppmtompeg/file.c
+++ b/converter/ppm/ppmtompeg/file.c
@@ -301,3 +301,6 @@ MatchesGlob(char *string, char *glob) {
 
     return TRUE;
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/frame.c b/converter/ppm/ppmtompeg/frame.c
index 09e35410..81c1ff9f 100644
--- a/converter/ppm/ppmtompeg/frame.c
+++ b/converter/ppm/ppmtompeg/frame.c
@@ -395,6 +395,7 @@ Frame_Init(unsigned int const numOfFramesRequested) {
 }
 
 
+
 /*===========================================================================*
  *
  * FreeFrame
@@ -495,6 +496,7 @@ Frame_Exit(void) {
 }
 
 
+
 /*===========================================================================*
  *
  * Frame_Free
@@ -845,3 +847,4 @@ Frame_Resize(MpegFrame * const omf,
 }
 
 
+
diff --git a/converter/ppm/ppmtompeg/frametype.c b/converter/ppm/ppmtompeg/frametype.c
index 78e324d0..ff45564b 100644
--- a/converter/ppm/ppmtompeg/frametype.c
+++ b/converter/ppm/ppmtompeg/frametype.c
@@ -187,6 +187,7 @@ FType_PastRef(currFrameNum)
 }
 
 
+
 /*===========================================================================*
  *
  * SetFramePattern
diff --git a/converter/ppm/ppmtompeg/fsize.c b/converter/ppm/ppmtompeg/fsize.c
index 84772719..83b383e4 100644
--- a/converter/ppm/ppmtompeg/fsize.c
+++ b/converter/ppm/ppmtompeg/fsize.c
@@ -94,6 +94,7 @@ Fsize_Validate(int * const xP,
 }
 
 
+
 /*===========================================================================*
  *
  * Fsize_Note
@@ -132,3 +133,6 @@ Fsize_Note(int          const id,
     }
 #endif
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/gethostname.c b/converter/ppm/ppmtompeg/gethostname.c
index 649fff91..dedb3129 100644
--- a/converter/ppm/ppmtompeg/gethostname.c
+++ b/converter/ppm/ppmtompeg/gethostname.c
@@ -26,3 +26,6 @@ GetHostName(void) {
 
     return strdup(utsname.nodename);
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/gethostname_win32.c b/converter/ppm/ppmtompeg/gethostname_win32.c
index b831e22d..2e03476d 100644
--- a/converter/ppm/ppmtompeg/gethostname_win32.c
+++ b/converter/ppm/ppmtompeg/gethostname_win32.c
@@ -30,6 +30,8 @@ pushString(push_string_t *p, const char *fmt, ...)
     va_end(args);
 }
 
+
+
 #if _WIN32_WINNT < 0x0600
 /*
  * Reference available here:
@@ -371,6 +373,8 @@ get_string_version(push_string_t *str)
     return TRUE;
 }
 
+
+
 const char *
 GetHostName(void)
 {
@@ -389,6 +393,8 @@ GetHostName(void)
     return (const char *)_strdup(str.str);
 }
 
+
+
 #ifdef GETHOSTNAME_LOCAL_DEBUG
 int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst,
                    LPSTR lpsCmdLine, int nCmdShow)
diff --git a/converter/ppm/ppmtompeg/headers/frames.h b/converter/ppm/ppmtompeg/headers/frames.h
index 9108ac21..88638690 100644
--- a/converter/ppm/ppmtompeg/headers/frames.h
+++ b/converter/ppm/ppmtompeg/headers/frames.h
@@ -125,6 +125,8 @@ MotionToFrameCoord(int   const by,
     *xP = bx * DCTSIZE + mx;
 }
 
+
+
 #define COORD_IN_FRAME(fy,fx, type)                 \
     ((type == LUM_BLOCK) ?                      \
      ((fy >= 0) && (fx >= 0) && (fy < Fsize_y) && (fx < Fsize_x)) : \
@@ -175,6 +177,7 @@ encodeMotionVector(int      const x,
 }
 
 
+
 #define DoQuant(bit, src, dest)                                         \
   if (pattern & bit) {                                                  \
     switch (Mpost_QuantZigBlock(src, dest, QScale, FALSE)) {            \
diff --git a/converter/ppm/ppmtompeg/iframe.c b/converter/ppm/ppmtompeg/iframe.c
index 81ff0ec0..2bc50196 100644
--- a/converter/ppm/ppmtompeg/iframe.c
+++ b/converter/ppm/ppmtompeg/iframe.c
@@ -983,3 +983,6 @@ int32 time_elapsed(void) {
     return timeBuffer.tms_utime + timeBuffer.tms_stime;
 #endif
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/input.c b/converter/ppm/ppmtompeg/input.c
index e12b0d4c..83aa387c 100644
--- a/converter/ppm/ppmtompeg/input.c
+++ b/converter/ppm/ppmtompeg/input.c
@@ -415,6 +415,7 @@ processSimpleFileName(const char *            const input,
 }
 
 
+
 #define INPUT_ENTRY_BLOCK_SIZE   128
 
 void
diff --git a/converter/ppm/ppmtompeg/jpeg.c b/converter/ppm/ppmtompeg/jpeg.c
index 4540f6f0..6680404b 100644
--- a/converter/ppm/ppmtompeg/jpeg.c
+++ b/converter/ppm/ppmtompeg/jpeg.c
@@ -339,7 +339,6 @@ JMovie2JPEG(const char * const infilename,
 
 
 
-
 /*===========================================================================*
  *
  * ReadJPEG  contributed by James Arthur Boucher of Boston University's
diff --git a/converter/ppm/ppmtompeg/jrevdct.c b/converter/ppm/ppmtompeg/jrevdct.c
index ebadb997..f46051bc 100644
--- a/converter/ppm/ppmtompeg/jrevdct.c
+++ b/converter/ppm/ppmtompeg/jrevdct.c
@@ -179,6 +179,8 @@ mpeg_jrevdct(data)
   else mpeg_jrevdct_quick(data);
 }
 
+
+
 /*
  * Perform the inverse DCT on one block of coefficients.
  */
@@ -1179,6 +1181,7 @@ mpeg_jrevdct_quick(data)
 }
 
 
+
 /* here is the reference one, in case of problems with the normal one */
 
 /* idctref.c, Inverse Discrete Fourier Transform, double precision          */
@@ -1273,3 +1276,6 @@ int16 *block;
       block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
     }
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/memory.c b/converter/ppm/ppmtompeg/memory.c
index 0ebe4686..8c272707 100644
--- a/converter/ppm/ppmtompeg/memory.c
+++ b/converter/ppm/ppmtompeg/memory.c
@@ -59,13 +59,20 @@ char    *MemAlloc(size_t size)
     return malloc(size);
 }
 
+
+
 void    MemFree(char *ptr, long bytes)
 {
     totalMemory -= bytes;
     free(ptr);
 }
 
+
+
 void    PrintMaxMemory(void)
 {
     fprintf(stdout, "MMMMM-----MAX MEMORY-----MMMMM = %ld\n", maxMemory);
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/mfwddct.c b/converter/ppm/ppmtompeg/mfwddct.c
index 8b379cd8..1355ef91 100644
--- a/converter/ppm/ppmtompeg/mfwddct.c
+++ b/converter/ppm/ppmtompeg/mfwddct.c
@@ -326,6 +326,7 @@ mp_fwd_dct_fast(data2d, dest2d)
 }
 
 
+
 extern boolean pureDCT;
 void
 mp_fwd_dct_block2(data, dest)
@@ -348,6 +349,8 @@ mp_fwd_dct_block2(data, dest)
   else mp_fwd_dct_fast(data, dest);
 }
 
+
+
 /* Modifies from the MPEG2 verification coder */
 /* fdctref.c, forward discrete cosine transform, double precision           */
 
diff --git a/converter/ppm/ppmtompeg/mheaders.c b/converter/ppm/ppmtompeg/mheaders.c
index 7e5db6c1..54dada83 100644
--- a/converter/ppm/ppmtompeg/mheaders.c
+++ b/converter/ppm/ppmtompeg/mheaders.c
@@ -429,6 +429,7 @@ GenMBType(bbPtr, pict_code_type, mb_quant, motion_forw, motion_back,
 }
 
 
+
 /*===========================================================================*
  *
  * GenMotionCode
@@ -459,6 +460,7 @@ GenMotionCode(BitBucket * const bbPtr,
 }
 
 
+
 /*===========================================================================*
  *
  * GenBlockPattern
@@ -485,6 +487,7 @@ GenBlockPattern(bbPtr, mb_pattern)
 }
 
 
+
 /*===========================================================================*
  *
  * GenMBAddrIncr
@@ -512,6 +515,7 @@ GenMBAddrIncr(bbPtr, addr_incr)
 }
 
 
+
 /*===========================================================================*
  *
  * GenPictHead
@@ -624,6 +628,7 @@ GenPictHead(bbPtr, temp_ref, code_type, vbv_delay, full_pel_forw_flag,
 }
 
 
+
 /*=====================*
  * EXPORTED PROCEDURES *
  *=====================*/
@@ -649,6 +654,7 @@ SetGOPStartTime(index)
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenPictureHeader
@@ -688,6 +694,7 @@ Mhead_GenPictureHeader(bbPtr, frameType, pictCount, f_code)
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenSequenceHeader
@@ -849,6 +856,7 @@ Mhead_GenSequenceHeader(BitBucket *   const bbPtr,
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenSequenceEnder
@@ -869,6 +877,7 @@ Mhead_GenSequenceEnder(bbPtr)
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenGOPHeader
@@ -967,6 +976,7 @@ Mhead_GenGOPHeader(bbPtr, drop_frame_flag, tc_hrs, tc_min, tc_sec, tc_pict,
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenSliceHeader
@@ -1010,6 +1020,7 @@ Mhead_GenSliceHeader(bbPtr, verticalPos, qscale, extra_info, extra_info_size)
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenSliceEnder
@@ -1030,6 +1041,7 @@ Mhead_GenSliceEnder(bbPtr)
 }
 
 
+
 /*===========================================================================*
  *
  * Mhead_GenMBHeader
@@ -1158,6 +1170,7 @@ if ( addr_incr != 1 )
 }
 
 
+
 #ifdef UNUSED_PROCEDURES
 
 /* GenMBEnd only used for `D` pictures. Shouldn't really ever be called. */
@@ -1169,4 +1182,6 @@ GenMBEnd(bbPtr)
     Bitio_Write(bbPtr, 0x01, 1);
 }
 
+
+
 #endif /* UNUSED_PROCEDURES */
diff --git a/converter/ppm/ppmtompeg/moutput.c b/converter/ppm/ppmtompeg/moutput.c
index 765a2b6f..bc7fb2b6 100644
--- a/converter/ppm/ppmtompeg/moutput.c
+++ b/converter/ppm/ppmtompeg/moutput.c
@@ -167,6 +167,7 @@ void    UnQuantZig(FlatBlock in, Block out, int qscale, boolean iblock)
 }
 
 
+
 /*
  * --------------------------------------------------------------
  *
@@ -335,6 +336,7 @@ void    mp_rle_huff_block(FlatBlock in, BitBucket *out)
 }
 
 
+
 /*
  * --------------------------------------------------------------
  *
@@ -440,3 +442,6 @@ void    mp_rle_huff_pblock(FlatBlock in, BitBucket *out)
     DBG_PRINT(("End of block\n"));
     Bitio_Write(out, 0x2, 2);   /* end of block marker */
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/mpeg.c b/converter/ppm/ppmtompeg/mpeg.c
index e67eec1e..ff8c6035 100644
--- a/converter/ppm/ppmtompeg/mpeg.c
+++ b/converter/ppm/ppmtompeg/mpeg.c
@@ -285,7 +285,6 @@ SetBitRateFileName(const char * const fileName) {
 
 
 
-
 static void
 finishFrameOutput(MpegFrame * const frameP,
                   BitBucket * const bbP,
@@ -316,7 +315,6 @@ finishFrameOutput(MpegFrame * const frameP,
 
 
 
-
 static void
 outputIFrame(MpegFrame * const frameP,
              BitBucket * const bbP,
@@ -1241,6 +1239,7 @@ SetStatFileName(const char * const fileName) {
 }
 
 
+
 /*===========================================================================*
  *
  * SetGOPSize
@@ -1260,6 +1259,7 @@ SetGOPSize(size)
 }
 
 
+
 /*===========================================================================*
  *
  * PrintStartStats
@@ -1463,6 +1463,7 @@ SetFrameRate()
 }
 
 
+
 /*=====================*
  * INTERNAL PROCEDURES *
  *=====================*/
diff --git a/converter/ppm/ppmtompeg/mquant.c b/converter/ppm/ppmtompeg/mquant.c
index 99b1cb8e..0251a142 100644
--- a/converter/ppm/ppmtompeg/mquant.c
+++ b/converter/ppm/ppmtompeg/mquant.c
@@ -42,3 +42,6 @@ void mp_quant_block(Block in, Block out) {
         out[i][7] = in[i][7] / qtable[i][7];
     }
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/nojpeg.c b/converter/ppm/ppmtompeg/nojpeg.c
index 5b86ab56..dc1b222e 100644
--- a/converter/ppm/ppmtompeg/nojpeg.c
+++ b/converter/ppm/ppmtompeg/nojpeg.c
@@ -52,6 +52,7 @@ JMovie2JPEG(const char * const infilename,
 }
 
 
+
 void
 ReadJPEG(MpegFrame * const mf,
          FILE *      const fp) {
@@ -59,3 +60,6 @@ ReadJPEG(MpegFrame * const mf,
     pm_error("This program has not been built with the "
              "ability to handle JPEG input files");
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/noparallel.c b/converter/ppm/ppmtompeg/noparallel.c
index 02c46a58..d21f3e9a 100644
--- a/converter/ppm/ppmtompeg/noparallel.c
+++ b/converter/ppm/ppmtompeg/noparallel.c
@@ -92,6 +92,7 @@ SetParallelPerfect(boolean const val) {
 }
 
 
+
 void
 SetRemoteShell(const char * const shell) {
     /* do nothing -- this may be called during non-parallel execution */
@@ -228,3 +229,6 @@ GetRemoteDecodedRefFrame(MpegFrame * const frame,
     pm_error("This version of Ppmtompeg cannot run parallel mode because "
              "it does not have socket capability.");
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/opts.c b/converter/ppm/ppmtompeg/opts.c
index 6f5f9816..9d750c54 100644
--- a/converter/ppm/ppmtompeg/opts.c
+++ b/converter/ppm/ppmtompeg/opts.c
@@ -157,7 +157,6 @@ SetupCollectQuantStats(const char * const charPtr)
 
 
 
-
 /*===========================================================================*
  *
  * SetupKillDimAreas
@@ -223,6 +222,7 @@ SetupSquashSmall(const char * const charPtr)
 }
 
 
+
 /*===========================================================================*
  *
  * SetupLocalDCT
@@ -254,6 +254,7 @@ SetupLocalDCT(const char * const charPtr)
 }
 
 
+
 /*===========================================================================*
  *
  * SetupLaplace
@@ -290,6 +291,8 @@ SetupLaplace()
   }
 }
 
+
+
 static void
 SetupWriteDistortions(const char * const charPtr)
 {
@@ -341,6 +344,8 @@ SetupWriteDistortions(const char * const charPtr)
     }}
 }
 
+
+
 /*=====================*
  * EXPORTED PROCEDURES *
  *=====================*/
@@ -361,6 +366,7 @@ CalcLambdas(void) {
 }
 
 
+
 /*===========================================================================*
  *
  * Mpost_UnQuantZigBlockLaplace
@@ -424,6 +430,8 @@ Mpost_UnQuantZigBlockLaplace(in, out, qscale, iblock)
     }
 }
 
+
+
 int
 mse(Block blk1, Block blk2)
 {
@@ -442,7 +450,6 @@ mse(Block blk1, Block blk2)
 
 
 
-
 /*===========================================================================*
  *
  * Tune_Init
@@ -489,6 +496,8 @@ void Tune_Init()
 
 }
 
+
+
 /*===========================================================================*
  *
  * ParseTuneParam
@@ -545,3 +554,4 @@ void ParseTuneParam(const char * const charPtr)
 }
 
 
+
diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c
index b24764d6..fb0f2fe9 100644
--- a/converter/ppm/ppmtompeg/parallel.c
+++ b/converter/ppm/ppmtompeg/parallel.c
@@ -324,6 +324,7 @@ static void
 }
 
 
+
 /*===========================================================================*
  *
  * NotifyDecodeServerReady
@@ -446,6 +447,7 @@ int id;
 }
 
 
+
 /*===========================================================================*
  *
  * SendDecodedFrame
@@ -484,6 +486,7 @@ SendDecodedFrame(MpegFrame * const frameP) {
 }
 
 
+
 /*===========================================================================*
  *
  * GetRemoteDecodedFrame
@@ -524,6 +527,7 @@ GetRemoteDecodedRefFrame(MpegFrame * const frameP,
 }
 
 
+
 /*********
   routines handling forks, execs, PIDs and signals
   save, system-style forks
@@ -559,6 +563,8 @@ static void cleanup_fork( dummy )       /* try to kill all child processes */
   }
 }
 
+
+
 /*===========================================================================*
  *
  * safe_fork
@@ -611,6 +617,7 @@ static int safe_fork(command)       /* fork child process and remember its PID *
 }
 
 
+
 /*=====================*
  * EXPORTED PROCEDURES *
  *=====================*/
@@ -638,6 +645,7 @@ SetIOConvert(boolean const separate) {
 }
 
 
+
 /*===========================================================================*
  *
  * SetParallelPerfect
@@ -657,6 +665,7 @@ SetParallelPerfect(boolean val)
 }
 
 
+
 /*===========================================================================*
  *
  * SetRemoteShell
@@ -675,6 +684,7 @@ SetRemoteShell(const char * const shell) {
 }
 
 
+
 static void
 decodedFrameToDisk(int const otherSock) {
 /*----------------------------------------------------------------------------
@@ -1146,6 +1156,7 @@ GetRemoteFrame(MpegFrame * const frameP,
 }
 
 
+
 struct combineControl {
     unsigned int numFrames;
 };
@@ -1323,6 +1334,7 @@ CombineServer(int          const numFrames,
 }
 
 
+
 /*=====================*
  * MASTER SERVER STUFF *
  *=====================*/
diff --git a/converter/ppm/ppmtompeg/param.c b/converter/ppm/ppmtompeg/param.c
index 9499b4ea..3408c6fc 100644
--- a/converter/ppm/ppmtompeg/param.c
+++ b/converter/ppm/ppmtompeg/param.c
@@ -241,6 +241,7 @@ ReadMachineNames(FILE * const fpointer)
 }
 
 
+
 /*===========================================================================*
  *
  * GetFrameRate
@@ -1044,6 +1045,7 @@ ReadParamFile(const char *         const fileName,
 }
 
 
+
 /*
  * Copyright (c) 1995 The Regents of the University of California.
  * All rights reserved.
diff --git a/converter/ppm/ppmtompeg/pframe.c b/converter/ppm/ppmtompeg/pframe.c
index d61848b1..89aab874 100644
--- a/converter/ppm/ppmtompeg/pframe.c
+++ b/converter/ppm/ppmtompeg/pframe.c
@@ -75,6 +75,8 @@ halfVector(vector const vector) {
     return half;
 }
 
+
+
 /*===========================================================================*
  *
  *  decide if (0,0) motion is better than the given motion vector
@@ -120,6 +122,7 @@ ZeroMotionBetter(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  *                USER-MODIFIABLE
@@ -851,6 +854,7 @@ GenPFrame(BitBucket * const bb,
 }
 
 
+
 /*===========================================================================*
  *
  * ResetPFrameStats
@@ -876,6 +880,7 @@ void
 }
 
 
+
 /*===========================================================================*
  *
  * SetPQScale
@@ -895,6 +900,7 @@ int qP;
 }
 
 
+
 /*===========================================================================*
  *
  * GetPQScale
@@ -913,6 +919,7 @@ int
 }
 
 
+
 float
 PFrameTotalTime(void) {
     return (float)totalTime/(float)TIME_RATE;
@@ -992,6 +999,7 @@ float
 }
 
 
+
 /*===========================================================================*
  *
  * ComputeHalfPixelData
@@ -1048,6 +1056,7 @@ MpegFrame *frame;
 }
 
 
+
 /*
  * Copyright (c) 1995 The Regents of the University of California.
  * All rights reserved.
diff --git a/converter/ppm/ppmtompeg/postdct.c b/converter/ppm/ppmtompeg/postdct.c
index 68712963..f3de075a 100644
--- a/converter/ppm/ppmtompeg/postdct.c
+++ b/converter/ppm/ppmtompeg/postdct.c
@@ -261,6 +261,7 @@ Mpost_UnQuantZigBlock(in, out, qscale, iblock)
 }
 
 
+
 /*===========================================================================*
  *
  * Mpost_QuantZigBlock
@@ -460,6 +461,7 @@ Mpost_RLEHuffIBlock(in, out)
 }
 
 
+
 /*===========================================================================*
  *
  * Mpost_RLEHuffPBlock
@@ -565,6 +567,7 @@ Mpost_RLEHuffPBlock(in, out)
 }
 
 
+
 /*===========================================================================*
  *
  * CalcRLEHuffLength
@@ -624,3 +627,6 @@ CalcRLEHuffLength(in)
   countbits += 2; /* end of block marker */
   return countbits;
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/ppmtompeg.c b/converter/ppm/ppmtompeg/ppmtompeg.c
index cc2cb27e..78e33c54 100644
--- a/converter/ppm/ppmtompeg/ppmtompeg.c
+++ b/converter/ppm/ppmtompeg/ppmtompeg.c
@@ -402,7 +402,6 @@ encodeSomeFrames(struct inputSource * const inputSourceP,
 
 
 
-
 static void
 encodeFrames(struct inputSource * const inputSourceP,
              boolean              const childProcess,
@@ -507,7 +506,6 @@ encodeFrames(struct inputSource * const inputSourceP,
 
 
 
-
 static void
 runMaster(struct inputSource * const inputSourceP,
           const char *         const paramFileName,
@@ -708,3 +706,6 @@ main(int argc, char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/psearch.c b/converter/ppm/ppmtompeg/psearch.c
index de3d3e26..c82ad4ad 100644
--- a/converter/ppm/ppmtompeg/psearch.c
+++ b/converter/ppm/ppmtompeg/psearch.c
@@ -135,6 +135,7 @@ SetPixelSearch(const char * const searchType) {
 }
 
 
+
 /*===========================================================================*
  *
  * SetPSearchAlg
@@ -164,6 +165,7 @@ SetPSearchAlg(const char * const alg)
 }
 
 
+
 /*===========================================================================*
  *
  * PSearchName
@@ -198,6 +200,7 @@ PSearchName(void)
 }
 
 
+
 /*===========================================================================*
  *
  * SetSearchRange
@@ -232,6 +235,7 @@ SetSearchRange(int const pixelsP, int const pixelsB) {
 }
 
 
+
 /*===========================================================================*
  *
  *              USER-MODIFIABLE
@@ -252,6 +256,7 @@ MotionSearchPreComputation(MpegFrame * const frameP) {
 }
 
 
+
 /*===========================================================================*
  *
  * PSubSampleSearch
@@ -649,6 +654,7 @@ PLocalSearch(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  * PTwoLevelSearch
@@ -837,6 +843,7 @@ ShowPMVHistogram(fpointer)
 }
 
 
+
 void
 ShowBBMVHistogram(fpointer)
     FILE *fpointer;
@@ -884,6 +891,7 @@ ShowBBMVHistogram(fpointer)
 }
 
 
+
 void
 ShowBFMVHistogram(fpointer)
     FILE *fpointer;
@@ -931,6 +939,7 @@ ShowBFMVHistogram(fpointer)
 }
 
 
+
 /*
  * Copyright (c) 1995 The Regents of the University of California.
  * All rights reserved.
diff --git a/converter/ppm/ppmtompeg/qtest.c b/converter/ppm/ppmtompeg/qtest.c
index 85eda2c8..15e4e197 100644
--- a/converter/ppm/ppmtompeg/qtest.c
+++ b/converter/ppm/ppmtompeg/qtest.c
@@ -61,3 +61,6 @@ main()
 
     printf("Huffman output is %d bits\n", bb->totalbits);
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c
index 26c30ffe..4237427e 100644
--- a/converter/ppm/ppmtompeg/rate.c
+++ b/converter/ppm/ppmtompeg/rate.c
@@ -316,6 +316,8 @@ initRateControl(bool const wantUnderflowWarning,
     return result;
 }
 
+
+
 /*===========================================================================*
  *
  * initGOPRateControl
@@ -464,7 +466,6 @@ targetRateControl(MpegFrame * const frame) {
 
 
 
-
 static void
 updateVBVBuffer(int const frameBits) {
 /*----------------------------------------------------------------------------
@@ -580,6 +581,7 @@ updateRateControl(int const type) {
 }
 
 
+
 /*===========================================================================*
  *
  * MB_RateOut
@@ -647,6 +649,7 @@ void incNumBlocks(num)
 }
 
 
+
 /*===========================================================================*
  *
  * incMacroBlockBits()
@@ -670,6 +673,7 @@ void incMacroBlockBits(num)
 }
 
 
+
 /*===========================================================================*
  *
  *      needQScaleChange(current Q scale, 4 luminance blocks)
@@ -707,6 +711,7 @@ int needQScaleChange(oldQScale, blk0, blk1, blk2, blk3)
 }
 
 
+
 /*===========================================================================*
  *
  * determineMBCount()
@@ -761,6 +766,7 @@ void checkBufferFullness (oldQScale)
 }
 
 
+
 /*===========================================================================*
  *
  * void checkSpatialActivity()
@@ -845,7 +851,6 @@ void checkSpatialActivity(blk0, blk1, blk2, blk3)
 
 
 
-
 /*============================================================================*
  *
  * getRateMode ()
@@ -864,6 +869,7 @@ int getRateMode()
 }
 
 
+
 /*===========================================================================*
  *
  * setBitRate ()
@@ -921,7 +927,6 @@ int getBitRate ()
 
 
 
-
 /*===========================================================================*
  *
  * setBufferSize ()
@@ -954,6 +959,7 @@ void setBufferSize (const char * const charPtr)
 }
 
 
+
 /*===========================================================================*
  *
  * getBufferSize ()
diff --git a/converter/ppm/ppmtompeg/readframe.c b/converter/ppm/ppmtompeg/readframe.c
index dcc02052..85f432d8 100644
--- a/converter/ppm/ppmtompeg/readframe.c
+++ b/converter/ppm/ppmtompeg/readframe.c
@@ -386,6 +386,7 @@ SetFileType(const char * const conversion)
 }
 
 
+
 /*===========================================================================*
  *
  * SetFileFormat
@@ -558,6 +559,8 @@ ReadEYUV(mf, fpointer, width, height)
     /* ignore leftover stuff on the bottom */
 }
 
+
+
 /*===========================================================================*
  *
  * ReadAYUV
@@ -616,6 +619,8 @@ ReadAYUV(mf, fpointer, width, height)
 
 }
 
+
+
 /*===========================================================================*
  *
  * SeparateLine
@@ -702,6 +707,7 @@ SeparateLine(fpointer, lineptr, width)
 }
 
 
+
 /*===========================================================================*
  *
  * ReadY
@@ -749,6 +755,7 @@ ReadY(mf, fpointer, width, height)
 }
 
 
+
 /*===========================================================================*
  *
  * ReadSub4
@@ -808,6 +815,7 @@ ReadSub4(mf, fpointer, width, height)
 }
 
 
+
 /*=====================*
  * INTERNAL PROCEDURES *
  *=====================*/
@@ -846,7 +854,6 @@ int w,h;
 
 
 
-
 /*===========================================================================*
  *
  * DoKillDim
@@ -912,6 +919,7 @@ int w,h;
 }
 
 
+
 /*
  * Copyright (c) 1995 The Regents of the University of California.
  * All rights reserved.
diff --git a/converter/ppm/ppmtompeg/rgbtoycc.c b/converter/ppm/ppmtompeg/rgbtoycc.c
index 9357c8d8..189003d7 100644
--- a/converter/ppm/ppmtompeg/rgbtoycc.c
+++ b/converter/ppm/ppmtompeg/rgbtoycc.c
@@ -108,6 +108,7 @@ compute_mult_tables(const pixval maxval) {
 }
 
 
+
 /*=====================*
  * EXPORTED PROCEDURES *
  *=====================*/
@@ -202,3 +203,6 @@ PNMtoYUV(MpegFrame *  const frameP,
         }
     }
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/specifics.c b/converter/ppm/ppmtompeg/specifics.c
index e8597978..acf98116 100644
--- a/converter/ppm/ppmtompeg/specifics.c
+++ b/converter/ppm/ppmtompeg/specifics.c
@@ -247,6 +247,8 @@ FILE *fp;
 
 }
 
+
+
 /* Version 1 */
 void Parse_Specifics_File_v1(fp)
 FILE *fp;
@@ -442,7 +444,6 @@ Parse_Specifics_File_v2(FILE * const fP) {
 
 
 
-
 /*=================================================================
  *
  *     MakeFslEntry
@@ -467,8 +468,6 @@ FrameSpecList *MakeFslEntry()
 
 
 
-
-
 /*================================================================
  *
  *   AddSlc
@@ -503,8 +502,6 @@ int snum,qs;
 
 
 
-
-
 /*================================================================
  *
  *   AddBs
@@ -544,9 +541,6 @@ int bnum,qs;
 
 
 
-
-
-
 /*================================================================
  *
  *  SpecLookup
@@ -685,6 +679,7 @@ int start_qs;
 }
 
 
+
 /*================================================================
  *
  *  SpecTypeLookup
@@ -718,3 +713,6 @@ int fn;
 #endif
   return tmp->frametype;
 }
+
+
+
diff --git a/converter/ppm/ppmtompeg/subsample.c b/converter/ppm/ppmtompeg/subsample.c
index 93b76db0..e411feb4 100644
--- a/converter/ppm/ppmtompeg/subsample.c
+++ b/converter/ppm/ppmtompeg/subsample.c
@@ -199,6 +199,7 @@ LumMotionErrorB(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  * LumMotionErrorC
@@ -240,6 +241,7 @@ LumMotionErrorC(const LumBlock * const currentBlockP,
 }
 
 
+
 /*===========================================================================*
  *
  * LumMotionErrorD
@@ -279,3 +281,6 @@ LumMotionErrorD(const LumBlock * const currentBlockP,
     }
     return diff;
 }
+
+
+
diff --git a/converter/ppm/ppmtoneo.c b/converter/ppm/ppmtoneo.c
index 5703c12a..d573e9e6 100644
--- a/converter/ppm/ppmtoneo.c
+++ b/converter/ppm/ppmtoneo.c
@@ -121,3 +121,6 @@ main(int argc, char *argv[] ) {
 
     exit( 0 );
 }
+
+
+
diff --git a/converter/ppm/ppmtopi1.c b/converter/ppm/ppmtopi1.c
index 64f836c7..896ec7f7 100644
--- a/converter/ppm/ppmtopi1.c
+++ b/converter/ppm/ppmtopi1.c
@@ -118,3 +118,6 @@ main( argc, argv )
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/ppmtopict.c b/converter/ppm/ppmtopict.c
index 36464b6c..c7f1d61d 100644
--- a/converter/ppm/ppmtopict.c
+++ b/converter/ppm/ppmtopict.c
@@ -12,8 +12,10 @@
 */
 
 #include <assert.h>
+
 #include "pm_c_util.h"
 #include "pm.h"
+#include "mallocvar.h"
 #include "ppm.h"
 
 #define HEADER_SIZE     512
@@ -130,14 +132,15 @@
 #define PICT_headerOp       0x0C00
 
 #define MAXCOLORS 256
-static colorhash_table cht;
 
 
 
 static void
 putFill(FILE *       const ifP,
         unsigned int const n) {
-
+/*----------------------------------------------------------------------------
+   Write 'n' bytes of zeroes to *ifP.
+-----------------------------------------------------------------------------*/
     unsigned int i;
 
     for (i = 0; i < n; ++i)
@@ -194,19 +197,21 @@ putRect(FILE * const ifP,
 #define     counttochar(c)  ((c)-1)
 
 static void
-putRow(FILE *         const ofP,
-       unsigned int   const row,
-       unsigned int   const cols,
-       pixel *        const rowpixels,
-       char *         const outBuf,
-       unsigned int * const outCountP) {
+putRow(FILE *          const ofP,
+       unsigned int    const row,
+       unsigned int    const cols,
+       pixel *         const rowpixels,
+       colorhash_table const cht,
+       unsigned char * const outBuf,
+       unsigned int *  const outCountP) {
 /*----------------------------------------------------------------------------
    Write the row rowpixels[], which is 'cols' pixels wide and is row 'row' of
    the image, to file *ofP in PICT format.
 
    Return as *outCountP the number of bytes we write to *ofP.
 
-   Use buffer 'outBuf'.
+   Use buffer 'outBuf', which is at least 1.5*cols + 1 bytes -- the worst
+   case compacted size of the row.
 -----------------------------------------------------------------------------*/
     unsigned int i;
     unsigned int count;
@@ -214,13 +219,13 @@ putRow(FILE *         const ofP,
     unsigned int rep;
     unsigned int outCount;
     pixel lastpix;
-    char * p;
+    unsigned int outCursor;
 
-    run = 0;
-    count = 0;
-    lastpix = rowpixels[cols-1];
+    run = 0;  /* initial value */
+    count = 0;  /* initial value */
+    lastpix = rowpixels[cols-1];  /* initial value */
 
-    for (i = 0, p = &outBuf[0]; i < cols; ++i) {
+    for (i = 0, outCursor = 0; i < cols; ++i) {
 
         pixel const pix = rowpixels[cols - 1 - i];
 
@@ -228,23 +233,23 @@ putRow(FILE *         const ofP,
             ++run;
         else if (run < RUN_THRESH) {
             while (run > 0) {
-                *p++ = ppm_lookupcolor(cht, &lastpix);
+                outBuf[outCursor++] = ppm_lookupcolor(cht, &lastpix);
                 --run;
                 ++count;
                 if (count == MAX_COUNT) {
-                    *p++ = counttochar(MAX_COUNT);
+                    outBuf[outCursor++] = counttochar(MAX_COUNT);
                     count -= MAX_COUNT;
                 }
             }
             run = 1;
         } else {
             if (count > 0)
-                *p++ = counttochar(count);
+                outBuf[outCursor++] = counttochar(count);
             count = 0;
             while (run > 0) {
                 rep = MIN(run, MAX_RUN);
-                *p++ = ppm_lookupcolor(cht, &lastpix);
-                *p++ = runtochar(rep);
+                outBuf[outCursor++] = ppm_lookupcolor(cht, &lastpix);
+                outBuf[outCursor++] = runtochar(rep);
                 assert(run >= rep);
                 run -= rep;
             }
@@ -254,46 +259,43 @@ putRow(FILE *         const ofP,
     }
     if (run < RUN_THRESH) {
         while (run > 0) {
-            *p++ = ppm_lookupcolor(cht, &lastpix);
+            outBuf[outCursor++] = ppm_lookupcolor(cht, &lastpix);
             --run;
             ++count;
             if (count == MAX_COUNT) {
-                *p++ = counttochar(MAX_COUNT);
+                outBuf[outCursor++] = counttochar(MAX_COUNT);
                 count -= MAX_COUNT;
             }
         }
     } else {
         if (count > 0)
-            *p++ = counttochar(count);
+            outBuf[outCursor++] = counttochar(count);
         count = 0;
         while (run > 0) {
             rep = MIN(run, MAX_RUN);
-            *p++ = ppm_lookupcolor(cht, &lastpix);
-            *p++ = runtochar(rep);
+            outBuf[outCursor++] = ppm_lookupcolor(cht, &lastpix);
+            outBuf[outCursor++] = runtochar(rep);
             assert(run >= rep);
             run -= rep;
         }
         run = 1;
     }
     if (count > 0)
-        *p++ = counttochar(count);
+        outBuf[outCursor++] = counttochar(count);
 
-    {
-        unsigned int const packcols = p - outBuf;
-            /* How many we wrote */
-        if (cols-1 > 200) {
-            putShort(ofP, packcols);
-            outCount = packcols + 2;
-        } else {
-            putc(packcols, ofP);
-            outCount = packcols + 1;
-        }
-    }
-    /* now write out the packed row */
-    while (p != outBuf) {
-        --p;
-        putc(*p, ofP);
+    /* Write out the packed row */
+
+    if (cols-1 > 200) {
+        putShort(ofP, outCursor);
+        outCount = outCursor + 2;
+    } else {
+        putc(outCursor, ofP);
+        outCount = outCursor + 1;
     }
+
+    for (i = 0; i < outCursor; ++i)
+        putc(outBuf[outCursor-i-1], ofP);
+
     *outCountP = outCount;
 }
 
@@ -303,12 +305,13 @@ putRow(FILE *         const ofP,
 
 /* real dumb putRow with no compression */
 static void
-putRow(FILE *         const ifP,
-       unsigned int   const row,
-       unsigned int   const cols,
-       pixel *        const rowpixels,
-       char *         const outBuf,
-       unsigned int * const outCountP) {
+putRow(FILE *          const ifP,
+       unsigned int    const row,
+       unsigned int    const cols,
+       pixel *         const rowpixels,
+       char *          const outBuf,
+       colorhash_table const cht,
+       unsigned int *  const outCountP) {
 
     unsigned int const bc = cols + (cols + MAX_COUNT - 1) / MAX_COUNT;
 
@@ -345,20 +348,82 @@ putRow(FILE *         const ifP,
 
 
 
+static void
+writeColorMap(FILE *           const ofP,
+              colorhist_vector const chv,
+              unsigned int     const colorCt,
+              long             const lmaxval) {
+
+    unsigned int i;
+
+    for (i = 0; i < colorCt; ++i) {
+        long rval, gval, bval;
+
+        putShort(ofP, i);
+        rval = PPM_GETR(chv[i].color);
+        gval = PPM_GETG(chv[i].color);
+        bval = PPM_GETB(chv[i].color);
+        if (lmaxval != 65535L) {
+            rval = rval * 65535L / lmaxval;
+            gval = gval * 65535L / lmaxval;
+            bval = bval * 65535L / lmaxval;
+        }
+        putShort(ofP, (short)rval);
+        putShort(ofP, (short)gval);
+        putShort(ofP, (short)bval);
+    }
+}
+
+
+
+static void
+writeRaster(FILE *          const ofP,
+            pixel **        const pixels,
+            unsigned int    const rows,
+            unsigned int    const cols,
+            colorhash_table const cht) {
+
+    unsigned char * outBuf;  /* malloc'ed */
+    unsigned int oc;
+    unsigned int row;
+
+    if (cols > UINT_MAX - cols/MAX_COUNT - 1) {
+        /* We can't compute the size of buffer 'putRow' needs for worst-case
+           compaction.
+        */
+        pm_error("Image is too wide (%u columns) for computation", cols);
+    }
+
+    MALLOCARRAY(outBuf, cols + cols/MAX_COUNT + 1);
+    if (!outBuf)
+        pm_error("Unable to allocate %u-byte row buffer",
+                 cols + cols/MAX_COUNT + 1);
+
+    for (row = 0, oc = 0; row < rows; ++row) {
+        unsigned int rowSize;
+        putRow(ofP, row, cols, pixels[row], cht, outBuf, &rowSize);
+        oc += rowSize;
+    }
+    /* Pad to an even number of pixdata bytes */
+    if (oc & 0x1)
+        putc(0, ofP);
+
+    free(outBuf);
+}
+
+
+
 int
 main(int argc, const char ** argv) {
 
     FILE * ifP;
-    int nColors;
-    unsigned int oc;
-    unsigned int i;
+    int colorCt;
     int rows, cols;
-    unsigned int row;
     pixel ** pixels;
-    char * outBuf;
     pixval maxval;
-    long lmaxval, rval, gval, bval;
     colorhist_vector chv;
+    colorhash_table cht;
+    long lmaxval;
 
     pm_proginit(&argc, argv);
 
@@ -367,8 +432,8 @@ main(int argc, const char ** argv) {
     else
         ifP = stdin;
     if (argc-1 > 1)
-        pm_error("Too many arguments.  The only argument is the "
-                 "input file name");
+        pm_error("Too many arguments (%u).  The only argument is the "
+                 "input file name", argc-1);
 
     pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
     if (cols < 8)
@@ -378,19 +443,19 @@ main(int argc, const char ** argv) {
 
     /* Figure out the colormap. */
     pm_message("computing colormap..." );
-    chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &nColors);
+    chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colorCt);
     if (chv == NULL)
         pm_error("too many colors - try doing a 'pnmquant %u'", MAXCOLORS);
-    pm_message("%u colors found", nColors);
+    pm_message("%u colors found", colorCt);
 
     /* Make a hash table for fast color lookup. */
-    cht = ppm_colorhisttocolorhash(chv, nColors);
+    cht = ppm_colorhisttocolorhash(chv, colorCt);
 
     /* write the header */
     putFill(stdout, HEADER_SIZE);
 
     /* write picSize and picFrame */
-    putShort(stdout, 0);
+    putShort(stdout, 0);  /* We overwrite this later when we know the size */
     putRect(stdout, 0, 0, rows, cols);
 
     /* write version op and version */
@@ -427,43 +492,24 @@ main(int argc, const char ** argv) {
     putLong(stdout, 0L);    /* pmReserved */
     putLong(stdout, 0L);    /* ctSeed */
     putShort(stdout, 0);    /* ctFlags */
-    putShort(stdout, nColors-1); /* ctSize */
+    putShort(stdout, colorCt-1); /* ctSize */
 
-    /* Write out the colormap. */
-    for (i = 0; i < nColors; ++i) {
-        putShort(stdout, i);
-        rval = PPM_GETR(chv[i].color);
-        gval = PPM_GETG(chv[i].color);
-        bval = PPM_GETB(chv[i].color);
-        if (lmaxval != 65535L) {
-            rval = rval * 65535L / lmaxval;
-            gval = gval * 65535L / lmaxval;
-            bval = bval * 65535L / lmaxval;
-        }
-        putShort(stdout, (short)rval);
-        putShort(stdout, (short)gval);
-        putShort(stdout, (short)bval);
-    }
+    writeColorMap(stdout, chv, colorCt, lmaxval);
 
     putRect(stdout, 0, 0, rows, cols);  /* srcRect */
     putRect(stdout, 0, 0, rows, cols);  /* dstRect */
     putShort(stdout, 0);            /* mode */
 
-    /* Finally, write out the data. */
-    outBuf = malloc((unsigned)(cols+cols/MAX_COUNT+1));
-    for (row = 0, oc = 0; row < rows; ++row) {
-        unsigned int rowSize;
-        putRow(stdout, row, cols, pixels[row], outBuf, &rowSize);
-        oc += rowSize;
-    }
-    /* if we wrote an odd number of pixdata bytes, pad */
-    if (oc & 0x1)
-        putc(0, stdout);
+    writeRaster(stdout, pixels, rows, cols, cht);
+
     putShort(stdout, PICT_EndOfPicture);
 
-    lmaxval = ftell(stdout) - HEADER_SIZE;
-    if (fseek(stdout, (long)HEADER_SIZE, 0) >= 0)
-        putShort(stdout, (short)(lmaxval & 0xffff));
+    {
+        /* patch size of pict in */
+        long const picSz = ftell(stdout) - HEADER_SIZE;
+        if (fseek(stdout, (long)HEADER_SIZE, 0) >= 0)
+            putShort(stdout, (short)(picSz & 0xffff));
+    }
 
     return 0;
 }
diff --git a/converter/ppm/ppmtopj.c b/converter/ppm/ppmtopj.c
index d116773f..8fe6c05d 100644
--- a/converter/ppm/ppmtopj.c
+++ b/converter/ppm/ppmtopj.c
@@ -1,4 +1,4 @@
-/* ppmtopj.c - convert a portable pixmap to an HP PainJetXL image
+/* ppmtopj.c - convert a PPM to an HP PainJetXL image
 **
 ** Copyright (C) 1990 by Christos Zoulas (christos@ee.cornell.edu)
 **
@@ -12,245 +12,263 @@
 
 #include <string.h>
 
+#include "mallocvar.h"
 #include "nstring.h"
 #include "ppm.h"
 
-static int compress_row ARGS((unsigned char *op, unsigned char *oe, unsigned char *cp));
 /*
  * XXX: Only 8.5 x 11 paper
  */
-#define WIDTH	  8.5
-#define HEIGHT	  11.0
-#define DPI	  180
-#define XPIX	  ((int) ((DPI * WIDTH + 7) / 8) << 3)
-#define YPIX	  ((int) ((DPI * HEIGHT + 7) / 8) << 3)
-
-#define C_RESET 			"\033E"
-#define C_RENDER 			"\033*t%dJ"
-# define C_RENDER_NONE			0
-# define C_RENDER_SNAP			1
-# define C_RENDER_BW			2
-# define C_RENDER_DITHER		3
-# define C_RENDER_DIFFUSE		4
-# define C_RENDER_MONODITHER		5
-# define C_RENDER_MONODIFFUSE		6
-# define C_RENDER_MONO_CL_DITHER	5
-# define C_RENDER_MONO_CL_DIFFUSE	6
-#define C_BACK_SCALE			"\033*t%dK"
-# define C_BACK_SCALE_LIGHT		0
-# define C_BACK_SCALE_DARK		1
-#define C_GAMMA				"\033*t%dI"
-#define C_IMAGE_WIDTH			"\033*r%dS"
-#define C_IMAGE_HEIGHT			"\033*r%dT"
-#define C_DATA_PLANES			"\033*r%dU"
-#define C_TRANS_MODE			"\033*b%dM"
-# define C_TRANS_MODE_STD		0
-# define C_TRANS_MODE_RLE		1
-# define C_TRANS_MODE_TIFF		2
-#define C_SEND_PLANE			"\033*b%dV"
-#define C_LAST_PLANE			"\033*b%dW"
-#define C_BEGIN_RASTER			"\033*r%dA"
-# define C_BEGIN_RASTER_MARGIN		0
-# define C_BEGIN_RASTER_ACTIVE		1
-# define C_BEGIN_RASTER_NOSCALE		0
-# define C_BEGIN_RASTER_SCALE		2
-#define C_END_RASTER			"\033*r%dC"
-# define C_END_RASTER_UNUSED		0
-#define C_RESOLUTION			"\033*t%dR"
-# define C_RESOLUTION_90DPI		90
-# define C_RESOLUTION_180DPI		180
-#define C_MOVE_X			"\033*p+%dX"
-#define C_MOVE_Y			"\033*p+%dY"
-
-static const char * const rmode[] = { 
-    "none", "snap", "bw", "dither", "diffuse", 
-    "monodither", "monodiffuse", "clusterdither", 
-    "monoclusterdither", NULL 
+#define WIDTH     8.5
+#define HEIGHT    11.0
+#define DPI   180
+#define XPIX      ((int) ((DPI * WIDTH + 7) / 8) << 3)
+#define YPIX      ((int) ((DPI * HEIGHT + 7) / 8) << 3)
+
+#define C_RESET             "\033E"
+#define C_RENDER            "\033*t%dJ"
+# define C_RENDER_NONE          0
+# define C_RENDER_SNAP          1
+# define C_RENDER_BW            2
+# define C_RENDER_DITHER        3
+# define C_RENDER_DIFFUSE       4
+# define C_RENDER_MONODITHER        5
+# define C_RENDER_MONODIFFUSE       6
+# define C_RENDER_MONO_CL_DITHER    5
+# define C_RENDER_MONO_CL_DIFFUSE   6
+#define C_BACK_SCALE            "\033*t%dK"
+# define C_BACK_SCALE_LIGHT     0
+# define C_BACK_SCALE_DARK      1
+#define C_GAMMA             "\033*t%dI"
+#define C_IMAGE_WIDTH           "\033*r%dS"
+#define C_IMAGE_HEIGHT          "\033*r%dT"
+#define C_DATA_PLANES           "\033*r%dU"
+#define C_TRANS_MODE            "\033*b%dM"
+# define C_TRANS_MODE_STD       0
+# define C_TRANS_MODE_RLE       1
+# define C_TRANS_MODE_TIFF      2
+#define C_SEND_PLANE            "\033*b%dV"
+#define C_LAST_PLANE            "\033*b%dW"
+#define C_BEGIN_RASTER          "\033*r%dA"
+# define C_BEGIN_RASTER_MARGIN      0
+# define C_BEGIN_RASTER_ACTIVE      1
+# define C_BEGIN_RASTER_NOSCALE     0
+# define C_BEGIN_RASTER_SCALE       2
+#define C_END_RASTER            "\033*r%dC"
+# define C_END_RASTER_UNUSED        0
+#define C_RESOLUTION            "\033*t%dR"
+# define C_RESOLUTION_90DPI     90
+# define C_RESOLUTION_180DPI        180
+#define C_MOVE_X            "\033*p+%dX"
+#define C_MOVE_Y            "\033*p+%dY"
+
+static const char * const rmode[] = {
+    "none",
+    "snap",
+    "bw",
+    "dither",
+    "diffuse",
+    "monodither",
+    "monodiffuse",
+    "clusterdither",
+    "monoclusterdither",
+    NULL
 };
 
-/*
- * Run-length encoding for the PaintJet. We have pairs of <instances>
- * <value>, where instances goes from 0 (meaning one instance) to 255
- * If we are unlucky we can double the size of the image.
- */
-static int
-compress_row(op, oe, cp)
-unsigned char *op, *oe, *cp;
-{
-    unsigned char *ce = cp;
-    while ( op < oe ) {	
-	unsigned char px = *op++;
-	unsigned char *pr = op;
-	while ( op < oe && *op == px && op - pr < 255) op++;
-	*ce++ = op - pr;
-	*ce++ = px;
+
+
+static void
+compressRow(const unsigned char * const opArg,
+            const unsigned char * const oe,
+            unsigned char *       const cp,
+            int *                 const szP) {
+/*----------------------------------------------------------------------------
+  Run-length encoding for the PaintJet. We have pairs of <instances> <value>,
+  where instances goes from 0 (meaning one instance) to 255 If we are unlucky
+  we can double the size of the image.
+-----------------------------------------------------------------------------*/
+    unsigned char * ce;
+    const unsigned char * op;
+
+    for (op = opArg, ce = cp; op < oe; ) {
+        unsigned char         const px = *op++;
+        const unsigned char * const pr = op;
+
+        while (op < oe && *op == px && op - pr < 255)
+            ++op;
+
+        *ce++ = op - pr;
+        *ce++ = px;
     }
-    return ce - cp;
+    *szP = ce - cp;
 }
 
-int main(argc, argv)
-int argc;
-char *argv[];
-{
-	pixel **pixels;
-	FILE *ifp;
-	int argn, rows, cols, r, c, k, p;
-	pixval maxval;
-	unsigned char *obuf, *op, *cbuf;
-	int render_mode = C_RENDER_NONE;
-	int back_scale = C_BACK_SCALE_DARK;
-	int gamma = 0;
-	int mode = C_TRANS_MODE_STD;
-	int center = 0;
-	int xoff = 0, yoff = 0;
-	/*
-	 * XXX: Someday we could make this command line options.
-	 */
-	int posscale = C_BEGIN_RASTER_MARGIN | C_BEGIN_RASTER_NOSCALE;
-	int resolution = C_RESOLUTION_180DPI;
-
-	const char * const usage = "[-center] [-xpos <pos>] [-ypos <pos>] [-gamma <val>] [-back <dark|lite>] [-rle] [-render <none|snap|bw|dither|diffuse|monodither|monodiffuse|clusterdither|monoclusterdither>] [ppmfile]";
-
-
-	ppm_init( &argc, argv );
-
-	argn = 1;
-	while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
-	    {
-	    if ( pm_keymatch(argv[argn],"-render",2) && argn + 1 < argc )
-		{
-		++argn;
-		for (r = 0; rmode[r] != NULL; r++)
-		     if (streq(rmode[r], argv[argn]))
-			 break;
-		if (rmode[r] != NULL)
-		    render_mode = r;
-		else
-		    pm_usage(usage);
-		}
-	    else if ( pm_keymatch(argv[argn],"-back",2) && argn + 1 < argc )
-		{
-		++argn;
-		if (streq(argv[argn], "dark"))
-		    back_scale = C_BACK_SCALE_DARK;
-		else if (streq(argv[argn], "lite"))
-		    back_scale = C_BACK_SCALE_LIGHT;
-		else
-		    pm_usage(usage);
-		}
-	    else if ( pm_keymatch(argv[argn],"-gamma",2) && argn + 1 < argc )
-		{
-		++argn;
-		if ( sscanf( argv[argn], "%d",&gamma ) != 1 )
-		    pm_usage( usage );
-		}
-	    else if ( pm_keymatch(argv[argn],"-xpos",2) && argn + 1 < argc )
-		{
-		++argn;
-		if ( sscanf( argv[argn], "%d",&xoff ) != 1 )
-		    pm_usage( usage );
-		}
-	    else if ( pm_keymatch(argv[argn],"-ypos",2) && argn + 1 < argc )
-		{
-		++argn;
-		if ( sscanf( argv[argn], "%d",&yoff ) != 1 )
-		    pm_usage( usage );
-		}
-	    else if (pm_keymatch(argv[argn],"-rle",2))
-		mode = C_TRANS_MODE_RLE;
-	    else if (pm_keymatch(argv[argn],"-center",2))
-		center = 1;
-	    else
-		pm_usage( usage );
-	    ++argn;
-	    }
-
-	if ( argn < argc )
-	    {
-	    ifp = pm_openr( argv[argn] );
-	    ++argn;
-	    }
-	else
-	    ifp = stdin;
-
-	if ( argn != argc )
-	    pm_usage( usage );
-
-	pixels = ppm_readppm( ifp, &cols, &rows, &maxval );
-
-	pm_close( ifp );
-	obuf = (unsigned char *) pm_allocrow(cols, sizeof(unsigned char));
-	cbuf = (unsigned char *) pm_allocrow(cols * 2, sizeof(unsigned char));
-
-        if (cols > XPIX || rows > YPIX)
-	    pm_message("image too large for page");
-        if (center) {
-	    if (xoff || yoff)
-		pm_error("cannot specify both center and position");
-	    xoff = (XPIX - cols) / 2;
-	    yoff = (YPIX - rows) / 2;
-	}
-
-	(void) printf(C_RESET);
-	/*
-	 * Set the resolution before begin raster otherwise it
-	 * does not work.
-	 */
-	(void) printf(C_RESOLUTION, resolution);
-	(void) printf(C_BEGIN_RASTER, posscale);
-	if (xoff)
-	    (void) printf(C_MOVE_X, xoff);
-	if (yoff)
-	    (void) printf(C_MOVE_Y, yoff);
-	(void) printf(C_TRANS_MODE, mode);
-	(void) printf(C_RENDER, render_mode);
-	(void) printf(C_BACK_SCALE, back_scale);
-	(void) printf(C_GAMMA,	 gamma);
-	(void) printf(C_IMAGE_WIDTH, cols);
-	(void) printf(C_IMAGE_HEIGHT, rows);
-	(void) printf(C_DATA_PLANES, 3);
-
-        for (r = 0; r < rows; r++)
-	    /* for each primary */
-	    for (p = 0; p < 3; p++) {
-		switch (p) {
-		case 0:
-		    for (c = 0, op = &obuf[-1]; c < cols; c++) {
-			if ((k = (c & 7)) == 0)
-			    *++op = 0;
-			if (PPM_GETR(pixels[r][c]) > maxval / 2)
-			    *op |= 1 << (7 - k);
-		    }
-		    break;
-		case 1:
-		    for (c = 0, op = &obuf[-1]; c < cols; c++) {
-			if ((k = (c & 7)) == 0)
-			    *++op = 0;
-			if (PPM_GETG(pixels[r][c]) > maxval / 2)
-			    *op |= 1 << (7 - k);
-		    }
-		    break;
-		case 2:
-		    for (c = 0, op = &obuf[-1]; c < cols; c++) {
-			if ((k = (c & 7)) == 0)
-			    *++op = 0;
-			if (PPM_GETB(pixels[r][c]) > maxval / 2)
-			    *op |= 1 << (7 - k);
-		    }
-		    break;
-		}
-		++op;
-		if (mode == C_TRANS_MODE_RLE) {
-		    k = compress_row(obuf, op, cbuf);
-		    op = cbuf;
-		}
-		else {
-		    k = op - obuf;
-		    op = obuf;
-		}
-		(void) printf(p == 2 ? C_LAST_PLANE : C_SEND_PLANE, k);
-		(void) fwrite(op, 1, k, stdout);
-	    }
-	(void) printf(C_END_RASTER, C_END_RASTER_UNUSED);
-	exit(0);
+
+
+int
+main(int argc, const char ** argv) {
+
+    pixel ** pixels;
+    FILE * ifP;
+    int argn, rows, cols, k;
+    unsigned int row;
+    pixval maxval;
+    unsigned char *obuf, *op, *cbuf;
+    int render_mode = C_RENDER_NONE;
+    int back_scale = C_BACK_SCALE_DARK;
+    int gamma = 0;
+    int mode = C_TRANS_MODE_STD;
+    int center = 0;
+    int xoff = 0, yoff = 0;
+    /*
+     * XXX: Someday we could make this command line options.
+     */
+    int const posscale = C_BEGIN_RASTER_MARGIN | C_BEGIN_RASTER_NOSCALE;
+    int const resolution = C_RESOLUTION_180DPI;
+
+    const char * const usage = "[-center] [-xpos <pos>] [-ypos <pos>] [-gamma <val>] [-back <dark|lite>] [-rle] [-render <none|snap|bw|dither|diffuse|monodither|monodiffuse|clusterdither|monoclusterdither>] [ppmfile]";
+
+
+    pm_proginit( &argc, argv );
+
+    argn = 1;
+    while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
+        {
+        if ( pm_keymatch(argv[argn],"-render",2) && argn + 1 < argc )
+        {
+        unsigned int r;
+        ++argn;
+        for (r = 0; rmode[r] != NULL; r++)
+             if (streq(rmode[r], argv[argn]))
+             break;
+        if (rmode[r] != NULL)
+            render_mode = r;
+        else
+            pm_usage(usage);
+        }
+        else if ( pm_keymatch(argv[argn],"-back",2) && argn + 1 < argc )
+        {
+        ++argn;
+        if (streq(argv[argn], "dark"))
+            back_scale = C_BACK_SCALE_DARK;
+        else if (streq(argv[argn], "lite"))
+            back_scale = C_BACK_SCALE_LIGHT;
+        else
+            pm_usage(usage);
+        }
+        else if ( pm_keymatch(argv[argn],"-gamma",2) && argn + 1 < argc )
+        {
+        ++argn;
+        if ( sscanf( argv[argn], "%d",&gamma ) != 1 )
+            pm_usage( usage );
+        }
+        else if ( pm_keymatch(argv[argn],"-xpos",2) && argn + 1 < argc )
+        {
+        ++argn;
+        if ( sscanf( argv[argn], "%d",&xoff ) != 1 )
+            pm_usage( usage );
+        }
+        else if ( pm_keymatch(argv[argn],"-ypos",2) && argn + 1 < argc )
+        {
+        ++argn;
+        if ( sscanf( argv[argn], "%d",&yoff ) != 1 )
+            pm_usage( usage );
+        }
+        else if (pm_keymatch(argv[argn],"-rle",2))
+        mode = C_TRANS_MODE_RLE;
+        else if (pm_keymatch(argv[argn],"-center",2))
+        center = 1;
+        else
+        pm_usage( usage );
+        ++argn;
+        }
+
+    if ( argn < argc )
+        {
+        ifP = pm_openr( argv[argn] );
+        ++argn;
+        }
+    else
+        ifP = stdin;
+
+    if ( argn != argc )
+        pm_usage( usage );
+
+    pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
+
+    pm_close(ifP);
+
+    MALLOCARRAY_NOFAIL(obuf, cols);
+
+    if (cols > UINT_MAX / 2)
+        pm_error("Image too wide (%u columns) for computation", cols);
+
+    MALLOCARRAY_NOFAIL(cbuf, cols * 2);
+
+    if (cols > XPIX || rows > YPIX)
+        pm_message("image too large for page");
+
+    if (center) {
+        if (xoff || yoff)
+        pm_error("cannot specify both center and position");
+        xoff = (XPIX - cols) / 2;
+        yoff = (YPIX - rows) / 2;
+    }
+
+    printf(C_RESET);
+    /*
+     * Set the resolution before begin raster otherwise it
+     * does not work.
+     */
+    printf(C_RESOLUTION, resolution);
+    printf(C_BEGIN_RASTER, posscale);
+    if (xoff)
+        printf(C_MOVE_X, xoff);
+    if (yoff)
+        printf(C_MOVE_Y, yoff);
+    printf(C_TRANS_MODE, mode);
+    printf(C_RENDER, render_mode);
+    printf(C_BACK_SCALE, back_scale);
+    printf(C_GAMMA,   gamma);
+    printf(C_IMAGE_WIDTH, cols);
+    printf(C_IMAGE_HEIGHT, rows);
+    printf(C_DATA_PLANES, 3);
+
+    for (row = 0; row < rows; ++row) {
+        /* for each primary */
+        unsigned int plane;
+        for (plane = 0; plane < 3; ++plane) {
+            unsigned int col;
+
+            for (col = 0, op = &obuf[-1]; col < cols; ++col) {
+                pixel  const p = pixels[row][col];
+                pixval const comp =
+                    plane == 0 ? PPM_GETR(p) :
+                    plane == 1 ? PPM_GETG(p) :
+                    plane == 2 ? PPM_GETB(p) :
+                    0; /* can't happen */
+
+                if ((k = (col & 0x7)) == 0)
+                    *++op = 0;
+                if (comp > maxval / 2)
+                        *op |= 1 << (7 - k);
+            }
+            ++op;
+            if (mode == C_TRANS_MODE_RLE) {
+                compressRow(obuf, op, cbuf, &k);
+                op = cbuf;
+            } else {
+                k = op - obuf;
+                op = obuf;
+            }
+            printf(plane == 2 ? C_LAST_PLANE : C_SEND_PLANE, k);
+            fwrite(op, 1, k, stdout);
+        }
+    }
+    printf(C_END_RASTER, C_END_RASTER_UNUSED);
+
+    exit(0);
 }
+
+
+
diff --git a/converter/ppm/ppmtopjxl.c b/converter/ppm/ppmtopjxl.c
index 90bcef0f..daaf7d59 100644
--- a/converter/ppm/ppmtopjxl.c
+++ b/converter/ppm/ppmtopjxl.c
@@ -1,7 +1,7 @@
 /* ppmtopcl.c - convert PPM into PCL language for HP PaintJet and
  *              PaintJet XL color printers
  * AJCD 12/3/91
- * 
+ *
  * usage:
  *       ppmtopcl [-nopack] [-gamma <n>] [-presentation] [-dark]
  *          [-diffuse] [-cluster] [-dither]
@@ -18,6 +18,7 @@
 #include <string.h>
 
 #include "pm_c_util.h"
+#include "mallocvar.h"
 #include "nstring.h"
 #include "ppm.h"
 #include "runlength.h"
@@ -47,7 +48,7 @@ static int yshift = 0;
 static int quality = 0;
 static double xscale = 0.0;
 static double yscale = 0.0;
-static double gamma_val = 0.0;
+static double gammaVal = 0.0;
 
 /* argument types */
 #define DIM 0
@@ -58,7 +59,7 @@ static const struct options {
     int type;
     void *value;
 } options[] = {
-   {"-gamma",        REAL, &gamma_val },
+   {"-gamma",        REAL, &gammaVal },
    {"-presentation", BOOL, &quality },
    {"-width",        DIM,  &xsize },
    {"-xsize",        DIM,  &xsize },
@@ -86,12 +87,12 @@ putword(unsigned short const w) {
 
 
 static unsigned int
-bitsperpixel(unsigned int v) {
+bitwidth(unsigned int v) {
 
     unsigned int bpp;
 
     /* calculate # bits for value */
-    
+
     for (bpp = 0; v > 0; ) {
         ++bpp;
         v >>= 1;
@@ -101,83 +102,350 @@ bitsperpixel(unsigned int v) {
 
 
 
-static char *inrow = NULL;
-static char *outrow = NULL;
-/* "signed" was commented out below, but it caused warnings on an SGI 
+/* The following belong to the bit putter.  They really should be in a
+   struct passed to the methods of the bit putter instead.
+*/
+
+static char *inrow;
+static char *outrow;
+/* "signed" was commented out below, but it caused warnings on an SGI
    compiler, which defaulted to unsigned character.  2001.03.30 BJH */
-static signed char *runcnt = NULL;
+static signed char * runcnt;
+static int out = 0;
+static int cnt = 0;
+static int num = 0;
+static bool pack = false;
+
+static void
+initbits(unsigned int const bytesPerRow) {
+
+    MALLOCARRAY(inrow,  bytesPerRow);
+    MALLOCARRAY(outrow, bytesPerRow * 2);
+    MALLOCARRAY(runcnt, bytesPerRow);
+
+    if (!inrow || !outrow || !runcnt)
+        pm_error("can't allocate space for row");
+}
+
+
+
+static void
+termbits() {
+
+    free(runcnt);
+    free(outrow);
+    free(inrow);
+}
 
-static void 
-putbits(int const bArg,
-        int const nArg) {
+
+
+static void
+putbits(unsigned int const bArg,
+        unsigned int const nArg) {
 /*----------------------------------------------------------------------------
-  Put 'n' bits in 'b' out, packing into bytes; n=0 flushes bits.
+  Add 'bArg' to byte-packing output buffer as 'n' bits.
 
-  n should never be > 8 
+  n should never be > 8
 -----------------------------------------------------------------------------*/
-    static int out = 0;
-    static int cnt = 0;
-    static int num = 0;
-    static bool pack = false;
-
     int b;
     int n;
+    int xo;
+    int xc;
 
     b = bArg;
     n = nArg;
 
-    if (n) {
-        int xo = 0;
-        int xc = 0;
+    assert(n <= 8);
+
+    if (cnt + n > 8) {  /* overflowing current byte? */
+        xc = cnt + n - 8;
+        xo = (b & ~(-1 << xc)) << (8-xc);
+        n -= xc;
+        b >>= xc;
+    } else {
+        xo = 0;
+        xc = 0;
+    }
+
+    cnt += n;
 
-        assert(n <= 8);
+    out |= (b & ~(-1 << n)) << (8-cnt);
 
-        if (cnt + n > 8) {  /* overflowing current byte? */
-            xc = cnt + n - 8;
-            xo = (b & ~(-1 << xc)) << (8-xc);
-            n -= xc;
-            b >>= xc;
-        }
-        cnt += n;
-        out |= (b & ~(-1 << n)) << (8-cnt);
-        if (cnt >= 8) {
-            inrow[num++] = out;
-            out = xo;
-            cnt = xc;
+    if (cnt >= 8) {
+        inrow[num++] = out;
+        out = xo;
+        cnt = xc;
+    }
+}
+
+
+
+static void
+flushbits() {
+/*----------------------------------------------------------------------------
+   flush a row of buffered bits.
+-----------------------------------------------------------------------------*/
+    if (cnt) {
+        inrow[num++] = out;
+        out = cnt = 0;
+    }
+    for (; num > 0 && inrow[num-1] == 0; --num);
+    /* remove trailing zeros */
+    printf("\033*b");
+    if (num && !nopack) {            /* TIFF 4.0 packbits encoding */
+        size_t outSize;
+        pm_rlenc_compressbyte(
+            (unsigned char *)inrow, (unsigned char *)outrow,
+            PM_RLE_PACKBITS, num, &outSize);
+        if (outSize < num) {
+            num = outSize;
+            if (!pack) {
+                printf("2m");
+                pack = true;
+            }
+        } else {
+            if (pack) {
+                printf("0m");
+                pack = false;
+            }
         }
-    } else { /* flush row */
-        if (cnt) {
-            inrow[num++] = out;
-            out = cnt = 0;
+    }
+    printf("%dW", num);
+    {
+        unsigned int i;
+        for (i = 0; i < num; ++i)
+            putchar(pack ? outrow[i] : inrow[i]);
+    }
+    num = 0; /* new row */
+}
+
+
+
+static void
+computeColormap(pixel **           const pixels,
+                unsigned int       const cols,
+                unsigned int       const rows,
+                unsigned int       const maxColors,
+                colorhist_vector * const chvP,
+                colorhash_table *  const chtP,
+                unsigned int *     const colorCtP) {
+
+    colorhist_vector chv;
+    colorhash_table cht;
+    int colorCt;
+
+    pm_message("Computing colormap...");
+
+    chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colorCt);
+    if (!chv)
+        pm_error("too many colors; reduce to %u or fewer with 'pnmquant'",
+                 MAXCOLORS);
+
+    pm_message("... Done.  %u colors found.", colorCt);
+
+    /* And make a hash table for fast lookup. */
+    cht = ppm_colorhisttocolorhash(chv, colorCt);
+
+    *chvP     = chv;
+    *chtP     = cht;
+    *colorCtP = colorCt;
+}
+
+
+
+static unsigned int
+nextPowerOf2(unsigned int const arg) {
+/*----------------------------------------------------------------------------
+   Works only on 0-7
+-----------------------------------------------------------------------------*/
+        switch (arg) { /* round up to 1,2,4,8 */
+        case 0:                         return 0; break;
+        case 1:                         return 1; break;
+        case 2:                         return 2; break;
+        case 3: case 4:                 return 4; break;
+        case 5: case 6: case 7: case 8: return 8; break;
+        default:
+            assert(false);
         }
-        for (; num > 0 && inrow[num-1] == 0; --num);
-            /* remove trailing zeros */
-        printf("\033*b"); 
-        if (num && !nopack) {            /* TIFF 4.0 packbits encoding */
-            size_t outSize;
-            pm_rlenc_compressbyte(
-                (unsigned char *)inrow, (unsigned char *)outrow,
-                PM_RLE_PACKBITS, num, &outSize); 
-            if (outSize < num) {
-                num = outSize;
-                if (!pack) {
-                    printf("2m");
-                    pack = true;
-                }
-            } else {
-                if (pack) {
-                    printf("0m");
-                    pack = false;
-                }
+}
+
+
+
+static void
+computeColorDownloadingMode(unsigned int   const colorCt,
+                            unsigned int   const cols,
+                            pixval         const maxval,
+                            unsigned int * const bytesPerRowP,
+                            bool *         const colorMappedP,
+                            unsigned int * const bitsPerPixelRedP,
+                            unsigned int * const bitsPerPixelGrnP,
+                            unsigned int * const bitsPerPixelBluP,
+                            unsigned int * const bitsPerIndexP) {
+/*----------------------------------------------------------------------------
+-----------------------------------------------------------------------------*/
+    unsigned int const indexBitCt = bitwidth(colorCt);
+
+    assert(colorCt > 0);
+    assert(indexBitCt > 0);
+
+    if (indexBitCt > 8) {
+        /* Can't use indexed mode */
+        /* We will instead write 1-3 full bytes per pixel, with those
+           bytes divided into red bits, green bits, and blue bits.  We
+           pad the red bits as needed to fill out whole bytes.  We
+           stick to 1, 2, 4, or 8 bits per pixel only because this program's
+           bit writer can't handle more than 8, which would happen with those
+           padded red fields if we allowed e.g. 7 bits for green and blue
+           (ergo 10 bits for red).
+        */
+        unsigned int const bitsPerSample = nextPowerOf2(bitwidth(maxval));
+        unsigned int const bitsPerPixel  = ROUNDUP(3 * bitsPerSample, 8);
+        unsigned int const bytesPerPixel = bitsPerPixel / 8;
+
+        *colorMappedP     = false;
+        *bitsPerPixelGrnP = bitsPerSample;
+        *bitsPerPixelBluP = bitsPerSample;
+        *bitsPerPixelRedP =
+            bitsPerPixel - *bitsPerPixelGrnP - *bitsPerPixelBluP;
+        *bytesPerRowP = bytesPerPixel * cols;
+    } else {
+        unsigned int const bitsPerPixel = nextPowerOf2(indexBitCt);
+
+        unsigned int pixelsPerByte;
+
+        *colorMappedP = true;
+
+        *bitsPerIndexP = bitsPerPixel;
+        pixelsPerByte = 8 / bitsPerPixel;
+        *bytesPerRowP = (cols + pixelsPerByte - 1) / pixelsPerByte;
+    }
+    if (*colorMappedP)
+        pm_message("Writing %u bit color indices", *bitsPerIndexP);
+    else
+        pm_message("Writing direct color, %u red bits, %u green, %u blue",
+                   *bitsPerPixelRedP, *bitsPerPixelGrnP, *bitsPerPixelBluP);
+}
+
+
+
+static void
+writePclHeader(unsigned int const cols,
+               unsigned int const rows,
+               pixval       const maxval,
+               int          const xshift,
+               int          const yshift,
+               unsigned int const quality,
+               unsigned int const xsize,
+               unsigned int const ysize,
+               double       const gammaVal,
+               unsigned int const dark,
+               unsigned int const render,
+               bool         const colorMapped,
+               unsigned int const bitsPerPixelRed,
+               unsigned int const bitsPerPixelGrn,
+               unsigned int const bitsPerPixelBlu,
+               unsigned int const bitsPerIndex) {
+
+#if 0
+    printf("\033&l26A");                         /* paper size */
+#endif
+    printf("\033*r%us%uT", cols, rows);          /* source width, height */
+    if (xshift != 0 || yshift != 0)
+        printf("\033&a%+dh%+dV", xshift, yshift); /* xshift, yshift */
+    if (quality)
+        printf("\033*o%uQ", quality);             /* print quality */
+    printf("\033*t");
+    if (xsize == 0 && ysize == 0)
+        printf("180r");                   /* resolution */
+    else {                               /* destination width, height */
+        if (xsize != 0)
+            printf("%uh", xsize);
+        if (ysize != 0)
+            printf("%uv", ysize);
+    }
+    if (gammaVal != 0)
+        printf("%.3fi", gammaVal);                    /* gamma correction */
+    if (dark)
+        printf("%uk", dark);              /* scaling algorithms */
+    printf("%uJ", render);               /* rendering algorithm */
+    printf("\033*v18W");                           /* configure image data */
+    putchar(0); /* relative colors */
+    putchar(colorMapped ? 1 : 3); /* index/direct pixel mode */
+    putchar(bitsPerIndex); /* ignored in direct pixel mode */
+    putchar(colorMapped ? 0 : bitsPerPixelRed);
+    putchar(colorMapped ? 0 : bitsPerPixelGrn);
+    putchar(colorMapped ? 0 : bitsPerPixelBlu);
+    putword(maxval); /* max red reference */
+    putword(maxval); /* max green reference */
+    putword(maxval); /* max blue reference */
+    putword(0); /* min red reference */
+    putword(0); /* min green reference */
+    putword(0); /* min blue reference */
+}
+
+
+
+static void
+writePalette(colorhist_vector const chv,
+             unsigned int     const colorCt) {
+
+    unsigned int i;
+
+    for (i = 0; i < colorCt; ++i) {
+        unsigned int const r = PPM_GETR( chv[i].color);
+        unsigned int const g = PPM_GETG( chv[i].color);
+        unsigned int const b = PPM_GETB( chv[i].color);
+
+        if (i == 0)
+            printf("\033*v");
+        if (r)
+            printf("%ua", r);
+        if (g)
+            printf("%ub", g);
+        if (b)
+            printf("%uc", b);
+        if (i == colorCt - 1)
+            printf("%uI", i);    /* assign color index */
+        else
+            printf("%ui", i);    /* assign color index */
+    }
+}
+
+
+
+static void
+writeRaster(pixel **        const pixels,
+            unsigned int    const rows,
+            unsigned int    const cols,
+            colorhash_table const cht,
+            bool            const colorMapped,
+            unsigned int    const bitsPerIndex,
+            unsigned int    const bitsPerPixelRed,
+            unsigned int    const bitsPerPixelGrn,
+            unsigned int    const bitsPerPixelBlu) {
+
+    unsigned int row;
+
+    for (row = 0; row < rows; ++row) {
+        pixel * const pixrow = pixels[row];
+
+        if (colorMapped) {
+            unsigned int col;
+
+            for (col = 0; col < cols; ++col)
+                putbits(ppm_lookupcolor(cht, &pixrow[col]), bitsPerIndex);
+            flushbits();
+        } else {
+            unsigned int col;
+
+            for (col = 0; col < cols; ++col) {
+                putbits(PPM_GETR(pixrow[col]), bitsPerPixelRed);
+                putbits(PPM_GETG(pixrow[col]), bitsPerPixelGrn);
+                putbits(PPM_GETB(pixrow[col]), bitsPerPixelBlu);
+                /* don't need to flush */
             }
+            flushbits();
         }
-        printf("%dW", num);
-        {
-            unsigned int i;
-            for (i = 0; i < num; ++i)
-                putchar(pack ? outrow[i] : inrow[i]);
-        }
-        num = 0; /* new row */
     }
 }
 
@@ -188,16 +456,17 @@ main(int argc, const char * argv[]) {
 
     FILE * ifP;
     pixel ** pixels;
-    unsigned int row;
-    unsigned int bpp;
     int rows, cols;
     pixval maxval;
-    int bpr, bpg, bpb;
+    bool colorMapped;
+    unsigned int bytesPerRow;
+    unsigned int bitsPerPixelRed, bitsPerPixelGrn, bitsPerPixelBlu;
+    unsigned int bitsPerIndex;
     int render;
-    int colors, pclindex;
+    unsigned int colorCt;
     colorhist_vector chv;
     colorhash_table cht;
-   
+
     pm_proginit(&argc, argv);
 
     while (argc > 1 && argv[1][0] == '-') {
@@ -267,42 +536,14 @@ main(int argc, const char * argv[]) {
     if (maxval > PCL_MAXVAL)
         pm_error("color range too large; reduce with ppmcscale");
 
-    /* Figure out the colormap. */
-    pm_message("Computing colormap...");
-    chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colors);
-    if (!chv)
-        pm_error("too many colors; reduce with pnmquant");
-    pm_message("... Done.  %u colors found.", colors);
+    computeColormap(pixels, cols, rows, MAXCOLORS, &chv, &cht, &colorCt);
 
-    /* And make a hash table for fast lookup. */
-    cht = ppm_colorhisttocolorhash(chv, colors);
-
-    /* work out color downloading mode */
-    pclindex = bitsperpixel(colors);
-    if (pclindex > 8) /* can't use indexed mode */
-        pclindex = 0;
-    else {
-        switch (pclindex) { /* round up to 1,2,4,8 */
-        case 0: /* direct mode (no palette) */
-            bpp = bitsperpixel(maxval); /* bits per pixel */
-            bpg = bpp; bpb = bpp;
-            bpp = (bpp*3+7)>>3;     /* bytes per pixel now */
-            bpr = (bpp<<3)-bpg-bpb; 
-            bpp *= cols;            /* bytes per row now */
-            break;
-        case 5:         pclindex++;
-        case 6:         pclindex++;
-        case 3: case 7: pclindex++;
-        default:
-            bpp = 8/pclindex;
-            bpp = (cols+bpp-1)/bpp;      /* bytes per row */
-        }
-    }
-    inrow = (char *)malloc((unsigned)bpp);
-    outrow = (char *)malloc((unsigned)bpp*2);
-    runcnt = (signed char *)malloc((unsigned)bpp);
-    if (inrow == NULL || outrow == NULL || runcnt == NULL)
-        pm_error("can't allocate space for row");
+    computeColorDownloadingMode(
+        colorCt, cols, maxval,
+        &bytesPerRow, &colorMapped,
+        &bitsPerPixelRed, &bitsPerPixelGrn, &bitsPerPixelBlu, &bitsPerIndex);
+
+    initbits(bytesPerRow);
 
     /* set up image details */
     if (xscale != 0.0)
@@ -310,92 +551,31 @@ main(int argc, const char * argv[]) {
     if (yscale != 0.0)
         ysize = rows * yscale * 4;
 
-    /* write PCL header */
-#if 0
-    printf("\033&l26A");                         /* paper size */
-#endif
-    printf("\033*r%ds%dT", cols, rows);          /* source width, height */
-    if (xshift != 0 || yshift != 0)
-        printf("\033&a%+dh%+dV", xshift, yshift); /* xshift, yshift */
-    if (quality)
-        printf("\033*o%dQ", quality);             /* print quality */
-    printf("\033*t");
-    if (xsize == 0 && ysize == 0)
-        printf("180r");                   /* resolution */
-    else {                               /* destination width, height */
-        if (xsize != 0)
-            printf("%dh", xsize);
-        if (ysize != 0)
-            printf("%dv", ysize);
-    }
-    if (gamma_val != 0)
-        printf("%.3fi", gamma_val);                    /* gamma correction */
-    if (dark)
-        printf("%dk", dark);              /* scaling algorithms */
-    printf("%dJ", render);               /* rendering algorithm */
-    printf("\033*v18W");                           /* configure image data */
-    putchar(0); /* relative colors */
-    putchar(pclindex ? 1 : 3); /* index/direct pixel mode */
-    putchar(pclindex); /* ignored in direct pixel mode */
-    if (pclindex) {
-        putchar(0);
-        putchar(0);
-        putchar(0);
-    } else {
-        putchar(bpr); /* bits per red */
-        putchar(bpg); /* bits per green */
-        putchar(bpb); /* bits per blue */
-    }
-    putword(maxval); /* max red reference */
-    putword(maxval); /* max green reference */
-    putword(maxval); /* max blue reference */
-    putword(0); /* min red reference */
-    putword(0); /* min green reference */
-    putword(0); /* min blue reference */
-    if (pclindex) {                        /* set palette */
-        unsigned int i;
-        for (i = 0; i < colors; ++i) {
-            int const r = PPM_GETR( chv[i].color);
-            int const g = PPM_GETG( chv[i].color);
-            int const b = PPM_GETB( chv[i].color);
-            if (i == 0)
-                printf("\033*v");
-            if (r)
-                printf("%da", r);
-            if (g)
-                printf("%db", g);
-            if (b)
-                printf("%dc", b);
-            if (i == colors-1)
-                printf("%dI", i);    /* assign color index */
-            else
-                printf("%di", i);    /* assign color index */
-        }
-    }
-    ppm_freecolorhist(chv);
+    writePclHeader(cols, rows, maxval, xshift, yshift, quality, xsize, ysize,
+                   gammaVal, dark, render,
+                   colorMapped,
+                   bitsPerPixelRed, bitsPerPixelGrn, bitsPerPixelBlu,
+                   bitsPerIndex);
+
+    if (colorMapped)
+        writePalette(chv, colorCt);
 
     /* start raster graphics at CAP */
     printf("\033*r%dA", (xsize != 0 || ysize != 0) ? 3 : 1);
 
-    for (row = 0; row < rows; row++) {
-        pixel * const pixrow = pixels[row];
-        if (pclindex) { /* indexed color mode */
-            unsigned int col;
-            for (col = 0; col < cols; ++col)
-                putbits(ppm_lookupcolor(cht, &pixrow[col]), pclindex);
-            putbits(0, 0); /* flush row */
-        } else { /* direct color mode */
-            unsigned int col;
-            for (col = 0; col < cols; ++col) {
-                putbits(PPM_GETR(pixrow[col]), bpr);
-                putbits(PPM_GETG(pixrow[col]), bpg);
-                putbits(PPM_GETB(pixrow[col]), bpb);
-                /* don't need to flush */
-            }
-            putbits(0, 0); /* flush row */
-        }
-    }
+    writeRaster(pixels, rows, cols, cht, colorMapped,
+                bitsPerIndex,
+                bitsPerPixelRed, bitsPerPixelGrn, bitsPerPixelBlu);
+
     printf("\033*rC"); /* end raster graphics */
 
+    ppm_freecolorhash(cht);
+    ppm_freecolorhist(chv);
+
+    termbits();
+
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtoppm.c b/converter/ppm/ppmtoppm.c
index 500c9856..3a48eacc 100644
--- a/converter/ppm/ppmtoppm.c
+++ b/converter/ppm/ppmtoppm.c
@@ -20,7 +20,7 @@ main(int argc, char *argv[]) {
     pixval maxval;
     int row;
     pixel* pixelrow;
-    
+
     ppm_init(&argc, argv);
 
     if (argc-1 != 0)
@@ -42,3 +42,6 @@ main(int argc, char *argv[]) {
 
     exit(0);
 }
+
+
+
diff --git a/converter/ppm/ppmtopuzz.c b/converter/ppm/ppmtopuzz.c
index 1277cc20..08b852b0 100644
--- a/converter/ppm/ppmtopuzz.c
+++ b/converter/ppm/ppmtopuzz.c
@@ -33,12 +33,12 @@ main( argc, argv )
     ppm_init( &argc, argv );
 
     if ( argc > 2 )
-	pm_usage( "[ppmfile]" );
+        pm_usage( "[ppmfile]" );
 
     if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+        ifp = pm_openr( argv[1] );
     else
-	ifp = stdin;
+        ifp = stdin;
 
     pixels = ppm_readppm( ifp, &cols, &rows, &maxval );
     pm_close( ifp );
@@ -46,11 +46,11 @@ main( argc, argv )
     pm_message( "computing colormap..." );
     chv = ppm_computecolorhist( pixels, cols, rows, MAXCOLORS, &colors );
     if ( chv == (colorhist_vector) 0 )
-	{
-	pm_message(
-	    "too many colors - try doing a 'pnmquant %d'", MAXCOLORS );
-	exit( 1 );
-	}
+        {
+        pm_message(
+            "too many colors - try doing a 'pnmquant %d'", MAXCOLORS );
+        exit( 1 );
+        }
     pm_message( "%d colors found", colors );
 
     /* Write puzzle header. */
@@ -58,19 +58,19 @@ main( argc, argv )
     (void) pm_writebiglong( stdout, rows );
     (void) putchar( (unsigned char) colors );
     if ( maxval > MAXVAL )
-	pm_message(
-	    "maxval is not %d - automatically rescaling colors", MAXVAL );
+        pm_message(
+            "maxval is not %d - automatically rescaling colors", MAXVAL );
     for ( i = 0; i < colors; ++i )
-	{
-	pixel p;
+        {
+        pixel p;
 
-	p = chv[i].color;
-	if ( maxval != MAXVAL )
-	    PPM_DEPTH( p, p, maxval, MAXVAL );
-	(void) putchar( (unsigned char) PPM_GETR( p ) );
-	(void) putchar( (unsigned char) PPM_GETG( p ) );
-	(void) putchar( (unsigned char) PPM_GETB( p ) );
-	}
+        p = chv[i].color;
+        if ( maxval != MAXVAL )
+            PPM_DEPTH( p, p, maxval, MAXVAL );
+        (void) putchar( (unsigned char) PPM_GETR( p ) );
+        (void) putchar( (unsigned char) PPM_GETG( p ) );
+        (void) putchar( (unsigned char) PPM_GETB( p ) );
+        }
 
     /* Convert color vector to color hash table, for fast lookup. */
     cht = ppm_colorhisttocolorhash( chv, colors );
@@ -78,19 +78,22 @@ main( argc, argv )
 
     /* And write out the data. */
     for ( row = 0; row < rows; ++row )
-	{
-	for ( col = 0, pP = pixels[row]; col < cols; ++col, ++pP )
-	    {
-	    register int color;
-
-	    color = ppm_lookupcolor( cht, pP );
-	    if ( color == -1 )
-		pm_error(
-		    "color not found?!?  row=%d col=%d  r=%d g=%d b=%d",
-		    row, col, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP) );
-	    (void) putchar( (unsigned char) color );
-	    }
-	}
+        {
+        for ( col = 0, pP = pixels[row]; col < cols; ++col, ++pP )
+            {
+            register int color;
+
+            color = ppm_lookupcolor( cht, pP );
+            if ( color == -1 )
+                pm_error(
+                    "color not found?!?  row=%d col=%d  r=%d g=%d b=%d",
+                    row, col, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP) );
+            (void) putchar( (unsigned char) color );
+            }
+        }
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/ppmtospu.c b/converter/ppm/ppmtospu.c
index a6acbaa0..df0fb970 100644
--- a/converter/ppm/ppmtospu.c
+++ b/converter/ppm/ppmtospu.c
@@ -48,11 +48,11 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0,   "d0",       OPT_FLAG,   
+    OPTENT3(0,   "d0",       OPT_FLAG,
             NULL,                       &d0Spec, 0);
-    OPTENT3(0,   "d2",       OPT_FLAG,   
+    OPTENT3(0,   "d2",       OPT_FLAG,
             NULL,                       &d2Spec, 0);
-    OPTENT3(0,   "d4",       OPT_FLAG,   
+    OPTENT3(0,   "d4",       OPT_FLAG,
             NULL,                       &d4Spec, 0);
 
     opt.opt_table = option_def;
@@ -72,7 +72,7 @@ parseCommandLine(int argc, const char ** argv,
     else
         cmdlineP->dithflag = 2;
 
-    if (argc-1 < 1) 
+    if (argc-1 < 1)
         cmdlineP->inputFileName = "-";
     else {
         cmdlineP->inputFileName = argv[1];
@@ -129,7 +129,7 @@ findIndex(unsigned int const col,
    Spectrum palette index.
 -----------------------------------------------------------------------------*/
     int r, x1;
-    
+
     x1 = 10 * index;  /* initial value */
     if (index & 0x1)
         x1 -= 5;
@@ -143,7 +143,7 @@ findIndex(unsigned int const col,
 
     if (col >= (x1+160))
         r += 32;
-    
+
     return r;
 }
 
@@ -183,7 +183,7 @@ dither(unsigned int       const row,
         { 0, 2 },
         { 3, 1 }
     };
-    
+
     unsigned int c[3];  /* An element for each plane */
     unsigned int col;
 
@@ -262,7 +262,7 @@ sort(struct PixelType * const pixelType,
             ++i;
         while (pixelType[j-1].popularity > pivot)
             --j;
-        
+
         if (i < j) {
             /* An element not less popular than pivot is to the left of a
                pixel not more popular than pivot, so swap them.  Note that we
@@ -274,7 +274,7 @@ sort(struct PixelType * const pixelType,
             --j;
         }
     }
-    
+
     if (j - left > 1)
         sort(pixelType, left, j);
     if (right - i > 1)
@@ -445,7 +445,7 @@ convertRow(unsigned int       const row,
     /* Mark palette entries as all free */
     for (i = 0; i < 48; ++i)
         palP->pal[row][i] = -1;
-    
+
     /* Mark reserved palette entries */
     palP->pal[row][0]  = palP->pal[row][15] = palP->pal[row][16] = 0;
     palP->pal[row][31] = palP->pal[row][32] = palP->pal[row][47] = 0;
@@ -494,7 +494,7 @@ writeScreen(const short * const screen) {
     /* Write the bitmap */
 
     unsigned int i;
-    
+
     for (i = 0; i < 16000; ++i) {
         char const c0 = 0xff & (screen[i] >> 8);
         char const c1 = 0xff & screen[i];
diff --git a/converter/ppm/ppmtoterm.c b/converter/ppm/ppmtoterm.c
index d388f77d..6e41a8cb 100644
--- a/converter/ppm/ppmtoterm.c
+++ b/converter/ppm/ppmtoterm.c
@@ -86,7 +86,7 @@ parseCommandLine(int argc, const char ** argv,
 
 
 static void
-generatePalette(unsigned char        rgb[NUM_COLORS][3], 
+generatePalette(unsigned char        rgb[NUM_COLORS][3],
                 char                 ansiCode[NUM_COLORS][MAX_ANSI_STR_LEN],
                 unsigned int * const paletteSizeP) {
 /*----------------------------------------------------------------------------
@@ -150,7 +150,7 @@ generatePalette(unsigned char        rgb[NUM_COLORS][3],
 static void
 lookupInPalette(pixel          const pixel,
                 pixval         const maxval,
-                unsigned char        rgb[NUM_COLORS][3], 
+                unsigned char        rgb[NUM_COLORS][3],
                 unsigned int   const palLen,
                 unsigned int * const paletteIdxP) {
 /*----------------------------------------------------------------------------
@@ -166,7 +166,7 @@ lookupInPalette(pixel          const pixel,
     unsigned int paletteIdxSoFar;
     unsigned int dist;
     unsigned int i;
-            
+
     /* The following loop calculates the index that corresponds to the
        minimum color distance between the given RGB values and the
        values available in the palette.
@@ -200,18 +200,18 @@ main(int argc, const char ** argv) {
     unsigned char   rgb[NUM_COLORS][3];
     char            ansiCode[NUM_COLORS][MAX_ANSI_STR_LEN];
 
-    pm_proginit(&argc, argv);    
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
     ifP = pm_openr(cmdline.inputFileName);
-    
+
     pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
 
     pm_close(ifP);
-        
+
     generatePalette(rgb, ansiCode, &palLen);
-    
+
     for (row = 0; row < rows; ++row) {
         unsigned int col;
         for (col = 0; col < cols; ++col) {
@@ -227,6 +227,9 @@ main(int argc, const char ** argv) {
     printf(ESC "\x30m");
 
     ppm_freearray(pixels, rows);
-    
+
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c
index c673798f..0e2751f3 100644
--- a/converter/ppm/ppmtowinicon.c
+++ b/converter/ppm/ppmtowinicon.c
@@ -1,4 +1,4 @@
-/* ppmtowinicon.c - read portable pixmap file(s) and write a MS Windows .ico
+/* ppmtowinicon.c - read PPM images and write a MS Windows .ico
 **
 ** Copyright (C) 2000 by Lee Benfield - lee@benf.org
 **
@@ -10,6 +10,7 @@
 ** implied warranty.
 */
 
+#include <assert.h>
 #include <math.h>
 #include <string.h>
 
@@ -25,31 +26,30 @@
 
 #define MAXCOLORS 256
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    unsigned int iconCount;
-    const char **inputFilespec;  /* '-' if stdin; malloc'ed array */
-    const char **andpgmFilespec;    /* NULL if unspecified; malloc'ed array */
-    const char *output;     /* '-' if unspecified */
-    unsigned int truetransparent;
-    unsigned int verbose;
+    unsigned int  iconCount;
+    const char ** inputFileNm;  /* '-' if stdin; malloc'ed array */
+    const char ** andpgmFileNm;    /* NULL if unspecified; malloc'ed array */
+    const char *  output;     /* '-' if unspecified */
+    unsigned int  truetransparent;
+    unsigned int  verbose;
 };
 
 
 static bool verbose;
 
-static int      file_offset = 0; /* not actually used, but useful for debug. */
-static FILE *   ofp;
+static int      fileOffset = 0; /* not actually used, but useful for debug. */
 
 static void
-parseCommandLine(int                 argc, 
-                 char **             argv,
-                 struct cmdlineInfo *cmdlineP ) {
+parseCommandLine(int                  argc,
+                 const char **        argv,
+                 struct CmdlineInfo * cmdlineP) {
 /*----------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -82,31 +82,30 @@ parseCommandLine(int                 argc,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (!outputSpec)
         cmdlineP->output = "-";
 
-
     if (!andpgms) {
         if (argc-1 == 0) {
             cmdlineP->iconCount = 1;
-            MALLOCARRAY_NOFAIL(cmdlineP->inputFilespec, cmdlineP->iconCount);
-            cmdlineP->inputFilespec[0] = "-";
+            MALLOCARRAY_NOFAIL(cmdlineP->inputFileNm, cmdlineP->iconCount);
+            cmdlineP->inputFileNm[0] = "-";
         } else {
             unsigned int iconIndex;
 
             cmdlineP->iconCount = argc-1;
-            MALLOCARRAY_NOFAIL(cmdlineP->inputFilespec, cmdlineP->iconCount);
+            MALLOCARRAY_NOFAIL(cmdlineP->inputFileNm, cmdlineP->iconCount);
             for (iconIndex = 0; iconIndex < cmdlineP->iconCount; ++iconIndex)
-                cmdlineP->inputFilespec[iconIndex] = argv[iconIndex+1];
+                cmdlineP->inputFileNm[iconIndex] = argv[iconIndex+1];
         }
         {
             unsigned int iconIndex;
-            MALLOCARRAY_NOFAIL(cmdlineP->andpgmFilespec, cmdlineP->iconCount);
+            MALLOCARRAY_NOFAIL(cmdlineP->andpgmFileNm, cmdlineP->iconCount);
             for (iconIndex = 0; iconIndex < cmdlineP->iconCount; ++iconIndex)
-                cmdlineP->andpgmFilespec[iconIndex] = NULL;
+                cmdlineP->andpgmFileNm[iconIndex] = NULL;
         }
     } else {
         if (argc-1 < 2)
@@ -119,11 +118,11 @@ parseCommandLine(int                 argc,
         else {
             unsigned int iconIndex;
             cmdlineP->iconCount = (argc-1)/2;
-            MALLOCARRAY_NOFAIL(cmdlineP->inputFilespec, cmdlineP->iconCount);
-            MALLOCARRAY_NOFAIL(cmdlineP->andpgmFilespec, cmdlineP->iconCount);
+            MALLOCARRAY_NOFAIL(cmdlineP->inputFileNm, cmdlineP->iconCount);
+            MALLOCARRAY_NOFAIL(cmdlineP->andpgmFileNm, cmdlineP->iconCount);
             for (iconIndex = 0; iconIndex < cmdlineP->iconCount; ++iconIndex) {
-                cmdlineP->inputFilespec[iconIndex] = argv[1 + iconIndex*2];
-                cmdlineP->andpgmFilespec[iconIndex] = argv[2 + iconIndex*2];
+                cmdlineP->inputFileNm[iconIndex] = argv[1 + iconIndex*2];
+                cmdlineP->andpgmFileNm[iconIndex] = argv[2 + iconIndex*2];
             }
         }
     }
@@ -132,429 +131,423 @@ parseCommandLine(int                 argc,
 
 
 
-static void 
-PutByte(int const v) {
-   
-   if (putc(v, ofp) == EOF)
-       pm_error("Unable to write byte to output file.");
+static void
+freeCmdline(struct CmdlineInfo const cmdline) {
+
+    free(cmdline.inputFileNm);
+    free(cmdline.andpgmFileNm);
 }
-   
 
 
-static void 
-PutShort(short const v) {
-   
-   if (pm_writelittleshort(ofp, v) == -1)
-       pm_error("Unable to write short integer to output file");
-}
-   
 
+static void
+writeU1(FILE * const ofP,
+        u1     const v) {
 
-static void 
-PutLong(long const v) {
-   
-   if (pm_writelittlelong(ofp, v) == -1)
-       pm_error("Unable to write long integer to output file");
+    ++fileOffset;
+    pm_writechar(ofP, v);
 }
 
 
-   
-/*
- * These have no purpose but to wrapper the Byte, Short & Long 
- * functions.
- */
-static void 
-writeU1 (u1 const v) {
-   file_offset++;
-   PutByte(v);
-}
 
-static  void 
-writeU2 (u2 const v) {
-   file_offset +=2;
-   PutShort(v);
-}
+static  void
+writeU2(FILE * const ofP,
+        u2     const v) {
 
-static void 
-writeU4 (u4 const v) {
-   file_offset += 4;
-   PutLong(v);
+    fileOffset +=2;
+    pm_writelittleshort(ofP, v);
 }
 
-static MS_Ico 
-createIconFile (void) {
-   MS_Ico MSIconData;
-   
-   MALLOCVAR_NOFAIL(MSIconData);
-
-   MSIconData->reserved     = 0;
-   MSIconData->type         = 1;
-   MSIconData->count        = 0;
-   MSIconData->entries      = NULL;
-   return MSIconData;
+
+
+static void
+writeU4(FILE * const ofP,
+        u4     const v) {
+
+    fileOffset += 4;
+    pm_writelittlelong(ofP, v);
 }
 
 
-/* create andBitmap from pgm */
 
-static ICON_bmp 
-createAndBitmap (gray ** const ba, int const cols, int const rows,
-                 gray const maxval) {
-   /*
-    * How wide should the u1 string for each row be?
-    * each byte is 8 pixels, but must be a multiple of 4 bytes.
-    */
-   unsigned int const xBytes = ROUNDUP(cols, 32)/8;
-   ICON_bmp icBitmap;
-   int y,x;
-   u1 ** rowData;
-
-   MALLOCVAR_NOFAIL(icBitmap);
-
-   MALLOCARRAY_NOFAIL(rowData, rows);
-   icBitmap->xBytes = xBytes;
-   icBitmap->data   = rowData;
-   icBitmap->size   = xBytes * rows;
-   for (y=0;y<rows;y++) {
-      u1 * row;
-      int byteOn = 0;
-      int bitOn = 128;
-
-      MALLOCARRAY_NOFAIL(row, xBytes);
-
-      memset (row, 0, xBytes);
-      rowData[rows-y-1] = row;
-      /* 
-       * Check there's a bit array, otherwise we're just faking this...
-       */
-      if (ba) {
-     for (x=0;x<cols;x++) {
-            /* Black (bit clear) is transparent in PGM alpha maps,
-             * in ICO bit *set* is transparent.
-             */
-            if (ba[y][x] <= maxval/2) row[byteOn] |= bitOn;
-
-        if (bitOn == 1) {
-           byteOn++;
-           bitOn = 128;
-        } else {
-           bitOn >>= 1;
-        }
-     }
-      }
-   }
-   return icBitmap;
+static MS_Ico *
+newIconFile(void) {
+
+   MS_Ico * MSIconDataP;
+
+   MALLOCVAR_NOFAIL(MSIconDataP);
+
+   MSIconDataP->reserved     = 0;
+   MSIconDataP->type         = 1;
+   MSIconDataP->count        = 0;
+   MSIconDataP->entries      = NULL;
+
+   return MSIconDataP;
 }
 
 
-/*
- * Depending on if the image is stored as 1bpp, 4bpp or 8bpp, the 
- * encoding mechanism is different.
- * 
- * I didn't re-use the code from ppmtobmp since I need to keep the
- * bitmaps in memory till I've loaded all ppms.
- * 
- * 8bpp => 1 byte/palette index.
- * 4bpp => High Nibble, Low Nibble
- * 1bpp => 1 palette value per bit, high bit 1st.
- */
-static ICON_bmp 
-create1Bitmap (pixel ** const pa, int const cols, int const rows, 
-               colorhash_table const cht) {
-   /*
-    * How wide should the u1 string for each row be?
-    * each byte is 8 pixels, but must be a multiple of 4 bytes.
-    */
-   ICON_bmp icBitmap;
-   int xBytes,y,x;
-   int wt = cols;
-   u1 ** rowData;
-
-   MALLOCVAR_NOFAIL(icBitmap);
-   
-   wt >>= 3;
-   if (wt & 3) {
-      wt = (wt & ~3) + 4;
-   }
-   xBytes = wt;
-   MALLOCARRAY_NOFAIL(rowData, rows);
-   icBitmap->xBytes = xBytes;
-   icBitmap->data   = rowData;
-   icBitmap->size   = xBytes * rows;
-   for (y=0;y<rows;y++) {
-      u1 * row;
-      int byteOn = 0;
-      int bitOn = 128;
-      int value;
-      
-      MALLOCARRAY_NOFAIL(row, xBytes);
-      memset (row, 0, xBytes);
-      rowData[rows-y-1] = row;
-      /* 
-       * Check there's a pixel array, otherwise we're just faking this...
+
+static ICON_bmp *
+newAndBitmap(gray **      const ba,
+             unsigned int const cols,
+             unsigned int const rows,
+             gray         const maxval) {
+/*----------------------------------------------------------------------------
+  create andBitmap from PGM
+-----------------------------------------------------------------------------*/
+    unsigned int const xByteCt = ROUNDUP(cols, 32)/8;
+       /* How wide the u1 string for each row should be -- Each byte is 8
+          pixels, but must be a multiple of 4 bytes.
        */
-      if (pa) {
-     for (x=0;x<cols;x++) {
-        /*
-         * So we've got a colorhash_table with two colors in it.
-         * Which is black?!
-         * 
-         * Unless the hashing function changes, 0's black.
-         */
-        value = ppm_lookupcolor(cht, &pa[y][x]);
-        if (!value) {
-           /* leave black. */
-        } else {
-           row[byteOn] |= bitOn;
-        }
-        if (bitOn == 1) {
-           byteOn++;
-           bitOn = 128;
+    ICON_bmp * icBitmapP;
+    unsigned int row;
+    u1 ** rowData;
+
+    MALLOCVAR_NOFAIL(icBitmapP);
+
+    MALLOCARRAY_NOFAIL(rowData, rows);
+    icBitmapP->xBytes = xByteCt;
+    icBitmapP->data   = rowData;
+    icBitmapP->size   = xByteCt * rows;
+    for (row = 0; row < rows; ++row) {
+        u1 * thisRow;  /* malloc'ed */
+        unsigned int byteOn;
+        unsigned int bitOn;
+
+        MALLOCARRAY_NOFAIL(thisRow, xByteCt);
+
+        byteOn =   0;  /* initial value */
+        bitOn  = 128;  /* initial value */
+
+        memset (thisRow, 0, xByteCt);
+        rowData[rows - row - 1] = thisRow;
+
+        if (ba) {
+            unsigned int col;
+
+            for (col = 0; col < cols; ++col) {
+                /* Black (bit clear) is transparent in PGM alpha maps,
+                   in ICO bit *set* is transparent.
+                */
+                if (ba[row][col] <= maxval/2) thisRow[byteOn] |= bitOn;
+
+                if (bitOn == 1) {
+                    ++byteOn;
+                    bitOn = 128;
+                } else {
+                    bitOn >>= 1;
+                }
+            }
         } else {
-           bitOn >>= 1;
+            /* No array -- we're just faking this */
         }
-     }
-      }
-   }
-   return icBitmap;
+    }
+    return icBitmapP;
 }
 
 
-static ICON_bmp 
-create4Bitmap (pixel ** const pa, int const cols, int const rows,
-               colorhash_table const cht) {
-   /*
-    * How wide should the u1 string for each row be?
-    * each byte is 8 pixels, but must be a multiple of 4 bytes.
-    */
-   ICON_bmp icBitmap;
-   int xBytes,y,x;
-   int wt = cols;
-   u1 ** rowData;
-
-   MALLOCVAR_NOFAIL(icBitmap);
-
-   wt >>= 1;
-   if (wt & 3) {
-      wt = (wt & ~3) + 4;
-   }
-   xBytes = wt;
-   MALLOCARRAY_NOFAIL(rowData, rows);
-   icBitmap->xBytes = xBytes;
-   icBitmap->data   = rowData;
-   icBitmap->size   = xBytes * rows;
-
-   for (y=0;y<rows;y++) {
-      u1 * row;
-      int byteOn = 0;
-      int nibble = 1;   /* high nibble = 1, low nibble = 0; */
-      int value;
-
-      MALLOCARRAY_NOFAIL(row, xBytes);
-
-      memset (row, 0, xBytes);
-      rowData[rows-y-1] = row;
-      /* 
-       * Check there's a pixel array, otherwise we're just faking this...
-       */
-      if (pa) {
-     for (x=0;x<cols;x++) {
-        value = ppm_lookupcolor(cht, &pa[y][x]);
-        /*
-         * Shift it, if we're putting it in the high nibble.
-         */
-        if (nibble) {
-           value <<= 4;
-        }
-        row[byteOn] |= value;
-        if (nibble) {
-           nibble = 0;
+
+/* Depending on if the image is stored as 1bpp, 4bpp or 8bpp, the
+   encoding mechanism is different.
+
+   I didn't re-use the code from ppmtobmp since I need to keep the
+   bitmaps in memory until I've loaded all ppms.
+
+   8bpp => 1 byte/palette index.
+   4bpp => High Nibble, Low Nibble
+   1bpp => 1 palette value per bit, high bit 1st.
+*/
+
+
+
+static void
+fillInRaster1(u1 **           const rowData,
+              unsigned int    const xByteCt,
+              pixel **        const pa,
+              unsigned int    const cols,
+              unsigned int    const rows,
+              colorhash_table const cht) {
+
+    unsigned int row;
+
+    for (row = 0; row <rows; ++row) {
+        u1 * thisRow;  /* malloc'ed */
+        unsigned int byteOn;
+        unsigned int bitOn;
+
+        MALLOCARRAY_NOFAIL(thisRow, xByteCt);
+        memset (thisRow, 0, xByteCt);
+        rowData[rows - row - 1] = thisRow;
+        byteOn =   0;  /* initial value */
+        bitOn  = 128;  /* initial value */
+
+        if (pa) {
+            unsigned int col;
+
+            for (col = 0; col < cols; ++col) {
+                /* So we've got a colorhash_table with two colors in it.  Which
+                   is black?!
+
+                   Unless the hashing function changes, 0's black.
+                */
+                int const value = ppm_lookupcolor(cht, &pa[row][col]);
+                if (!value) {
+                    /* leave black. */
+                } else {
+                    thisRow[byteOn] |= bitOn;
+                }
+                if (bitOn == 1) {
+                    ++byteOn;
+                    bitOn = 128;
+                } else {
+                    bitOn >>= 1;
+                }
+            }
         } else {
-           nibble = 1;
-           byteOn++;
+            /* No pixel array -- we're just faking this */
         }
-     }
-      }
-   }
-   return icBitmap;
+    }
 }
 
 
 
-static ICON_bmp 
-create8Bitmap (pixel ** const pa, int const cols, int const rows,
-               colorhash_table const cht) {
-   /*
-    * How wide should the u1 string for each row be?
-    * each byte is 8 pixels, but must be a multiple of 4 bytes.
-    */
-   ICON_bmp icBitmap;
-   int xBytes,y,x;
-   int wt = cols;
-   u1 ** rowData;
-
-   MALLOCVAR_NOFAIL(icBitmap);
-
-   if (wt & 3) {
-      wt = (wt & ~3) + 4;
-   }
-   xBytes = wt;
-   MALLOCARRAY_NOFAIL(rowData, rows);
-   icBitmap->xBytes = xBytes;
-   icBitmap->data   = rowData;
-   icBitmap->size   = xBytes * rows;
-
-   for (y=0;y<rows;y++) {
-      u1 * row;
-
-      MALLOCARRAY_NOFAIL(row, xBytes);
-      memset (row, 0, xBytes);
-      rowData[rows-y-1] = row;
-      /* 
-       * Check there's a pixel array, otherwise we're just faking this...
-       */
-      if (pa) {
-     for (x=0;x<cols;x++) {
-        row[x] = ppm_lookupcolor(cht, &pa[y][x]);
-     }
-      }
-   }
-   return icBitmap;
+static void
+fillInRaster4(u1 **           const rowData,
+              unsigned int    const xByteCt,
+              pixel **        const pa,
+              unsigned int    const cols,
+              unsigned int    const rows,
+              colorhash_table const cht) {
+
+    unsigned int row;
+
+    for (row = 0; row < rows; ++row) {
+        u1 * thisRow;
+        unsigned int byteOn;
+        unsigned int nibble;   /* high nibble = 1, low nibble = 0; */
+
+        MALLOCARRAY_NOFAIL(thisRow, xByteCt);
+
+        memset(thisRow, 0, xByteCt);
+        rowData[rows - row - 1] = thisRow;
+        byteOn = 0;  /* initial value */
+        nibble = 1;  /* initial value */
+
+        if (pa) {
+            unsigned int col;
+
+            for (col = 0; col < cols; ++col) {
+                int value;
+
+                value = ppm_lookupcolor(cht, &pa[row][col]);  /* init value */
+                /* Shift it, if we're putting it in the high nibble. */
+                if (nibble)
+                    value <<= 4;
+                thisRow[byteOn] |= value;
+                if (nibble == 1)
+                    nibble = 0;
+                else {
+                    nibble = 1;
+                    ++byteOn;
+                }
+            }
+        } else {
+            /* No pixel array -- we're just faking this */
+        }
+    }
 }
 
 
 
-static IC_InfoHeader 
-createInfoHeader(IC_Entry const entry, ICON_bmp const xbmp,
-                 ICON_bmp const abmp) {
-   IC_InfoHeader ih;
-   
-   MALLOCVAR_NOFAIL(ih);
-
-   ih->size          = 40;
-   ih->width         = entry->width;
-   ih->height        = entry->height * 2;  
-   ih->planes        = 1;  
-   ih->bitcount      = entry->bitcount;
-   ih->compression   = 0;
-   ih->imagesize     = entry->width * entry->height * 8 / entry->bitcount;
-   ih->x_pixels_per_m= 0;
-   ih->y_pixels_per_m= 0;
-   ih->colors_used   = 1 << entry->bitcount;
-   ih->colors_important = 0;
-   return ih;
-}
+static void
+fillInRaster8(u1 **           const rowData,
+              unsigned int    const xByteCt,
+              pixel **        const pa,
+              unsigned int    const cols,
+              unsigned int    const rows,
+              colorhash_table const cht) {
 
+    unsigned int row;
 
+    for (row = 0; row < rows; ++row) {
+        u1 * thisRow;  /* malloc'ed */
 
-static IC_Palette 
-createCleanPalette(void) {
-   IC_Palette palette;
-   int x;
-   
-   MALLOCVAR_NOFAIL(palette);
+        MALLOCARRAY_NOFAIL(thisRow, xByteCt);
+        memset (thisRow, 0, xByteCt);
+        rowData[rows - row - 1] = thisRow;
+        if (pa) {
+            unsigned int col;
 
-   MALLOCARRAY_NOFAIL(palette->colors, MAXCOLORS);
-   for (x=0;x<MAXCOLORS;x++ ){
-      palette->colors[x] = NULL;
-   }
-   return palette;
+            for (col = 0; col < cols; ++col)
+                thisRow[col] = ppm_lookupcolor(cht, &pa[row][col]);
+        } else {
+            /* No pixel array -- we're just faking this */
+        }
+    }
 }
 
 
 
-static void 
-addColorToPalette(IC_Palette const palette, int const i,
-                  int const r, int const g, int const b) {
+static ICON_bmp *
+newBitmap(unsigned int    const bpp,
+          pixel **        const pa,
+          unsigned int    const cols,
+          unsigned int    const rows,
+          colorhash_table const cht) {
 
-    MALLOCVAR_NOFAIL(palette->colors[i]);
+    unsigned int const xByteCt = ROUNDUP(cols, 32)/8;
+       /* How wide the u1 string for each row should be -- Each byte is 8
+          pixels, but must be a multiple of 4 bytes.
+       */
+    ICON_bmp * icBitmapP;  /* malloc'ed */
+    u1 ** rowData;  /* malloc'ed */
 
-    palette->colors[i]->red      = r;
-    palette->colors[i]->green    = g;
-    palette->colors[i]->blue     = b;
-    palette->colors[i]->reserved = 0;
-}
+    assert(cols < 256); assert(rows < 256);  /* required for no overflow */
 
+    MALLOCVAR_NOFAIL(icBitmapP);
 
+    MALLOCARRAY_NOFAIL(rowData, rows);
 
-static ICON_bmp 
-createBitmap (int const bpp, pixel ** const pa, 
-              int const cols, int const rows, 
-              colorhash_table const cht) {
-    
-    ICON_bmp retval;
-    const int assumed_bpp = (pa == NULL) ? 1 : bpp;
+    icBitmapP->xBytes = xByteCt;
+    icBitmapP->data   = rowData;
+    icBitmapP->size   = xByteCt * rows;
 
-    switch (assumed_bpp) {
+    unsigned int const assumedBpp = (pa == NULL) ? 1 : bpp;
+
+    switch (assumedBpp) {
     case 1:
-        retval = create1Bitmap (pa,cols,rows,cht);
+        fillInRaster1(rowData, xByteCt, pa, cols, rows, cht);
         break;
     case 4:
-        retval = create4Bitmap (pa,cols,rows,cht);
+        fillInRaster4(rowData, xByteCt, pa, cols, rows, cht);
         break;
     case 8:
     default:
-        retval = create8Bitmap (pa,cols,rows,cht);
+        fillInRaster8(rowData, xByteCt, pa, cols, rows, cht);
         break;
     }
-    return retval;
+    return icBitmapP;
+}
+
+
+
+static IC_InfoHeader *
+newInfoHeader(IC_Entry const entry) {
+
+   IC_InfoHeader * ihP;
+
+   MALLOCVAR_NOFAIL(ihP);
+
+   ihP->size             = 40;
+   ihP->width            = entry.width;
+   ihP->height           = entry.height * 2;
+   ihP->planes           = 1;
+   ihP->bitcount         = entry.bitcount;
+   ihP->compression      = 0;
+   ihP->imagesize        = entry.width * entry.height * 8 / entry.bitcount;
+   ihP->x_pixels_per_m   = 0;
+   ihP->y_pixels_per_m   = 0;
+   ihP->colors_used      = 1 << entry.bitcount;
+   ihP->colors_important = 0;
+
+   return ihP;
+}
+
+
+
+static IC_Palette *
+newCleanPalette(void) {
+
+    IC_Palette * paletteP;  /* malloc'ed */
+
+    unsigned int i;
+
+    MALLOCVAR_NOFAIL(paletteP);
+
+    MALLOCARRAY_NOFAIL(paletteP->colors, MAXCOLORS);
+
+    for (i=0; i <MAXCOLORS; ++i) {
+        paletteP->colors[i] = NULL;
+    }
+    return paletteP;
+}
+
+
+
+static void
+addColorToPalette(IC_Palette * const paletteP,
+                  unsigned int const i,
+                  unsigned int const r,
+                  unsigned int const g,
+                  unsigned int const b) {
+
+    MALLOCVAR_NOFAIL(paletteP->colors[i]);
+
+    paletteP->colors[i]->red      = r;
+    paletteP->colors[i]->green    = g;
+    paletteP->colors[i]->blue     = b;
+    paletteP->colors[i]->reserved = 0;
 }
 
 
 
 static void
 makePalette(pixel **          const xorPPMarray,
-            int               const xorCols,
-            int               const xorRows,
+            unsigned int      const xorCols,
+            unsigned int      const xorRows,
             pixval            const xorMaxval,
-            IC_Palette *      const paletteP,
+            IC_Palette **     const palettePP,
             colorhash_table * const xorChtP,
-            int *             const colorsP,
+            unsigned int *    const colorsP,
             const char **     const errorP) {
-   /*
-    * Figure out the colormap and turn it into the appropriate GIF
-    * colormap - this code's pretty much straight from ppmtobpm
-    */
+/*----------------------------------------------------------------------------
+   Figure out the colormap and turn it into the appropriate GIF colormap -
+   this code's pretty much straight from 'ppmtobpm'.
+-----------------------------------------------------------------------------*/
+    IC_Palette * const paletteP = newCleanPalette();
+
     colorhist_vector xorChv;
     unsigned int i;
-    int colors;
-    IC_Palette palette = createCleanPalette();
+    int colorCt;
+
+    if (verbose)
+        pm_message("computing colormap...");
 
-    if (verbose) pm_message("computing colormap...");
-    xorChv = ppm_computecolorhist(xorPPMarray, xorCols, xorRows, MAXCOLORS, 
-                                  &colors);
-    if (xorChv == NULL)
+    xorChv = ppm_computecolorhist(xorPPMarray, xorCols, xorRows, MAXCOLORS,
+                                  &colorCt);
+    if (!xorChv)
         pm_asprintf(errorP,
-                    "image has too many colors - try doing a 'pnmquant %d'",
+                    "image has too many colors - try doing a 'pnmquant %u'",
                     MAXCOLORS);
     else {
         *errorP = NULL;
 
-        if (verbose) pm_message("%d colors found", colors);
-        
+        if (verbose)
+            pm_message("%u colors found", colorCt);
+
         if (verbose && (xorMaxval > 255))
             pm_message("maxval is not 255 - automatically rescaling colors");
-        for (i = 0; i < colors; ++i) {
+        for (i = 0; i < colorCt; ++i) {
             if (xorMaxval == 255) {
-                addColorToPalette(palette,i,
+                addColorToPalette(paletteP, i,
                                   PPM_GETR(xorChv[i].color),
                                   PPM_GETG(xorChv[i].color),
                                   PPM_GETB(xorChv[i].color));
             } else {
-                addColorToPalette(palette,i,
+                addColorToPalette(paletteP, i,
                                   PPM_GETR(xorChv[i].color) * 255 / xorMaxval,
                                   PPM_GETG(xorChv[i].color) * 255 / xorMaxval,
                                   PPM_GETB(xorChv[i].color) * 255 / xorMaxval);
             }
         }
-        
+
         /* And make a hash table for fast lookup. */
-        *xorChtP = ppm_colorhisttocolorhash(xorChv, colors);
-        
+        *xorChtP = ppm_colorhisttocolorhash(xorChv, colorCt);
+
         ppm_freecolorhist(xorChv);
-        
-        *paletteP = palette;
-        *colorsP = colors;
+
+        *palettePP = paletteP;
+        *colorsP   = colorCt;
     }
 }
 
@@ -562,15 +555,15 @@ makePalette(pixel **          const xorPPMarray,
 
 static void
 getOrFakeAndMap(const char *      const andPgmFname,
-                int               const xorCols,
-                int               const xorRows,
+                unsigned int      const xorCols,
+                unsigned int      const xorRows,
                 gray ***          const andPGMarrayP,
                 pixval *          const andMaxvalP,
                 colorhash_table * const andChtP,
                 const char **     const errorP) {
 
     int andRows, andCols;
-    
+
     if (!andPgmFname) {
         /* He's not supplying a bitmap for 'and'.  Fake the bitmap. */
         *andPGMarrayP = NULL;
@@ -578,15 +571,15 @@ getOrFakeAndMap(const char *      const andPgmFname,
         *andChtP      = NULL;
         *errorP       = NULL;
     } else {
-        FILE * andfile;
-        andfile = pm_openr(andPgmFname);
-        *andPGMarrayP = pgm_readpgm(andfile, &andCols, &andRows, andMaxvalP);
-        pm_close(andfile);
+        FILE * andFileP;
+        andFileP = pm_openr(andPgmFname);
+        *andPGMarrayP = pgm_readpgm(andFileP, &andCols, &andRows, andMaxvalP);
+        pm_close(andFileP);
 
         if ((andCols != xorCols) || (andRows != xorRows)) {
             pm_asprintf(errorP,
                         "And mask and image have different dimensions "
-                        "(%d x %d vs %d x %d).  Aborting.",
+                        "(%u x %u vs %u x %u).  Aborting.",
                         andCols, xorCols, andRows, xorRows);
         } else
             *errorP = NULL;
@@ -596,18 +589,20 @@ getOrFakeAndMap(const char *      const andPgmFname,
 
 
 static void
-blackenTransparentAreas(pixel ** const xorPPMarray,
-                        int      const cols,
-                        int      const rows,
-                        gray **  const andPGMarray,
-                        pixval   const andMaxval) {
+blackenTransparentAreas(pixel **     const xorPPMarray,
+                        unsigned int const cols,
+                        unsigned int const rows,
+                        gray **      const andPGMarray,
+                        pixval       const andMaxval) {
 
     unsigned int row;
 
-    if (verbose) pm_message("Setting transparent pixels to black");
+    if (verbose)
+        pm_message("Setting transparent pixels to black");
 
     for (row = 0; row < rows; ++row) {
         unsigned int col;
+
         for (col = 0; col < cols; ++col) {
             if (andPGMarray[row][col] < andMaxval)
                 /* It's not opaque here; make it black */
@@ -618,70 +613,69 @@ blackenTransparentAreas(pixel ** const xorPPMarray,
 
 
 
-static void 
-addEntryToIcon(MS_Ico       const MSIconData, 
+static void
+addEntryToIcon(MS_Ico *     const MSIconDataP,
                const char * const xorPpmFname,
                const char * const andPgmFname,
                bool         const trueTransparent) {
 
-    IC_Entry entry;
+    IC_Entry * entryP;
     FILE * xorfile;
     pixel ** xorPPMarray;
     gray ** andPGMarray;
-    ICON_bmp xorBitmap;
-    ICON_bmp andBitmap;
+    ICON_bmp * xorBitmapP;
+    ICON_bmp * andBitmapP;
     int rows, cols;
-    int bpp, colors;
-    int entry_cols;
-    IC_Palette palette;
-    colorhash_table  xorCht;
-    colorhash_table  andCht; 
+    unsigned int bpp;
+    unsigned int colorCt;
+    unsigned int entryCols;
+    IC_Palette * paletteP;
+    colorhash_table xorCht;
+    colorhash_table andCht;
     const char * error;
-   
+
     pixval xorMaxval;
     gray andMaxval;
 
-    MALLOCVAR_NOFAIL(entry);
+    MALLOCVAR_NOFAIL(entryP);
 
-   /*
-    * Read the xor PPM.
-    */
+    /* Read the xor PPM. */
     xorfile = pm_openr(xorPpmFname);
     xorPPMarray = ppm_readppm(xorfile, &cols, &rows, &xorMaxval);
     pm_close(xorfile);
-    /*
-    * Since the entry uses 1 byte to hold the width and height of the icon, the
-    * image can't be more than 256 x 256.
+
+    /* Since the entry uses 1 byte to hold the width and height of the icon,
+       the image can't be more than 256 x 256.
     */
     if (rows > 255 || cols > 255) {
         pm_error("Max size for a icon is 255 x 255 (1 byte fields).  "
-                 "%s is %d x %d", xorPpmFname, cols, rows);
+                 "%s is %u x %u", xorPpmFname, cols, rows);
     }
-   
-    if (verbose) pm_message("read PPM: %dw x %dh, maxval = %d", 
-                            cols, rows, xorMaxval);
 
-    makePalette(xorPPMarray, cols, rows, xorMaxval, 
-                &palette, &xorCht, &colors, &error);
+    if (verbose)
+        pm_message("read PPM: %uw x %uh, maxval = %u", cols, rows, xorMaxval);
+
+    makePalette(xorPPMarray, cols, rows, xorMaxval,
+                &paletteP, &xorCht, &colorCt, &error);
 
     if (error)
         pm_error("Unable to make palette for '%s'.  %s", xorPpmFname, error);
-   /*
-    * All the icons I found seemed to pad the palette to the max entries
-    * for that bitdepth.
-    * 
-    * The spec indicates this isn't necessary, but I'll follow this behaviour
-    * just in case.
+
+    /* All the icons I found seemed to pad the palette to the max entries for
+       that bitdepth.
+
+       The spec indicates this isn't necessary, but I'll follow this behaviour
+       just in case.
     */
-    if (colors < 3) {
+    if (colorCt < 3) {
         bpp = 1;
-        entry_cols = 2;
-    } else if (colors < 17) {
+        entryCols = 2;
+    } else if (colorCt < 17) {
         bpp = 4;
-        entry_cols = 16;
+        entryCols = 16;
     } else {
         bpp = 8;
-        entry_cols = 256;
+        entryCols = 256;
     }
 
     getOrFakeAndMap(andPgmFname, cols, rows,
@@ -690,164 +684,182 @@ addEntryToIcon(MS_Ico       const MSIconData,
         pm_error("Error in and map for '%s'.  %s", xorPpmFname, error);
 
     if (andPGMarray && trueTransparent)
-        blackenTransparentAreas(xorPPMarray, cols, rows, 
+        blackenTransparentAreas(xorPPMarray, cols, rows,
                                 andPGMarray, andMaxval);
 
-    xorBitmap = createBitmap(bpp, xorPPMarray, cols, rows, xorCht);
-    andBitmap = createAndBitmap(andPGMarray, cols, rows, andMaxval);
-    /*
-     * Fill in the entry data fields.
-    */
-    entry->width         = cols;
-    entry->height        = rows;
-    entry->color_count   = entry_cols;
-    entry->reserved      = 0;
-    entry->planes        = 1;
-    /* 
-    * all the icons I looked at ignored this value...
-    */
-    entry->bitcount      = bpp;
-    entry->ih            = createInfoHeader(entry, xorBitmap, andBitmap);
-    entry->colors        = palette->colors;
-    entry->size_in_bytes = 
-        xorBitmap->size + andBitmap->size + 40 + (4 * entry->color_count);
-    if (verbose) 
-        pm_message("entry->size_in_bytes = %d + %d + %d = %d",
-                   xorBitmap->size ,andBitmap->size, 
-                   40, entry->size_in_bytes );
-    /*
-    * We don't know the offset ATM, set to 0 for now.
-    * Have to calculate this at the end.
-    */
-    entry->file_offset   = 0;
-    entry->xorBitmapOut  = xorBitmap->data;
-    entry->andBitmapOut  = andBitmap->data;
-    entry->xBytesXor     = xorBitmap->xBytes;
-    entry->xBytesAnd     = andBitmap->xBytes;  
-    /*
-    * Add the entry to the entries array.
+    xorBitmapP = newBitmap(bpp, xorPPMarray, cols, rows, xorCht);
+    andBitmapP = newAndBitmap(andPGMarray, cols, rows, andMaxval);
+
+    /* Fill in the entry data fields. */
+    entryP->width         = cols;
+    entryP->height        = rows;
+    entryP->color_count   = entryCols;
+    entryP->reserved      = 0;
+    entryP->planes        = 1;
+    entryP->bitcount      = bpp;
+    /* all the icons I looked at ignored this value */
+    entryP->ih            = newInfoHeader(*entryP);
+    entryP->colors        = paletteP->colors;
+    entryP->size_in_bytes =
+        xorBitmapP->size + andBitmapP->size + 40 + (4 * entryCols);
+    if (verbose)
+        pm_message("entry->size_in_bytes = %u + %u + %u = %u",
+                   xorBitmapP->size, andBitmapP->size,
+                   40, entryP->size_in_bytes );
+
+    /* We don't know the offset ATM, set to 0 for now.  Have to calculate this
+       at the end.
     */
-    ++MSIconData->count;
+    entryP->file_offset  = 0;
+    entryP->xorBitmapOut = xorBitmapP->data;
+    entryP->andBitmapOut = andBitmapP->data;
+    entryP->xBytesXor    = xorBitmapP->xBytes;
+    entryP->xBytesAnd    = andBitmapP->xBytes;
+
+    /* Add the entry to the entries array. */
+    ++MSIconDataP->count;
+
     /* Perhaps I should allocate ahead, and take fewer trips to the well. */
-    REALLOCARRAY(MSIconData->entries, MSIconData->count);
-    MSIconData->entries[MSIconData->count-1] = entry;
+    REALLOCARRAY(MSIconDataP->entries, MSIconDataP->count);
+    MSIconDataP->entries[MSIconDataP->count - 1] = entryP;
 }
 
 
 
-static void 
-writeIC_Entry (IC_Entry const entry) {
-   writeU1(entry->width);
-   writeU1(entry->height);
-   writeU1(entry->color_count); /* chops 256->0 on its own.. */
-   writeU1(entry->reserved);
-   writeU2(entry->planes);
-   writeU2(entry->bitcount);
-   writeU4(entry->size_in_bytes);
-   writeU4(entry->file_offset);
+static void
+writeIC_Entry(FILE *     const ofP,
+              IC_Entry * const entryP) {
+
+   writeU1(ofP, entryP->width);
+   writeU1(ofP, entryP->height);
+   writeU1(ofP, entryP->color_count); /* chops 256->0 on its own.. */
+   writeU1(ofP, entryP->reserved);
+   writeU2(ofP, entryP->planes);
+   writeU2(ofP, entryP->bitcount);
+   writeU4(ofP, entryP->size_in_bytes);
+   writeU4(ofP, entryP->file_offset);
 }
 
 
 
-static void 
-writeIC_InfoHeader (IC_InfoHeader const ih) {
-   writeU4(ih->size);
-   writeU4(ih->width);
-   writeU4(ih->height);
-   writeU2(ih->planes);
-   writeU2(ih->bitcount);
-   writeU4(ih->compression);
-   writeU4(ih->imagesize);
-   writeU4(ih->x_pixels_per_m);
-   writeU4(ih->y_pixels_per_m);
-   writeU4(ih->colors_used);
-   writeU4(ih->colors_important);
+static void
+writeIC_InfoHeader(FILE *          const ofP,
+                   IC_InfoHeader * const ihP) {
+
+   writeU4(ofP, ihP->size);
+   writeU4(ofP, ihP->width);
+   writeU4(ofP, ihP->height);
+   writeU2(ofP, ihP->planes);
+   writeU2(ofP, ihP->bitcount);
+   writeU4(ofP, ihP->compression);
+   writeU4(ofP, ihP->imagesize);
+   writeU4(ofP, ihP->x_pixels_per_m);
+   writeU4(ofP, ihP->y_pixels_per_m);
+   writeU4(ofP, ihP->colors_used);
+   writeU4(ofP, ihP->colors_important);
 }
 
 
 
-static void 
-writeIC_Color (IC_Color const col) {
-   /* Since the ppm might not have as many colors in it as we'd like,
-    * (2, 16, 256), stick 0 in the gaps.
-    * 
-    * This means that we lose palette information, but that can't be
-    * helped.  
+static void
+writeIC_Color(FILE *     const ofP,
+              IC_Color * const colorP) {
+
+    /* Since the ppm might not have as many colors in it as we'd like,
+       (2, 16, 256), stick 0 in the gaps.
+
+       This means that we lose palette information, but that can't be helped.
     */
-   if (col == NULL) {
-      writeU1(0);
-      writeU1(0);
-      writeU1(0);
-      writeU1(0);
-   } else {
-      writeU1(col->blue);
-      writeU1(col->green);
-      writeU1(col->red);
-      writeU1(col->reserved);
-   }
+    if (!colorP) {
+        writeU1(ofP, 0);
+        writeU1(ofP, 0);
+        writeU1(ofP, 0);
+        writeU1(ofP, 0);
+    } else {
+        writeU1(ofP, colorP->blue);
+        writeU1(ofP, colorP->green);
+        writeU1(ofP, colorP->red);
+        writeU1(ofP, colorP->reserved);
+    }
 }
 
 
 
 static void
-writeBitmap(u1 ** const bitmap, int const xBytes, int const height) {
-   int y;
-   for (y = 0;y<height;y++) {
-      fwrite (bitmap[y],1,xBytes,ofp);
-      file_offset += xBytes;
-   }
+writeBitmap(FILE *       const ofP,
+            u1 **        const bitmap,
+            unsigned int const xByteCt,
+            unsigned int const height) {
+
+    unsigned int row;
+
+    for (row = 0; row < height; ++row) {
+        fwrite(bitmap[row], 1, xByteCt, ofP);
+        fileOffset += xByteCt;
+    }
 }
 
 
 
-static void 
-writeMS_Ico(MS_Ico       const MSIconData, 
+static void
+writeMS_Ico(MS_Ico *     const MSIconDataP,
             const char * const outFname) {
-    int x,y;
-   
-    ofp = pm_openw(outFname);
-
-    writeU2(MSIconData->reserved);
-    writeU2(MSIconData->type);
-    writeU2(MSIconData->count);
-    for (x=0;x<MSIconData->count;x++) writeIC_Entry(MSIconData->entries[x]);
-    for (x=0;x<MSIconData->count;x++) {
-        writeIC_InfoHeader(MSIconData->entries[x]->ih);
-        for (y=0;y<(MSIconData->entries[x]->color_count);y++) {
-            writeIC_Color(MSIconData->entries[x]->colors[y]);
+
+    FILE * const ofP = pm_openw(outFname);
+
+    unsigned int i;
+
+    writeU2(ofP, MSIconDataP->reserved);
+    writeU2(ofP, MSIconDataP->type);
+    writeU2(ofP, MSIconDataP->count);
+
+    for (i = 0; i < MSIconDataP->count; ++i)
+        writeIC_Entry(ofP, MSIconDataP->entries[i]);
+
+    for (i = 0; i < MSIconDataP->count; ++i) {
+        IC_Entry * const entryP = MSIconDataP->entries[i];
+
+        unsigned int j;
+
+        writeIC_InfoHeader(ofP, MSIconDataP->entries[i]->ih);
+
+        for (j = 0; j < (MSIconDataP->entries[i]->color_count); ++j) {
+            writeIC_Color(ofP, MSIconDataP->entries[i]->colors[j]);
         }
-        if (verbose) pm_message("writing xor bitmap");
-        writeBitmap(MSIconData->entries[x]->xorBitmapOut,
-                    MSIconData->entries[x]->xBytesXor,
-                    MSIconData->entries[x]->height);
-        if (verbose) pm_message("writing and bitmap");
-        writeBitmap(MSIconData->entries[x]->andBitmapOut,
-                    MSIconData->entries[x]->xBytesAnd,
-                    MSIconData->entries[x]->height);
+        if (verbose)
+            pm_message("writing xor bitmap");
+
+        writeBitmap(ofP,
+                    entryP->xorBitmapOut, entryP->xBytesXor, entryP->height);
+        if (verbose)
+            pm_message("writing and bitmap");
+
+        writeBitmap(ofP,
+                    entryP->andBitmapOut, entryP->xBytesAnd, entryP->height);
     }
-    fclose(ofp);
+    fclose(ofP);
 }
 
 
 
-int 
-main(int argc, char ** argv) {
+int
+main(int argc, const char ** argv) {
 
-    struct cmdlineInfo cmdline;
+    MS_Ico * const MSIconDataP = newIconFile();
 
-    MS_Ico const MSIconDataP = createIconFile();
+    struct CmdlineInfo cmdline;
     unsigned int iconIndex;
     unsigned int offset;
-   
-    ppm_init (&argc, argv);
+
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
     verbose = cmdline.verbose;
 
     for (iconIndex = 0; iconIndex < cmdline.iconCount; ++iconIndex) {
-        addEntryToIcon(MSIconDataP, cmdline.inputFilespec[iconIndex],
-                       cmdline.andpgmFilespec[iconIndex], 
+        addEntryToIcon(MSIconDataP, cmdline.inputFileNm[iconIndex],
+                       cmdline.andpgmFileNm[iconIndex],
                        cmdline.truetransparent);
     }
     /*
@@ -856,22 +868,24 @@ main(int argc, char ** argv) {
      */
     offset = (MSIconDataP->count * 16) + 6;
     for (iconIndex = 0; iconIndex < MSIconDataP->count; ++iconIndex) {
-        IC_Entry entry = MSIconDataP->entries[iconIndex];
-        entry->file_offset = offset;
-        /* 
+        IC_Entry * const entryP = MSIconDataP->entries[iconIndex];
+
+        entryP->file_offset = offset;
+        /*
          * Increase the offset by the size of this offset & data.
          * this includes the size of the color data.
          */
-        offset += entry->size_in_bytes;
+        offset += entryP->size_in_bytes;
     }
     /*
      * And now, we have to actually SAVE the .ico!
      */
     writeMS_Ico(MSIconDataP, cmdline.output);
 
-    free(cmdline.inputFilespec);
-    free(cmdline.andpgmFilespec);
+    freeCmdline(cmdline);
 
     return 0;
 }
 
+
+
diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c
index 0e316928..2167acb2 100644
--- a/converter/ppm/ppmtoxpm.c
+++ b/converter/ppm/ppmtoxpm.c
@@ -1,4 +1,4 @@
-/* ppmtoxpm.c - read a portable pixmap and produce a (version 3) X11 pixmap
+/* ppmtoxpm.c - read a PPM image and produce a (version 3) X11 pixmap
 **
 ** Copyright (C) 1990 by Mark W. Snitily
 **
@@ -24,7 +24,7 @@
 ** Rainer Sinkwitz sinkwitz@ifi.unizh.ch - 21 Nov 91:
 **  - Bug fix, should should malloc space for rgbn[j].name+1 in line 441
 **    caused segmentation faults
-**    
+**
 **  - lowercase conversion of RGB names def'ed out,
 **    considered harmful.
 **
@@ -37,6 +37,7 @@
 #define _BSD_SOURCE   /* Make sure strdup() is in string.h */
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
@@ -47,7 +48,7 @@
 #include "nstring.h"
 #include "mallocvar.h"
 
-/* Max number of entries we will put in the XPM color map 
+/* Max number of entries we will put in the XPM color map
    Don't forget the one entry for transparency.
 
    We don't use this anymore.  Ppmtoxpm now has no arbitrary limit on
@@ -75,14 +76,14 @@ static const char * const printable =
 ASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
 
 
-struct cmdlineInfo {
+struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *inputFilename;
-    const char *name;
-    const char *rgb;
-    const char *alpha_filename;
+    const char * inputFilename;
+    const char * name;
+    const char * rgb;
+    const char * alphaFilename;
     unsigned int hexonly;
     unsigned int verbose;
 };
@@ -90,8 +91,8 @@ struct cmdlineInfo {
 
 
 static void
-parseCommandLine(int argc, char ** argv,
-                 struct cmdlineInfo * const cmdlineP) {
+parseCommandLine(int argc, const char ** argv,
+                 struct CmdlineInfo * const cmdlineP) {
 /*----------------------------------------------------------------------------
    Note that the file spec array we return is stored in the storage that
    was passed to us as the argv array.
@@ -108,11 +109,11 @@ parseCommandLine(int argc, char ** argv,
     MALLOCARRAY(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENTRY */
-    OPTENT3(0,   "alphamask",   OPT_STRING, &cmdlineP->alpha_filename, 
+    OPTENT3(0,   "alphamask",   OPT_STRING, &cmdlineP->alphaFilename,
             NULL, 0);
-    OPTENT3(0,   "name",        OPT_STRING, &nameOpt,                   
+    OPTENT3(0,   "name",        OPT_STRING, &nameOpt,
             &nameSpec, 0);
-    OPTENT3(0,   "rgb",         OPT_STRING, &cmdlineP->rgb,            
+    OPTENT3(0,   "rgb",         OPT_STRING, &cmdlineP->rgb,
             NULL, 0);
     OPTENT3(0,   "hexonly",     OPT_FLAG, NULL,
             &cmdlineP->hexonly, 0);
@@ -120,17 +121,17 @@ parseCommandLine(int argc, char ** argv,
             &cmdlineP->verbose, 0);
 
     /* Set the defaults */
-    cmdlineP->alpha_filename = NULL;  /* no transparency */
+    cmdlineP->alphaFilename = NULL;  /* no transparency */
     cmdlineP->rgb = NULL;      /* no rgb file specified */
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
 
-    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
-    if (argc-1 == 0) 
+    if (argc-1 == 0)
         cmdlineP->inputFilename = "-";
     else if (argc-1 != 1)
         pm_error("Program takes zero or one argument (filename).  You "
@@ -156,28 +157,24 @@ parseCommandLine(int argc, char ** argv,
 }
 
 
-typedef struct {            /* rgb values and ascii names (from
-                             * rgb text file) */
-    int r, g, b;            /* rgb values, range of 0 -> 65535 */
-    char *name;             /* color mnemonic of rgb value */
-} rgb_names;
 
-typedef struct {            
+typedef struct {
     /* Information for an XPM color map entry */
-    char *cixel;    
+    char *cixel;
        /* XPM color number, as might appear in the XPM raster */
-    const char *rgbname;  
+    const char *rgbname;
        /* color name, e.g. "blue" or "#01FF23" */
-} cixel_map;
+} CixelMap;
 
 
 
 static char *
-genNumstr(unsigned int const input, int const digits) {
+numstr(unsigned int const input,
+       unsigned int const digitCt) {
 /*---------------------------------------------------------------------------
    Given a number and a base (MAXPRINTABLE), this routine prints the
    number into a malloc'ed string and returns it.  The length of the
-   string is specified by "digits".  It is not printed in decimal or
+   string is specified by 'digitCt'.  It is not printed in decimal or
    any other number system you're used to.  Rather, each digit is from
    the set printable[], which contains MAXPRINTABLE characters; the
    character printable[n] has value n.
@@ -185,35 +182,35 @@ genNumstr(unsigned int const input, int const digits) {
    The string is printable[0] filled with high order zeroes.
 
    Example:
-     Assume: 
+     Assume:
        printable[0] == 'q'
        printable[1] == '%'
-       MAXPRINTABLE == 2 
-       digits == 5
-       input == 3 
+       MAXPRINTABLE == 2
+       digitCt == 5
+       input == 3
      Result is the malloc'ed string "qqq%%"
 ---------------------------------------------------------------------------*/
-    char *str, *p;
-    int d;
+    char * str;  /* malloc'ed */
+    char * p;
     unsigned int i;
 
     /* Allocate memory for printed number.  Abort if error. */
-    if (!(str = (char *) malloc(digits + 1)))
-        pm_error("out of memory");
+    MALLOCARRAY_NOFAIL(str, digitCt + 1);
 
-    i = input;
+    i = input; /* initial value */
     /* Generate characters starting with least significant digit. */
-    p = str + digits;
+    p = str + digitCt;  /* initial value */
     *p-- = '\0';            /* nul terminate string */
     while (p >= str) {
-        d = i % MAXPRINTABLE;
+        unsigned int const d = i % MAXPRINTABLE;
+
         i /= MAXPRINTABLE;
         *p-- = printable[d];
     }
 
     if (i != 0)
-        pm_error("Overflow converting %d to %d digits in base %d",
-                 input, digits, MAXPRINTABLE);
+        pm_error("Overflow converting %u to %u digits in base %u",
+                 input, digitCt, MAXPRINTABLE);
 
     return str;
 }
@@ -225,10 +222,9 @@ xpmMaxvalFromMaxval(pixval const maxval) {
 
     unsigned int retval;
 
-    /*
-     * Determine how many hex digits we'll be normalizing to if the rgb
-     * value doesn't match a color mnemonic. 
-     */
+    /* Determine how many hex digits we'll be normalizing to if the rgb
+       value doesn't match a color mnemonic.
+    */
     if (maxval <= 0x000F)
         retval = 0x000F;
     else if (maxval <= 0x00FF)
@@ -242,22 +238,21 @@ xpmMaxvalFromMaxval(pixval const maxval) {
 
     return retval;
 }
-    
+
 
 
 static unsigned int
-charsPerPixelForSize(unsigned int const cmapSize) { 
+charsPerPixelForSize(unsigned int const cmapSize) {
 /*----------------------------------------------------------------------------
-   Return the number of characters it will take to represent a pixel in
-   an XPM that has a colormap of size 'cmapSize'.  Each pixel in an XPM
-   represents an index into the colormap with a base-92 scheme where each
-   character is one of 92 printable characters.  Ergo, if the colormap
-   has at most 92 characters, each pixel will be represented by a single
-   character.  If it has more than 92, but at most 92*92, it will take 2, 
-   etc.
-
-   If cmapSize is zero, there's no such thing as an XPM pixel, so we
-   return an undefined value.
+   The number of characters it will take to represent a pixel in an XPM that
+   has a colormap of size 'cmapSize'.  Each pixel in an XPM represents an
+   index into the colormap with a base-92 scheme where each character is one
+   of 92 printable characters.  Ergo, if the colormap has at most 92
+   characters, each pixel will be represented by a single character.  If it
+   has more than 92, but at most 92*92, it will take 2, etc.
+
+   If cmapSize is zero, there's no such thing as an XPM pixel, so we return an
+   undefined value.
 -----------------------------------------------------------------------------*/
     unsigned int charsPerPixel;
 
@@ -268,23 +263,23 @@ charsPerPixelForSize(unsigned int const cmapSize) {
             j /= MAXPRINTABLE;
     }
     return charsPerPixel;
-} 
+}
 
 
 
 static void
-genCmap(colorhist_vector const chv, 
-        int              const ncolors, 
-        pixval           const maxval, 
+genCmap(colorhist_vector const chv,
+        unsigned int     const ncolors,
+        pixval           const maxval,
         colorhash_table  const colornameHash,
-        const char *     const colornames[],
+        const char **    const colornames,
         bool             const includeTransparent,
-        cixel_map **     const cmapP, 
+        CixelMap **      const cmapP,
         unsigned int *   const transIndexP,
         unsigned int *   const cmapSizeP,
         unsigned int *   const charsPerPixelP) {
 /*----------------------------------------------------------------------------
-   Generate the XPM color map in cixel_map format (which is just a step
+   Generate the XPM color map in CixelMap format (which is just a step
    away from the actual text that needs to be written the XPM file).  The
    color map is defined by 'chv', which contains 'ncolors' colors which
    have maxval 'maxval'.
@@ -310,15 +305,14 @@ genCmap(colorhist_vector const chv,
 -----------------------------------------------------------------------------*/
     unsigned int const cmapSize = ncolors + (includeTransparent ? 1 : 0);
 
-    cixel_map * cmap;  /* malloc'ed */
+    CixelMap * cmap;  /* malloc'ed */
     unsigned int cmapIndex;
     unsigned int charsPerPixel;
     unsigned int xpmMaxval;
-    
+
     MALLOCARRAY(cmap, cmapSize);
     if (cmapP == NULL)
-        pm_error("Out of memory allocating %u bytes for a color map.",
-                 (unsigned)sizeof(cixel_map) * (ncolors+1));
+        pm_error("Can't get memory for a %u-entry color map", cmapSize);
 
     xpmMaxval = xpmMaxvalFromMaxval(maxval);
 
@@ -326,7 +320,7 @@ genCmap(colorhist_vector const chv,
 
     /*
      * Generate the character-pixel string and the rgb name for each
-     * colormap entry. 
+     * colormap entry.
      */
     for (cmapIndex = 0; cmapIndex < ncolors; ++cmapIndex) {
         pixel const color = chv[cmapIndex].color;
@@ -338,10 +332,10 @@ genCmap(colorhist_vector const chv,
          * The character-pixel string is simply a printed number in base
          * MAXPRINTABLE where the digits of the number range from
          * printable[0] .. printable[MAXPRINTABLE-1] and the printed length
-         * of the number is 'charsPerPixel'. 
+         * of the number is 'charsPerPixel'.
          */
-        cmap[cmapIndex].cixel = genNumstr(cmapIndex, charsPerPixel);
-        
+        cmap[cmapIndex].cixel = numstr(cmapIndex, charsPerPixel);
+
         PPM_DEPTH(color255, color, maxval, 255);
 
         if (colornameHash == NULL)
@@ -367,7 +361,7 @@ genCmap(colorhist_vector const chv,
             pm_asprintf(&hexString, xpmMaxval == 0x000F ? "#%X%X%X" :
                         xpmMaxval == 0x00FF ? "#%02X%02X%02X" :
                         xpmMaxval == 0x0FFF ? "#%03X%03X%03X" :
-                        "#%04X%04X%04X", 
+                        "#%04X%04X%04X",
                         PPM_GETR(scaledColor),
                         PPM_GETG(scaledColor),
                         PPM_GETB(scaledColor)
@@ -383,7 +377,7 @@ genCmap(colorhist_vector const chv,
         /* Add the special transparency entry to the colormap */
         unsigned int const transIndex = ncolors;
         cmap[transIndex].rgbname = strdup("None");
-        cmap[transIndex].cixel = genNumstr(transIndex, charsPerPixel);
+        cmap[transIndex].cixel = numstr(transIndex, charsPerPixel);
         *transIndexP = transIndex;
     }
     *cmapP          = cmap;
@@ -394,107 +388,111 @@ genCmap(colorhist_vector const chv,
 
 
 static void
-destroyCmap(cixel_map *  const cmap, 
+destroyCmap(CixelMap *   const cmap,
             unsigned int const cmapSize) {
 
-    int i;
+    unsigned int i;
+
     /* Free the real color entries */
-    for (i = 0; i < cmapSize; i++) {
+    for (i = 0; i < cmapSize; ++i) {
         pm_strfree(cmap[i].rgbname);
         free(cmap[i].cixel);
     }
+
     free(cmap);
 }
 
 
 
 static void
-writeXpmFile(FILE *          const outfile, 
-             pixel **        const pixels, 
-             gray **         const alpha, 
-             pixval          const alphamaxval,
-             char            const name[], 
-             int             const cols, 
-             int             const rows, 
-             unsigned int    const cmapSize,
-             unsigned int    const charsPerPixel, 
-             cixel_map       const cmap[],
-             colorhash_table const cht,
-             unsigned int    const transIndex) {
+writeXpmFile(FILE *           const ofP,
+             pixel **         const pixels,
+             gray **          const alpha,
+             pixval           const alphamaxval,
+             char             const name[],
+             unsigned int     const cols,
+             unsigned int     const rows,
+             unsigned int     const cmapSize,
+             unsigned int     const charsPerPixel,
+             const CixelMap * const cmap,
+             colorhash_table  const cht,
+             unsigned int     const transIndex) {
 /*----------------------------------------------------------------------------
-   Write the whole XPM file to the open stream 'outfile'.
+   Write the whole XPM file to the open stream 'ofP'.
 
-   'cmap' is the colormap to be placed in the XPM.  'cmapSize' is the
-   number of entries in it.  'cht' is a hash table that gives you an 
-   index into 'cmap' given a color.  'transIndex' is the index into cmap
-   of the transparent color, and is valid only if 'alpha' is non-null
-   (otherwise, cmap might not contain a transparent color).
+   'cmap' is the colormap to be placed in the XPM.  'cmapSize' is the number
+   of entries in it.  'cht' is a hash table that gives you an index into
+   'cmap' given a color.  'transIndex' is the index into cmap of the
+   transparent color, and is valid only if 'alpha' is non-null (otherwise,
+   cmap might not contain a transparent color).
 -----------------------------------------------------------------------------*/
     /* First the header */
     printf("/* XPM */\n");
-    fprintf(outfile, "static char *%s[] = {\n", name);
-    fprintf(outfile, "/* width height ncolors chars_per_pixel */\n");
-    fprintf(outfile, "\"%d %d %d %d\",\n", cols, rows, 
-            cmapSize, charsPerPixel);
+    fprintf(ofP, "static char *%s[] = {\n", name);
+    fprintf(ofP, "/* width height ncolors chars_per_pixel */\n");
+    fprintf(ofP, "\"%u %u %u %u\",\n", cols, rows, cmapSize, charsPerPixel);
 
     {
-        int i;
+        unsigned int i;
         /* Write out the colormap (part of header) */
-        fprintf(outfile, "/* colors */\n");
-        for (i = 0; i < cmapSize; i++) { 
-            fprintf(outfile, "\"%s c %s\",\n", cmap[i].cixel, cmap[i].rgbname);
+        fprintf(ofP, "/* colors */\n");
+        for (i = 0; i < cmapSize; i++) {
+            fprintf(ofP, "\"%s c %s\",\n", cmap[i].cixel, cmap[i].rgbname);
         }
     }
     {
-        int row;
+        unsigned int row;
 
         /* And now the raster */
-        fprintf(outfile, "/* pixels */\n");
-        for (row = 0; row < rows; row++) {
-            int col;
-            fprintf(outfile, "\"");
-            for (col = 0; col < cols; col++) {
+        fprintf(ofP, "/* pixels */\n");
+        for (row = 0; row < rows; ++row) {
+            unsigned int col;
+            fprintf(ofP, "\"");
+            for (col = 0; col < cols; ++col) {
                 if (alpha && alpha[row][col] <= alphamaxval/2)
                     /* It's a transparent pixel */
-                    fprintf(outfile, "%s", cmap[transIndex].cixel);
-                else 
-                    fprintf(outfile, "%s", 
-                            cmap[ppm_lookupcolor(cht, 
+                    fprintf(ofP, "%s", cmap[transIndex].cixel);
+                else
+                    fprintf(ofP, "%s",
+                            cmap[ppm_lookupcolor(cht,
                                                  &pixels[row][col])].cixel);
             }
-            fprintf(outfile, "\"%s\n", (row == (rows - 1) ? "" : ","));
+            fprintf(ofP, "\"%s\n", (row == (rows - 1) ? "" : ","));
         }
     }
     /* And close up */
-    fprintf(outfile, "};\n");
+    fprintf(ofP, "};\n");
 }
 
 
 
 static void
-readAlpha(const char filespec[], gray *** const alphaP,
-          int const cols, int const rows, pixval * const alphamaxvalP) {
+readAlpha(const char * const fileNm,
+          gray ***     const alphaP,
+          unsigned int const cols,
+          unsigned int const rows,
+          pixval *     const alphamaxvalP) {
 
-    FILE * alpha_file;
+    FILE * alphaFileP;
     int alphacols, alpharows;
-        
-    alpha_file = pm_openr(filespec);
-    *alphaP = pgm_readpgm(alpha_file, &alphacols, &alpharows, alphamaxvalP);
-    pm_close(alpha_file);
-    
+
+    alphaFileP = pm_openr(fileNm);
+    *alphaP = pgm_readpgm(alphaFileP, &alphacols, &alpharows, alphamaxvalP);
+    pm_close(alphaFileP);
+
     if (cols != alphacols || rows != alpharows)
         pm_error("Alpha mask is not the same dimensions as the "
-                 "image.  Image is %d by %d, while mask is %d x %d.",
+                 "image.  Image is %u by %u, while mask is %d x %d.",
                  cols, rows, alphacols, alpharows);
 }
-    
+
 
 
 static void
 computecolorhash(pixel **          const pixels,
                  gray **           const alpha,
-                 int               const cols,
-                 int               const rows,
+                 unsigned int      const cols,
+                 unsigned int      const rows,
                  gray              const alphaMaxval,
                  colorhash_table * const chtP,
                  unsigned int *    const ncolorsP,
@@ -507,49 +505,55 @@ computecolorhash(pixel **          const pixels,
    The value associated with the color in the hash we build is meaningless.
 
    Return the colorhash_table as *chtP, and the number of colors in it
-   as *ncolorsP.  Return *transparentSomewhereP == TRUE iff the image has
+   as *ncolorsP.  Return *transparentSomewhereP == true iff the image has
    at least one pixel that is mostly transparent.
 -----------------------------------------------------------------------------*/
     colorhash_table cht;
-    int row;
-    
-    cht = ppm_alloccolorhash( );
-    *ncolorsP = 0;   /* initial value */
-    *transparentSomewhereP = FALSE;  /* initial assumption */
+    unsigned int row;
+    bool foundTransparent;
+    unsigned int ncolors;
+
+    cht = ppm_alloccolorhash();
 
     /* Go through the entire image, building a hash table of colors. */
-    for (row = 0; row < rows; ++row) {
-        int col;
+    for (row = 0, ncolors = 0, foundTransparent = false; row < rows; ++row) {
+        unsigned int col;
 
         for (col = 0; col < cols; ++col) {
             if (!alpha || alpha[row][col] > alphaMaxval/2) {
                 /* It's mostly opaque, so add this color to the hash
-                   if it's not already there.  
+                   if it's not already there.
                 */
                 pixel const color = pixels[row][col];
                 int const lookupRc = ppm_lookupcolor(cht, &color);
- 
+
                 if (lookupRc < 0) {
                     /* It's not in the hash yet, so add it */
+                    if (ncolors > UINT_MAX - 10)
+                        pm_error("Number of colors (> %u) "
+                                 "is uncomputably large",
+                                 ncolors);
                     ppm_addtocolorhash(cht, &color, 0);
-                    ++(*ncolorsP);
+                    ++ncolors;
                 }
             } else
                 *transparentSomewhereP = TRUE;
         }
     }
-    *chtP = cht;
+    *chtP                  = cht;
+    *ncolorsP              = ncolors;
+    *transparentSomewhereP = foundTransparent;
 }
 
 
 
 static void
-computeColormap(pixel **           const pixels, 
+computeColormap(pixel **           const pixels,
                 gray **            const alpha,
-                int                const cols, 
-                int                const rows,
+                unsigned int       const cols,
+                unsigned int       const rows,
                 gray               const alphaMaxval,
-                colorhist_vector * const chvP, 
+                colorhist_vector * const chvP,
                 colorhash_table *  const chtP,
                 unsigned int *     const ncolorsP,
                 bool *             const transparentSomewhereP) {
@@ -558,23 +562,21 @@ computeColormap(pixel **           const pixels,
    in Netpbm data structures (a colorhist_vector for index-to-color lookups
    and a colorhash_table for color-to-index lookups).
 
-   Exclude pixels that alpha mask 'alpha' (which has maxval
-   'alphaMaxval') says are mostly transparent.  alpha == NULL means all
-   pixels are opaque.
+   Exclude pixels that alpha mask 'alpha' (which has maxval 'alphaMaxval')
+   says are mostly transparent.  alpha == NULL means all pixels are opaque.
 
-   We return as *chvP an array of the colors present in 'pixels',
-   excluding those that are mostly transparent.  We return as
-   *ncolorsP the number of such colors.  We return
-   *transparentSomewhereP == TRUE iff the image has at least one
-   pixel that is mostly transparent.
+   We return as *chvP an array of the colors present in 'pixels', excluding
+   those that are mostly transparent.  We return as *ncolorsP the number of
+   such colors.  We return *transparentSomewhereP == true iff the image has at
+   least one pixel that is mostly transparent.
 -----------------------------------------------------------------------------*/
     colorhash_table histCht;
 
     pm_message("(Computing colormap...");
-    computecolorhash(pixels, alpha, cols, rows, alphaMaxval, 
+    computecolorhash(pixels, alpha, cols, rows, alphaMaxval,
                      &histCht, ncolorsP, transparentSomewhereP);
     pm_message("...Done.  %d colors found.)", *ncolorsP);
-    
+
     *chvP = ppm_colorhashtocolorhist(histCht, *ncolorsP);
     ppm_freecolorhash(histCht);
     /* Despite the name, the following generates an index on *chvP,
@@ -587,9 +589,9 @@ computeColormap(pixel **           const pixels,
 
 
 int
-main(int argc, char *argv[]) {
+main(int argc, const char * *argv) {
 
-    FILE *ifp;
+    FILE * ifP;
     int rows, cols;
     unsigned int ncolors;
     bool transparentSomewhere;
@@ -604,31 +606,31 @@ main(int argc, char *argv[]) {
            array.
         */
 
-    pixel **pixels;
-    gray **alpha;
+    pixel ** pixels;
+    gray ** alpha;
 
     /* Used for rgb value -> character-pixel string mapping */
-    cixel_map *cmap;  /* malloc'ed */
+    CixelMap * cmap;  /* malloc'ed */
         /* The XPM colormap */
     unsigned int cmapSize;
         /* Number of entries in 'cmap' */
     unsigned int transIndex;
         /* Index into 'cmap' of the transparent color, if there is one */
 
-    unsigned int charsPerPixel;  
+    unsigned int charsPerPixel;
 
-    struct cmdlineInfo cmdline;
+    struct CmdlineInfo cmdline;
 
-    ppm_init(&argc, argv);
+    pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
-    ifp = pm_openr(cmdline.inputFilename);
-    pixels = ppm_readppm(ifp, &cols, &rows, &maxval);
-    pm_close(ifp);
+    ifP = pm_openr(cmdline.inputFilename);
+    pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
+    pm_close(ifP);
 
-    if (cmdline.alpha_filename) 
-        readAlpha(cmdline.alpha_filename, &alpha, cols, rows, &alphaMaxval);
+    if (cmdline.alphaFilename)
+        readAlpha(cmdline.alphaFilename, &alpha, cols, rows, &alphaMaxval);
     else
         alpha = NULL;
 
@@ -643,14 +645,14 @@ main(int argc, char *argv[]) {
         ppm_readcolornamefile(NULL, FALSE, &colornameHash, &colornames);
 
     /* Now generate the character-pixel colormap table. */
-    genCmap(chv, ncolors, maxval, 
-            colornameHash, colornames, transparentSomewhere, 
+    genCmap(chv, ncolors, maxval,
+            colornameHash, colornames, transparentSomewhere,
             &cmap, &transIndex, &cmapSize, &charsPerPixel);
 
     writeXpmFile(stdout, pixels, alpha, alphaMaxval,
                  cmdline.name, cols, rows, cmapSize,
                  charsPerPixel, cmap, cht, transIndex);
-    
+
     if (colornameHash) {
         ppm_freecolorhash(colornameHash);
         ppm_freecolornames(colornames);
@@ -662,3 +664,5 @@ main(int argc, char *argv[]) {
     return 0;
 }
 
+
+
diff --git a/converter/ppm/ppmtoyuv.c b/converter/ppm/ppmtoyuv.c
index 75f79c1e..3b6f873d 100644
--- a/converter/ppm/ppmtoyuv.c
+++ b/converter/ppm/ppmtoyuv.c
@@ -2,7 +2,7 @@
 **
 ** by Marc Boucher
 ** Internet: marc@PostImage.COM
-** 
+**
 ** Based on Example Conversion Program, A60/A64 Digital Video Interface
 ** Manual, page 69.
 **
@@ -42,7 +42,7 @@ convertRow(const pixel *   const pixelrow,
             pixval const r = PPM_GETR(pixelrow[col]);
             pixval const g = PPM_GETG(pixelrow[col]);
             pixval const b = PPM_GETB(pixelrow[col]);
-            
+
             y1 = 16829 * r + 33039 * g +  6416 * b + (*y2CarryP & 0xffff);
             u1 = -4853 * r -  9530 * g + 14383 * b;
             v1 = 14386 * r - 12046 * g -  2340 * b;
@@ -110,7 +110,7 @@ main(int argc, const char **argv) {
         ppm_readppmrow(ifP, pixelrow, cols, maxval, format);
 
         convertRow(pixelrow, cols, yuvBuf, &u, &v, &u0, &v0, &y2Carry);
-        
+
         fwrite(yuvBuf, cols*2, 1, stdout);
     }
 
@@ -118,3 +118,6 @@ main(int argc, const char **argv) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ppmtoyuvsplit.c b/converter/ppm/ppmtoyuvsplit.c
index eb89ad29..a8723e32 100644
--- a/converter/ppm/ppmtoyuvsplit.c
+++ b/converter/ppm/ppmtoyuvsplit.c
@@ -209,3 +209,6 @@ main(int argc, const char ** argv) {
     fclose(vf);
     return 0;
 }
+
+
+
diff --git a/converter/ppm/qrttoppm.c b/converter/ppm/qrttoppm.c
index 935463e7..48a395e9 100644
--- a/converter/ppm/qrttoppm.c
+++ b/converter/ppm/qrttoppm.c
@@ -1,4 +1,4 @@
-/* qrttoppm.c - read a QRT ray-tracer output file and produce a portable pixmap
+/* qrttoppm.c - read a QRT ray-tracer output file and produce a PPM
 **
 ** Copyright (C) 1989 by Jef Poskanzer.
 **
@@ -10,60 +10,76 @@
 ** implied warranty.
 */
 
+#include "mallocvar.h"
 #include "ppm.h"
 
+
+
 int
-main( argc, argv )
-    int argc;
-    char* argv[];
-    {
-    FILE* ifp;
-    register pixel* pixelrow;
-    int rows, cols, row, col;
-    pixval maxval;
-    unsigned char* buf;
+main(int argc, const char ** argv) {
 
+    FILE * ifP;
+    pixel * pixelrow;
+    unsigned int rows, cols;
+    unsigned int row;
+    pixval maxval;
+    unsigned char * buf;
 
-    ppm_init( &argc, argv );
+    pm_proginit(&argc, argv);
 
-    if ( argc > 2 )
-	pm_usage( "[qrtfile]" );
+    if (argc-1 > 1)
+        pm_error("Too many arguments (%u).  The only possible argument "
+                 "is the input file name", argc-1);
 
-    if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+    if (argc-1 >= 1)
+        ifP = pm_openr(argv[1]);
     else
-	ifp = stdin;
+        ifP = stdin;
 
     /* Read in the QRT file.  First the header. */
-    cols = getc( ifp );
-    cols += getc( ifp ) << 8;
-    rows = getc( ifp );
-    rows += getc( ifp ) << 8;
+    cols = (unsigned char)getc(ifP);
+    cols += (unsigned char)getc(ifP) << 8;
+    rows = (unsigned char)getc(ifP);
+    rows += (unsigned char)getc(ifP) << 8;
+
+    if (cols <= 0 || rows <= 0)
+        pm_error("Invalid size: %u %u", cols, rows);
 
-    if ( cols <= 0 || rows <= 0 )
-	pm_error( "invalid size: %d %d", cols, rows );
     maxval = 255;
 
-    ppm_writeppminit( stdout, cols, rows, maxval, 0 );
-    pixelrow = ppm_allocrow( cols );
-    buf = (unsigned char *) malloc( 3 * cols );
-    if ( buf == (unsigned char *) 0 )
-	pm_error( "out of memory" );
-
-    for ( row = 0; row < rows; row++ )
-	{
-        (void) getc( ifp );	/* discard */
-        (void) getc( ifp );	/* linenum */
-	if ( fread( buf, 3 * cols, 1, ifp ) != 1 )
-	    pm_error( "EOF / read error" );
-	for ( col = 0; col < cols; col++ )
-	    PPM_ASSIGN(
-		pixelrow[col], buf[col], buf[cols + col], buf[2 * cols + col] );
-	ppm_writeppmrow( stdout, pixelrow, cols, maxval, 0 );
-	}
-
-    pm_close( ifp );
-    pm_close( stdout );
-
-    exit( 0 );
+    ppm_writeppminit(stdout, cols, rows, maxval, 0);
+
+    pixelrow = ppm_allocrow(cols);
+
+    MALLOCARRAY(buf, 3 * cols);
+
+    if (!buf)
+        pm_error("Failed to allocate buffer for %u columns", cols);
+
+    for (row = 0; row < rows; ++row) {
+        unsigned int col;
+
+        getc(ifP); /* discard */
+        getc(ifP); /* linenum */
+
+        if (fread(buf, 3 * cols, 1, ifP) != 1)
+            pm_error("EOF / read error");
+
+        for (col = 0; col < cols; ++col) {
+            PPM_ASSIGN(pixelrow[col],
+                       buf[col], buf[cols + col], buf[2 * cols + col]);
+        }
+        ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
     }
+
+    free(buf);
+    ppm_freerow(pixelrow);
+
+    pm_close(ifP);
+    pm_close(stdout);
+
+    exit(0);
+}
+
+
+
diff --git a/converter/ppm/rawtoppm.c b/converter/ppm/rawtoppm.c
index 44e856da..7ba579ef 100644
--- a/converter/ppm/rawtoppm.c
+++ b/converter/ppm/rawtoppm.c
@@ -201,7 +201,7 @@ main(int argc, const char * argv[]) {
 
     if ( argn + 2 > argc )
         pm_usage( usage );
-    
+
     cols = pm_parse_width(argv[argn++]);
     rows = pm_parse_height(argv[argn++]);
 
@@ -250,3 +250,6 @@ main(int argc, const char * argv[]) {
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/rgb3toppm.c b/converter/ppm/rgb3toppm.c
index a666553c..00d76916 100644
--- a/converter/ppm/rgb3toppm.c
+++ b/converter/ppm/rgb3toppm.c
@@ -37,7 +37,7 @@ main( argc, argv )
     ppm_init( &argc, argv );
 
     if ( argc != 4 )
-	pm_usage( "<red pgmfile> <green pgmfile> <blue pgmfile> " );
+        pm_usage( "<red pgmfile> <green pgmfile> <blue pgmfile> " );
 
     rfd = pm_openr( argv[1] );
     gfd = pm_openr( argv[2] );
@@ -46,10 +46,10 @@ main( argc, argv )
     pgm_readpgminit( rfd, &cols, &rows, &rmaxval, &rformat );
     pgm_readpgminit( gfd, &tcols, &trows, &gmaxval, &gformat );
     if ( tcols != cols || trows != rows )
-	pm_error( "all three graymaps must be the same size" );
+        pm_error( "all three graymaps must be the same size" );
     pgm_readpgminit( bfd, &tcols, &trows, &bmaxval, &bformat );
     if ( tcols != cols || trows != rows )
-	pm_error( "all three graymaps must be the same size" );
+        pm_error( "all three graymaps must be the same size" );
 
     pmaxval = rmaxval;
     if ( gmaxval > pmaxval ) pmaxval = gmaxval;
@@ -62,22 +62,22 @@ main( argc, argv )
     pixelrow = ppm_allocrow( cols );
 
     for ( row = 0; row < rows; row++ )
-	{
-	pgm_readpgmrow( rfd, rrow, cols, rmaxval, rformat );
-	pgm_readpgmrow( gfd, grow, cols, gmaxval, gformat );
-	pgm_readpgmrow( bfd, brow, cols, bmaxval, bformat );
-
-	for ( col = 0, rP = rrow, gP = grow, bP = brow, pP = pixelrow;
-	      col < cols;
-	      ++col, ++rP, ++gP, ++bP, ++pP )
-	    {
-	    if ( rmaxval != pmaxval ) *rP = (int) *rP * pmaxval / rmaxval;
-	    if ( gmaxval != pmaxval ) *gP = (int) *gP * pmaxval / gmaxval;
-	    if ( bmaxval != pmaxval ) *bP = (int) *bP * pmaxval / bmaxval;
-	    PPM_ASSIGN( *pP, *rP, *gP, *bP );
-	    }
-	ppm_writeppmrow( stdout, pixelrow, cols, pmaxval, 0 );
-	}
+        {
+        pgm_readpgmrow( rfd, rrow, cols, rmaxval, rformat );
+        pgm_readpgmrow( gfd, grow, cols, gmaxval, gformat );
+        pgm_readpgmrow( bfd, brow, cols, bmaxval, bformat );
+
+        for ( col = 0, rP = rrow, gP = grow, bP = brow, pP = pixelrow;
+              col < cols;
+              ++col, ++rP, ++gP, ++bP, ++pP )
+            {
+            if ( rmaxval != pmaxval ) *rP = (int) *rP * pmaxval / rmaxval;
+            if ( gmaxval != pmaxval ) *gP = (int) *gP * pmaxval / gmaxval;
+            if ( bmaxval != pmaxval ) *bP = (int) *bP * pmaxval / bmaxval;
+            PPM_ASSIGN( *pP, *rP, *gP, *bP );
+            }
+        ppm_writeppmrow( stdout, pixelrow, cols, pmaxval, 0 );
+        }
 
     pm_close( rfd );
     pm_close( gfd );
@@ -86,3 +86,6 @@ main( argc, argv )
 
     exit( 0 );
     }
+
+
+
diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
index 2fef0233..35d8c33a 100644
--- a/converter/ppm/sldtoppm.c
+++ b/converter/ppm/sldtoppm.c
@@ -23,6 +23,8 @@
 
 */
 
+#include <limits.h>
+#include <assert.h>
 #include <string.h>
 #include <math.h>
 
@@ -30,35 +32,38 @@
 #include "ppm.h"
 #include "ppmdraw.h"
 #include "nstring.h"
-#include <assert.h>
 
 #include "autocad.h"                  /* AutoCAD standard color assignments */
 
 
 /*  Define a variable type accepting numbers -127 <= n <= 127.  But note
-    that we still expect it to act UNSIGNED. */
+    that we still expect it to act UNSIGNED.
+*/
 
 #define smallint unsigned char        /* Small integers */
 
 #define EOS     '\0'
 
-/* Screen point */
-
 struct spoint {
+/*----------------------------------------------------------------------------
+   A screen point
+-----------------------------------------------------------------------------*/
     int x, y;
 };
 
-/* Screen polygon */
-
 struct spolygon {
-    int npoints,              /* Number of points in polygon */
-          fill;           /* Fill type */
-    struct spoint pt[11];         /* Actual points */
+/*----------------------------------------------------------------------------
+   A screen polygon
+-----------------------------------------------------------------------------*/
+    int npoints;           /* Number of points in polygon */
+    int fill;              /* Fill type */
+    struct spoint pt[11];  /* The points */
 };
 
-/* Screen vector */
-
 struct svector {
+/*----------------------------------------------------------------------------
+   A screen vector
+-----------------------------------------------------------------------------*/
     struct spoint f;          /* From point */
     struct spoint t;          /* To point */
 };
@@ -73,12 +78,8 @@ static int ixdots, iydots;        /* Screen size in dots */
 static FILE * slfile;             /* Slide file descriptor */
 static bool blither;              /* Dump slide file information ? */
 static bool info;                 /* Print header information */
-static pixel **pixels;            /* Pixel map */
+static pixel ** pixels;           /* Pixel map */
 static int pixcols, pixrows;      /* Pixel map size */
-static double uscale = -1;        /* Uniform scale factor */
-static int sxsize = -1, sysize = -1;  /* Scale to X, Y size ? */
-
-/*  Local variables  */
 
 struct slhead {
     char slh[17];             /* Primate-readable header */
@@ -90,7 +91,6 @@ struct slhead {
     char spad;                /* Pad to even byte length */
 };
 
-static bool adjust;           /* Adjust to correct aspect ratio ? */
 static struct slhead slfrof;  /* Slide file header */
 static long xfac, yfac;       /* Aspect ratio scale factors */
 
@@ -99,21 +99,22 @@ static bool sdrawkcab;
 
 
 
-/*  EXTEND  --  Turn a smallint into an int with sign extension, whether
-    or not that happens automatically.
-*/
-
 static int
 extend(unsigned char const ch) {
+/*----------------------------------------------------------------------------
+   Turn a smallint into an int with sign extension, whether
+   or not that happens automatically.
+-----------------------------------------------------------------------------*/
     return ((int) ((ch & 0x80) ? (ch | ~0xFF) : ch));
 }
 
 
 
-/*  SLI  --  Input word from slide file  */
-
 static int
 sli(void) {
+/*----------------------------------------------------------------------------
+   Read and return a word from the slide file.
+-----------------------------------------------------------------------------*/
     short wd;
 
     if (fread(&wd, sizeof wd, 1, slfile) != 1) {
@@ -128,10 +129,11 @@ sli(void) {
 
 
 
-/*  SLIB  --  Input byte from slide file  */
-
 static int
 slib(void) {
+/*----------------------------------------------------------------------------
+   Read and return a byte from the slide file.
+-----------------------------------------------------------------------------*/
     unsigned char ch;
 
     if (fread(&ch, sizeof(ch), 1, slfile) != 1) {
@@ -142,12 +144,12 @@ slib(void) {
 
 
 
-/*  VSCALE -- scale screen coordinates for mismatched display.  */
-
 static void
 vscale(int * const px,
        int * const py) {
-
+/*----------------------------------------------------------------------------
+    Scale screen coordinates for mismatched display.
+-----------------------------------------------------------------------------*/
     *px = (((unsigned) *px) * xfac) >> 16;
     *py = (((unsigned) *py) * yfac) >> 16;
 }
@@ -244,16 +246,17 @@ scanDirectory(FILE *       const slFileP,
     *foundP = found;
 }
 
-/*  SLIDEFIND  --  Find  a  slide  in  a  library  or,  if  DIRONLY is
-           nonzero, print a directory listing of the  library.
-           If  UCASEN  is nonzero, the requested slide name is
-           converted to upper case. */
+
 
 static void
 slidefind(const char * const slideName,
           bool         const dirOnly,
           bool         const ucasen) {
-
+/*----------------------------------------------------------------------------
+   Find a slide in a library or, if DIRONLY is nonzero, print a directory
+   listing of the library.  If UCASEN is nonzero, the requested slide name is
+   converted to upper case.
+-----------------------------------------------------------------------------*/
     char uname[32];  /* upper case translation of 'slideName' */
     char header[32]; /* (supposed) header read from file */
     bool found;
@@ -279,14 +282,14 @@ slidefind(const char * const slideName,
 
 
 
-/*  DRAW  --  Draw a vector in the given AutoCAD color.  */
-
 static slvecfn draw;
 
 static void
 draw(struct svector * vec,
      int              color) {
-
+/*----------------------------------------------------------------------------
+   Draw a vector in the given AutoCAD color.
+-----------------------------------------------------------------------------*/
     pixel rgbcolor;
 
     if (blither) {
@@ -307,14 +310,14 @@ draw(struct svector * vec,
 
 
 
-/*  FLOOD  --  Draw a filled polygon.  */
-
 static slfloodfn flood;
 
 static void
 flood(struct spolygon * const poly,
       int               const color) {
-
+/*----------------------------------------------------------------------------
+  Draw a filled polygon.
+-----------------------------------------------------------------------------*/
     unsigned int i;
     struct fillobj * handle;
     pixel rgbcolor;
@@ -350,16 +353,116 @@ flood(struct spolygon * const poly,
 
 
 
-/*  SLIDER  --  Read slide file.  This is called with the name of the
-        file to be read and function pointers to the routines
-        which process vectors and polygon fill requests
-        respectively.
-*/
-
 static void
-slider(slvecfn   slvec,
-       slfloodfn slflood) {
+computeSize(struct slhead const slfrof,
+            bool          const wantAdjust,
+            double        const uscale,
+            int           const sxsize,
+            int           const sysize,
+            int *         const ixdotsP,
+            int *         const iydotsP,
+            double *      const dsarP) {
+/*----------------------------------------------------------------------------
+-----------------------------------------------------------------------------*/
+    double const originalDsar = ((double) slfrof.sxdots) / slfrof.sydots;
+
+    double ixdots, iydots;
+        /* Algorithmic variables -- value changes as algorithm progresses */
+    bool adjusted;
+
+    /*
+      If the display aspect ratio indicates that the pixels on the sending
+      screen were not square, adjust the size of the generated bitmap to
+      correct the aspect ratio to square the pixels.
+
+      We always correct the aspect ratio by adjusting the width of the image.
+      This guarantees that output from the SHADE command, which is essentially
+      scan-line data written in vector form, will not be corrupted.
+    */
+
+    if (fabs(slfrof.sdsar - originalDsar) > 0.0001) {
+        if (wantAdjust) {
+            ixdots   = slfrof.sxdots * (slfrof.sdsar / originalDsar);
+            iydots   = slfrof.sydots;
+            *dsarP   = ixdots / iydots;
+            adjusted = true;
+        } else {
+            pm_message("Warning - pixels on source screen were non-square.  "
+                       "Specifying -adjust will correct image width "
+                       "to compensate.");
+            ixdots   = slfrof.sxdots;
+            iydots   = slfrof.sydots;
+            *dsarP   = slfrof.sdsar;
+            adjusted = false;
+        }
+    } else {
+        /* Source pixels were square. */
+        ixdots   = slfrof.sxdots;
+        iydots   = slfrof.sydots;
+        *dsarP   = slfrof.sdsar;
+        adjusted = false;
+    }
+
+    if (uscale > 0) {
+        /* There is a uniform scale factor specified.  Apply it. */
+        ixdots *= uscale;
+        iydots *= uscale;
+    }
+
+    /* If the image is to be stretched  to  a  given  width,  set  the
+       output  image  sizes accordingly.  If only a height or width is
+       given, scale the other direction proportionally to preserve the
+       aspect ratio.
+    */
 
+    if (sxsize > 0) {
+        if (sysize > 0)
+            iydots = sysize - 1;
+        else {
+            double const stretchFactor = (sxsize - 1) / ixdots;
+            iydots = iydots * stretchFactor;
+        }
+        ixdots = sxsize - 1;
+    } else if (sysize > 0) {
+        if (sxsize > 0)
+            ixdots = sxsize - 1;
+        else {
+            double const stretchFactor = (sysize - 1) / iydots;
+            ixdots = ixdots * stretchFactor;
+        }
+        iydots = sysize - 1;
+    }
+
+    if (ixdots > INT_MAX-10)
+        pm_error("width is uncomputable large (%f dots)", ixdots);
+    else
+        *ixdotsP = ROUND(ixdots);
+    if (iydots > INT_MAX-10)
+        pm_error("height is uncomputable large (%f dots)", iydots);
+    else
+        *iydotsP = ROUND(iydots);
+
+    if (adjusted) {
+        pm_message(
+            "Resized from %dx%d to %dx%d to correct pixel aspect ratio.",
+            slfrof.sxdots + 1, slfrof.sydots + 1, *ixdotsP + 1, *iydotsP + 1);
+    }
+}
+
+
+
+static void
+slider(slvecfn         slvec,
+       slfloodfn       slflood,
+       bool      const wantAdjust,
+       double    const uscale,
+       int       const sxsize,
+       int       const sysize) {
+/*----------------------------------------------------------------------------
+   Read slide file.  This is called with the name of the file to be read and
+   function pointers to the routines which process vectors and polygon fill
+   requests respectively.
+-----------------------------------------------------------------------------*/
     int i, rescale;
     unsigned char ubfr[4];        /* Utility character buffer */
     int lx, ly;               /* Last x and y point */
@@ -372,7 +475,7 @@ slider(slvecfn   slvec,
     short rtest;              /* Value to test byte reversal */
     short btest = 0x1234;         /* Value to test byte-reversal */
     static struct slhead slhi =       /* Master slide header sample */
-    {"AutoCAD Slide\r\n\32", 86,2, 0,0, 0.0, 0};
+        {"AutoCAD Slide\r\n\32", 86,2, 0,0, 0.0, 0};
     int curcolor = 7;             /* Current vector color */
     pixel rgbcolor;           /* Pixel used to clear pixmap */
 
@@ -434,79 +537,14 @@ slider(slvecfn   slvec,
                    sdrawkcab ? "being reversed" : "the same");
     }
 
-    /* If the display aspect ratio indicates that the  pixels  on  the
-       sending  screen  were  not  square,  adjust  the  size  of  the
-       generated bitmap to correct the  aspect  ratio  to  square  the
-       pixels.
-
-       We  always  correct  the aspect ratio by adjusting the width of
-       the image.  This guarantees that output from the SHADE command,
-       which  is  essentially  scan-line  data written in vector form,
-       will not be corrupted.
-    */
-
-    dsar = ((double) slfrof.sxdots) / slfrof.sydots;
-    if (fabs(slfrof.sdsar - dsar) > 0.0001) {
-        if (adjust) {
-            ixdots = slfrof.sxdots * (slfrof.sdsar / dsar) + 0.5;
-            iydots = slfrof.sydots;
-            dsar = ((double) ixdots) / iydots;
-        } else {
-            pm_message("Warning - pixels on source screen were non-square.  "
-                       "Specifying -adjust will correct image width "
-                       "to compensate.");
-            ixdots = slfrof.sxdots;
-            iydots = slfrof.sydots;
-            dsar = slfrof.sdsar;
-        }
-    } else {
-        /* Source pixels were square. */
-        ixdots = slfrof.sxdots;
-        iydots = slfrof.sydots;
-        dsar = slfrof.sdsar;
-        adjust = false;           /* Mark no adjustment needed */
-    }
-
-    /* If there's a uniform scale factor specified, apply it. */
-
-    if (uscale > 0) {
-        ixdots = (ixdots * uscale) + 0.5;
-        iydots = (iydots * uscale) + 0.5;
-    }
-
-    /* If the image is to be stretched  to  a  given  width,  set  the
-       output  image  sizes accordingly.  If only a height or width is
-       given, scale the other direction proportionally to preserve the
-       aspect ratio.
-    */
-
-    if (sxsize > 0) {
-        if (sysize > 0) {
-            iydots = sysize - 1;
-        } else {
-            iydots = ((((long) iydots) * (sxsize - 1)) +
-                      (iydots / 2)) / ixdots;
-        }
-        ixdots = sxsize - 1;
-    } else if (sysize > 0) {
-        if (sxsize > 0) {
-            ixdots = sxsize - 1;
-        } else {
-            ixdots = ((((long) ixdots) * (sysize - 1)) +
-                      (ixdots / 2)) / iydots;
-        }
-        iydots = sysize - 1;
-    }
-
-    if (adjust) {
-        pm_message(
-            "Resized from %dx%d to %dx%d to correct pixel aspect ratio.",
-            slfrof.sxdots + 1, slfrof.sydots + 1, ixdots + 1, iydots + 1);
-    }
+    computeSize(slfrof, wantAdjust, uscale, sxsize, sysize,
+                &ixdots, &iydots, &dsar);
 
     /* Allocate image buffer and clear it to black. */
 
-    pixels = ppm_allocarray(pixcols = ixdots + 1, pixrows = iydots + 1);
+    pixcols = ixdots + 1;
+    pixrows = iydots + 1;
+    pixels = ppm_allocarray(pixcols, pixrows);
     PPM_ASSIGN(rgbcolor, 0, 0, 0);
     ppmd_filledrectangle(pixels, pixcols, pixrows, pixmaxval, 0, 0,
                          pixcols, pixrows, PPMD_NULLDRAWPROC,
@@ -619,8 +657,6 @@ slider(slvecfn   slvec,
 
 
 
-/*  Main program. */
-
 int
 main(int          argc,
      const char * argv[]) {
@@ -634,7 +670,10 @@ main(int          argc,
     bool widspec;
     bool scalespec;
     bool ucasen;
-    const char * slobber;       /* Slide library item */
+    bool adjust;           /* Adjust to correct aspect ratio ? */
+    double uscale;         /* Uniform scale factor */
+    int sxsize, sysize;    /* Scale to X, Y size ? */
+    const char * slobber;  /* Slide library item */
 
     pm_proginit(&argc, argv);
     argn = 1;
@@ -648,6 +687,9 @@ main(int          argc,
     blither = false;
     info = false;
     adjust = false;
+    uscale = -1.0;
+    sxsize = -1;
+    sysize = -1;
 
     while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
         if (pm_keymatch(argv[argn], "-verbose", 2)) {
@@ -725,7 +767,7 @@ main(int          argc,
         slidefind(slobber, dironly, ucasen);
 
     if (!dironly) {
-        slider(draw, flood);
+        slider(draw, flood, adjust, uscale, sxsize, sysize);
         ppm_writeppm(stdout, pixels, pixcols, pixrows, pixmaxval, 0);
     }
     pm_close(slfile);
@@ -733,3 +775,6 @@ main(int          argc,
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/spctoppm.c b/converter/ppm/spctoppm.c
index d2a48187..a20fcfd4 100644
--- a/converter/ppm/spctoppm.c
+++ b/converter/ppm/spctoppm.c
@@ -41,19 +41,19 @@ main( argc, argv )
 
     /* Check args. */
     if ( argc > 2 )
-	pm_usage( "[spcfile]" );
+        pm_usage( "[spcfile]" );
 
     if ( argc == 2 )
-	ifp = pm_openr( argv[1] );
+        ifp = pm_openr( argv[1] );
     else
-	ifp = stdin;
+        ifp = stdin;
 
     /* Check SPC file header. */
     c1 = getc( ifp );
     c2 = getc( ifp );
 
     if ( ( c1 != 'S' ) || ( c2 != 'P' ) )
-	pm_error( "not a Spectrum picture" );
+        pm_error( "not a Spectrum picture" );
 
     /* Skip reserved bytes. */
     getc( ifp );
@@ -78,35 +78,35 @@ main( argc, argv )
     pixelrow = ppm_allocrow( COLS );
 
     for ( row = 0; row < ROWS; ++row )
-	{
-	for ( col = 0, pP = pixelrow; col < COLS; ++col, ++pP )
-	    {
-	    int c, ind, b, plane, x1;
-
-	    /* Compute pixel value. */
-	    ind = ( 80 * row ) + ( ( col >> 4 ) << 2 );
-	    b = 0x8000 >> (col & 0xf);
-	    c = 0;
-	    for ( plane = 0; plane < 4; ++plane )
-		if ( b & sscreen[ind+plane] )
-		    c |= (1 << plane);
-
-	    /* Compute palette index. */
-	    x1 = 10 * c;
-	    if ( c & 1 )
-		x1 -= 5;
-	    else
-		++x1;
-	    if ( ( col >= x1 ) && ( col < ( x1 + 160 ) ) )
-		c += 16;
-	    if ( col >= ( x1 + 160 ) )
-		c += 32;
-
-	    /* Store the proper color. */
-	    *pP = pal[row][c];
-	    }
-	ppm_writeppmrow( stdout, pixelrow, COLS, (pixval) MAXVAL, 0 );
-	}
+        {
+        for ( col = 0, pP = pixelrow; col < COLS; ++col, ++pP )
+            {
+            int c, ind, b, plane, x1;
+
+            /* Compute pixel value. */
+            ind = ( 80 * row ) + ( ( col >> 4 ) << 2 );
+            b = 0x8000 >> (col & 0xf);
+            c = 0;
+            for ( plane = 0; plane < 4; ++plane )
+                if ( b & sscreen[ind+plane] )
+                    c |= (1 << plane);
+
+            /* Compute palette index. */
+            x1 = 10 * c;
+            if ( c & 1 )
+                x1 -= 5;
+            else
+                ++x1;
+            if ( ( col >= x1 ) && ( col < ( x1 + 160 ) ) )
+                c += 16;
+            if ( col >= ( x1 + 160 ) )
+                c += 32;
+
+            /* Store the proper color. */
+            *pP = pal[row][c];
+            }
+        ppm_writeppmrow( stdout, pixelrow, COLS, (pixval) MAXVAL, 0 );
+        }
 
     pm_close( stdout );
 
@@ -123,7 +123,7 @@ DoBitmap( ifp )
 
     /* Zero out first scan line. */
     for ( i = 0; i < 160; ++i )
-	screen[i] = 0;
+        screen[i] = 0;
 
     /* 'count' counts number of input bytes. */
     count = 0;
@@ -132,37 +132,37 @@ DoBitmap( ifp )
     data = 0;
 
     while ( count < bitmap_length )
-	{
-	/* Get next record header. */
-	h = getc( ifp );
-	++count;
-
-	if ( ( h >= 0 ) && ( count < bitmap_length ) )
-	    {
-	    for ( i = 0; i <= h; ++i )
-		{
-		c = getc( ifp );
-		++count;
-		DoChar( data, c );
-		++data;
-		}
-	    }
-	else if ( ( h < 0 ) && ( count < bitmap_length ) )
-	    {
-	    c = getc( ifp );
-	    ++count;
-
-	    for ( i = 0; i < ( 2 - h ); ++i )
-		{
-		DoChar( data, c );
-		++data;
-		}
-	    }
+        {
+        /* Get next record header. */
+        h = getc( ifp );
+        ++count;
+
+        if ( ( h >= 0 ) && ( count < bitmap_length ) )
+            {
+            for ( i = 0; i <= h; ++i )
+                {
+                c = getc( ifp );
+                ++count;
+                DoChar( data, c );
+                ++data;
+                }
+            }
+        else if ( ( h < 0 ) && ( count < bitmap_length ) )
+            {
+            c = getc( ifp );
+            ++count;
+
+            for ( i = 0; i < ( 2 - h ); ++i )
+                {
+                DoChar( data, c );
+                ++data;
+                }
+            }
     }
 
     /* Convert the char version of the screen to short. */
     for ( i = 0; i < ROWS*COLS/4; ++i )
-	sscreen[i] = ( screen[i<<1] << 8 ) + ( 0xff & screen[(i<<1)+1] );
+        sscreen[i] = ( screen[i<<1] << 8 ) + ( 0xff & screen[(i<<1)+1] );
     }
 
 static void
@@ -184,22 +184,25 @@ DoColormap( ifp )
 
     /* Clear first three palettes. */
     for ( j = 0; j < 48; ++j )
-	PPM_ASSIGN( pal[0][j], 0, 0, 0 );
+        PPM_ASSIGN( pal[0][j], 0, 0, 0 );
 
     /* Read the palettes. */
     for ( i = 1; i < ROWS; ++i )
-	for ( j = 0; j < 3; ++j )
-	    {
-	    (void) pm_readbigshort( ifp, &mask );
-	    for ( b = 0; b < 15; ++b )
-		if ( mask & ( 1 << b ) )
-		    {
-		    short k;
-		    (void) pm_readbigshort( ifp, &k );
-		    PPM_ASSIGN( pal[i][(j*16)+b],
-			( k & 0x700 ) >> 8,
-			( k & 0x070 ) >> 4,
-			( k & 0x007 ) );
-		    }
-	    }
+        for ( j = 0; j < 3; ++j )
+            {
+            (void) pm_readbigshort( ifp, &mask );
+            for ( b = 0; b < 15; ++b )
+                if ( mask & ( 1 << b ) )
+                    {
+                    short k;
+                    (void) pm_readbigshort( ifp, &k );
+                    PPM_ASSIGN( pal[i][(j*16)+b],
+                        ( k & 0x700 ) >> 8,
+                        ( k & 0x070 ) >> 4,
+                        ( k & 0x007 ) );
+                    }
+            }
     }
+
+
+
diff --git a/converter/ppm/tgatoppm.c b/converter/ppm/tgatoppm.c
index 662f741b..82225516 100644
--- a/converter/ppm/tgatoppm.c
+++ b/converter/ppm/tgatoppm.c
@@ -94,7 +94,6 @@ parseCommandLine(int argc, char ** argv,
 
 
 
-
 static unsigned char
 getbyte(FILE * const ifP) {
 
diff --git a/converter/ppm/vidtoppm.c b/converter/ppm/vidtoppm.c
index f3c20404..b0abe731 100644
--- a/converter/ppm/vidtoppm.c
+++ b/converter/ppm/vidtoppm.c
@@ -1,15 +1,15 @@
 /* Bryan got this from mm.ftp-cs.berkeley.edu from the package
-   mpeg-encode-1.5b-src under the name vidtoppm.c on March 30, 2000.  
-   The file was dated January 19, 1995.  
+   mpeg-encode-1.5b-src under the name vidtoppm.c on March 30, 2000.
+   The file was dated January 19, 1995.
 
    This program does not use the netpbm libraries, but generates its
    output via the program rawtoppm.  If any work is ever done on it
    (or, more to the point, any interest ever expressed in it), it
    should be converted just to call ppmwrite(), etc. directly.
 
-   There was no attached documentation, but the program appears to 
+   There was no attached documentation, but the program appears to
    convert from Parallax XVideo JPEG format to a sequence of PPM files.  It
-   does this conversion by putting each frame in a window and then 
+   does this conversion by putting each frame in a window and then
    reading it out of the window, using libXvid.
 
    Because it requires special libraries and there is no known
@@ -57,6 +57,8 @@ char *p;
     exit (1);
 }
 
+
+
 static char buffer[300000];
 
 Visual *
@@ -67,11 +69,11 @@ FindFullColorVisual (dpy, depth)
   XVisualInfo vinfo;
   XVisualInfo *vinfo_ret;
   int numitems, maxdepth;
-  
+
   vinfo.class = TrueColor;
-  
+
   vinfo_ret = XGetVisualInfo(dpy, VisualClassMask, &vinfo, &numitems);
-  
+
   if (numitems == 0) return NULL;
 
   maxdepth = 0;
@@ -85,15 +87,17 @@ FindFullColorVisual (dpy, depth)
 
   if (maxdepth < 24) return NULL;
 
-  if (XMatchVisualInfo(dpy, DefaultScreen(dpy), maxdepth, 
-		       TrueColor, &vinfo)) {
+  if (XMatchVisualInfo(dpy, DefaultScreen(dpy), maxdepth,
+                       TrueColor, &vinfo)) {
     *depth = maxdepth;
     return vinfo.visual;
   }
-  
+
   return NULL;
 }
 
+
+
 Window
 CreateFullColorWindow (dpy, x, y, w, h)
     Display *dpy;
@@ -107,21 +111,23 @@ CreateFullColorWindow (dpy, x, y, w, h)
     int screen;
 
     screen = XDefaultScreen(dpy);
-    class = InputOutput;	/* Could be InputOnly */
+    class = InputOutput;        /* Could be InputOnly */
     visual = FindFullColorVisual (dpy, &depth);
     if (visual == NULL) {
-	return 0;
+        return 0;
     }
     mask = CWBackPixel | CWColormap | CWBorderPixel;
     xswa.colormap = XCreateColormap(dpy, XRootWindow(dpy, screen),
-		    visual, AllocNone);
+                    visual, AllocNone);
     xswa.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
     xswa.border_pixel = WhitePixel(dpy, DefaultScreen(dpy));
 
     return XCreateWindow(dpy, RootWindow(dpy, screen), x, y, w, h,
-	1, depth, class, visual, mask, &xswa);
+        1, depth, class, visual, mask, &xswa);
 }
 
+
+
 main (argc, argv)
 int argc;
 char **argv;
@@ -169,16 +175,16 @@ char **argv;
   obase = argv[6];
 
   quality = 100;
-  
+
   if (argc > 7)
     quality = atoi (argv[7]);
-  
+
   dpy = XOpenDisplay (NULL);
   screen = DefaultScreen(dpy);
   root = DefaultRootWindow(dpy);
 /*  gc = DefaultGC(dpy, screen); */
 /*  win = XCreateSimpleWindow (dpy, root, 0, 0, width, height,
-			     0, NULL, NULL);
+                             0, NULL, NULL);
 */
   win = CreateFullColorWindow(dpy, 0, 0, width+4, height+4);
   gc = XCreateGC(dpy, win, 0, NULL);
@@ -195,7 +201,7 @@ char **argv;
   XPlxPutTable(dpy, win, gc, qTable, size, 0);
   XPlxPutTable(dpy, win, gc, qTable, size, 1);
   XPlxVideoTag (dpy, win, gc, PLX_VIDEO);
-  
+
   inFile = fopen(filename, "rb");
   if (inFile == NULL) {
     perror (filename);
@@ -215,7 +221,7 @@ char **argv;
       exit();
     }
   }
-    
+
   for (i=start; i<=end; i++) {
     fprintf(stdout, "GRABBING FRAME %d\n", i);
 
@@ -228,15 +234,15 @@ char **argv;
       perror("End of file.");
       exit();
     }
-    
+
     XPlxPutCImage (dpy, win, gc, &image, 0, 0, image.width,
-		   image.height, 0, 0, width+2, height+2, 1);
+                   image.height, 0, 0, width+2, height+2, 1);
 
     XFlush(dpy);
 
     ximage = XGetImage(dpy, win, 0, 0, width, height, 0x00ffffff,
-		       ZPixmap);
-    
+                       ZPixmap);
+
     if (i == 0) {
       fprintf(stderr, "Depth %d\n", ximage->depth);
       fprintf(stderr, "Height: %d Width: %d\n", height, width );
@@ -252,10 +258,10 @@ char **argv;
 
     for (r=0; r<height; r++) {
       for (j=0; j<width; j++) {
-	fputc(*(tdata+3), outFile);
-	fputc(*(tdata+2), outFile);
-	fputc(*(tdata+1), outFile);
-	tdata += 4;
+        fputc(*(tdata+3), outFile);
+        fputc(*(tdata+2), outFile);
+        fputc(*(tdata+1), outFile);
+        tdata += 4;
       }
     }
 
@@ -264,7 +270,10 @@ char **argv;
     free(tdata);
 
     sprintf(command, "rawtoppm %d %d < /tmp/foobar > %s",
-	    width, height, ofname);
+            width, height, ofname);
     system(command);
   }
 }
+
+
+
diff --git a/converter/ppm/winico.h b/converter/ppm/winico.h
index c6133ef0..de05ca4d 100644
--- a/converter/ppm/winico.h
+++ b/converter/ppm/winico.h
@@ -11,19 +11,19 @@ typedef unsigned char      u1;
 typedef unsigned short int u2;
 typedef unsigned int       u4;
 
-typedef struct MS_Ico_ *          MS_Ico;
-typedef struct IC_Entry_ *        IC_Entry;
-typedef struct IC_InfoHeader_ *   IC_InfoHeader;
-typedef struct IC_Color_ *        IC_Color;
+typedef struct MS_Ico_           MS_Ico;
+typedef struct IC_Entry_         IC_Entry;
+typedef struct IC_InfoHeader_    IC_InfoHeader;
+typedef struct IC_Color_         IC_Color;
 /* Not part of the spec, but useful in constructing the icon. */
-typedef struct IC_Palette_ *      IC_Palette;
-typedef struct ICON_bmp_ *        ICON_bmp;
+typedef struct IC_Palette_       IC_Palette;
+typedef struct ICON_bmp_         ICON_bmp;
 
 struct MS_Ico_ {
    u2 reserved;
    u2 type;
    u2 count;
-   IC_Entry * entries;
+   IC_Entry ** entries;
 };
 
 
@@ -40,8 +40,8 @@ struct IC_Entry_ {
    u2 bitcount;    /* 0, 1, 4, or 8 */
    u4 size_in_bytes;
    u4 file_offset;
-   IC_InfoHeader ih;
-   IC_Color * colors;
+   IC_InfoHeader * ih;
+   IC_Color ** colors;
    /*
     * Below here, I have useful fields which aren't in the spec, but
     * save having to keep stoopid amounts of global data.
@@ -77,7 +77,7 @@ struct IC_Color_ {
 
 struct IC_Palette_ {
    u4 col_amount;
-   IC_Color * colors;
+   IC_Color ** colors;
 };
 
 struct ICON_bmp_ {
diff --git a/converter/ppm/winicontoppm.c b/converter/ppm/winicontoppm.c
index ede0a2b9..54bc0809 100644
--- a/converter/ppm/winicontoppm.c
+++ b/converter/ppm/winicontoppm.c
@@ -115,7 +115,6 @@ parseCommandLine (int argc, const char ** argv,
 
 
 
-
 static int
 GetByte(FILE * const ifP) {
 
@@ -216,17 +215,17 @@ readU4 (FILE * const ifP) {
 
 
 
-static IC_Entry
+static IC_Entry *
 readICEntry(FILE * const ifP) {
 
-    IC_Entry entryP;
+    IC_Entry * entryP;  /* malloc'ed */
     u1 widthFld;   /* 0 means 256 */
     u1 heightFld;  /* 0 means 256 */
     u1 colorCtFld; /* 0 means 256 */
 
     MALLOCVAR(entryP);
 
-    if (entryP == NULL)
+    if (!entryP)
         pm_error("Unable to allocate memory for IC entry");
 
     widthFld              = readU1(ifP);
@@ -255,15 +254,15 @@ readICEntry(FILE * const ifP) {
 
 
 
-static IC_InfoHeader
-readInfoHeader (FILE *   const ifP,
-                IC_Entry const entryP) {
+static IC_InfoHeader *
+readInfoHeader(FILE *           const ifP,
+               const IC_Entry * const entryP) {
 
-    IC_InfoHeader ihP;
+    IC_InfoHeader * ihP;  /* malloc'ed */
 
     MALLOCVAR(ihP);
 
-    if (ihP == NULL)
+    if (!ihP)
         pm_error("Unable to allocate memory for info header");
 
     ihP->size             = readU4(ifP);  /* never referenced */
@@ -315,14 +314,14 @@ readInfoHeader (FILE *   const ifP,
 
 
 
-static IC_Color
+static IC_Color *
 readICColor(FILE * const ifP)  {
 
-    IC_Color colorP;
+    IC_Color * colorP;  /* malloc'ed */
 
     MALLOCVAR(colorP);
 
-    if (colorP == NULL)
+    if (!colorP)
         pm_error("Unable to allocate memory for color");
 
     /* I don't know why this isn't the same as the spec, it just isn't.
@@ -514,40 +513,40 @@ readXBitmap (FILE *       const ifP,
 
 
 
-static MS_Ico
+static MS_Ico *
 readIconFile(FILE * const ifP,
              bool   const verbose) {
 
     unsigned int i;
 
-    MS_Ico MSIconData;
+    MS_Ico * MSIconDataP;  /* malloc'ed */
 
-    MALLOCVAR(MSIconData);
+    MALLOCVAR(MSIconDataP);
 
-    MSIconData->reserved = readU2(ifP);  /* should be 0 */
-    MSIconData->type     = readU2(ifP);  /* should be 1 (ICO) or 2 (CUR) */
-    MSIconData->count    = readU2(ifP);  /* # icons in file */
+    MSIconDataP->reserved = readU2(ifP);  /* should be 0 */
+    MSIconDataP->type     = readU2(ifP);  /* should be 1 (ICO) or 2 (CUR) */
+    MSIconDataP->count    = readU2(ifP);  /* # icons in file */
 
-    if (MSIconData->reserved != 0)
+    if (MSIconDataP->reserved != 0)
        pm_message("Signature 'reserved' field is %u (should be 0)",
-                  MSIconData->reserved);
+                  MSIconDataP->reserved);
 
-    if (MSIconData->type != 1 && MSIconData->type != 2)
+    if (MSIconDataP->type != 1 && MSIconDataP->type != 2)
         pm_error("Type %u file.  Can handle only type 1 or 2.",
-                 MSIconData->type);
+                 MSIconDataP->type);
 
-    if (MSIconData->count == 0)
+    if (MSIconDataP->count == 0)
         pm_error("Invalid image count: 0");
     else if (verbose)
-        pm_message("File contains %u images", MSIconData->count);
+        pm_message("File contains %u images", MSIconDataP->count);
 
-    MALLOCARRAY(MSIconData->entries, MSIconData->count);
-    if (MSIconData->entries == NULL)
+    MALLOCARRAY(MSIconDataP->entries, MSIconDataP->count);
+    if (MSIconDataP->entries == NULL)
         pm_error("out of memory");
 
     /* Read in each of the entries */
-    for (i = 0; i < MSIconData->count; ++i)
-        MSIconData->entries[i] = readICEntry(ifP);
+    for (i = 0; i < MSIconDataP->count; ++i)
+        MSIconDataP->entries[i] = readICEntry(ifP);
 
     /* Read in the infoheader, color map (if any) and the actual bit/pix maps
        for the icons.
@@ -555,12 +554,12 @@ readIconFile(FILE * const ifP,
     if (verbose)
         pm_message("#\tColors\tBPP\tWidth\tHeight\n");
 
-    for (i = 0; i < MSIconData->count; ++i) {
-        IC_Entry const entryP = MSIconData->entries[i];
+    for (i = 0; i < MSIconDataP->count; ++i) {
+        IC_Entry * const entryP = MSIconDataP->entries[i];
 
         unsigned int bpp;  /* bits per pixel */
 
-        entryP->ih = readInfoHeader(ifP, MSIconData->entries[i]);
+        entryP->ih = readInfoHeader(ifP, MSIconDataP->entries[i]);
 
         bpp  = entryP->bitcount ? entryP->bitcount : entryP->ih->bitcount;
 
@@ -633,7 +632,7 @@ readIconFile(FILE * const ifP,
         }
 
     }
-    return MSIconData;
+    return MSIconDataP;
 }
 
 
@@ -655,15 +654,15 @@ trimmedOutputName(const char inputName[]) {
 
 
 static int
-getBestQualityIcon(MS_Ico MSIconData)
-{
+getBestQualityIcon(MS_Ico * const MSIconDataP) {
+
     unsigned int i;
     unsigned int best;
     unsigned int bestSize;
     unsigned int bestBpp;
 
-    for (i = 0, bestSize = 0, bestBpp = 0; i < MSIconData->count; ++i) {
-        IC_Entry const entryP = MSIconData->entries[i];
+    for (i = 0, bestSize = 0, bestBpp = 0; i < MSIconDataP->count; ++i) {
+        IC_Entry * const entryP = MSIconDataP->entries[i];
         unsigned int const size = entryP->width * entryP->height;
         unsigned int const bpp  =
             entryP->bitcount ? entryP->bitcount : entryP->ih->bitcount;
@@ -682,12 +681,12 @@ getBestQualityIcon(MS_Ico MSIconData)
 
 
 static void
-writeXors(FILE *   const multiOutF,
-          char *   const outputFileBase,
-          IC_Entry const entryP,
-          int      const entryNum,
-          bool     const multiple,
-          bool     const xor) {
+writeXors(FILE *     const multiOutF,
+          char *     const outputFileBase,
+          IC_Entry * const entryP,
+          int        const entryNum,
+          bool       const multiple,
+          bool       const xor) {
 /*----------------------------------------------------------------------------
    Write an "xor" image (i.e. the main image) out.
 
@@ -751,7 +750,7 @@ writeXors(FILE *   const multiOutF,
                     pm_error("Invalid color index %u (max is %u)",
                               colorIndex, entryP->color_count - 1);
                 } else {
-                    IC_Color const colorP = entryP->colors[colorIndex];
+                    IC_Color * const colorP = entryP->colors[colorIndex];
                     PPM_ASSIGN(pixArray[row][col],
                                colorP->red, colorP->green, colorP->blue);
                 }
@@ -775,7 +774,7 @@ writeXors(FILE *   const multiOutF,
 static void
 writeAnds(FILE *       const multiOutF,
           char         const outputFileBase[],
-          IC_Entry     const entryP,
+          IC_Entry *   const entryP,
           unsigned int const entryNum,
           bool         const multiple) {
 /*----------------------------------------------------------------------------
@@ -866,7 +865,7 @@ openMultiAnd(char    const outputFileBase[],
 
 
 static void
-freeIconentry(IC_Entry const entryP) {
+freeIconentry(IC_Entry * const entryP) {
 
     if (entryP->colors && entryP->color_count) {
         unsigned int i;
@@ -883,7 +882,7 @@ freeIconentry(IC_Entry const entryP) {
 
 
 static void
-freeIcondata(MS_Ico const MSIconDataP) {
+freeIcondata(MS_Ico * const MSIconDataP) {
 
     unsigned int i;
     for (i = 0; i < MSIconDataP->count; ++i)
@@ -900,7 +899,7 @@ main(int argc, const char *argv[]) {
     struct cmdlineInfo cmdline;
     FILE * ifP;
     unsigned int startEntry, endEntry;
-    MS_Ico MSIconDataP;
+    MS_Ico * MSIconDataP;
     char * outputFileBase;
     FILE * multiOutF;
     FILE * multiAndOutF;
@@ -961,7 +960,7 @@ main(int argc, const char *argv[]) {
         unsigned int entryNum;
 
         for (entryNum = startEntry; entryNum < endEntry; ++entryNum) {
-            IC_Entry const entryP = MSIconDataP->entries[entryNum];
+            IC_Entry * const entryP = MSIconDataP->entries[entryNum];
 
             writeXors(multiOutF, outputFileBase, entryP, entryNum,
                       cmdline.allicons, cmdline.writeands);
@@ -980,3 +979,6 @@ main(int argc, const char *argv[]) {
 
     return 0;
 }
+
+
+
diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
index d839e770..b82463c3 100644
--- a/converter/ppm/ximtoppm.c
+++ b/converter/ppm/ximtoppm.c
@@ -17,6 +17,7 @@
 #include <string.h>
 
 #include "pm_c_util.h"
+#include "mallocvar.h"
 #include "ppm.h"
 #include "xim.h"
 #include "shhopt.h"
@@ -28,9 +29,9 @@ struct CmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *input_filename;
-    const char *alpha_filename;
-    bool alpha_stdout;
+    const char * inputFilename;
+    const char * alphaFilename;
+    bool         alphaStdout;
 };
 
 
@@ -53,7 +54,7 @@ parseCommandLine(int argc, const char ** argv,
 
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3(0,   "alphaout",   OPT_STRING,
-            &cmdlineP->alpha_filename, &alphaoutSpec, 0);
+            &cmdlineP->alphaFilename, &alphaoutSpec, 0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -63,21 +64,21 @@ parseCommandLine(int argc, const char ** argv,
         /* Uses and sets argc, argv, and all of *cmdlineP. */
 
     if (!alphaoutSpec)
-        cmdlineP->alpha_filename = NULL;
+        cmdlineP->alphaFilename = NULL;
 
     if (argc - 1 == 0)
-        cmdlineP->input_filename = "-";  /* he wants stdin */
+        cmdlineP->inputFilename = "-";  /* he wants stdin */
     else if (argc - 1 == 1)
-        cmdlineP->input_filename = strdup(argv[1]);
+        cmdlineP->inputFilename = pm_strdup(argv[1]);
     else
         pm_error("Too many arguments.  The only argument accepted "
                  "is the input file specification");
 
-    if (cmdlineP->alpha_filename &&
-        streq(cmdlineP->alpha_filename, "-"))
-        cmdlineP->alpha_stdout = TRUE;
+    if (cmdlineP->alphaFilename &&
+        streq(cmdlineP->alphaFilename, "-"))
+        cmdlineP->alphaStdout = true;
     else
-        cmdlineP->alpha_stdout = FALSE;
+        cmdlineP->alphaStdout = false;
 }
 
 
@@ -87,191 +88,202 @@ parseCommandLine(int argc, const char ** argv,
 */
 
 static int
-ReadXimHeader(FILE *     const in_fp,
-              XimImage * const header) {
+readXimHeader(FILE *     const ifP,
+              XimImage * const headerP) {
 
-    int  i;
-    char *cp;
-    XimAsciiHeader  a_head;
+    unsigned int  i;
+    XimAsciiHeader  aHead;
 
-    cp = (char *) header;
-    for (i = 0; i < sizeof(XimImage); ++i )
-    *cp++ = 0;
+    {
+        unsigned char * cp;
+        cp = (unsigned char *)headerP;
+        for (i = 0; i < sizeof(XimImage); ++i)
+            *cp++ = 0;
+    }
     /* Read header and verify image file formats */
-    if (fread((char *)&a_head, sizeof(ImageHeader), 1, in_fp) != 1) {
+    if (fread((char *)&aHead, sizeof(ImageHeader), 1, ifP) != 1) {
         pm_message("ReadXimHeader: unable to read file header" );
-        return(0);
+        return 0;
     }
     /* Force broken ASCIIZ strings to at least be valid ASCIIZ */
-    a_head.author [sizeof(a_head.author)  - 1] = '\0';
-    a_head.date   [sizeof(a_head.date)    - 1] = '\0';
-    a_head.program[sizeof(a_head.program) - 1] = '\0';
+    aHead.author [sizeof(aHead.author)  - 1] = '\0';
+    aHead.date   [sizeof(aHead.date)    - 1] = '\0';
+    aHead.program[sizeof(aHead.program) - 1] = '\0';
 
-    if (atoi(a_head.header_size) != sizeof(ImageHeader)) {
+    if (atoi(aHead.header_size) != sizeof(ImageHeader)) {
         pm_message("ReadXimHeader: header size mismatch" );
         return(0);
     }
-    if (atoi(a_head.file_version) != IMAGE_VERSION) {
+    if (atoi(aHead.file_version) != IMAGE_VERSION) {
         pm_message("ReadXimHeader: incorrect Image_file version" );
         return(0);
     }
-    header->width = atoi(a_head.image_width);
-    header->height = atoi(a_head.image_height);
-    header->ncolors = atoi(a_head.num_colors);
-    header->nchannels = atoi(a_head.num_channels);
-    header->bytes_per_line = atoi(a_head.bytes_per_line);
+    headerP->width          = atoi(aHead.image_width);
+    headerP->height         = atoi(aHead.image_height);
+    headerP->ncolors        = atoi(aHead.num_colors);
+    headerP->nchannels      = atoi(aHead.num_channels);
+    headerP->bytes_per_line = atoi(aHead.bytes_per_line);
 #if 0
-    header->npics = atoi(a_head.num_pictures);
+    headerP->npics          = atoi(aHead.num_pictures);
 #endif
-    header->bits_channel = atoi(a_head.bits_per_channel);
-    header->alpha_flag = atoi(a_head.alpha_channel);
-    header->author = pm_strdup(a_head.author);
-    header->date = pm_strdup(a_head.date);
-    header->program = pm_strdup(a_head.program);
+    headerP->bits_channel   = atoi(aHead.bits_per_channel);
+    headerP->alpha_flag     = atoi(aHead.alpha_channel);
+    headerP->author         = pm_strdup(aHead.author);
+    headerP->date           = pm_strdup(aHead.date);
+    headerP->program        = pm_strdup(aHead.program);
 
     /* Do double checking for backwards compatibility */
-    if (header->npics == 0)
-        header->npics = 1;
-    if (header->bits_channel == 0)
-        header->bits_channel = 8;
-    else if (header->bits_channel == 24) {
-        header->nchannels = 3;
-        header->bits_channel = 8;
+    if (headerP->npics == 0)
+        headerP->npics = 1;
+    if (headerP->bits_channel == 0)
+        headerP->bits_channel = 8;
+    else if (headerP->bits_channel == 24) {
+        headerP->nchannels = 3;
+        headerP->bits_channel = 8;
     }
-    if ((int)header->bytes_per_line == 0)
-        header->bytes_per_line =
-            (header->bits_channel == 1 && header->nchannels == 1) ?
-                (header->width + 7) / 8 :
-                header->width;
-    header->datasize =(unsigned int)header->bytes_per_line * header->height;
-    if (header->nchannels == 3 && header->bits_channel == 8)
-        header->ncolors = 0;
-    else if (header->nchannels == 1 && header->bits_channel == 8) {
-        header->colors = (Color *)calloc((unsigned int)header->ncolors,
-                sizeof(Color));
-        if (header->colors == NULL) {
-            pm_message("ReadXimHeader: can't calloc colors" );
-            return(0);
-        }
-        for (i=0; i < header->ncolors; i++) {
-            header->colors[i].red = a_head.c_map[i][0];
-            header->colors[i].grn = a_head.c_map[i][1];
-            header->colors[i].blu = a_head.c_map[i][2];
+    if (headerP->bytes_per_line == 0)
+        headerP->bytes_per_line =
+            (headerP->bits_channel == 1 && headerP->nchannels == 1) ?
+                (headerP->width + 7) / 8 :
+                headerP->width;
+    headerP->datasize =
+        (unsigned int)headerP->bytes_per_line * headerP->height;
+    if (headerP->nchannels == 3 && headerP->bits_channel == 8)
+        headerP->ncolors = 0;
+    else if (headerP->nchannels == 1 && headerP->bits_channel == 8) {
+        unsigned int i;
+
+        MALLOCARRAY_NOFAIL(headerP->colors, headerP->ncolors);
+
+        for (i=0; i < headerP->ncolors; ++i) {
+            headerP->colors[i].red = aHead.c_map[i][0];
+            headerP->colors[i].grn = aHead.c_map[i][1];
+            headerP->colors[i].blu = aHead.c_map[i][2];
         }
     }
-    return(1);
+    return 1;
 }
 
 
 
 static int
-ReadImageChannel(FILE *         const infp,
+readImageChannel(FILE *         const ifP,
                  byte *         const buf,
-                 unsigned int * const bufsize,
-                 int            const encoded) {
+                 unsigned int * const bufsizeP,
+                 bool           const encoded) {
 
-    int  i, runlen, nbytes;
-    unsigned int  j;
-    byte *line;
+    unsigned int j;
     long  marker;
 
     if (!encoded)
-        j = fread((char *)buf, 1, (int)*bufsize, infp);
+        j = fread((char *)buf, 1, (int)*bufsizeP, ifP);
     else {
-        if ((line=(byte *)malloc((unsigned int)BUFSIZ)) == NULL) {
+        byte * line;
+
+        MALLOCARRAY(line, BUFSIZ);
+        if (!line) {
             pm_message("ReadImageChannel: can't malloc() fread string" );
-            return(0);
-        }
-        /* Unrunlength encode data */
-        marker = ftell(infp);
-        j = 0;
-        while (((nbytes=fread((char *)line, 1, BUFSIZ, infp)) > 0) &&
-            (j < *bufsize)) {
-            for (i=0; (i < nbytes) && (j < *bufsize); i++) {
-                runlen = (int)line[i]+1;
-                i++;
-                while (runlen--)
-                    buf[j++] = line[i];
+            return 0;
+        } else {
+            /* Unrunlength encode data */
+            unsigned int byteCt;
+
+            marker = ftell(ifP);
+            j = 0;
+            while (((byteCt = fread((char *)line, 1, BUFSIZ, ifP)) > 0) &&
+                   (j < *bufsizeP)) {
+                unsigned int i;
+                for (i=0; (i < byteCt) && (j < *bufsizeP); ++i) {
+                    unsigned int runlen;
+                    runlen = (unsigned int)line[i] + 1;
+                    ++i;
+                    while (runlen--)
+                        buf[j++] = line[i];
+                }
+                marker += i;
             }
-            marker += i;
-        }
-        /* return to the beginning of the next image's buffer */
-        if (fseek(infp, marker, 0) == -1) {
-            pm_message("ReadImageChannel: can't fseek to location "
-                       "in image buffer");
-            return(0);
+            /* return to the beginning of the next image's buffer */
+            if (fseek(ifP, marker, 0) == -1) {
+                pm_message("ReadImageChannel: can't fseek to location "
+                           "in image buffer");
+                return 0;
+            }
+            free(line);
         }
-        free((char *)line);
     }
-    if (j != *bufsize) {
-        pm_message("unable to complete channel: %u / %u (%d%%)",
-            j, *bufsize, (int)(j*100.0 / *bufsize) );
-        *bufsize = j;
+    if (j != *bufsizeP) {
+        pm_message("unable to complete channel: %u / %u (%f%%)",
+                   j, *bufsizeP, j * 100.0 / *bufsizeP);
+        *bufsizeP = j;
     }
-    return(1);
+    return 1;
 }
 
 
 
 static int
-ReadXimImage(FILE *     const in_fp,
-             XimImage * const xim) {
+readXimImage(FILE *     const ifP,
+             XimImage * const ximP) {
 
-    if (xim->data) {
-        free((char *)xim->data);
-        xim->data = (byte *)0;
+    if (ximP->data) {
+        free(ximP->data);
+        ximP->data = NULL;
     }
-    if (xim->grn_data) {
-        free((char *)xim->grn_data);
-        xim->grn_data = (byte *)0;
+    if (ximP->grn_data) {
+        free(ximP->grn_data);
+        ximP->grn_data = NULL;
     }
-    if (xim->blu_data) {
-        free((char *)xim->blu_data);
-        xim->blu_data = (byte *)0;
+    if (ximP->blu_data) {
+        free(ximP->blu_data);
+        ximP->blu_data = NULL;
     }
-    if (xim->other) {
-        free((char *)xim->other);
-        xim->other = (byte *)0;
+    if (ximP->other) {
+        free(ximP->other);
+        ximP->other = NULL;
     }
-    xim->npics = 0;
-    if (!(xim->data = (byte *)calloc(xim->datasize, 1))) {
-        pm_message("ReadXimImage: can't malloc pixmap data" );
-        return(0);
+    ximP->npics = 0;
+    MALLOCARRAY(ximP->data, ximP->datasize);
+    if (!ximP->data) {
+        pm_message("ReadXimImage: can't malloc pixmap data");
+        return 0;
     }
-    if (!ReadImageChannel(in_fp, xim->data, &xim->datasize, 0)) {
-        pm_message("ReadXimImage: end of the images" );
-        return(0);
+    if (!readImageChannel(ifP, ximP->data, &ximP->datasize, false)) {
+        pm_message("ReadXimImage: end of the images");
+        return 0;
     }
-    if (xim->nchannels == 3) {
-        xim->grn_data = (byte *)malloc(xim->datasize);
-        xim->blu_data = (byte *)malloc(xim->datasize);
-        if (xim->grn_data == NULL || xim->blu_data == NULL) {
-            pm_message("ReadXimImage: can't malloc rgb channel data" );
-            free((char *)xim->data);
-            if (xim->grn_data)  free((char *)xim->grn_data);
-            if (xim->blu_data)  free((char *)xim->blu_data);
-            xim->data = xim->grn_data = xim->blu_data = (byte*)0;
-            return(0);
+    if (ximP->nchannels == 3) {
+        MALLOCARRAY(ximP->grn_data, ximP->datasize);
+        MALLOCARRAY(ximP->blu_data, ximP->datasize);
+        if (!ximP->grn_data || !ximP->blu_data) {
+            pm_message("ReadXimImage: can't malloc rgb channel data");
+            free(ximP->data);
+            if (ximP->grn_data)
+                free(ximP->grn_data);
+            if (ximP->blu_data)
+                free(ximP->blu_data);
+            ximP->data = ximP->grn_data = ximP->blu_data = NULL;
+            return 0;
         }
-        if (!ReadImageChannel(in_fp, xim->grn_data, &xim->datasize, 0))
-            return(0);
-        if (!ReadImageChannel(in_fp, xim->blu_data, &xim->datasize, 0))
-            return(0);
-    }
-    if (xim->nchannels > 3) {
-        /* In theory, this can be any fourth channel, but the only one we
-           know about is an Alpha channel, so we'll call it that, even
-           though we process it generically.
-           */
-        if ((xim->other = (byte *)malloc(xim->datasize)) == NULL) {
-            pm_message("ReadXimImage: can't malloc alpha data" );
-            return(0);
+        if (!readImageChannel(ifP, ximP->grn_data, &ximP->datasize, false))
+            return 0;
+        if (!readImageChannel(ifP, ximP->blu_data, &ximP->datasize, false))
+            return 0;
+    } else if (ximP->nchannels > 3) {
+        /* In theory, this can be any fourth channel, but the only one we know
+           about is an Alpha channel, so we'll call it that, even though we
+           process it generically.
+        */
+        MALLOCARRAY(ximP->other, ximP->datasize);
+        if (!ximP->other) {
+            pm_message("ReadXimImage: can't malloc alpha data");
+            return 0;
         }
-        if (!ReadImageChannel(in_fp, xim->other, &xim->datasize, 0))
+        if (!readImageChannel(ifP, ximP->other, &ximP->datasize, false))
             return(0);
     }
-    xim->npics = 1;
-    return(1);
+    ximP->npics = 1;
+
+    return 1;
 }
 
 
@@ -307,17 +319,21 @@ ReadXimImage(FILE *     const in_fp,
 ***********************************************************************/
 
 static int
-ReadXim(FILE *     const in_fp,
-        XimImage * const xim) {
+readXim(FILE *     const ifP,
+        XimImage * const ximP) {
 
-    if (!ReadXimHeader(in_fp, xim)) {
-        pm_message("can't read xim header" );
-        return 0;
-    } else if (!ReadXimImage(in_fp, xim)) {
-        pm_message("can't read xim data" );
-        return 0;
+    int retval;
+
+    if (!readXimHeader(ifP, ximP)) {
+        pm_message("can't read xim header");
+        retval = 0;
+    } else if (!readXimImage(ifP, ximP)) {
+        pm_message("can't read xim data");
+        retval = 0;
     } else
-        return 1;
+        retval = 1;
+
+    return retval;
 }
 
 
@@ -327,44 +343,48 @@ main(int          argc,
      const char **argv) {
 
     struct CmdlineInfo cmdline;
-    FILE *ifP, *imageout_file, *alpha_file;
+    FILE * ifP;
+    FILE * imageoutFileP;
+    FILE * alphaFileP;
     XimImage xim;
-    pixel *pixelrow, colormap[256];
-    gray *alpharow;
-        /* The alpha channel of the row we're currently converting, in
-           pgm fmt
+    pixel * pixelrow;
+    pixel colormap[256];
+    gray * alpharow;
+        /* The alpha channel of the row we're currently converting, in PGM fmt
         */
-    int rows, cols, row, mapped;
+    unsigned int rows, cols;
+    unsigned int row;
+    bool mapped;
     pixval maxval;
-    bool success;
+    bool succeeded;
 
     pm_proginit(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
-    ifP = pm_openr(cmdline.input_filename);
+    ifP = pm_openr(cmdline.inputFilename);
 
-    if (cmdline.alpha_stdout)
-        alpha_file = stdout;
-    else if (cmdline.alpha_filename == NULL)
-        alpha_file = NULL;
+    if (cmdline.alphaStdout)
+        alphaFileP = stdout;
+    else if (cmdline.alphaFilename == NULL)
+        alphaFileP = NULL;
     else
-        alpha_file = pm_openw(cmdline.alpha_filename);
+        alphaFileP = pm_openw(cmdline.alphaFilename);
 
-    if (cmdline.alpha_stdout)
-        imageout_file = NULL;
+    if (cmdline.alphaStdout)
+        imageoutFileP = NULL;
     else
-        imageout_file = stdout;
+        imageoutFileP = stdout;
 
-    success = ReadXim(ifP, &xim);
-    if (!success)
+    succeeded = readXim(ifP, &xim);
+    if (!succeeded)
         pm_error("can't read Xim file");
 
     rows = xim.height;
     cols = xim.width;
 
     if (xim.nchannels == 1 && xim.bits_channel == 8) {
-        int i;
+        unsigned int i;
 
         mapped = true;
         maxval = 255;
@@ -382,27 +402,29 @@ main(int          argc,
             "unknown Xim file type, nchannels == %d, bits_channel == %d",
             xim.nchannels, xim.bits_channel);
 
-    if (imageout_file)
-        ppm_writeppminit(imageout_file, cols, rows, maxval, 0);
-    if (alpha_file)
-        pgm_writepgminit(alpha_file, cols, rows, maxval, 0);
+    if (imageoutFileP)
+        ppm_writeppminit(imageoutFileP, cols, rows, maxval, 0);
+    if (alphaFileP)
+        pgm_writepgminit(alphaFileP, cols, rows, maxval, 0);
 
     pixelrow = ppm_allocrow(cols);
     alpharow = pgm_allocrow(cols);
 
     for (row = 0; row < rows; ++row) {
         if (mapped) {
-            byte * const ximrow = xim.data + row * xim.bytes_per_line;
+            byte * const ximrow = &xim.data[row * xim.bytes_per_line];
+
             unsigned int col;
 
             for (col = 0; col < cols; ++col)
                 pixelrow[col] = colormap[ximrow[col]];
+
             alpharow[col] = 0;
         } else {
-            byte * const redrow = xim.data     + row * xim.bytes_per_line;
-            byte * const grnrow = xim.grn_data + row * xim.bytes_per_line;
-            byte * const blurow = xim.blu_data + row * xim.bytes_per_line;
-            byte * const othrow = xim.other    + row * xim.bytes_per_line;
+            byte * const redrow = &xim.data     [row * xim.bytes_per_line];
+            byte * const grnrow = &xim.grn_data [row * xim.bytes_per_line];
+            byte * const blurow = &xim.blu_data [row * xim.bytes_per_line];
+            byte * const othrow = &xim.other    [row * xim.bytes_per_line];
 
             unsigned int col;
 
@@ -415,16 +437,16 @@ main(int          argc,
                     alpharow[col] = 0;
             }
         }
-        if (imageout_file)
-            ppm_writeppmrow(imageout_file, pixelrow, cols, maxval, 0);
-        if (alpha_file)
-            pgm_writepgmrow(alpha_file, alpharow, cols, maxval, 0);
+        if (imageoutFileP)
+            ppm_writeppmrow(imageoutFileP, pixelrow, cols, maxval, 0);
+        if (alphaFileP)
+            pgm_writepgmrow(alphaFileP, alpharow, cols, maxval, 0);
     }
     pm_close(ifP);
-    if (imageout_file)
-        pm_close(imageout_file);
-    if (alpha_file)
-        pm_close(alpha_file);
+    if (imageoutFileP)
+        pm_close(imageoutFileP);
+    if (alphaFileP)
+        pm_close(alphaFileP);
 
     return 0;
 }
diff --git a/converter/ppm/yuvsplittoppm.c b/converter/ppm/yuvsplittoppm.c
index 5343a21e..b734be91 100644
--- a/converter/ppm/yuvsplittoppm.c
+++ b/converter/ppm/yuvsplittoppm.c
@@ -43,12 +43,12 @@ struct cmdlineInfo {
 
 
 static void
-parseCommandLine(int                 argc, 
+parseCommandLine(int                 argc,
                  char **             argv,
                  struct cmdlineInfo *cmdlineP ) {
 /*----------------------------------------------------------------------------
    Parse program command line described in Unix standard form by argc
-   and argv.  Return the information in the options as *cmdlineP.  
+   and argv.  Return the information in the options as *cmdlineP.
 
    If command line is internally inconsistent (invalid options, etc.),
    issue error message to stderr and abort program.
@@ -64,7 +64,7 @@ parseCommandLine(int                 argc,
     unsigned int option_def_index;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "ccir601",     OPT_FLAG,   NULL,                  
+    OPTENT3(0, "ccir601",     OPT_FLAG,   NULL,
             &cmdlineP->ccir601,       0);
 
     opt.opt_table = option_def;
@@ -103,13 +103,13 @@ computeTwoOutputRows(int             const cols,
                      unsigned char * const vbuf,
                      pixel *         const pixelrow1,
                      pixel *         const pixelrow2) {
-                     
+
     int col;
 
     for (col = 0; col < cols; col += 2) {
         long int r0,g0,b0,r1,g1,b1,r2,g2,b2,r3,g3,b3;
         long int  u,v,y0,y1,y2,y3,u0,u1,u2,u3,v0,v1,v2,v3;
-        
+
         y0 = y1buf[col];
         y1 = y1buf[col+1];
         y2 = y2buf[col];
@@ -117,7 +117,7 @@ computeTwoOutputRows(int             const cols,
 
         u = ubuf[col/2] - 128;
         v = vbuf[col/2] - 128;
-        
+
         if (ccir601) {
             y0 = ((y0-16)*255)/219;
             y1 = ((y1-16)*255)/219;
@@ -128,7 +128,7 @@ computeTwoOutputRows(int             const cols,
             v  = (v*255)/224 ;
         }
         /* mean the chroma for subsampling */
-        
+
         u0=u1=u2=u3=u;
         v0=v1=v2=v3=v;
 
@@ -138,25 +138,25 @@ computeTwoOutputRows(int             const cols,
            [Y]   [65496        0   91880] [R]
            [U] = [65533   -22580  -46799] [G]
            [V]   [65537   116128      -8] [B]
-           
+
         */
 
         r0 = 65536 * y0               + 91880 * v0;
         g0 = 65536 * y0 -  22580 * u0 - 46799 * v0;
         b0 = 65536 * y0 + 116128 * u0             ;
-        
+
         r1 = 65536 * y1               + 91880 * v1;
         g1 = 65536 * y1 -  22580 * u1 - 46799 * v1;
         b1 = 65536 * y1 + 116128 * u1             ;
-        
+
         r2 = 65536 * y2               + 91880 * v2;
         g2 = 65536 * y2 -  22580 * u2 - 46799 * v2;
         b2 = 65536 * y2 + 116128 * u2             ;
-        
+
         r3 = 65536 * y3               + 91880 * v3;
         g3 = 65536 * y3 -  22580 * u3 - 46799 * v3;
         b3 = 65536 * y3 + 116128 * u3             ;
-        
+
         r0 = limit(r0);
         r1 = limit(r1);
         r2 = limit(r2);
@@ -195,7 +195,7 @@ main(int argc, char **argv) {
     ppm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
-        
+
     pm_asprintf(&ufname, "%s.U", cmdline.filenameBase);
     pm_asprintf(&vfname, "%s.V", cmdline.filenameBase);
     pm_asprintf(&yfname, "%s.Y", cmdline.filenameBase);
@@ -215,7 +215,7 @@ main(int argc, char **argv) {
     if (cmdline.height % 2 != 0) {
         pm_message("Warning: odd height; last row ignored");
         rows = cmdline.height - 1;
-    } else 
+    } else
         rows = cmdline.height;
 
     pixelrow1 = ppm_allocrow(cols);
@@ -251,3 +251,6 @@ main(int argc, char **argv) {
 
     exit(0);
 }
+
+
+
diff --git a/converter/ppm/yuvtoppm.c b/converter/ppm/yuvtoppm.c
index 9c5d79c4..87f541e5 100644
--- a/converter/ppm/yuvtoppm.c
+++ b/converter/ppm/yuvtoppm.c
@@ -2,7 +2,7 @@
 **
 ** by Marc Boucher
 ** Internet: marc@PostImage.COM
-** 
+**
 ** Based on Example Conversion Program, A60/A64 Digital Video Interface
 ** Manual, page 69
 **
@@ -72,7 +72,7 @@ parseCommandLine(int argc, const char ** argv,
 
         cmdlineP->cols = widthArg;
         cmdlineP->rows = heightArg;
-                 
+
         if (cmdlineP->cols % 2 != 0)
             pm_error("Number of columns (%u) is odd.  "
                      "A YUV image must have an "
@@ -213,9 +213,12 @@ main (int argc, const char ** argv) {
     ifP = pm_openr(cmdline.inputFileName);
 
     yuvtoppm(ifP, cmdline.cols, cmdline.rows, stdout);
-    
+
     pm_close(ifP);
     pm_close(stdout);
 
     return 0;
 }
+
+
+