about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-09-26 20:20:52 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-09-26 20:20:52 +0000
commit2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94 (patch)
treeb062862164ab41e78b5efc436330db65cb2887f9
parent68256547a054109f09c55e2e913df2dfdd2144ff (diff)
downloadnetpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.tar.gz
netpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.tar.xz
netpbm-mirror-2087fc45bd38ac1dd3b90789c5bfb94f2dbbad94.zip
Rebase 'advanced' to 10.40.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@416 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--Makefile3
-rw-r--r--Makefile.config.in4
-rw-r--r--Makefile.version4
-rw-r--r--README206
-rw-r--r--converter/other/Makefile2
-rw-r--r--converter/other/fiasco/lib/misc.c32
-rw-r--r--converter/other/fiasco/params.c3
-rw-r--r--converter/other/giftopnm.c4
-rw-r--r--converter/other/hdifftopam.c2
-rw-r--r--converter/other/jpegtopnm.c8
-rw-r--r--converter/other/pamtogif.c6
-rw-r--r--converter/other/pamtouil.c6
-rw-r--r--converter/other/pnmtopclxl.c2
-rw-r--r--converter/other/pnmtopng.c8
-rw-r--r--converter/other/pnmtops.c2
-rw-r--r--converter/other/pnmtotiffcmyk.c2
-rw-r--r--converter/other/pnmtoxwd.c2
-rw-r--r--converter/other/pstopnm.c149
-rw-r--r--converter/other/rletopnm.c4
-rw-r--r--converter/other/tiff.c6
-rw-r--r--converter/other/tifftopnm.c4
-rw-r--r--converter/other/xwdtopnm.c2
-rw-r--r--converter/pbm/atktopbm.c2
-rw-r--r--converter/pbm/g3topbm.c12
-rw-r--r--converter/pbm/icontopbm.c12
-rw-r--r--converter/pbm/mrftopbm.c2
-rw-r--r--converter/pbm/pbmto4425.c2
-rw-r--r--converter/pbm/pbmtoatk.c2
-rw-r--r--converter/pbm/pbmtoln03.c5
-rw-r--r--converter/pbm/pbmtolps.c2
-rw-r--r--converter/pbm/pbmtonokia.c20
-rw-r--r--converter/pbm/pbmtopk.c2
-rw-r--r--converter/pbm/pbmtoxbm.c2
-rw-r--r--converter/pbm/pbmtozinc.c2
-rw-r--r--converter/pbm/pktopbm.c2
-rw-r--r--converter/pbm/xbmtopbm.c4
-rw-r--r--converter/pgm/asciitopgm.c2
-rw-r--r--converter/pgm/hipstopgm.c2
-rw-r--r--converter/pgm/lispmtopgm.c2
-rw-r--r--converter/pgm/sbigtopgm.c2
-rw-r--r--converter/ppm/picttoppm.c2
-rw-r--r--converter/ppm/ppmtoarbtxt.c24
-rw-r--r--converter/ppm/ppmtompeg/param.c112
-rw-r--r--converter/ppm/ppmtopj.c6
-rw-r--r--converter/ppm/ppmtoxpm.c2
-rw-r--r--converter/ppm/sldtoppm.c6
-rw-r--r--converter/ppm/tgatoppm.c2
-rw-r--r--converter/ppm/winicontoppm.c4
-rw-r--r--converter/ppm/ximtoppm.c2
-rw-r--r--converter/ppm/xpmtoppm.c14
-rw-r--r--converter/ppm/xvminitoppm.c6
-rw-r--r--doc/HISTORY69
-rw-r--r--doc/INSTALL16
-rw-r--r--editor/pamfunc.c190
-rw-r--r--editor/pammixinterlace.c4
-rw-r--r--editor/pnmconvol.c20
-rw-r--r--editor/pnmgamma.c19
-rwxr-xr-xeditor/pnmmargin14
-rw-r--r--editor/pnmsmooth.c39
-rw-r--r--editor/ppmcolormask.c2
-rw-r--r--generator/ppmrough.c5
-rw-r--r--lib/Makefile2
-rw-r--r--lib/libpbm2.c50
-rw-r--r--lib/libpgm.h9
-rw-r--r--lib/libpgm1.c41
-rw-r--r--lib/libpgm2.c29
-rw-r--r--lib/libpm.c3
-rw-r--r--lib/libppm1.c48
-rw-r--r--lib/libsystem.c242
-rw-r--r--lib/pm_system.h17
-rw-r--r--lib/util/mallocvar.h15
-rw-r--r--lib/util/nstring.c13
-rw-r--r--lib/util/nstring.h58
-rw-r--r--other/pamx/window.c4
-rw-r--r--urt/rle_open_f.c116
75 files changed, 901 insertions, 844 deletions
diff --git a/Makefile b/Makefile
index 2227eb5c..7f946702 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,11 @@
 # GNU Make uses a make file named "GNUmakefile" in preference to "Makefile"
 # if it exists.  Netpbm is shipped with a "GNUmakefile".
 
+default: all
+
 all merge install clean dep:
 	@echo "You must use GNU Make to build Netpbm.  You are running some "
 	@echo "other Make.  GNU Make may be installed on your system with "
 	@echo "the name 'gmake'.  If not, see http://www.gnu.org/software ."
 	@echo
+	false
diff --git a/Makefile.config.in b/Makefile.config.in
index 4929a6d8..2cf49fa6 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -153,7 +153,7 @@ LEX = flex
 # -pedantic isn't a problem because it causes at worst a warning.
 #CFLAGS = -O3 -ffast-math -pedantic -fno-common \
 #          -Wall -Wno-uninitialized -Wmissing-declarations -Wimplicit \
-#          -Wwrite-string -Wmissing-prototypes -Wundef
+#          -Wwrite-strings -Wmissing-prototypes -Wundef
 # The merged programs have a main_XXX subroutine instead of main(),
 # which would cause a warning with -Wmissing-declarations or 
 # -Wmissing-prototypes.
@@ -313,7 +313,7 @@ CFLAGS_SHLIB =
 
 SHLIB_CLIB = -lc
 # SCO:
-SHLIB_CLIB =
+#SHLIB_CLIB =
 
 # On some systems you have to build into an executable the list of
 # directories where its dynamically linked libraries can be found at
diff --git a/Makefile.version b/Makefile.version
index 678c881c..2ae77b21 100644
--- a/Makefile.version
+++ b/Makefile.version
@@ -1,4 +1,4 @@
 NETPBM_MAJOR_RELEASE = 10
-NETPBM_MINOR_RELEASE = 39
-NETPBM_POINT_RELEASE = 06
+NETPBM_MINOR_RELEASE = 40
+NETPBM_POINT_RELEASE = 00
 
diff --git a/README b/README
index ece3a32d..7209c8e6 100644
--- a/README
+++ b/README
@@ -1,10 +1,7 @@
 
-                              NETPBM
+                                 NETPBM
 
-
-THIS IS THE PRIMARY DOCUMENTATION DISTRIBUTED WITH NETPBM.  SEE THE doc
-DIRECTORY IN THE SOURCE TREE FOR OTHER INFORMATION, SUCH AS INSTALLATION
-INSTRUCTIONS, AND SEE <http://netpbm.sourceforge.net>.
+This file is part of the source tree for Netpbm.
 
 Netpbm is a toolkit for manipulation of graphic images, including
 conversion of images between a variety of different formats.  There
@@ -14,200 +11,25 @@ manipulation we're talking about are: Shrinking an image by 10%;
 Cutting the top half off of an image; Making a mirror image; Creating
 a sequence of images that fade from one image to another;
 
-For more information on what the package does, see
-<http://netpbm.sourceforge.net/doc>.
-
-The package is intended to be portable to many platforms. It has, at
-least at one time, been tested under various Unix-based systems,
-Windows, Mac OS X, VMS and Amiga OS.  The maintainer uses and builds
-it on a platform that consists (in relevant part) mainly of GNU
-software (you probably know this kind of system by the name "Linux").
-
-The goal of Netpbm is to be a single source for all the primitive
-graphics utilities, especially converters, one might need.  So if you
-know of some freely redistributable software in this vein which is not
-in the package yet, you should bring it to the attention of the Netpbm
-maintainer so it can be included in the next release.
-
-Netpbm does not contain interactive tools and doesn't have a graphical
-interface.
-
-Netpbm replaces the widely spread Pbmplus package (last released
-December 10, 1991).  A lot of improvements and additions have been
-made.  After the latest release of Pbmplus, a lot of additional
-filters began circulating on the net, which was a fairly novel state
-of affairs at the time.  The aim of Netpbm was to collect these and to
-turn them into a package, hence the name "Netpbm."  This work has been
-performed by programmers all over the world.  If _you_ have some code
-to add, please contact the Netpbm maintainer.
-
-
-USING NETPBM IN A WEBSITE
--------------------------
-
-Many people use Netpbm to perform graphics functions in a web site.  They
-have CGI scripts that invoke Netpbm programs to process images for display
-on a web page.  Gallery and 4Images are two web site software packages
-that rely on Netpbm for graphics manipulation.
-
-Installing Netpbm requires different skills and system access than 
-installing most other web site software.  You must be able to compile
-C code for the web server machine and have a basic understanding of 
-how files are organized and programs run on the web server.  Diagnosing
-inevitable problems usually requires shell access to the web server.
-
-Netpbm is basic graphics software that ought to be supplied by any
-web hosting service.  If it isn't on your web server already, you should
-request that the system administrator add it.
-
-The Gallery project provides an easy install package for the parts of
-Netpbm that Gallery needs, and provides technical support at:
-
-    http://gallery.sourceforge.net/forums.php
-
-
-DISTRIBUTION
-------------
-
-You'll find the latest release of Netpbm source code at
-<http://prdownloads.sourceforge.net/netpbm/>.
-
-The user manual is not in the source code package.  It is available online
-at <http://netpbm.sourceforge.net/doc> and you can download it from there.
-See the file doc/USERDOC for details.
-
-A list of prebuilt Netpbm distributions is on the Netpbm
-website, <http://netpbm.sourceforge.net>.
-
-
-PREREQUISITES
--------------
-
-Don't sweat the prerequisites too much.  In most cases, if you're
-missing something, the build of the programs that depend on it will
-bomb, but the rest of the Netpbm programs will build just fine.  And
-you may not need the more demanding programs.
-
-If you have trouble getting, building, or installing the
-prerequisites, the Netpbm maintainer wants to know.  Since he uses
-them himself, he can help you.  And if there is a problem with a
-prerequisite package that its own maintainer cannot fix, it may be
-possible to ship a fix with Netpbm.
-
-To build and install Netpbm, you need GNU Make and a Perl interpreter.
-You can get GNU Make from http://www.gnu.org/software and Perl from 
-http://www.cpan.org.  It's possible to get around the Perl requirement
-by running some of the steps on a different machine that has Perl and
-doing others manually.  There is no practical substitute for GNU Make.
-
-To build pnmtotiff or tifftopnm or pnmtotiffcmyk, you need the Tiff
-library.  You can get it from http://www.libtiff.org.
-
-To build ppmtojpeg or jpegtopnm, you need the JPEG/JFIF library from
-the Independent JPEG Group (IJG).  You can get it at
-ftp://ftp.uu.net/graphics/jpeg.  See http://www.ijg.org for more
-information.  You need Release 6b or better.  With earlier releases, Netpbm
-build fails with undefined jpeg symbols.  The basic JPEG library installation
-procedure installs only the runtime part of the package -- you nee the
-development part as well, so run 'make install-lib'.  The JPEG library 
-documentation erroneously calls this installing "the library itself."
-This apparently was written before shared libraries.  With shared libraries,
-"the library itself" is part of the runtime installation, but install-lib
-still installs the compile-time stuff you need.
-
-You may also need the JPEG library to build the Tiff converters.  If
-your Tiff library references a shared JPEG library, then you do.  The
-Tiff library may also include a static copy of the JPEG library, in
-which case you won't need a separate JPEG library.  Or it may have
-been built without any JPEG compression capability, in which case you
-won't need a separate JPEG library, but the Tiff converters won't be
-able to handle Tiff with JPEG compression.
-
-The same goes for Ppmtompeg.  You need the jpeg library if you want to
-create MPEGs from JPEGs (without the loss of quality that comes with
-converting from JPEG to PPM first), and if you don't have the JPEG
-library and don't say so in Makefile.config, you won't be able to
-build Ppmtompeg at all.
-
-To build or use Pnmtopng and Pngtopnm, you need the Zlib compression
-library and the PNG library (libpng).  You can get Zlib from
-ftp://quest.jpl.nasa.gov/pub/zlib or
-ftp://metalab.unc.edu/pub/Linux/libs.  You can get libpng from
-http://www.libpng.org/pub/png/libpng.html or
-http://libpng.sourceforge.net.  Older libpng won't work -- you get
-unresolved external references to png_sig_cmp and png_set_sig_bytes.
-
-You may also need the Zlib library to build the Tiff converters, in
-the same way as the Tiff converters require the JPEG libraries, as
-explained above.
-
-Pstopnm (the Postscript to PNM image converter) requires Ghostscript
-(installed with the name 'gs' in your command search path).  And it 
-requires in particular that Ghostscript be built with the relevant 
-PNM device drivers.  See http://www.ghostscript.com/doc/GPL/ .
-
-The Utah Raster Toolkit is not a prerequisite because Netpbm includes
-a subset of it that meets the needs of Pnmtorle and Rletopnm.
-However, you can also substitute the real package by properly
-configuring Makefile.config.  You can get it from 
-ftp://ftp.cs.utah.edu/pub/dept/OLD/pub/urt-3.1b.tar.Z.  There's a 
-patch at ftp://ptolemy.berkeley.edu/pub/misc/urt/urt-3.1b-3.1b1.patch
-
-You generally need a compiler other than Gcc 2.96.  Gcc 2.96 has a bug
-in its inlining optimization.  It generates incorrect code.  Netpbm
-source code takes advantage of inlining and you normally build Netpbm
-with inlining enabled.  Therefore, if you use Gcc 2.96 you will get
-broken Netpbm programs.  The usual symptom is bogus syntax error
-messages when you run the program.  You can avoid this compiler bug by
-using a -O0 compile option instead of the usual -O3.  The automatic
-configuration program will usually detect that you need this and set
-it up for you.  This will make some programs noticeably slower,
-though.
-
-Netpbm requires about 3.5 MiB of disk space, not including documentation.
-The documentation is 1.1 MiB, but you don't necessarily have to install
-it; you can just access the public copy.
-
-
-INSTALLATION
-------------
-
-See doc/INSTALL.
-
-
-SUPPORT
--------
-
-The maintainer of Netpbm, since September 1999, is Bryan Henderson:
+For more information, see <http://netpbm.sourceforge.net>.  Examples of
+information there:
 
-  bryanh@giraffe-data.com.  
+  - How to use Netpbm
 
-If for some reason that email address doesn't work, you can reach
-Bryan at giraffedata@yahoo.com as a backup.  Please don't mail to 
-both at the same time.  Bryan doesn't need two copies of your email.
+  - Where to get current Netpbm code
 
-Bryan actively maintains the package and wants to know about any bugs
-or problems people have with Netpbm or suggestions for improvement.
+  - What prerequisites there are and how to satisfy them
 
-There is no bug reporting database or mailing list.  These would not
-be very useful with Netpbm because Bryan personally responds to all
-bug reports and requests for help immediately.  All known bugs in the
-"latest" release are listed in its release notes on Sourceforge
-(updated as the bugs are reported) and the "stable" release is
-generally maintained so as not to have known bugs for more than a few
-days.  The doc/HISTORY file in the package may be useful if you want
-to find out whether upgrading to the current release would solve your
-problem.  The information in that file, on a per-release basis, is 
-also in the change histories on Sourceforge.
+  - How to get help using Netpbm
 
+  - How to report a bug or suggest an enhancement
 
+  - How to contribute code
 
-MORE INFORMATION, DOCUMENTATION
--------------------------------
+The doc/ directory of the source tree contains further documentation, mainly
+of use only to someone who already has the source code.  For example:
 
-For more information about Netpbm, see <http://netpbm.sourceforge.net/doc>.
+  - Build and installation instructions
 
-The 'doc' directory in the source tree has more information.
+  - Where to get the manual (it's not in the source tree).
 
-A good place to start for information about the wide world of computer
-graphics is http://www.faqs.org/faqs/graphics/  .
diff --git a/converter/other/Makefile b/converter/other/Makefile
index 3b6d8288..976c215a 100644
--- a/converter/other/Makefile
+++ b/converter/other/Makefile
@@ -221,8 +221,10 @@ install.bin.local: $(PKGDIR)/bin
 	cd $(PKGDIR)/bin ; \
 	$(SYMLINK) gemtopnm$(EXE) gemtopbm
 # In October 2001, pnmtojpeg replaced ppmtojpeg
+ifneq ($(JPEGLIB),NONE)
 	cd $(PKGDIR)/bin ; \
 	$(SYMLINK) pnmtojpeg$(EXE) ppmtojpeg
+endif
 # In March 2002, bmptopnm replaced bmptoppm
 	cd $(PKGDIR)/bin ; \
 	$(SYMLINK) bmptopnm$(EXE) bmptoppm
diff --git a/converter/other/fiasco/lib/misc.c b/converter/other/fiasco/lib/misc.c
index 02a1314f..12b94e7a 100644
--- a/converter/other/fiasco/lib/misc.c
+++ b/converter/other/fiasco/lib/misc.c
@@ -432,38 +432,6 @@ Log2 (double x)
    return log (x) / 0.69314718;
 }
 
-#ifndef HAVE_STRCASECMP
-bool_t
-strcaseeq (const char *s1, const char *s2)
-/*
- *  Compare strings 's1' and 's2', ignoring  the  case of the characters.
- *
- *  Return value:
- *	TRUE if strings match, else FALSE
- */
-{
-   bool_t  matched;
-   char	  *ls1, *ls2, *ptr;
-
-   assert (s1 && s2);
-   
-   ls1 = strdup (s1);
-   ls2 = strdup (s2);
-   
-   for (ptr = ls1; *ptr; ptr++)
-      *ptr = tolower (*ptr);
-   for (ptr = ls2; *ptr; ptr++)
-      *ptr = tolower (*ptr);
-
-   matched = streq (ls1, ls2) ? YES : NO;
-
-   Free (ls1);
-   Free (ls2);
-   
-   return matched;
-}
-#endif /* not HAVE_STRCASECMP */
-
 real_t
 variance (const word_t *pixels, unsigned x0, unsigned y0,
 	  unsigned width, unsigned height, unsigned cols)
diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c
index 3d0a0252..7a302b82 100644
--- a/converter/other/fiasco/params.c
+++ b/converter/other/fiasco/params.c
@@ -15,7 +15,8 @@
  *  $State: Exp $
  */
 
-#define _BSD_SOURCE 1   /* Make sure strdup() is in string.h */
+#define _BSD_SOURCE 1
+    /* Make sure strdup() is in string.h and strcaseeq() is in nstring.h */
 #define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */
 
 #include "config.h"
diff --git a/converter/other/giftopnm.c b/converter/other/giftopnm.c
index 0e261da4..a79a0bbe 100644
--- a/converter/other/giftopnm.c
+++ b/converter/other/giftopnm.c
@@ -1336,7 +1336,7 @@ readGifHeader(FILE * const gifFile, struct gifScreen * const gifScreenP) {
     if (verbose)
         pm_message("GIF format version is '%s'", version);
     
-    if ((!STREQ(version, "87a")) && (!STREQ(version, "89a")))
+    if ((!streq(version, "87a")) && (!streq(version, "89a")))
         pm_error("bad version number, not '87a' or '89a'" );
     
     if (! ReadOK(gifFile,buf,7))
@@ -1658,7 +1658,7 @@ main(int argc, char **argv) {
     else
         alpha_file = pm_openw(cmdline.alpha_filename);
 
-    if (alpha_file && STREQ(cmdline.alpha_filename, "-"))
+    if (alpha_file && streq(cmdline.alpha_filename, "-"))
         imageout_file = NULL;
     else
         imageout_file = stdout;
diff --git a/converter/other/hdifftopam.c b/converter/other/hdifftopam.c
index 0f1a5ca3..48282526 100644
--- a/converter/other/hdifftopam.c
+++ b/converter/other/hdifftopam.c
@@ -106,7 +106,7 @@ main(int argc, char *argv[]) {
 
     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);
 
diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
index 180ef3d4..4679d497 100644
--- a/converter/other/jpegtopnm.c
+++ b/converter/other/jpegtopnm.c
@@ -240,11 +240,11 @@ parseCommandLine(int                  const argc,
     if (!dctvalSpec)
         cmdlineP->dct_method = JDCT_DEFAULT;
     else {
-        if (STREQ(dctval, "int"))
+        if (streq(dctval, "int"))
             cmdlineP->dct_method = JDCT_ISLOW;
-        else if (STREQ(dctval, "fast"))
+        else if (streq(dctval, "fast"))
             cmdlineP->dct_method = JDCT_IFAST;
-        else if (STREQ(dctval, "float"))
+        else if (streq(dctval, "float"))
             cmdlineP->dct_method = JDCT_FLOAT;
         else pm_error("Invalid value for the --dct option: '%s'.", dctval);
     }
@@ -952,7 +952,7 @@ main(int argc, char **argv) {
 
     parseCommandLine(argc, argv, &cmdline);
 
-    if (cmdline.exif_filespec && STREQ(cmdline.exif_filespec, "-"))
+    if (cmdline.exif_filespec && streq(cmdline.exif_filespec, "-"))
         /* He's got exif going to stdout, so there can be no image output */
         ofP = NULL;
     else
diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c
index 68a445c6..edaf0695 100644
--- a/converter/other/pamtogif.c
+++ b/converter/other/pamtogif.c
@@ -91,11 +91,11 @@ pamAlphaPlane(struct pam * const pamP) {
 
     unsigned int alphaPlane;
 
-    if (STREQ(pamP->tuple_type, "RGB_ALPHA"))
+    if (streq(pamP->tuple_type, "RGB_ALPHA"))
         alphaPlane = 3;
-    else if (STREQ(pamP->tuple_type, "GRAYSCALE_ALPHA"))
+    else if (streq(pamP->tuple_type, "GRAYSCALE_ALPHA"))
         alphaPlane = 2;
-    else if (STREQ(pamP->tuple_type, "BLACKANDWHITE_ALPHA"))
+    else if (streq(pamP->tuple_type, "BLACKANDWHITE_ALPHA"))
         alphaPlane = 2;
     else
         alphaPlane = 0;
diff --git a/converter/other/pamtouil.c b/converter/other/pamtouil.c
index b9ddc749..58f57eef 100644
--- a/converter/other/pamtouil.c
+++ b/converter/other/pamtouil.c
@@ -95,10 +95,10 @@ parseCommandLine(int argc, char ** argv,
 
         /* Remove trailing "_icon" */
         barPos = strrchr(cmdlineP->outname, '_');
-        if (STREQ(barPos, "_icon")) 
+        if (streq(barPos, "_icon")) 
             *barPos = '\0';
     } else {
-        if (STREQ(cmdlineP->inputFilespec, "-"))
+        if (streq(cmdlineP->inputFilespec, "-"))
             cmdlineP->outname = strdup("noname");
         else {
             char * dotPos;
@@ -237,7 +237,7 @@ genCmap(struct pam *   const pamP,
         nameAlreadyInCmap = FALSE;   /* initial assumption */
         for (j = 0; j < colorIndex; ++j) {
             if (cmap[j].rgbname != NULL && 
-                STREQ(colorname, cmap[j].rgbname) &&
+                streq(colorname, cmap[j].rgbname) &&
                 cmap[j].transparent == transparent) {
                 nameAlreadyInCmap = TRUE;
                 indexOfName = j;
diff --git a/converter/other/pnmtopclxl.c b/converter/other/pnmtopclxl.c
index fe4833d8..7ba64210 100644
--- a/converter/other/pnmtopclxl.c
+++ b/converter/other/pnmtopclxl.c
@@ -153,7 +153,7 @@ parseCommandLine(int argc, char ** argv,
         bool found;
         int i;
         for (i = 0, found=FALSE; xlPaperFormats[i].name && !found; ++i) {
-            if (STREQ(xlPaperFormats[i].name, formatOpt)) {
+            if (streq(xlPaperFormats[i].name, formatOpt)) {
                 found = TRUE;
                 cmdlineP->format = xlPaperFormats[i].xl_nr;
             }
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c
index 83860ffa..b339a1fe 100644
--- a/converter/other/pnmtopng.c
+++ b/converter/other/pnmtopng.c
@@ -52,8 +52,6 @@
    because xels were only 24 bits.  Now they're 96.
 */
    
-#define GRR_GRAY_PALETTE_FIX
-
 #ifndef PNMTOPNG_WARNING_LEVEL
 #  define PNMTOPNG_WARNING_LEVEL 0   /* use 0 for backward compatibility, */
 #endif                               /*  2 for warnings (1 == error) */
@@ -464,7 +462,7 @@ parseCommandLine(int argc, char ** argv,
     }
 
     if (cmdlineP->zlibCompression.methodSpec) {
-        if (STREQ(compMethod, "deflated"))
+        if (streq(compMethod, "deflated"))
             cmdlineP->zlibCompression.method = Z_DEFLATED;
         else
             pm_error("The only valid value for -method is 'deflated'.  "
@@ -472,9 +470,9 @@ parseCommandLine(int argc, char ** argv,
     }
 
     if (cmdlineP->zlibCompression.strategySpec) {
-        if (STREQ(compStrategy, "huffman_only"))
+        if (streq(compStrategy, "huffman_only"))
             cmdlineP->zlibCompression.strategy = Z_HUFFMAN_ONLY;
-        else if (STREQ(compStrategy, "filtered"))
+        else if (streq(compStrategy, "filtered"))
             cmdlineP->zlibCompression.strategy = Z_FILTERED;
         else
             pm_error("Valid values for -strategy are 'huffman_only' and "
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 5b12cee9..410fa0b9 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -1295,7 +1295,7 @@ main(int argc, char * argv[]) {
 
     ifp = pm_openr(cmdline.inputFileName);
 
-    if (STREQ(cmdline.inputFileName, "-"))
+    if (streq(cmdline.inputFileName, "-"))
         name = strdup("noname");
     else
         name = basebasename(cmdline.inputFileName);
diff --git a/converter/other/pnmtotiffcmyk.c b/converter/other/pnmtotiffcmyk.c
index 0fda6b08..9b5f25d4 100644
--- a/converter/other/pnmtotiffcmyk.c
+++ b/converter/other/pnmtotiffcmyk.c
@@ -794,7 +794,7 @@ standardOpt( Conv *conv, Root *r, int *argn, int argc, char **argv ) {
   }
   /* handle the special case of -1 (no removal) */
   if ( oldn == *argn && pm_keymatch( argv[*argn], "-gammap", 7 ) &&
-       *argn + 1 < argc && STREQ(argv[*argn + 1], "-1") ) {
+       *argn + 1 < argc && streq(argv[*argn + 1], "-1") ) {
     p->remove = 0 ;
     *argn = (*argn) + 2 ;
   } 
diff --git a/converter/other/pnmtoxwd.c b/converter/other/pnmtoxwd.c
index 32fb8a7b..d0625b0b 100644
--- a/converter/other/pnmtoxwd.c
+++ b/converter/other/pnmtoxwd.c
@@ -471,7 +471,7 @@ main(int argc, char * argv[]) {
         }
     }
 
-    if (STREQ(cmdline.inputFilespec, "-"))
+    if (streq(cmdline.inputFilespec, "-"))
         dumpname = "stdin";
     else {
         if (strlen(cmdline.inputFilespec) > XWDVAL_MAX - sizeof(h11) - 1)
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index a31c3f64..f99478db 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -196,8 +196,9 @@ parseCommandLine(int argc, char ** argv,
 
 
 static void
-add_ps_to_filespec(const char orig_filespec[], char ** const new_filespec_p,
-                   const int verbose) {
+addPsToFilespec(char          const orig_filespec[],
+                const char ** const new_filespec_p,
+                bool          const verbose) {
 /*----------------------------------------------------------------------------
    If orig_filespec[] does not name an existing file, but the same
    name with ".ps" added to the end does, return the name with the .ps
@@ -288,13 +289,13 @@ computeSizeResBlind(unsigned int   const xmax,
 
 
 static void
-compute_size_res(struct cmdlineInfo const cmdline, 
-                 enum orientation   const orientation, 
-                 struct box         const bordered_box,
-                 unsigned int *     const xsizeP, 
-                 unsigned int *     const ysizeP,
-                 unsigned int *     const xresP, 
-                 unsigned int *     const yresP) {
+computeSizeRes(struct cmdlineInfo const cmdline, 
+               enum orientation   const orientation, 
+               struct box         const bordered_box,
+               unsigned int *     const xsizeP, 
+               unsigned int *     const ysizeP,
+               unsigned int *     const xresP, 
+               unsigned int *     const yresP) {
 /*----------------------------------------------------------------------------
   Figure out how big the output image should be (return as
   *xsizeP and *ysizeP) and what output device resolution Ghostscript
@@ -353,7 +354,8 @@ compute_size_res(struct cmdlineInfo const cmdline,
 enum postscript_language {COMMON_POSTSCRIPT, ENCAPSULATED_POSTSCRIPT};
 
 static enum postscript_language
-language_declaration(const char input_filespec[], int const verbose) {
+languageDeclaration(char const input_filespec[],
+                    bool const verbose) {
 /*----------------------------------------------------------------------------
   Return the Postscript language in which the file declares it is written.
   (Except that if the file is on Standard Input or doesn't validly declare
@@ -361,7 +363,7 @@ language_declaration(const char input_filespec[], int const verbose) {
 -----------------------------------------------------------------------------*/
     enum postscript_language language;
 
-    if (STREQ(input_filespec, "-"))
+    if (streq(input_filespec, "-"))
         /* Can't read stdin, because we need it to remain positioned for the 
            Ghostscript interpreter to read it.
         */
@@ -395,9 +397,9 @@ language_declaration(const char input_filespec[], int const verbose) {
 
 
 static struct box
-compute_box_to_extract(struct box const cmdline_extract_box,
-                       char       const input_filespec[],
-                       bool       const verbose) {
+computeBoxToExtract(struct box const cmdline_extract_box,
+                    char       const input_filespec[],
+                    bool       const verbose) {
 
     struct box retval;
 
@@ -410,7 +412,7 @@ compute_box_to_extract(struct box const cmdline_extract_box,
         */
         struct box ps_bb;  /* Box described by %%BoundingBox stmt in input */
 
-        if (STREQ(input_filespec, "-"))
+        if (streq(input_filespec, "-"))
             /* Can't read stdin, because we need it to remain
                positioned for the Ghostscript interpreter to read it.  
             */
@@ -466,8 +468,8 @@ compute_box_to_extract(struct box const cmdline_extract_box,
 
 
 static enum orientation
-compute_orientation(struct cmdlineInfo const cmdline, 
-                    struct box         const extract_box) {
+computeOrientation(struct cmdlineInfo const cmdline, 
+                   struct box         const extract_box) {
 
     enum orientation retval;
     unsigned int const input_width  = extract_box.urx - extract_box.llx;
@@ -511,9 +513,10 @@ compute_orientation(struct cmdlineInfo const cmdline,
 
 
 static struct box
-add_borders(const struct box input_box, 
-            const float xborder_scale, float yborder_scale,
-            const int verbose) {
+addBorders(struct box const input_box, 
+           float      const xborder_scale,
+           float      const yborder_scale,
+           bool       const verbose) {
 /*----------------------------------------------------------------------------
    Return a box which is 'input_box' plus some borders.
 
@@ -543,9 +546,12 @@ add_borders(const struct box input_box,
 
 
 static const char *
-compute_pstrans(const struct box box, const enum orientation orientation,
-                const int xsize, const int ysize, 
-                const int xres, const int yres) {
+computePstrans(struct box       const box,
+               enum orientation const orientation,
+               int              const xsize,
+               int              const ysize, 
+               int              const xres,
+               int              const yres) {
 
     const char * retval;
 
@@ -570,13 +576,13 @@ compute_pstrans(const struct box box, const enum orientation orientation,
 
 
 static const char *
-compute_outfile_arg(const struct cmdlineInfo cmdline) {
+computeOutfileArg(struct cmdlineInfo const cmdline) {
 
     const char *retval;  /* malloc'ed */
 
     if (cmdline.goto_stdout)
         retval = strdup("-");
-    else if (STREQ(cmdline.input_filespec, "-"))
+    else if (streq(cmdline.input_filespec, "-"))
         retval = strdup("-");
     else {
         char * basename;
@@ -584,7 +590,7 @@ compute_outfile_arg(const struct cmdlineInfo cmdline) {
         
         basename  = strdup(cmdline.input_filespec);
         if (strlen(basename) > 3 && 
-            STREQ(basename+strlen(basename)-3, ".ps")) 
+            streq(basename+strlen(basename)-3, ".ps")) 
             /* The input filespec ends in ".ps".  Chop it off. */
             basename[strlen(basename)-3] = '\0';
 
@@ -605,7 +611,8 @@ compute_outfile_arg(const struct cmdlineInfo cmdline) {
 
 
 static const char *
-compute_gs_device(const int format_type, const int forceplain) {
+computeGsDevice(int  const format_type,
+                bool const forceplain) {
 
     const char * basetype;
     const char * retval;
@@ -673,19 +680,22 @@ findGhostscriptProg(const char ** const retvalP) {
 
 
 static void
-execGhostscript(int const inputPipeFd,
-                const char ghostscript_device[],
-                const char outfile_arg[], 
-                int const xsize, int const ysize, 
-                int const xres, int const yres,
-                const char input_filespec[], int const verbose) {
+execGhostscript(int  const inputPipeFd,
+                char const ghostscript_device[],
+                char const outfile_arg[], 
+                int  const xsize,
+                int  const ysize, 
+                int  const xres,
+                int  const yres,
+                char const input_filespec[],
+                bool const verbose) {
     
-    const char *arg0;
-    const char *ghostscriptProg;
-    const char *deviceopt;
-    const char *outfileopt;
-    const char *gopt;
-    const char *ropt;
+    const char * arg0;
+    const char * ghostscriptProg;
+    const char * deviceopt;
+    const char * outfileopt;
+    const char * gopt;
+    const char * ropt;
     int rc;
 
     findGhostscriptProg(&ghostscriptProg);
@@ -723,15 +733,17 @@ execGhostscript(int const inputPipeFd,
 
 
 
-
 static void
-execute_ghostscript(const char pstrans[], const char ghostscript_device[],
-                    const char outfile_arg[], 
-                    const int xsize, const int ysize, 
-                    const int xres, const int yres,
-                    const char input_filespec[], 
-                    const enum postscript_language language,
-                    const int verbose) {
+executeGhostscript(char                     const pstrans[],
+                   char                     const ghostscript_device[],
+                   char                     const outfile_arg[], 
+                   int                      const xsize,
+                   int                      const ysize, 
+                   int                      const xres,
+                   int                      const yres,
+                   char                     const input_filespec[], 
+                   enum postscript_language const language,
+                   bool                     const verbose) {
 
     int gs_exit;  /* wait4 exit code from Ghostscript */
     FILE *gs;  /* Pipe to Ghostscript's standard input */
@@ -835,10 +847,10 @@ execute_ghostscript(const char pstrans[], const char ghostscript_device[],
 
 
 int
-main(int argc, char **argv) {
+main(int argc, char ** argv) {
 
     struct cmdlineInfo cmdline;
-    char *input_filespec;  /* malloc'ed */
+    const char * input_filespec;  /* malloc'ed */
         /* The file specification of our Postscript input file */
     unsigned int xres, yres;    /* Resolution in pixels per inch */
     unsigned int xsize, ysize;  /* output image size in pixels */
@@ -851,43 +863,42 @@ main(int argc, char **argv) {
 
     enum postscript_language language;
     enum orientation orientation;
-    const char *ghostscript_device;
-    const char *outfile_arg;
-    const char *pstrans;
+    const char * ghostscript_device;
+    const char * outfile_arg;
+    const char * pstrans;
 
     pnm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
-    add_ps_to_filespec(cmdline.input_filespec, &input_filespec,
-                       cmdline.verbose);
+    addPsToFilespec(cmdline.input_filespec, &input_filespec, cmdline.verbose);
 
-    extract_box = compute_box_to_extract(cmdline.extract_box, input_filespec, 
-                                         cmdline.verbose);
+    extract_box = computeBoxToExtract(cmdline.extract_box, input_filespec, 
+                                      cmdline.verbose);
 
-    language = language_declaration(input_filespec, cmdline.verbose);
+    language = languageDeclaration(input_filespec, cmdline.verbose);
     
-    orientation = compute_orientation(cmdline, extract_box);
+    orientation = computeOrientation(cmdline, extract_box);
 
-    bordered_box = add_borders(extract_box, cmdline.xborder, cmdline.yborder,
-                               cmdline.verbose);
+    bordered_box = addBorders(extract_box, cmdline.xborder, cmdline.yborder,
+                              cmdline.verbose);
 
-    compute_size_res(cmdline, orientation, bordered_box, 
-                     &xsize, &ysize, &xres, &yres);
+    computeSizeRes(cmdline, orientation, bordered_box, 
+                   &xsize, &ysize, &xres, &yres);
     
-    pstrans = compute_pstrans(bordered_box, orientation,
-                              xsize, ysize, xres, yres);
+    pstrans = computePstrans(bordered_box, orientation,
+                             xsize, ysize, xres, yres);
 
-    outfile_arg = compute_outfile_arg(cmdline);
+    outfile_arg = computeOutfileArg(cmdline);
 
     ghostscript_device = 
-        compute_gs_device(cmdline.format_type, cmdline.forceplain);
+        computeGsDevice(cmdline.format_type, cmdline.forceplain);
     
     pm_message("Writing %s file", ghostscript_device);
     
-    execute_ghostscript(pstrans, ghostscript_device, outfile_arg, 
-                        xsize, ysize, xres, yres, input_filespec,
-                        language, cmdline.verbose);
+    executeGhostscript(pstrans, ghostscript_device, outfile_arg, 
+                       xsize, ysize, xres, yres, input_filespec,
+                       language, cmdline.verbose);
 
     strfree(ghostscript_device);
     strfree(outfile_arg);
diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c
index aaa86388..f98ea8a8 100644
--- a/converter/other/rletopnm.c
+++ b/converter/other/rletopnm.c
@@ -124,7 +124,7 @@ parseCommandLine(int argc, char ** argv,
     if (argc - 1 == 0)
         cmdlineP->input_filename = NULL;  /* he wants stdin */
     else if (argc - 1 == 1) {
-        if (STREQ(argv[1], "-"))
+        if (streq(argv[1], "-"))
             cmdlineP->input_filename = NULL;  /* he wants stdin */
         else 
             cmdlineP->input_filename = strdup(argv[1]);
@@ -133,7 +133,7 @@ parseCommandLine(int argc, char ** argv,
                  "is the input file specification");
 
     if (cmdlineP->alpha_filename && 
-        STREQ(cmdlineP->alpha_filename, "-"))
+        streq(cmdlineP->alpha_filename, "-"))
         cmdlineP->alpha_stdout = TRUE;
     else 
         cmdlineP->alpha_stdout = FALSE;
diff --git a/converter/other/tiff.c b/converter/other/tiff.c
index a498571b..90d50710 100644
--- a/converter/other/tiff.c
+++ b/converter/other/tiff.c
@@ -6,6 +6,8 @@
 
 ============================================================================*/
 
+#define _BSD_SOURCE    /* Make sure strcaseeq() is in nstring.h */
+
 #include <string.h>
 
 #ifdef VMS
@@ -40,7 +42,7 @@ number(const char * const value,
         /* It's not a numeric string, so it must be an enumerated value name */
         unsigned int i;
         for (i = 0; tagvallist[i].name; ++i) {
-            if (STRCASEEQ(value, tagvallist[i].name))
+            if (strcaseeq(value, tagvallist[i].name))
                 return tagvallist[i].value;
         }
         pm_error("'%s' is neither a number nor a valid value name", value);
@@ -460,7 +462,7 @@ tagDefFind(const char * const name) {
     for (i = 0;
          i < ARRAY_SIZE(tagDefinitions) && tagDefinitions[i].name;
          ++i) {
-        if (STRCASEEQ(tagDefinitions[i].name, name))
+        if (strcaseeq(tagDefinitions[i].name, name))
             return &tagDefinitions[i];
     }
 
diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
index 5969a49a..ce17b7e1 100644
--- a/converter/other/tifftopnm.c
+++ b/converter/other/tifftopnm.c
@@ -138,7 +138,7 @@ parseCommandLine(int argc, char ** argv,
                  "is the input file name");
 
     if (alphaSpec) {
-        if (STREQ(cmdlineP->alphaFilename, "-"))
+        if (streq(cmdlineP->alphaFilename, "-"))
             cmdlineP->alphaStdout = TRUE;
         else
             cmdlineP->alphaStdout = FALSE;
@@ -1024,7 +1024,7 @@ main(int argc, char * argv[]) {
 
     parseCommandLine(argc, argv, &cmdline);
 
-    if (!STREQ(cmdline.inputFilename, "-")) {
+    if (!streq(cmdline.inputFilename, "-")) {
         tif = TIFFOpen(cmdline.inputFilename, "r");
         if (tif == NULL)
             pm_error("error opening TIFF file %s", cmdline.inputFilename);
diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
index 357db323..59dab002 100644
--- a/converter/other/xwdtopnm.c
+++ b/converter/other/xwdtopnm.c
@@ -134,7 +134,7 @@ parseCommandLine(int argc, char ** argv,
     if (argc - 1 == 0)
         cmdlineP->inputFilename = NULL;  /* he wants stdin */
     else if (argc - 1 == 1) {
-        if (STREQ(argv[1], "-"))
+        if (streq(argv[1], "-"))
             cmdlineP->inputFilename = NULL;  /* he wants stdin */
         else 
             cmdlineP->inputFilename = strdup(argv[1]);
diff --git a/converter/pbm/atktopbm.c b/converter/pbm/atktopbm.c
index c4a81808..62664999 100644
--- a/converter/pbm/atktopbm.c
+++ b/converter/pbm/atktopbm.c
@@ -273,7 +273,7 @@ ReadATKRaster(FILE * const file,
 
     /* read the keyword */
     fscanf(file, " %5s", keyword);
-    if (!STREQ(keyword, "bits"))
+    if (!streq(keyword, "bits"))
       pm_error ("keyword is not 'bits'!");
 
     fscanf(file, " %d %d %d ", &objectid, &width, &height);
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c
index 1eefee96..261b6c39 100644
--- a/converter/pbm/g3topbm.c
+++ b/converter/pbm/g3topbm.c
@@ -18,6 +18,8 @@
   contributing their work to the public domain.
 ===========================================================================*/
 
+#define _BSD_SOURCE   /* Make nstring.h define strcaseeq() */
+
 #include "pbm.h"
 #include "shhopt.h"
 #include "nstring.h"
@@ -100,15 +102,15 @@ parseCommandLine(int argc, char ** const argv,
         if (cmdlineP->expectedLineSize < 1)
             pm_error("-width must be at least 1");
     } else if (paper_sizeSpec) {
-        if (STRCASEEQ(paperSize, "A6"))
+        if (strcaseeq(paperSize, "A6"))
             cmdlineP->expectedLineSize = 864;
-        else if (STRCASEEQ(paperSize, "A5"))
+        else if (strcaseeq(paperSize, "A5"))
             cmdlineP->expectedLineSize = 1216;
-        else if (STRCASEEQ(paperSize, "A4"))
+        else if (strcaseeq(paperSize, "A4"))
             cmdlineP->expectedLineSize = 1728;
-        else if (STRCASEEQ(paperSize, "B4"))
+        else if (strcaseeq(paperSize, "B4"))
             cmdlineP->expectedLineSize = 2048;
-        else if (STRCASEEQ(paperSize, "A3"))
+        else if (strcaseeq(paperSize, "A3"))
             cmdlineP->expectedLineSize = 2432;
         else
             pm_error("Unrecognized value for -paper_size '%s'.  "
diff --git a/converter/pbm/icontopbm.c b/converter/pbm/icontopbm.c
index d6dba8ae..a0d1bd2b 100644
--- a/converter/pbm/icontopbm.c
+++ b/converter/pbm/icontopbm.c
@@ -46,35 +46,35 @@ ReadIconFile(FILE *                const file,
         }
         variable[i] = '\0';
 
-        if ( STREQ( variable, "*/" )&& gotsome )
+        if ( streq( variable, "*/" )&& gotsome )
             break;
 
         if ( fscanf( file, "%d", &value ) != 1 )
             continue;
 
-        if ( STREQ( variable, "Width" ) )
+        if ( streq( variable, "Width" ) )
         {
             *widthP = value;
             gotsome = 1;
         }
-        else if ( STREQ( variable, "Height" ) )
+        else if ( streq( variable, "Height" ) )
         {
             *heightP = value;
             gotsome = 1;
         }
-        else if ( STREQ( variable, "Depth" )  )
+        else if ( streq( variable, "Depth" )  )
         {
             if ( value != 1 )
                 pm_error( "invalid depth" );
             gotsome = 1;
         }
-        else if ( STREQ( variable, "Format_version" ) )
+        else if ( streq( variable, "Format_version" ) )
         {
             if ( value != 1 )
                 pm_error( "invalid Format_version" );
             gotsome = 1;
         }
-        else if ( STREQ( variable, "Valid_bits_per_item" ) )
+        else if ( streq( variable, "Valid_bits_per_item" ) )
         {
             if ( value != 16 )
                 pm_error( "invalid Valid_bits_per_item" );
diff --git a/converter/pbm/mrftopbm.c b/converter/pbm/mrftopbm.c
index 696fe839..9cf93d47 100644
--- a/converter/pbm/mrftopbm.c
+++ b/converter/pbm/mrftopbm.c
@@ -176,7 +176,7 @@ main(int argc, char *argv[]) {
 
     expandAll = FALSE;  /* initial assumption */
 
-    if (argc-1 >= 1 && STREQ(argv[1], "-a")) {
+    if (argc-1 >= 1 && streq(argv[1], "-a")) {
         expandAll = TRUE;
         argc--,argv++;
     }
diff --git a/converter/pbm/pbmto4425.c b/converter/pbm/pbmto4425.c
index 605b12d5..1d97ac6a 100644
--- a/converter/pbm/pbmto4425.c
+++ b/converter/pbm/pbmto4425.c
@@ -145,7 +145,7 @@ main(int argc, char * argv[]) {
         pbmfile = argv[argn];
     }
 
-    if(STREQ(pbmfile, "-"))
+    if(streq(pbmfile, "-"))
     {
         pbmfp = stdin;
     }
diff --git a/converter/pbm/pbmtoatk.c b/converter/pbm/pbmtoatk.c
index de7adf63..dd829776 100644
--- a/converter/pbm/pbmtoatk.c
+++ b/converter/pbm/pbmtoatk.c
@@ -137,7 +137,7 @@ main(int argc, char *argv[]) {
     else if (argc-1 == 1) {
         ifd = pm_openr( argv[1] );
         strcpy(name, argv[1]);
-        if (STREQ( name, "-"))
+        if (streq( name, "-"))
             strcpy(name, "noname");
         
         if ((cp = strchr(name, '.')) != 0)
diff --git a/converter/pbm/pbmtoln03.c b/converter/pbm/pbmtoln03.c
index 07c8629f..f7cf53c7 100644
--- a/converter/pbm/pbmtoln03.c
+++ b/converter/pbm/pbmtoln03.c
@@ -219,13 +219,8 @@ main (int argc, char **argv) {
    if( argn != argc )
       pm_usage(usage);
 
-
-   /* Initialize pbm file */
    pbm_readpbminit (input, &width, &height, &format) ;
 
-   if (format != PBM_FORMAT && format != RPBM_FORMAT)
-      pm_error ("input not in PBM format") ;
-
 /*
  * In explanation of the sequence below:
  *      <ESC>[!p        DECSTR  soft terminal reset
diff --git a/converter/pbm/pbmtolps.c b/converter/pbm/pbmtolps.c
index 13a14e2b..5adef4c8 100644
--- a/converter/pbm/pbmtolps.c
+++ b/converter/pbm/pbmtolps.c
@@ -112,7 +112,7 @@ main(int argc, char ** argv) {
 	pbm_init(&argc, argv);
 
     i = 1;
-    if (i < argc && STREQ(argv[i], "-dpi")) {
+    if (i < argc && streq(argv[i], "-dpi")) {
         if (i == argc - 1)
             pm_usage(usage);
         sscanf(argv[i + 1], "%f", &dpi);
diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c
index 58d0ec5b..ebcd813d 100644
--- a/converter/pbm/pbmtonokia.c
+++ b/converter/pbm/pbmtonokia.c
@@ -4,7 +4,7 @@
    Copyright information is at end of file.
 */
 
-#define _BSD_SOURCE    /* Make sure strcasecmp() is in string.h */
+#define _BSD_SOURCE    /* Make sure strcaseeq() is in nstring.h */
 #include <string.h>
 #include <assert.h>
 
@@ -96,17 +96,17 @@ parseCommandLine(int argc, char ** argv,
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (fmtSpec) {
-        if (STRCASEEQ(fmtOpt, "HEX_NOL"))
+        if (strcaseeq(fmtOpt, "HEX_NOL"))
             cmdlineP->outputFormat = FMT_HEX_NOL;
-        else if (STRCASEEQ(fmtOpt, "HEX_NGG"))
+        else if (strcaseeq(fmtOpt, "HEX_NGG"))
             cmdlineP->outputFormat = FMT_HEX_NGG;
-        else if (STRCASEEQ(fmtOpt, "HEX_NPM"))
+        else if (strcaseeq(fmtOpt, "HEX_NPM"))
             cmdlineP->outputFormat = FMT_HEX_NPM;
-        else if (STRCASEEQ(fmtOpt, "NOL"))
+        else if (strcaseeq(fmtOpt, "NOL"))
             cmdlineP->outputFormat = FMT_NOL;
-        else if (STRCASEEQ(fmtOpt, "NGG"))
+        else if (strcaseeq(fmtOpt, "NGG"))
             cmdlineP->outputFormat = FMT_NGG;
-        else if (STRCASEEQ(fmtOpt, "NPM"))
+        else if (strcaseeq(fmtOpt, "NPM"))
             cmdlineP->outputFormat = FMT_NPM;
         else
             pm_error("-fmt option must be HEX_NGG, HEX_NOL, HEX_NPM, "
@@ -153,7 +153,8 @@ freeCmdline(struct cmdlineInfo const cmdline) {
 
 
 static void
-checkSize(int cols, int rows){
+validateSize(unsigned int const cols,
+             unsigned int const rows){
 
     if (cols > 255)
         pm_error("This program cannot handle files with more than 255 "
@@ -469,7 +470,8 @@ main(int    argc,
     ifP = pm_openr(cmdline.inputFileName);
     bits = pbm_readpbm(ifP, &cols, &rows);
     pm_close(ifP);
-    checkSize(cols, rows);
+
+    validateSize(cols, rows);
 
     switch (cmdline.outputFormat) {
     case FMT_HEX_NGG:
diff --git a/converter/pbm/pbmtopk.c b/converter/pbm/pbmtopk.c
index b84818b1..a9683190 100644
--- a/converter/pbm/pbmtopk.c
+++ b/converter/pbm/pbmtopk.c
@@ -172,7 +172,7 @@ pbmtopk_add_suffix(char * const name,
     char *slash = strrchr(name, '/');
     char *dot = strrchr(name, '.');
 
-    if ((dot && slash ? dot < slash : !dot) && !STREQ(name, "-"))
+    if ((dot && slash ? dot < slash : !dot) && !streq(name, "-"))
         strcat(name, suffix);
 }
 
diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
index eb45f11b..0051194c 100644
--- a/converter/pbm/pbmtoxbm.c
+++ b/converter/pbm/pbmtoxbm.c
@@ -130,7 +130,7 @@ generateName(char          const filenameArg[],
    "noname".  Also, if the argument is null or ends in a slash, we
    return "noname".
 -----------------------------------------------------------------------------*/
-    if (STREQ(filenameArg, "-"))
+    if (streq(filenameArg, "-"))
         *nameP = strdup("noname");
     else {
         int nameIndex, argIndex;
diff --git a/converter/pbm/pbmtozinc.c b/converter/pbm/pbmtozinc.c
index d39b71bc..2df39f0d 100644
--- a/converter/pbm/pbmtozinc.c
+++ b/converter/pbm/pbmtozinc.c
@@ -49,7 +49,7 @@ main(int argc, char * argv[]) {
 	{
         ifp = pm_openr( argv[1] );
         strcpy( name, argv[1] );
-        if ( STREQ( name, "-" ) )
+        if ( streq( name, "-" ) )
             strcpy( name, "noname" );
 
         if ( ( cp = strchr( name, '.' ) ) != 0 )
diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
index 32ed4fde..a3584ee5 100644
--- a/converter/pbm/pktopbm.c
+++ b/converter/pbm/pktopbm.c
@@ -50,7 +50,7 @@ pktopbm_add_suffix(char *       const name,
     char * const slash = strrchr(name, '/');
     char * const dot   = strrchr(name, '.');
     
-    if ((dot && slash ? dot < slash : !dot) && !STREQ(name, "-"))
+    if ((dot && slash ? dot < slash : !dot) && !streq(name, "-"))
         strcat(name, suffix);
 }
 
diff --git a/converter/pbm/xbmtopbm.c b/converter/pbm/xbmtopbm.c
index 63be16ef..135b79f1 100644
--- a/converter/pbm/xbmtopbm.c
+++ b/converter/pbm/xbmtopbm.c
@@ -80,10 +80,10 @@ parseWidthHeightLine(const char *   const line,
             type = underscorePos + 1;
         else
             type = nameAndType;
-        if (STREQ(type, "width")) {
+        if (streq(type, "width")) {
             *gotWidthP = TRUE;
             *widthP = value;
-        } else if (STREQ(type, "height")) {
+        } else if (streq(type, "height")) {
             *gotHeightP = TRUE;
             *heightP = value;
         }
diff --git a/converter/pgm/asciitopgm.c b/converter/pgm/asciitopgm.c
index b6b9c9a7..6cc24025 100644
--- a/converter/pgm/asciitopgm.c
+++ b/converter/pgm/asciitopgm.c
@@ -67,7 +67,7 @@ main( argc, argv )
 
     if ( argv[argn][0] == '-' )
     {
-        if ( STREQ( argv[argn], "-d" ) )
+        if ( streq( argv[argn], "-d" ) )
         {
             if ( argc == argn + 1 )
                 pm_usage( usage );
diff --git a/converter/pgm/hipstopgm.c b/converter/pgm/hipstopgm.c
index 826a8511..2f5956e1 100644
--- a/converter/pgm/hipstopgm.c
+++ b/converter/pgm/hipstopgm.c
@@ -98,7 +98,7 @@ read_hips_header( fd, hP )
 	{
         read_line( fd, buf, 5000 );
 	}
-    while ( !STREQ( buf, ".\n" ) );
+    while ( !streq( buf, ".\n" ) );
 }
 
 
diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
index 7b98ef00..40dd3fb4 100644
--- a/converter/pgm/lispmtopgm.c
+++ b/converter/pgm/lispmtopgm.c
@@ -89,7 +89,7 @@ getinit( file, colsP, rowsP, depthP, padrightP )
     for ( i = 0; i < sizeof(magic)-1; ++i )
         magic[i] = getc( file );
     magic[i]='\0';
-    if (!STREQ(LISPM_MAGIC, magic))
+    if (!streq(LISPM_MAGIC, magic))
         pm_error( "bad id string in Lispm file" );
     
     if ( pm_readlittleshort( file, colsP ) == -1 )
diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c
index bb3cb6fe..17e1e01e 100644
--- a/converter/pgm/sbigtopgm.c
+++ b/converter/pgm/sbigtopgm.c
@@ -140,7 +140,7 @@ int main(argc, argv)
 	    cols = atoi(hdr + 6);
         } else if (strncmp(hdr, "sat_level=", 10) == 0) {
 	    maxval = atoi(hdr + 10);
-        } else if (STREQ(hdr, "end")) {
+        } else if (streq(hdr, "end")) {
 	    break;
 	}
 	hdr = cp + 1;
diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
index 5b61401a..079f07ca 100644
--- a/converter/ppm/picttoppm.c
+++ b/converter/ppm/picttoppm.c
@@ -3995,7 +3995,7 @@ interpret_pict(FILE * const ofP) {
         if (opcode < 0xa2) {
             stage = optable[opcode].name;
             if (verbose) {
-                if (STREQ(stage, "reserved"))
+                if (streq(stage, "reserved"))
                     pm_message("reserved opcode=0x%x", opcode);
                 else
                     pm_message("Opcode: %s", optable[opcode].name);
diff --git a/converter/ppm/ppmtoarbtxt.c b/converter/ppm/ppmtoarbtxt.c
index 774a47c4..eaeff70f 100644
--- a/converter/ppm/ppmtoarbtxt.c
+++ b/converter/ppm/ppmtoarbtxt.c
@@ -294,20 +294,20 @@ SKL_OBJ **skl;
    sscanf (objstr,"%s",typstr);
 
                    /* Check for integer colors */
-   if      (STREQ(typstr,"ired")  ) otyp = IRED;
-   else if (STREQ(typstr,"igreen")) otyp = IGREEN;
-   else if (STREQ(typstr,"iblue") ) otyp = IBLUE;
-   else if (STREQ(typstr,"ilum")  ) otyp = ILUM;
+   if      (streq(typstr,"ired")  ) otyp = IRED;
+   else if (streq(typstr,"igreen")) otyp = IGREEN;
+   else if (streq(typstr,"iblue") ) otyp = IBLUE;
+   else if (streq(typstr,"ilum")  ) otyp = ILUM;
                    /* Check for real colors */
-   else if (STREQ(typstr,"fred")  ) otyp = FRED;
-   else if (STREQ(typstr,"fgreen")) otyp = FGREEN;
-   else if (STREQ(typstr,"fblue") ) otyp = FBLUE;
-   else if (STREQ(typstr,"flum")  ) otyp = FLUM;
+   else if (streq(typstr,"fred")  ) otyp = FRED;
+   else if (streq(typstr,"fgreen")) otyp = FGREEN;
+   else if (streq(typstr,"fblue") ) otyp = FBLUE;
+   else if (streq(typstr,"flum")  ) otyp = FLUM;
                    /* Check for integer data */
-   else if (STREQ(typstr,"width") ) otyp = WIDTH;
-   else if (STREQ(typstr,"height")) otyp = HEIGHT;
-   else if (STREQ(typstr,"posx")  ) otyp = POSX;
-   else if (STREQ(typstr,"posy")  ) otyp = POSY;
+   else if (streq(typstr,"width") ) otyp = WIDTH;
+   else if (streq(typstr,"height")) otyp = HEIGHT;
+   else if (streq(typstr,"posx")  ) otyp = POSX;
+   else if (streq(typstr,"posy")  ) otyp = POSY;
    else                                    otyp = BDATA;
 
    if ((otyp == IRED) || (otyp == IGREEN) || (otyp == IBLUE) || (otyp == ILUM))
diff --git a/converter/ppm/ppmtompeg/param.c b/converter/ppm/ppmtompeg/param.c
index 5ea69ab6..502aee5b 100644
--- a/converter/ppm/ppmtompeg/param.c
+++ b/converter/ppm/ppmtompeg/param.c
@@ -671,66 +671,66 @@ processParamLine(char const input[],
 
     switch(input[0]) {
     case 'A':
-        if (STRNEQ(input, "ASPECT_RATIO", 12)) {
+        if (strneq(input, "ASPECT_RATIO", 12)) {
             aspectRatio = GetAspectRatio(SkipSpacesTabs(&input[12]));
             optionSeen[OPTION_ASPECT_RATIO] = TRUE;
         }
         break;
         
     case 'B':
-        if (STRNEQ(input, "BQSCALE", 7)) {
+        if (strneq(input, "BQSCALE", 7)) {
             SetBQScale(atoi(SkipSpacesTabs(&input[7])));
             optionSeen[OPTION_BQSCALE] = TRUE;
-        } else if (STRNEQ(input, "BASE_FILE_FORMAT", 16)) {
+        } else if (strneq(input, "BASE_FILE_FORMAT", 16)) {
             const char * arg = SkipSpacesTabs(&input[16]);
             SetFileFormat(arg);
-            if (STRNEQ(arg, "YUV", 3) || STREQ(arg, "Y"))
+            if (strneq(arg, "YUV", 3) || streq(arg, "Y"))
                 *yuvUsedP = TRUE;
             optionSeen[OPTION_BASE_FORMAT] = TRUE;
-        } else if (STRNEQ(input, "BSEARCH_ALG", 11)) {
+        } else if (strneq(input, "BSEARCH_ALG", 11)) {
             SetBSearchAlg(SkipSpacesTabs(&input[11]));
             optionSeen[OPTION_BSEARCH_ALG] = TRUE;
-        } else if (STRNEQ(input, "BIT_RATE", 8)) {
+        } else if (strneq(input, "BIT_RATE", 8)) {
             setBitRate(SkipSpacesTabs(&input[8]));
             optionSeen[OPTION_BIT_RATE] = TRUE;
-        } else if (STRNEQ(input, "BUFFER_SIZE", 11)) {
+        } else if (strneq(input, "BUFFER_SIZE", 11)) {
             setBufferSize(SkipSpacesTabs(&input[11]));
             optionSeen[OPTION_BUFFER_SIZE] = TRUE;                  
         }
         break;
 
     case 'C':
-        if (STRNEQ(input, "CDL_FILE", 8)) {
+        if (strneq(input, "CDL_FILE", 8)) {
             strcpy(specificsFile, SkipSpacesTabs(&input[8]));
             specificsOn = TRUE;
             optionSeen[OPTION_SPECIFICS] = TRUE;
-        } else if (STRNEQ(input, "CDL_DEFINES", 11)) {
+        } else if (strneq(input, "CDL_DEFINES", 11)) {
             strcpy(specificsDefines, SkipSpacesTabs(&input[11]));
             optionSeen[OPTION_DEFS_SPECIFICS] = TRUE;
         }
         break;
 
     case 'F':
-        if (STRNEQ(input, "FRAME_INPUT_DIR", 15)) {
+        if (strneq(input, "FRAME_INPUT_DIR", 15)) {
             const char * const arg = SkipSpacesTabs(&input[15]);
-            if (STRNCASEEQ(arg, "stdin", 5))
+            if (strncaseeq(arg, "stdin", 5))
                 SetStdinInput(frameInputSourceP);
 
             strcpy(currentFramePath, arg);
-        } else if (STRNEQ(input, "FRAME_INPUT", 11)) {
+        } else if (strneq(input, "FRAME_INPUT", 11)) {
             ReadInputFileNames(fpointer, "FRAME_END_INPUT", 
                                frameInputSourceP->stdinUsed ? 
                                NULL : frameInputSourceP);
             optionSeen[OPTION_FRAME_INPUT] = TRUE;
-        } else if (STRNEQ(input, "FORCE_I_ALIGN", 13)) {
+        } else if (strneq(input, "FORCE_I_ALIGN", 13)) {
             forceIalign = TRUE;
-        } else if (STRNEQ(input, "FORCE_ENCODE_LAST_FRAME", 23)) {
+        } else if (strneq(input, "FORCE_ENCODE_LAST_FRAME", 23)) {
             /* NO-OP.  We used to drop trailing B frames by default and you
                needed this option to change the last frame to I so you could
                encode all the frames.  Now we just do that all the time.  
                Why wouldn't we?
             */
-        } else if (STRNEQ(input, "FRAME_RATE", 10)) {
+        } else if (strneq(input, "FRAME_RATE", 10)) {
             frameRate = GetFrameRate(SkipSpacesTabs(&input[10]));
             frameRateRounded = (int) VidRateNum[frameRate];
             if ((frameRate % 3) == 1)
@@ -740,21 +740,21 @@ processParamLine(char const input[],
         break;
         
     case 'G':
-        if (STRNEQ(input, "GOP_SIZE", 8)) {
+        if (strneq(input, "GOP_SIZE", 8)) {
             SetGOPSize(atoi(SkipSpacesTabs(&input[8])));
             optionSeen[OPTION_GOP] = TRUE;
-        } else if (STRNEQ(input, "GOP_INPUT_DIR", 13)) {
+        } else if (strneq(input, "GOP_INPUT_DIR", 13)) {
             const char * const arg = SkipSpacesTabs(&input[13]);
-            if (STRNCASEEQ(arg, "stdin", 5))
+            if (strncaseeq(arg, "stdin", 5))
                 SetStdinInput(gopInputSourceP);
 
             strcpy(currentGOPPath, arg);
-        } else if (STRNEQ(input, "GOP_INPUT", 9)) {
+        } else if (strneq(input, "GOP_INPUT", 9)) {
             ReadInputFileNames(fpointer, "GOP_END_INPUT", 
                                gopInputSourceP->stdinUsed ? 
                                NULL : gopInputSourceP);
             optionSeen[OPTION_GOP_INPUT] = TRUE;
-        } else if (STRNEQ(input, "GAMMA", 5)) {
+        } else if (strneq(input, "GAMMA", 5)) {
             GammaCorrection = TRUE;
             sscanf(SkipSpacesTabs(&input[5]), "%f", &GammaValue);
             optionSeen[OPTION_GAMMA] = TRUE;
@@ -762,27 +762,27 @@ processParamLine(char const input[],
         break;
         
     case 'I':
-        if (STRNEQ(input, "IQSCALE", 7)) {
+        if (strneq(input, "IQSCALE", 7)) {
             SetIQScale(atoi(SkipSpacesTabs(&input[7])));
             optionSeen[OPTION_IQSCALE] = TRUE;
-        } else if (STRNEQ(input, "INPUT_DIR", 9)) {
+        } else if (strneq(input, "INPUT_DIR", 9)) {
             const char * const arg = SkipSpacesTabs(&input[9]);
-            if (STRNCASEEQ(arg, "stdin", 5))
+            if (strncaseeq(arg, "stdin", 5))
                 SetStdinInput(inputSourceP);
             strcpy(currentPath, arg);
             optionSeen[OPTION_INPUT_DIR] = TRUE;
-        } else if (STRNEQ(input, "INPUT_CONVERT", 13)) {
+        } else if (strneq(input, "INPUT_CONVERT", 13)) {
             strcpy(inputConversion, SkipSpacesTabs(&input[13]));
             optionSeen[OPTION_INPUT_CONVERT] = TRUE;
-        } else if (STREQ(input, "INPUT")) {
+        } else if (streq(input, "INPUT")) {
             ReadInputFileNames(fpointer, "END_INPUT", 
                                inputSourceP->stdinUsed ?
                                NULL : inputSourceP);
             optionSeen[OPTION_INPUT] = TRUE;
-        } else if (STRNEQ(input, "IO_SERVER_CONVERT", 17)) {
+        } else if (strneq(input, "IO_SERVER_CONVERT", 17)) {
             strcpy(ioConversion, SkipSpacesTabs(&input[17]));
             optionSeen[OPTION_IO_CONVERT] = TRUE;
-        } else if (STRNEQ(input, "IQTABLE", 7)) {
+        } else if (strneq(input, "IQTABLE", 7)) {
             processIqtable(fpointer);
 
             optionSeen[OPTION_IQTABLE] = TRUE;
@@ -790,12 +790,12 @@ processParamLine(char const input[],
         break;
 
     case 'K':
-        if (STRNEQ(input, "KEEP_TEMP_FILES", 15))
+        if (strneq(input, "KEEP_TEMP_FILES", 15))
             keepTempFiles = TRUE;
         break;
         
     case 'N':
-      if (STRNEQ(input, "NIQTABLE", 8)) {
+      if (strneq(input, "NIQTABLE", 8)) {
           readNiqTable(fpointer);
 
           optionSeen[OPTION_NIQTABLE] = TRUE;
@@ -803,7 +803,7 @@ processParamLine(char const input[],
       break;
 
     case 'O':
-        if (STRNEQ(input, "OUTPUT", 6)) {
+        if (strneq(input, "OUTPUT", 6)) {
             const char * const arg = SkipSpacesTabs(&input[6]);
             if ( whichGOP == -1 )
                 strcpy(outputFileName, arg);
@@ -815,45 +815,45 @@ processParamLine(char const input[],
         break;
         
     case 'P':
-        if (STRNEQ(input, "PATTERN", 7)) {
+        if (strneq(input, "PATTERN", 7)) {
             SetFramePattern(SkipSpacesTabs(&input[7]));
             optionSeen[OPTION_PATTERN] = TRUE;
-        } else if (STRNEQ(input, "PIXEL", 5)) {
+        } else if (strneq(input, "PIXEL", 5)) {
             SetPixelSearch(SkipSpacesTabs(&input[5]));
             optionSeen[OPTION_PIXEL] = TRUE;
-        } else if (STRNEQ(input, "PQSCALE", 7)) {
+        } else if (strneq(input, "PQSCALE", 7)) {
             SetPQScale(atoi(SkipSpacesTabs(&input[7])));
             optionSeen[OPTION_PQSCALE] = TRUE;
-        } else if (STRNEQ(input, "PSEARCH_ALG", 11)) {
+        } else if (strneq(input, "PSEARCH_ALG", 11)) {
             SetPSearchAlg(SkipSpacesTabs(&input[11]));
             optionSeen[OPTION_PSEARCH_ALG] = TRUE;
-        } else if (STRNEQ(input, "PARALLEL_TEST_FRAMES", 20)) {
+        } else if (strneq(input, "PARALLEL_TEST_FRAMES", 20)) {
             SetParallelPerfect(FALSE);
             parallelTestFrames = atoi(SkipSpacesTabs(&input[20]));
-        } else if (STRNEQ(input, "PARALLEL_TIME_CHUNKS", 20)) {
+        } else if (strneq(input, "PARALLEL_TIME_CHUNKS", 20)) {
             SetParallelPerfect(FALSE);
             parallelTimeChunks = atoi(SkipSpacesTabs(&input[20]));
-        } else if (STRNEQ(input, "PARALLEL_CHUNK_TAPER", 20)) {
+        } else if (strneq(input, "PARALLEL_CHUNK_TAPER", 20)) {
             SetParallelPerfect(FALSE);
             parallelTimeChunks = -1;
-        } else if (STRNEQ(input, "PARALLEL_PERFECT", 16)) {
+        } else if (strneq(input, "PARALLEL_PERFECT", 16)) {
             SetParallelPerfect(TRUE);
-        } else if (STRNEQ(input, "PARALLEL", 8)) {
+        } else if (strneq(input, "PARALLEL", 8)) {
             ReadMachineNames(fpointer);
             optionSeen[OPTION_PARALLEL] = TRUE;
         }
         break;
         
     case 'R':
-        if (STRNEQ(input, "RANGE", 5)) {
+        if (strneq(input, "RANGE", 5)) {
             processRanges(SkipSpacesTabs(&input[5]));
             optionSeen[OPTION_RANGE] = TRUE;
-        } else if (STRNEQ(input, "REFERENCE_FRAME", 15)) {
+        } else if (strneq(input, "REFERENCE_FRAME", 15)) {
             SetReferenceFrameType(SkipSpacesTabs(&input[15]));
             optionSeen[OPTION_REF_FRAME] = TRUE;
-        } else if (STRNEQ(input, "RSH", 3)) {
+        } else if (strneq(input, "RSH", 3)) {
             SetRemoteShell(SkipSpacesTabs(&input[3]));
-        } else if (STRNEQ(input, "RESIZE", 6)) {
+        } else if (strneq(input, "RESIZE", 6)) {
             const char * const arg = SkipSpacesTabs(&input[6]);
             sscanf(arg, "%dx%d", &outputWidth, &outputHeight);
             outputWidth &= ~(DCTSIZE * 2 - 1);
@@ -863,22 +863,22 @@ processParamLine(char const input[],
         break;
 
     case 'S':
-        if (STRNEQ(input, "SLICES_PER_FRAME", 16)) {
+        if (strneq(input, "SLICES_PER_FRAME", 16)) {
             SetSlicesPerFrame(atoi(SkipSpacesTabs(&input[16])));
             optionSeen[OPTION_SPF] = TRUE;
-        } else if (STRNEQ(input, "SLAVE_CONVERT", 13)) {
+        } else if (strneq(input, "SLAVE_CONVERT", 13)) {
             strcpy(slaveConversion, SkipSpacesTabs(&input[13]));
             optionSeen[OPTION_SLAVE_CONVERT] = TRUE;
-        } else if (STRNEQ(input, "SPECIFICS_FILE", 14)) {
+        } else if (strneq(input, "SPECIFICS_FILE", 14)) {
             strcpy(specificsFile, SkipSpacesTabs(&input[14]));
             specificsOn = TRUE;
             optionSeen[OPTION_SPECIFICS] = TRUE;
-        } else if (STRNEQ(input, "SPECIFICS_DEFINES", 16)) {
+        } else if (strneq(input, "SPECIFICS_DEFINES", 16)) {
             strcpy(specificsDefines, SkipSpacesTabs(&input[17]));
             optionSeen[OPTION_DEFS_SPECIFICS] = TRUE;
-        } else if (STRNEQ(input, "SEQUENCE_SIZE", 13)) {
+        } else if (strneq(input, "SEQUENCE_SIZE", 13)) {
             mult_seq_headers = atoi(SkipSpacesTabs(&input[13]));
-        } else if (STRNEQ(input, "SIZE", 4)) {
+        } else if (strneq(input, "SIZE", 4)) {
             const char * const arg = SkipSpacesTabs(&input[4]);
             sscanf(arg, "%dx%d", &yuvWidth, &yuvHeight);
             realWidth = yuvWidth;
@@ -889,42 +889,42 @@ processParamLine(char const input[],
         break;
 
     case 'T':
-        if (STRNEQ(input, "TUNE", 4)) {
+        if (strneq(input, "TUNE", 4)) {
             tuneingOn = TRUE;
             ParseTuneParam(SkipSpacesTabs(&input[4]));
         }
         break;
 
     case 'U':
-        if (STRNEQ(input, "USER_DATA", 9)) {
+        if (strneq(input, "USER_DATA", 9)) {
             strcpy(userDataFileName, SkipSpacesTabs(&input[9]));
             optionSeen[OPTION_USER_DATA] = TRUE;
         }
         break;
         
     case 'W':
-        if (STRNEQ(input, "WARN_UNDERFLOW", 14))
+        if (strneq(input, "WARN_UNDERFLOW", 14))
             paramP->warnUnderflow = TRUE;
-        if (STRNEQ(input, "WARN_OVERFLOW", 13))
+        if (strneq(input, "WARN_OVERFLOW", 13))
             paramP->warnOverflow = TRUE;
         break;
         
     case 'Y':
-        if (STRNEQ(input, "YUV_SIZE", 8)) {
+        if (strneq(input, "YUV_SIZE", 8)) {
             const char * const arg = SkipSpacesTabs(&input[8]);
             sscanf(arg, "%dx%d", &yuvWidth, &yuvHeight);
             realWidth = yuvWidth;
             realHeight = yuvHeight;
             Fsize_Validate(&yuvWidth, &yuvHeight);
             optionSeen[OPTION_YUV_SIZE] = TRUE;
-        } else if (STRNEQ(input, "Y_SIZE", 6)) {
+        } else if (strneq(input, "Y_SIZE", 6)) {
             const char * const arg = SkipSpacesTabs(&input[6]);
             sscanf(arg, "%dx%d", &yuvWidth, &yuvHeight);
             realWidth = yuvWidth;
             realHeight = yuvHeight;
             Fsize_Validate(&yuvWidth, &yuvHeight);
             optionSeen[OPTION_YUV_SIZE] = TRUE;
-        } else if (STRNEQ(input, "YUV_FORMAT", 10)) {
+        } else if (strneq(input, "YUV_FORMAT", 10)) {
             strcpy(yuvConversion,  SkipSpacesTabs(&input[10]));
             optionSeen[OPTION_YUV_FORMAT] = TRUE;
         }
diff --git a/converter/ppm/ppmtopj.c b/converter/ppm/ppmtopj.c
index 5d449f7a..d116773f 100644
--- a/converter/ppm/ppmtopj.c
+++ b/converter/ppm/ppmtopj.c
@@ -121,7 +121,7 @@ char *argv[];
 		{
 		++argn;
 		for (r = 0; rmode[r] != NULL; r++)
-		     if (STREQ(rmode[r], argv[argn]))
+		     if (streq(rmode[r], argv[argn]))
 			 break;
 		if (rmode[r] != NULL)
 		    render_mode = r;
@@ -131,9 +131,9 @@ char *argv[];
 	    else if ( pm_keymatch(argv[argn],"-back",2) && argn + 1 < argc )
 		{
 		++argn;
-		if (STREQ(argv[argn], "dark"))
+		if (streq(argv[argn], "dark"))
 		    back_scale = C_BACK_SCALE_DARK;
-		else if (STREQ(argv[argn], "lite"))
+		else if (streq(argv[argn], "lite"))
 		    back_scale = C_BACK_SCALE_LIGHT;
 		else
 		    pm_usage(usage);
diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c
index 853ae711..ae597125 100644
--- a/converter/ppm/ppmtoxpm.c
+++ b/converter/ppm/ppmtoxpm.c
@@ -138,7 +138,7 @@ parseCommandLine(int argc, char ** argv,
     /* If output filename not specified, use input filename as default. */
     if (nameSpec)
         cmdlineP->name = nameOpt;
-    else if (STREQ(cmdlineP->inputFilename, "-"))
+    else if (streq(cmdlineP->inputFilename, "-"))
         cmdlineP->name = "noname";
     else {
         static char name[80+1];
diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
index e0760448..ad16a649 100644
--- a/converter/ppm/sldtoppm.c
+++ b/converter/ppm/sldtoppm.c
@@ -194,7 +194,7 @@ slidefind(const char * const sname,
     /* Read slide library header and verify. */
     
     if ((fread(libent, 32, 1, slfile) != 1) ||
-        (!STREQ((char *)libent, "AutoCAD Slide Library 1.0\015\012\32"))) {
+        (!streq((char *)libent, "AutoCAD Slide Library 1.0\015\012\32"))) {
         pm_error("not an AutoCAD slide library file.");
     }
     pos = 32;
@@ -212,7 +212,7 @@ slidefind(const char * const sname,
         pos += 36;
         if (dironly) {
             pm_message("  %s", libent);
-        } else if (STREQ((char *)libent, uname)) {
+        } else if (streq((char *)libent, uname)) {
             long dpos = (((((libent[35] << 8) | libent[34]) << 8) |
                           libent[33]) << 8) | libent[32];
             if ((slfile == stdin) || (fseek(slfile, dpos, 0) == -1)) {
@@ -341,7 +341,7 @@ slider(slvecfn   slvec,
 
     /* Verify that slide format is compatible with this program. */
 
-    if (STREQ(slfrof.slh, slhi.slh))
+    if (streq(slfrof.slh, slhi.slh))
         pm_error("this is not an AutoCAD slide file.");
 
     /* Verify that the number format and file level in the header  are
diff --git a/converter/ppm/tgatoppm.c b/converter/ppm/tgatoppm.c
index 9f2bc4c0..19d8b347 100644
--- a/converter/ppm/tgatoppm.c
+++ b/converter/ppm/tgatoppm.c
@@ -81,7 +81,7 @@ parseCommandLine(int argc, char ** argv,
                  "is the input file specification");
 
     if (alpha_spec &&
-        STREQ(cmdlineP->alpha_filename, "-"))
+        streq(cmdlineP->alpha_filename, "-"))
         cmdlineP->alpha_stdout = 1;
     else 
         cmdlineP->alpha_stdout = 0;
diff --git a/converter/ppm/winicontoppm.c b/converter/ppm/winicontoppm.c
index 2d9de567..9a606a93 100644
--- a/converter/ppm/winicontoppm.c
+++ b/converter/ppm/winicontoppm.c
@@ -572,7 +572,7 @@ trimOutputName(const char inputName[])
      * oh, for =~ ... :)
      */
     char * outFile = strdup(inputName);
-    if (STREQ(outFile + (strlen (outFile) - 4), ".ppm")) {
+    if (streq(outFile + (strlen (outFile) - 4), ".ppm")) {
         *(outFile + (strlen (outFile) - 4)) = 0;
     }
     return outFile;
@@ -828,7 +828,7 @@ main(int argc, char *argv[]) {
         pm_message("-bestqual doesn't make sense with -allicons.  "
                    "Ignoring -bestqual.");
    
-    if (STREQ(cmdline.outputFilespec, "-"))
+    if (streq(cmdline.outputFilespec, "-"))
         outputFileBase = NULL;
     else
         outputFileBase = trimOutputName(cmdline.outputFilespec);
diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
index 96798707..bb842f02 100644
--- a/converter/ppm/ximtoppm.c
+++ b/converter/ppm/ximtoppm.c
@@ -65,7 +65,7 @@ parseCommandLine(int argc, char ** argv,
                  "is the input file specification");
 
     if (cmdlineP->alpha_filename && 
-        STREQ(cmdlineP->alpha_filename, "-"))
+        streq(cmdlineP->alpha_filename, "-"))
         cmdlineP->alpha_stdout = TRUE;
     else 
         cmdlineP->alpha_stdout = FALSE;
diff --git a/converter/ppm/xpmtoppm.c b/converter/ppm/xpmtoppm.c
index 9dddfd83..97be6cc9 100644
--- a/converter/ppm/xpmtoppm.c
+++ b/converter/ppm/xpmtoppm.c
@@ -104,7 +104,7 @@ parse_command_line(int argc, char ** argv,
                  "is the input file specification");
 
     if (cmdline_p->alpha_filename && 
-        STREQ(cmdline_p->alpha_filename, "-"))
+        streq(cmdline_p->alpha_filename, "-"))
         cmdline_p->alpha_stdout = TRUE;
     else 
         cmdline_p->alpha_stdout = FALSE;
@@ -293,7 +293,7 @@ interpretXpm3ColorTableLine(char line[], int const seqNum,
                number if so)
             */
             for (key = 1; 
-                 key <= NKEYS && !STREQ(xpmColorKeys[key - 1], str2); 
+                 key <= NKEYS && !streq(xpmColorKeys[key - 1], str2); 
                  key++);
             isKey = (key <= NKEYS);
 
@@ -483,15 +483,15 @@ readXpm1Header(FILE * const stream, int * const widthP, int * const heightP,
                 t1 = str1;
             else
                 ++t1;
-            if (STREQ(t1, "format"))
+            if (streq(t1, "format"))
                 format = v;
-            else if (STREQ(t1, "width"))
+            else if (streq(t1, "width"))
                 *widthP = v;
-            else if (STREQ(t1, "height"))
+            else if (streq(t1, "height"))
                 *heightP = v;
-            else if (STREQ(t1, "ncolors"))
+            else if (streq(t1, "ncolors"))
                 *ncolorsP = v;
-            else if (STREQ(t1, "pixel"))
+            else if (streq(t1, "pixel"))
                 *chars_per_pixelP = v;
         } else if (!strncmp(line, "static char", 11)) {
             if ((t1 = strrchr(line, '_')) == NULL)
diff --git a/converter/ppm/xvminitoppm.c b/converter/ppm/xvminitoppm.c
index 8cea1f9d..e5bdac7d 100644
--- a/converter/ppm/xvminitoppm.c
+++ b/converter/ppm/xvminitoppm.c
@@ -109,16 +109,16 @@ readXvHeader(FILE *         const ifP,
     
     getline(ifP, buf, sizeof(buf));
 
-    if (!STRNEQ(buf, "P7 332", 6))
+    if (!strneq(buf, "P7 332", 6))
         pm_error("Input is not a XV thumbnail picture.  It does not "
                  "begin with the characters 'P7 332'.");
 
     endOfComments = FALSE;
     while (!endOfComments) {
         getline(ifP, buf, sizeof(buf));
-        if (STRNEQ(buf, "#END_OF_COMMENTS", 16))
+        if (strneq(buf, "#END_OF_COMMENTS", 16))
             endOfComments = TRUE;
-        else if (STRNEQ(buf, "#BUILTIN", 8))
+        else if (strneq(buf, "#BUILTIN", 8))
             pm_error("This program does not know how to "
                      "convert builtin XV thumbnail pictures");
     }
diff --git a/doc/HISTORY b/doc/HISTORY
index 955f91b9..489b16b3 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,47 +4,34 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
-07.09.17 BJH  Release 10.39.06
+07.09.26 BJH  Release 10.40.00
 
-              libnetpbm: Fix pm_drain() to use the specified limit.
-              Thanks Paul Bolle <pebolle@tiscali.nl>.
+              pamfunc: Add -andmask, -ormask, -xormask, -not,
+              -shiftleft, -shiftright.
 
-08.09.03 BJH  Release 10.39.05
+              pbmtonokia: fail if input is > 255 x 255.  Thanks Paul Bolle
+              <pebolle@tiscali.nl>.
 
-              pamstack: accept Standard Input properly.
+              pnmmargin: add -plain option.    Thanks
+              Prophet of the Way <afu@wta.att.ne.jp>.
 
-              libnetpbm: pbm_readppminit: read PBM as maxval of 255, not 1.
+              pnmgamma: improve error messages.
 
-              libnetpbm: Reject empty TUPLTYPE header.
+              pamstack: accept Standard Input properly.
 
-              libnetpbm: Fix uninitialized variable in pnm_allocpamrown().
+              pnmmargin: recognize invalid options better.  Thanks
+              Prophet of the Way <afu@wta.att.ne.jp>.
 
-              pbmtonokia: fail if input is > 255 x 255.  Thanks Paul Bolle
-              <pebolle@tiscali.nl>.
+              anytopnm, pnmmargin, pamstretch-gen, ppmquantall: fix
+              small temporary file security exposure.
 
               pnmtopalm: fix typo in error message.  Thanks Paul Bolle
               <pebolle@tiscali.nl>.
 
-              Build: don't build pstopnm on system without unix process
-              management.
-
-07.08.18 BJH  Release 10.39.04
-
-              Build: put -l's after .o's in test links.
-
-07.08.01 BJH  Release 10.39.03
-
               pnmtops: fix crash when program attempts to write 12 bits per
               sample Postscript.  It doesn't really know how to do that, so
               now it just writes 8 unless you do -psfilter.
 
-07.07.19 BJH  Release 10.39.02
-
-              anytopnm, pnmmargin, pamstretch-gen, ppmquantall: fix
-              small temporary file security exposure.
-
-07.07.03 BJH  Release 10.39.01
-
               pnmtopng: Sort palette properly when alpha maxval != 255.
 
               pnmtopng: Fix array bound violation with = 256 colors and -alpha.
@@ -52,11 +39,37 @@ CHANGE HISTORY
               pnmtopng: Fix array bound violation with > 256 alpha mask levels.
 
               pamtopfm: Fix wrong selection of default endianness.
-              
+
+              libnetpbm: Add pm_system_lp(), pm_system_vp().
+
+              libnetpbm: Make pbm_readpbminit() and pgm_readpgminit()
+              recognize incompatible Netpbm formats and issue a
+              helpful error message.
+
+              libnetpbm: pbm_readppminit: read PBM as maxval of 255, not 1.
+
+              libnetpbm: Fix pm_drain() to use the specified limit.
+              Thanks Paul Bolle <pebolle@tiscali.nl>.
+
+              libnetpbm: Fix multi-line TUPLTYPE interpretation:
+              separate lines with blank, not newline.  Thanks Paul
+              Bolle <pebolle@tiscali.nl>.
+
+              libnetpbm: Reject empty TUPLTYPE header.
+
               libnetpbm: Fix uninitialized variable in pnm_allocpamrown().
 
+              libnetpbm: fix crash in REALLOCARRAY with advanced optimization.
+
+              libnetpbm: REALLOCARRAY frees memory if it fails.
+
               Rename pamtooctave to pamtooctaveimg.
 
+              Build: don't build pstopnm on system without unix process
+              management.
+
+              Build: put -l's after .o's in test links.
+
               Build: don't use 'uint' type.  Solaris 10 apparently doesn't
               have it.
 
@@ -176,7 +189,7 @@ CHANGE HISTORY
               libnetpbm: fix crash with PBM images < 8 columns on MMX/SSE
               machine.
 
-              pamtogif: fail properly if image too wide or high for GIF.
+              pamtogif: fail properly if image to wide or high for GIF.
 
               ppmdraw: fix crash with use of freed storage.  Thanks
               John Walker <kelvin@fourmilab.ch>.
diff --git a/doc/INSTALL b/doc/INSTALL
index d18d58c7..c34eafd8 100644
--- a/doc/INSTALL
+++ b/doc/INSTALL
@@ -76,6 +76,14 @@ contents.  You can also run Configure interactively and use its output
 as an example.
 
 
+THE PREREQUISITE LIBRARIES
+--------------------------
+
+Netpbm uses lots of external libraries, but you don't necessarily have
+to install them all.  See http://netpbm.sourceforge.net/prereq.html .
+You do, however, have to tell Configure accurately whether you have the
+library installed and if so, where.
+
 
 INSTALLATION - WINDOWS
 ----------------------
@@ -105,9 +113,9 @@ just do
 It will build Pnmtojpeg and any of its dependencies, but nothing else.
 You have to install it manually.  
 
-When you build just one program, you should request static libraries
-in the configure step, because for just one program, the shared
-libraries would be pure masochism.
+When you build just one program, you should request a static Netpbm
+library in the configure step, because for just one program, the
+shared library would be pure masochism.
 
 
 CUSTOM BUILDING
@@ -128,7 +136,7 @@ your platform.
 
 If your system is even too exotic to accomodate with settings in
 Makefile.config, you may need to modify things in the main make files
-or pm_config.h.
+or pm_config.h.in.
 
 If you figure out how to install on other platforms, contact the
 Netpbm maintainer to have the 'configure' program or these
diff --git a/editor/pamfunc.c b/editor/pamfunc.c
index dbb1ca70..d380303a 100644
--- a/editor/pamfunc.c
+++ b/editor/pamfunc.c
@@ -18,10 +18,24 @@
 
 ******************************************************************************/
 
-#include "pam.h"
+#include "mallocvar.h"
 #include "shhopt.h"
+#include "pam.h"
 
-enum function {FN_MULTIPLY, FN_DIVIDE, FN_ADD, FN_SUBTRACT, FN_MIN, FN_MAX};
+enum function {
+    FN_MULTIPLY,
+    FN_DIVIDE,
+    FN_ADD,
+    FN_SUBTRACT,
+    FN_MIN,
+    FN_MAX,
+    FN_AND,
+    FN_OR,
+    FN_XOR,
+    FN_NOT,
+    FN_SHIFTLEFT,
+    FN_SHIFTRIGHT
+};
 
 /* Note that when the user specifies a minimum, that means he's requesting
    a "max" function.
@@ -40,11 +54,30 @@ struct cmdlineInfo {
         int subtractor;
         unsigned int max;
         unsigned int min;
+        unsigned int mask;
+        unsigned int shiftCount;
     } u;
     unsigned int verbose;
 };
 
 
+
+static unsigned int
+parseHex(const char * const hexString) {
+
+    unsigned int retval;
+    char * tail;
+
+    retval = strtol(hexString, &tail, 16);
+
+    if (*tail != '\0')
+        pm_error("Invalid hex string '%s'.  Junk: '%s'", hexString, tail);
+
+    return retval;
+}
+
+         
+
 static void
 parseCommandLine(int argc, char ** const argv,
                  struct cmdlineInfo * const cmdlineP) {
@@ -52,29 +85,46 @@ parseCommandLine(int argc, char ** const argv,
    Note that the file spec array we return is stored in the storage that
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
-    optEntry *option_def = malloc(100*sizeof(optEntry));
-        /* Instructions to OptParseOptions2 on how to parse our options.
-         */
+    optEntry * option_def;
+        /* Instructions to OptParseOptions3 on how to parse our options. */
     optStruct3 opt;
 
     unsigned int option_def_index;
 
     unsigned int multiplierSpec, divisorSpec, adderSpec, subtractorSpec;
     unsigned int maxSpec, minSpec;
+    unsigned int andmaskSpec, ormaskSpec, xormaskSpec, notSpec;
+    unsigned int shiftleftSpec, shiftrightSpec;
+
+    const char * mask;
+
+    MALLOCARRAY(option_def, 100);
 
-    option_def_index = 0;   /* incremented by OPTENTRY */
+    option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3(0,   "multiplier", OPT_FLOAT,  &cmdlineP->u.multiplier, 
             &multiplierSpec, 0);
     OPTENT3(0,   "divisor",    OPT_FLOAT,  &cmdlineP->u.divisor,
-            &divisorSpec, 0);
+            &divisorSpec,    0);
     OPTENT3(0,   "adder",      OPT_INT,    &cmdlineP->u.adder,
-            &adderSpec, 0);
+            &adderSpec,      0);
     OPTENT3(0,   "subtractor", OPT_INT,    &cmdlineP->u.subtractor,
             &subtractorSpec, 0);
     OPTENT3(0,   "min",        OPT_UINT,   &cmdlineP->u.min,
-            &minSpec, 0);
+            &minSpec,        0);
     OPTENT3(0,   "max",        OPT_UINT,   &cmdlineP->u.max,
-            &maxSpec, 0);
+            &maxSpec,        0);
+    OPTENT3(0,   "andmask",    OPT_STRING, &mask,
+            &andmaskSpec,    0);
+    OPTENT3(0,   "ormask",     OPT_STRING, &mask,
+            &ormaskSpec,     0);
+    OPTENT3(0,   "xormask",    OPT_STRING, &mask,
+            &xormaskSpec,    0);
+    OPTENT3(0,   "not",        OPT_FLAG,   NULL,
+            &notSpec,        0);
+    OPTENT3(0,   "shiftleft",  OPT_UINT,   &cmdlineP->u.shiftCount,
+            &shiftleftSpec,  0);
+    OPTENT3(0,   "shiftright", OPT_UINT,   &cmdlineP->u.shiftCount,
+            &shiftrightSpec, 0);
     OPTENT3(0,   "verbose",    OPT_FLAG,   NULL, &cmdlineP->verbose,       0);
 
     opt.opt_table = option_def;
@@ -85,9 +135,12 @@ parseCommandLine(int argc, char ** const argv,
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (multiplierSpec + divisorSpec + adderSpec + subtractorSpec +
-        minSpec + maxSpec > 1)
+        minSpec + maxSpec + andmaskSpec + ormaskSpec + xormaskSpec + notSpec +
+        shiftleftSpec + shiftrightSpec > 1)
         pm_error("You may specify at most one of -multiplier, -divisor,"
-                 "-adder, -subtractor, -min, and -max");
+                 "-adder, -subtractor, -min, -max, "
+                 "-andmask, -ormask, -xormask, -not, "
+                 "-shiftleft, and -shiftright");
 
     if (multiplierSpec) {
         cmdlineP->function = FN_MULTIPLY;
@@ -107,9 +160,25 @@ parseCommandLine(int argc, char ** const argv,
         cmdlineP->function = FN_MAX;
     } else if (maxSpec) {
         cmdlineP->function = FN_MIN;
+    } else if (andmaskSpec) {
+        cmdlineP->function = FN_AND;
+        cmdlineP->u.mask = parseHex(mask);
+    } else if (ormaskSpec) {
+        cmdlineP->function = FN_OR;
+        cmdlineP->u.mask = parseHex(mask);
+    } else if (xormaskSpec) {
+        cmdlineP->function = FN_XOR;
+        cmdlineP->u.mask = parseHex(mask);
+    } else if (notSpec) {
+        cmdlineP->function = FN_NOT;
+    } else if (shiftleftSpec) {
+        cmdlineP->function = FN_SHIFTLEFT;
+    } else if (shiftrightSpec) {
+        cmdlineP->function = FN_SHIFTRIGHT;
     } else 
         pm_error("You must specify one of -multiplier, -divisor, "
-                 "-adder, -subtractor, -min, or -max");
+                 "-adder, -subtractor, -min, -max, "
+                 "-and, -or, -xor, -not, -shiftleft, or -shiftright");
         
     if (argc-1 > 1)
         pm_error("Too many arguments (%d).  File spec is the only argument.",
@@ -124,6 +193,70 @@ parseCommandLine(int argc, char ** const argv,
 
 
 
+static bool
+isDyadicMaskFunction(enum function const fn) {
+
+    return (fn == FN_AND || fn == FN_OR || fn == FN_XOR);
+}
+
+
+
+static bool
+isMaskFunction(enum function const fn) {
+
+    return (isDyadicMaskFunction(fn) || fn == FN_NOT);
+}
+
+
+
+static bool
+isShiftFunction(enum function const fn) {
+
+    return (fn == FN_SHIFTLEFT || fn == FN_SHIFTRIGHT);
+}
+
+
+
+static bool
+isBitstringFunction(enum function const fn) {
+
+    return isMaskFunction(fn) || isShiftFunction(fn);
+}
+
+
+
+static void
+validateFunction(struct cmdlineInfo const cmdline,
+                 const struct pam * const pamP) {
+
+    if (isBitstringFunction(cmdline.function)) {
+        if (pm_bitstomaxval(pm_maxvaltobits(pamP->maxval)) != pamP->maxval)
+            pm_error("For a bit string function, the maxval must be a full "
+                     "binary count, i.e. a power of two minus one such as "
+                     "0xff or 0x1.  You have 0x%x",
+                     (unsigned)pamP->maxval);
+
+        if (isDyadicMaskFunction(cmdline.function)) {
+            if ((cmdline.u.mask & pamP->maxval) != cmdline.u.mask)
+                pm_error("Your bit string mask 0x%x is wider than the samples "
+                         "of the image (%u bits, according to the maxval %lu",
+                         cmdline.u.mask, pm_maxvaltobits(pamP->maxval),
+                         pamP->maxval);
+        }
+
+        if (isShiftFunction(cmdline.function)) {
+            if (cmdline.u.shiftCount > pm_maxvaltobits(pamP->maxval))
+                pm_error("Your shift count (%u) is greater than the width "
+                         "of the samples of the image (%u bits, according "
+                         "to the maxval %lu)",
+                         cmdline.u.shiftCount, pm_maxvaltobits(pamP->maxval),
+                         pamP->maxval);
+        }
+    }
+}
+
+
+
 static void
 applyFunction(struct cmdlineInfo const cmdline,
               struct pam         const inpam,
@@ -168,6 +301,25 @@ applyFunction(struct cmdlineInfo const cmdline,
             case FN_MIN:
                 outSample = MIN(inSample, cmdline.u.max);
                 break;
+            case FN_AND:
+                outSample = inSample & cmdline.u.mask;
+                break;
+            case FN_OR:
+                outSample = inSample | cmdline.u.mask;
+                break;
+            case FN_XOR:
+                outSample = inSample ^ cmdline.u.mask;
+                break;
+            case FN_NOT:
+                outSample = ~inSample;
+                break;
+            case FN_SHIFTLEFT:
+                outSample =
+                    (inSample << cmdline.u.shiftCount) & outpam.maxval;
+                break;
+            case FN_SHIFTRIGHT:
+                outSample = inSample >> cmdline.u.shiftCount;
+                break;
             }
             outputRow[col][plane] = MIN(outpam.maxval, outSample);
         }
@@ -179,15 +331,15 @@ applyFunction(struct cmdlineInfo const cmdline,
 int
 main(int argc, char *argv[]) {
 
-    FILE* ifP;
-    tuple* inputRow;   /* Row from input image */
-    tuple* outputRow;  /* Row of output image */
+    FILE * ifP;
+    tuple * inputRow;   /* Row from input image */
+    tuple * outputRow;  /* Row of output image */
     int row;
     struct cmdlineInfo cmdline;
     struct pam inpam;   /* Input PAM image */
     struct pam outpam;  /* Output PAM image */
 
-    pnm_init( &argc, argv );
+    pnm_init(&argc, argv);
 
     parseCommandLine(argc, argv, &cmdline);
 
@@ -195,6 +347,8 @@ main(int argc, char *argv[]) {
 
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
+    validateFunction(cmdline, &inpam);
+
     inputRow = pnm_allocpamrow(&inpam);
 
     outpam = inpam;    /* Initial value -- most fields should be same */
@@ -216,6 +370,6 @@ main(int argc, char *argv[]) {
     pm_close(inpam.file);
     pm_close(outpam.file);
     
-    exit(0);
+    return 0;
 }
 
diff --git a/editor/pammixinterlace.c b/editor/pammixinterlace.c
index 579a8092..f22563f6 100644
--- a/editor/pammixinterlace.c
+++ b/editor/pammixinterlace.c
@@ -14,6 +14,8 @@
 
 ******************************************************************************/
 
+#define _BSD_SOURCE    /* Make sure strcaseeq() is in nstring.h */
+
 #include <string.h>
 
 #include "mallocvar.h"
@@ -206,7 +208,7 @@ parseCommandLine(int argc, char ** argv,
         unsigned int i;
         cmdlineP->filterP = NULL;
         for (i = 0; i < sizeof filters / sizeof(struct filter); ++i) {
-            if (STRCASEEQ(filterName, filters[i].name)) {
+            if (strcaseeq(filterName, filters[i].name)) {
                 cmdlineP->filterP = &filters[i];
                 break;
             }
diff --git a/editor/pnmconvol.c b/editor/pnmconvol.c
index 0bf44ce3..365f7931 100644
--- a/editor/pnmconvol.c
+++ b/editor/pnmconvol.c
@@ -32,7 +32,7 @@ struct cmdlineInfo {
 
 static void
 parseCommandLine(int argc, char ** argv,
-                 struct cmdlineInfo *cmdlineP) {
+                 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.  
@@ -83,23 +83,23 @@ parseCommandLine(int argc, char ** argv,
 /* Macros to verify that r,g,b values are within proper range */
 
 #define CHECK_GRAY \
-    if ( tempgsum < 0L ) g = 0; \
-    else if ( tempgsum > maxval ) g = maxval; \
+    if (tempgsum < 0L) g = 0; \
+    else if (tempgsum > maxval) g = maxval; \
     else g = tempgsum;
 
 #define CHECK_RED \
-    if ( temprsum < 0L ) r = 0; \
-    else if ( temprsum > maxval ) r = maxval; \
+    if (temprsum < 0L) r = 0; \
+    else if (temprsum > maxval) r = maxval; \
     else r = temprsum;
 
 #define CHECK_GREEN \
-    if ( tempgsum < 0L ) g = 0; \
-    else if ( tempgsum > maxval ) g = maxval; \
+    if (tempgsum < 0L) g = 0; \
+    else if (tempgsum > maxval) g = maxval; \
     else g = tempgsum;
 
 #define CHECK_BLUE \
-    if ( tempbsum < 0L ) b = 0; \
-    else if ( tempbsum > maxval ) b = maxval; \
+    if (tempbsum < 0L) b = 0; \
+    else if (tempbsum > maxval) b = maxval; \
     else b = tempbsum;
 
 struct convolveType {
@@ -109,7 +109,7 @@ struct convolveType {
     void (*pgmConvolver)(const float ** const weights);
 };
 
-static FILE* ifp;
+static FILE * ifp;
 static int crows, ccols, ccolso2, crowso2;
 static int cols, rows;
 static xelval maxval;
diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c
index e13075ff..d3e0d18c 100644
--- a/editor/pnmgamma.c
+++ b/editor/pnmgamma.c
@@ -13,8 +13,8 @@
 #include <math.h>
 #include <ctype.h>
 
-#include "shhopt.h"
 #include "mallocvar.h"
+#include "shhopt.h"
 #include "pnm.h"
 
 enum transferFunction {
@@ -32,7 +32,7 @@ struct cmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *filespec;  /* '-' if stdin */
+    const char * filespec;  /* '-' if stdin */
     enum transferFunction transferFunction;
     float rgamma, ggamma, bgamma;
     unsigned int maxval;
@@ -103,13 +103,12 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
 
     if (gammaSpec)
         if (gammaOpt < 0.0)
-            pm_error("Invalid gamma value.  "
-                         "Must be positive floating point number.");
+            pm_error("Invalid gamma value %f.  Must be positive.", gammaOpt);
     
     if (rgammaSpec) {
         if (cmdlineP->rgamma < 0.0)
-            pm_error("Invalid gamma value.  "
-                     "Must be positive floating point number.");
+            pm_error("Invalid red gamma value %f.  Must be positive.",
+                     cmdlineP->rgamma);
     } else {
         if (gammaSpec)
             cmdlineP->rgamma = gammaOpt;
@@ -118,8 +117,8 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
     }
     if (ggammaSpec) {
         if (cmdlineP->ggamma < 0.0) 
-            pm_error("Invalid gamma value.  "
-                     "Must be positive floating point number.");
+            pm_error("Invalid green gamma value %f.  Must be positive.",
+                     cmdlineP->ggamma);
     } else {
         if (gammaSpec)
             cmdlineP->ggamma = gammaOpt;
@@ -128,8 +127,8 @@ getGammaFromOpts(struct cmdlineInfo * const cmdlineP,
     }
     if (bgammaSpec) {
         if (cmdlineP->bgamma < 0.0)
-            pm_error("Invalid gamma value.  "
-                     "Must be positive floating point number.");
+            pm_error("Invalid blue gamma value %f.  Must be positive.",
+                     cmdlineP->bgamma);
     } else {
         if (gammaSpec)
             cmdlineP->bgamma = gammaOpt;
diff --git a/editor/pnmmargin b/editor/pnmmargin
index d2c9cd72..f7c30b25 100755
--- a/editor/pnmmargin
+++ b/editor/pnmmargin
@@ -22,19 +22,24 @@ tmp3=$tempdir/pnmm3
 tmp4=$tempdir/pnmm4
 
 color="-gofigure"
+plainopt=""
 
 # Parse args.
 while true ; do
     case "$1" in
-	-w* )
+        -p|-pl|-pla|-plai|-plain )
+        plainopt="-plain"
+        shift
+        ;;
+	-w|-wh|-whi|-whit|-white )
 	color="-white"
 	shift
 	;;
-	-b* )
+	-b|-bl|-bla|-blac|-black )
 	color="-black"
 	shift
 	;;
-	-c* )
+	-c|-co|-col|-colo|-color )
 	shift
 	if [ ! ${1-""} ] ; then
 	    echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
@@ -84,4 +89,5 @@ pamflip -rotate90 $tmp2 > $tmp3
 
 # Cat things together.
 pnmcat -lr $tmp2 $tmp1 $tmp2 > $tmp4
-pnmcat -tb $tmp3 $tmp4 $tmp3
+pnmcat -tb $plainopt $tmp3 $tmp4 $tmp3
+
diff --git a/editor/pnmsmooth.c b/editor/pnmsmooth.c
index a18511c7..fa525e14 100644
--- a/editor/pnmsmooth.c
+++ b/editor/pnmsmooth.c
@@ -23,12 +23,12 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <sys/wait.h>
 
 #include "pm_c_util.h"
 #include "mallocvar.h"
 #include "shhopt.h"
 #include "nstring.h"
+#include "pm_system.h"
 #include "pnm.h"
 
 
@@ -36,7 +36,7 @@ struct cmdlineInfo {
     /* All the information the user supplied in the command line,
        in a form easy for the program to use.
     */
-    const char *inputFilespec;  /* Filespec of input file */
+    const char * inputFilespec;  /* Filespec of input file */
     unsigned int width;
     unsigned int height;
     const char * dump;
@@ -176,38 +176,6 @@ writeConvolutionImage(FILE *       const cofp,
 
 
 
-static void
-runPnmconvol(const char * const inputFilespec,
-             const char * const convolutionImageFilespec) {
-
-    /* fork a Pnmconvol process */
-    pid_t rc;
-
-    rc = fork();
-    if (rc < 0)
-        pm_error("fork() failed.  errno=%d (%s)", errno, strerror(errno));
-    else if (rc == 0) {
-        /* child process executes following code */
-
-        execlp("pnmconvol",
-               "pnmconvol", convolutionImageFilespec, inputFilespec,
-               NULL);
-
-        pm_error("error executing pnmconvol command.  errno=%d (%s)",
-                 errno, strerror(errno));
-    } else {
-        /* This is the parent */
-        pid_t const childPid = rc;
-
-        int status;
-
-        /* wait for child to finish */
-        while (wait(&status) != childPid);
-    }
-}
-
-
-
 int
 main(int argc, char ** argv) {
 
@@ -232,7 +200,8 @@ main(int argc, char ** argv) {
     if (cmdline.dump) {
         /* We're done.  Convolution image is in user's file */
     } else {
-        runPnmconvol(cmdline.inputFilespec, tempfileName);
+        pm_system_lp("pnmconvol", NULL, NULL, NULL, NULL,
+                     tempfileName, cmdline.inputFilespec, NULL);
 
         unlink(tempfileName);
         strfree(tempfileName);
diff --git a/editor/ppmcolormask.c b/editor/ppmcolormask.c
index 57e5c825..eed64c19 100644
--- a/editor/ppmcolormask.c
+++ b/editor/ppmcolormask.c
@@ -60,7 +60,7 @@ parseColorOpt(const char *         const colorOpt,
         const char * token;
         token = strsepN(&cursor, ",");
         if (token) {
-            if (STRNEQ(token, "bk:", 3)) {
+            if (strneq(token, "bk:", 3)) {
                 cmdlineP->maskColor[colorCount].matchType = MATCH_BK;
                 cmdlineP->maskColor[colorCount].u.bkColor =
                     ppm_bk_color_from_name(&token[3]);
diff --git a/generator/ppmrough.c b/generator/ppmrough.c
index 070dbbdc..879bcb06 100644
--- a/generator/ppmrough.c
+++ b/generator/ppmrough.c
@@ -10,11 +10,12 @@
 ** documentation.  This software is provided "as is" without express or
 ** implied warranty.  */
 
+#include <stdlib.h>
 #include <math.h>
 #include <sys/time.h>
-#include <stdlib.h>
-#include "ppm.h"
+
 #include "shhopt.h"
+#include "ppm.h"
 
 static pixel** PIX;
 static pixval BG_RED, BG_GREEN, BG_BLUE;
diff --git a/lib/Makefile b/lib/Makefile
index 69b3b1d0..be960250 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -46,7 +46,7 @@ MANUALS3 = libnetpbm
 MANUALS5 = pbm pgm ppm pnm pam
 
 INTERFACE_HEADERS =  pm.h pbm.h bitio.h pbmfont.h \
-	pgm.h ppm.h ppm.h ppmcmap.h ppmfloyd.h colorname.h \
+	pgm.h ppm.h ppmcmap.h ppmfloyd.h colorname.h \
 	pnm.h pam.h pammap.h util/shhopt.h util/nstring.h util/mallocvar.h \
 	pm_system.h pm_gamma.h
 
diff --git a/lib/libpbm2.c b/lib/libpbm2.c
index d04328ef..19ca93b3 100644
--- a/lib/libpbm2.c
+++ b/lib/libpbm2.c
@@ -13,6 +13,7 @@
 #include "pbm.h"
 #include "libpbm.h"
 #include "fileio.h"
+#include "pam.h"
 
 static bit 
 getbit (FILE * const file) {
@@ -54,25 +55,42 @@ pbm_readpbminitrest( file, colsP, rowsP )
         pm_error("Number of columns in header is too large.");
     }
 
-void
-pbm_readpbminit( file, colsP, rowsP, formatP )
-    FILE* file;
-    int* colsP;
-    int* rowsP;
-    int* formatP;
-    {
-    /* Check magic number. */
-    *formatP = pm_readmagicnumber( file );
-    switch ( PBM_FORMAT_TYPE(*formatP) )
-    {
-        case PBM_TYPE:
-    pbm_readpbminitrest( file, colsP, rowsP );
-    break;
 
+
+void
+pbm_readpbminit(FILE * const ifP,
+                int *  const colsP,
+                int *  const rowsP,
+                int *  const formatP) {
+
+    *formatP = pm_readmagicnumber(ifP);
+
+    switch (PAM_FORMAT_TYPE(*formatP)) {
+    case PBM_TYPE:
+        pbm_readpbminitrest(ifP, colsP, rowsP);
+        break;
+
+    case PGM_TYPE:
+        pm_error("The input file is a PGM, not a PBM.  You may want to "
+                 "convert it to PBM with 'pamditherbw | pamtopnm' or "
+                 "'pamthreshold | pamtopnm'");
+
+    case PPM_TYPE:
+        pm_error("The input file is a PPM, not a PBM.  You may want to "
+                 "convert it to PBM with 'ppmtopgm', 'pamditherbw', and "
+                 "'pamtopnm'");
+
+    case PAM_TYPE:
+        pm_error("The input file is a PAM, not a PBM.  "
+                 "If it is a black and white image, you can convert it "
+                 "to PBM with 'pamtopnm'");
+        break;
     default:
-    pm_error( "bad magic number - not a pbm file" );
-    }
+        pm_error("bad magic number - not a Netpbm file");
     }
+}
+
+
 
 void
 pbm_readpbmrow( file, bitrow, cols, format )
diff --git a/lib/libpgm.h b/lib/libpgm.h
index ba51f9a9..7523faaf 100644
--- a/lib/libpgm.h
+++ b/lib/libpgm.h
@@ -12,13 +12,4 @@ pgm_readpgminitrest(FILE * const file,
                     int *  const rowsP, 
                     gray * const maxvalP);
 
-gray
-pgm_getrawsample(FILE * const file,
-                 gray   const maxval);
-
-void
-pgm_writerawsample(FILE * const fileP,
-                   gray   const val,
-                   gray   const maxval);
-
 #endif
diff --git a/lib/libpgm1.c b/lib/libpgm1.c
index f5d89f9c..34cc6392 100644
--- a/lib/libpgm1.c
+++ b/lib/libpgm1.c
@@ -122,11 +122,6 @@ pgm_readpgminit(FILE * const fileP,
     /* Check magic number. */
     realFormat = pm_readmagicnumber(fileP);
     switch (PAM_FORMAT_TYPE(realFormat)) {
-    case PGM_TYPE:
-        *formatP = realFormat;
-        pgm_readpgminitrest(fileP, colsP, rowsP, maxvalP);
-        break;
-        
     case PBM_TYPE:
         *formatP = realFormat;
         pbm_readpbminitrest(fileP, colsP, rowsP);
@@ -150,6 +145,15 @@ pgm_readpgminit(FILE * const fileP,
         *maxvalP = PGM_MAXMAXVAL;
         break;
 
+    case PGM_TYPE:
+        *formatP = realFormat;
+        pgm_readpgminitrest(fileP, colsP, rowsP, maxvalP);
+        break;
+        
+    case PPM_TYPE:
+        pm_error("Input file is a PPM, which this program cannot process.  "
+                 "You may want to convert it to PGM with 'ppmtopgm'");
+
     case PAM_TYPE:
         pnm_readpaminitrestaspnm(fileP, colsP, rowsP, maxvalP, formatP);
 
@@ -159,38 +163,13 @@ pgm_readpgminit(FILE * const fileP,
         break;
 
     default:
-        pm_error("bad magic number - not a pgm or pbm file");
+        pm_error("bad magic number - not a Netpbm file");
     }
     validateComputableSize(*colsP, *rowsP);
 }
 
 
 
-gray
-pgm_getrawsample(FILE * const file,
-                 gray   const maxval) {
-
-    if (maxval < 256) {
-        /* The sample is just one byte.  Read it. */
-        return(pm_getrawbyte(file));
-    } else {
-        /* The sample is two bytes.  Read both. */
-        unsigned char byte_pair[2];
-        size_t pairs_read;
-
-        pairs_read = fread(&byte_pair, 2, 1, file);
-        if (pairs_read == 0) 
-            pm_error("EOF /read error while reading a long sample");
-        /* This could be a few instructions faster if exploited the internal
-           format (i.e. endianness) of a pixval.  Then we might be able to
-           skip the shifting and oring.
-           */
-        return((byte_pair[0]<<8) | byte_pair[1]);
-    }
-}
-
-
-
 static void
 readRpgmRow(FILE * const fileP,
                gray * const grayrow, 
diff --git a/lib/libpgm2.c b/lib/libpgm2.c
index 7a04f09b..9f607d73 100644
--- a/lib/libpgm2.c
+++ b/lib/libpgm2.c
@@ -57,35 +57,6 @@ putus(unsigned short const n,
 
 
 
-void
-pgm_writerawsample(FILE * const fileP,
-                   gray   const val,
-                   gray   const maxval) {
-
-    if (maxval < 256) {
-        /* Samples fit in one byte, so write just one byte */
-        int rc;
-        rc = putc(val, fileP);
-        if (rc == EOF)
-            pm_error("Error writing single byte sample to file");
-    } else {
-        /* Samples are too big for one byte, so write two */
-        int n_written;
-        unsigned char outval[2];
-        /* We could save a few instructions if we exploited the internal
-           format of a gray, i.e. its endianness.  Then we might be able
-           to skip the shifting and anding.
-           */
-        outval[0] = val >> 8;
-        outval[1] = val & 0xFF;
-        n_written = fwrite(&outval, 2, 1, fileP);
-        if (n_written == 0) 
-            pm_error("Error writing double byte sample to file");
-    }
-}
-
-
-
 static void
 format1bpsRow(const gray *    const grayrow,
               unsigned int    const cols,
diff --git a/lib/libpm.c b/lib/libpm.c
index 1c31ce84..9b1ff679 100644
--- a/lib/libpm.c
+++ b/lib/libpm.c
@@ -528,7 +528,8 @@ vmsProgname(int * const argcP, char * argv[]) {
 
 
 void
-pm_init(const char * const progname, unsigned int const flags) {
+pm_init(const char * const progname,
+        unsigned int const flags) {
 /*----------------------------------------------------------------------------
    Initialize static variables that Netpbm library routines use.
 
diff --git a/lib/libppm1.c b/lib/libppm1.c
index 425f2ab1..a6b00e08 100644
--- a/lib/libppm1.c
+++ b/lib/libppm1.c
@@ -154,11 +154,11 @@ ppm_readppminit(FILE *   const fileP,
 
 
 static void
-readppm(FILE *       const fileP, 
-        pixel *      const pixelrow, 
-        unsigned int const cols, 
-        pixval       const maxval, 
-        int          const format) {
+readPpmRow(FILE *       const fileP, 
+           pixel *      const pixelrow, 
+           unsigned int const cols, 
+           pixval       const maxval, 
+           int          const format) {
 
     unsigned int col;
 
@@ -184,11 +184,11 @@ readppm(FILE *       const fileP,
 
 
 static void
-readrppm(FILE *       const fileP, 
-         pixel *      const pixelrow, 
-         unsigned int const cols, 
-         pixval       const maxval, 
-         int          const format) {
+readRppmRow(FILE *       const fileP, 
+            pixel *      const pixelrow, 
+            unsigned int const cols, 
+            pixval       const maxval, 
+            int          const format) {
 
     unsigned int const bytesPerSample = maxval < 256 ? 1 : 2;
     unsigned int const bytesPerRow    = cols * 3 * bytesPerSample;
@@ -260,11 +260,11 @@ readrppm(FILE *       const fileP,
 
 
 static void
-readpgm(FILE *       const fileP, 
-        pixel *      const pixelrow, 
-        unsigned int const cols, 
-        pixval       const maxval, 
-        int          const format) {
+readPgmRow(FILE *       const fileP, 
+           pixel *      const pixelrow, 
+           unsigned int const cols, 
+           pixval       const maxval, 
+           int          const format) {
 
     jmp_buf jmpbuf;
     jmp_buf * origJmpbufP;
@@ -295,11 +295,11 @@ readpgm(FILE *       const fileP,
 
 
 static void
-readpbm(FILE *       const fileP, 
-        pixel *      const pixelrow, 
-        unsigned int const cols, 
-        pixval       const maxval, 
-        int          const format) {
+readPbmRow(FILE *       const fileP, 
+           pixel *      const pixelrow, 
+           unsigned int const cols, 
+           pixval       const maxval, 
+           int          const format) {
 
     jmp_buf jmpbuf;
     jmp_buf * origJmpbufP;
@@ -338,7 +338,7 @@ ppm_readppmrow(FILE *  const fileP,
 
     switch (format) {
     case PPM_FORMAT:
-        readppm(fileP, pixelrow, cols, maxval, format);
+        readPpmRow(fileP, pixelrow, cols, maxval, format);
         break;
 
     /* For PAM, we require a depth of 3, which means the raster format
@@ -346,17 +346,17 @@ ppm_readppmrow(FILE *  const fileP,
     */
     case PAM_FORMAT:
     case RPPM_FORMAT:
-        readrppm(fileP, pixelrow, cols, maxval, format);
+        readRppmRow(fileP, pixelrow, cols, maxval, format);
         break;
 
     case PGM_FORMAT:
     case RPGM_FORMAT:
-        readpgm(fileP, pixelrow, cols, maxval, format);
+        readPgmRow(fileP, pixelrow, cols, maxval, format);
         break;
 
     case PBM_FORMAT:
     case RPBM_FORMAT:
-        readpbm(fileP, pixelrow, cols, maxval, format);
+        readPbmRow(fileP, pixelrow, cols, maxval, format);
         break;
 
     default:
diff --git a/lib/libsystem.c b/lib/libsystem.c
index 59e05a5f..f0a1996a 100644
--- a/lib/libsystem.c
+++ b/lib/libsystem.c
@@ -14,6 +14,7 @@
 =============================================================================*/
 #define _XOPEN_SOURCE
 
+#include <stdarg.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -22,6 +23,8 @@
 #include <signal.h>
 #include <sys/wait.h>
 
+#include "pm_c_util.h"
+#include "mallocvar.h"
 #include "pm.h"
 #include "pm_system.h"
 
@@ -30,21 +33,25 @@
 
 
 static void
-execProgram(const char * const shellCommand,
-            int          const inputPipeFd,
-            int          const outputPipeFd) {
+execProgram(const char *  const progName,
+            const char ** const argArray,
+            int           const stdinFd,
+            int           const stdoutFd) {
 /*----------------------------------------------------------------------------
-   Run the shell command 'shellCommand', supplying to the shell
-   'inputPipeFd' as its Standard Input and 'outputPipeFd' as its 
+   Run the program 'progName' with arguments argArray[], in a child process
+   with 'stdinFd' as its Standard Input and 'stdoutFd' as its
    Standard Output.
 
    But leave Standard Input and Standard Output as we found them.
+
+   Note that stdinFd or stdoutFd may actually be Standard Input and
+   Standard Output already.
 -----------------------------------------------------------------------------*/
     int stdinSaveFd, stdoutSaveFd;
     int rc;
 
-    /* Make inputPipeFd Standard Input.
-       Make outputPipeFd Standard Output.
+    /* Make stdinFd Standard Input.
+       Make stdoutFd Standard Output.
     */
     stdinSaveFd = dup(STDIN);
     stdoutSaveFd = dup(STDOUT);
@@ -52,10 +59,10 @@ execProgram(const char * const shellCommand,
     close(STDIN);
     close(STDOUT);
 
-    dup2(inputPipeFd, STDIN);
-    dup2(outputPipeFd, STDOUT);
+    dup2(stdinFd, STDIN);
+    dup2(stdoutFd, STDOUT);
 
-    rc = execl("/bin/sh", "sh", "-c", shellCommand, NULL);
+    rc = execvp(progName, (char **)argArray);
 
     close(STDIN);
     close(STDOUT);
@@ -65,10 +72,12 @@ execProgram(const char * const shellCommand,
     close(stdoutSaveFd);
 
     if (rc < 0)
-        pm_error("Unable to exec the shell.  Errno=%d (%s)",
-                 errno, strerror(errno));
+        pm_error("Unable to exec '%s' "
+                 "(i.e. the program did not run at all).  "
+                 "execvp() errno=%d (%s)",
+                 progName, errno, strerror(errno));
     else
-        pm_error("INTERNAL ERROR.  execl() returns, but does not fail.");
+        pm_error("INTERNAL ERROR.  execvp() returns, but does not fail.");
 }
 
 
@@ -108,31 +117,47 @@ createPipeFeeder(void          pipeFeederRtn(int, void *),
 
 
 static void
-spawnProcessor(const char * const shellCommand, 
-               int          const stdinFd,
-               int *        const stdoutFdP,
-               pid_t *      const pidP) {
+spawnProcessor(const char *  const progName,
+               const char ** const argArray,
+               int           const stdinFd,
+               int *         const stdoutFdP,
+               pid_t *       const pidP) {
 /*----------------------------------------------------------------------------
-   Create a process to run a shell that runs command 'shellCommand'.
-   Pass file descriptor 'stdinFd' to the shell as Standard Input.
-   Set up a pipe and pass it to the shell as Standard Output.  Return
-   as *stdoutFdP the file descriptor of the other end of that pipe,
-   from which Caller can suck the shell's Standard Output.
+   Create a process to run program 'progName' with arguments
+   argArray[] (terminated by NULL element).  Pass file descriptor
+   'stdinFd' to the shell as Standard Input.
+
+   if 'stdoutFdP' is NULL, have that process write its Standard Output to
+   the current process' Standard Output.
+
+   If 'stdoutFdP' is non-NULL, set up a pipe and pass it to the new
+   process as Standard Output.  Return as *stdoutFdP the file
+   descriptor of the other end of that pipe, from which Caller can
+   suck the program's Standard Output.
 -----------------------------------------------------------------------------*/
+    bool const pipeStdout = !stdoutFdP;
     int stdoutpipe[2];
     pid_t rc;
-        
-    pipe(stdoutpipe);
+
+    if (pipeStdout)
+        pipe(stdoutpipe);
 
     rc = fork();
     if (rc < 0) {
         pm_error("fork() of processor process failed.  errno=%d (%s)\n", 
                  errno, strerror(errno));
     } else if (rc == 0) {
-        /* The second child */
-        close(stdoutpipe[0]);
+        /* The program child */
+
+        int stdoutFd;
+        
+        if (pipeStdout) {
+            close(stdoutpipe[0]);
+            stdoutFd = stdoutpipe[1];
+        } else
+            stdoutFd = STDOUT;
 
-        execProgram(shellCommand, stdinFd, stdoutpipe[1]);
+        execProgram(progName, argArray, stdinFd, stdoutFd);
 
         close(stdinFd);
         close(stdoutpipe[1]);
@@ -140,8 +165,11 @@ spawnProcessor(const char * const shellCommand,
     } else {
         /* The parent */
         pid_t const processorpid = rc;
-        close(stdoutpipe[1]);
-        *stdoutFdP = stdoutpipe[0];
+
+        if (pipeStdout) {
+            close(stdoutpipe[1]);
+            *stdoutFdP = stdoutpipe[0];
+        }
         *pidP = processorpid;
     }
 }
@@ -191,94 +219,150 @@ cleanupFeederProcess(pid_t const feederPid) {
 
 
 void
-pm_system(void stdinFeeder(int, void *),
-          void *          const feederParm,
-          void stdoutAccepter(int, void *),
-          void *          const accepterParm,
-          const char *    const shellCommand) {
+pm_system_vp(const char *    const progName,
+             const char **   const argArray,
+             void stdinFeeder(int, void *),
+             void *          const feederParm,
+             void stdoutAccepter(int, void *),
+             void *          const accepterParm) {
 /*----------------------------------------------------------------------------
-   Run a shell and have it run command 'shellCommand'.  Feed its
-   Standard Input with a pipe, which is fed by the routine
-   'stdinFeeder' with parameter 'feederParm'.  Process its Standard
-   Output with the routine 'stdoutAccepter' with parameter 'accepterParm'.
+   Run a program in a child process.  Feed its Standard Input with a
+   pipe, which is fed by the routine 'stdinFeeder' with parameter
+   'feederParm'.  Process its Standard Output with the routine
+   'stdoutAccepter' with parameter 'accepterParm'.
 
-   But if 'stdinFeeder' is NULL, just feed the shell our own Standard
+   But if 'stdinFeeder' is NULL, just feed the program our own Standard
    Input.  And if 'stdoutFeeder' is NULL, just send its Standard Output
    to our own Standard Output.
 -----------------------------------------------------------------------------*/
 
     /* If 'stdinFeeder' is non-NULL, we create a child process to run
-       'stdinFeeder' and create a pipe between from that process as the
-       shell's Standard Input.
+       'stdinFeeder' and create a pipe from that process as the
+       program's Standard Input.
 
-       If 'stdoutFeeder' is non-NULL, we create a child process to run
-       the shell and create a pipe between the shell's Standard Output
-       and the current process, and then the current process runs
-       'stdoutAccepter' to read the data from that pipe.
+       We create another child process to run the program.
+
+       If 'stdoutFeeder' is non-NULL, we create a pipe between the
+       program process and the current process and have the program
+       write its Standard Output to that pipe.  The current process
+       runs 'stdoutAccepter' to read the data from that pipe.
        
-       But if 'stdoutFeeder' is NULL, we just run the shell in the
-       current process.
+       But if 'stdoutFeeder' is NULL, we just tell the program process
+       to write to the current process' Standard Output.
 
-       So there can be 1, 2, or 3 processes involved depending on 
-       parameters.
+       So there are two processes when stdinFeeder is NULL and three when
+       stdinFeeder is non-null.
     */
     
-    int shellStdinFd;
+    int progStdinFd;
     pid_t feederPid;
+    pid_t processorPid;
 
     if (stdinFeeder) 
-        createPipeFeeder(stdinFeeder, feederParm, &shellStdinFd, &feederPid);
+        createPipeFeeder(stdinFeeder, feederParm, &progStdinFd, &feederPid);
     else {
-        shellStdinFd = STDIN;
+        progStdinFd = STDIN;
         feederPid = 0;
     }
 
     if (stdoutAccepter) {
-        int shellStdoutFd;
-        pid_t processorPid;
+        int progStdoutFd;
 
-        /* Make a child process to run the shell and pipe back to us its
+        /* Make a child process to run the program and pipe back to us its
            Standard Output 
         */
-        spawnProcessor(shellCommand, shellStdinFd, 
-                       &shellStdoutFd, &processorPid);
+        spawnProcessor(progName, argArray, progStdinFd, 
+                       &progStdoutFd, &processorPid);
 
-        /* The shell process has cloned our 'shellStdinFd'; we have no
+        /* The child process has cloned our 'progStdinFd'; we have no
            more use for our copy.
         */
-        close(shellStdinFd);
-        /* Dispose of the stdout from that shell */
-        (*stdoutAccepter)(shellStdoutFd, accepterParm);
-        close(shellStdoutFd);
-
-        cleanupProcessorProcess(processorPid);
+        close(progStdinFd);
+        /* Dispose of the stdout from that child */
+        (*stdoutAccepter)(progStdoutFd, accepterParm);
+        close(progStdoutFd);
     } else {
-        /* Run a child process for the shell that sends its Standard Output
+        /* Run a child process for the program that sends its Standard Output
            to our Standard Output
         */
-        int const stdinSaveFd = dup(STDIN);
-        int rc;
+        spawnProcessor(progName, argArray, STDIN, NULL, &processorPid);
+    }
 
-        dup2(shellStdinFd, STDIN);
-        
-        rc = system(shellCommand);
+    cleanupProcessorProcess(processorPid);
+
+    if (feederPid) 
+        cleanupFeederProcess(feederPid);
+}
+
+
+
+void
+pm_system_lp(const char *    const progName,
+             void stdinFeeder(int, void *),
+             void *          const feederParm,
+             void stdoutAccepter(int, void *),
+             void *          const accepterParm,
+             ...) {
+/*----------------------------------------------------------------------------
+  same as pm_system_vp() except with arguments as variable arguments
+  instead of an array.
+-----------------------------------------------------------------------------*/
+    va_list args;
+    bool endOfArgs;
+    const char ** argArray;
+    unsigned int n;
+
+    va_start(args, accepterParm);
 
-        close(STDIN);
-        dup2(stdinSaveFd, STDIN);
+    endOfArgs = FALSE;
+    argArray = NULL;
+
+    for (endOfArgs = FALSE, argArray = NULL, n = 0;
+         !endOfArgs;
+        ) {
+        const char * const arg = va_arg(args, const char *);
         
-        if (rc < 0)
-            pm_error("Unable to invoke the shell.  Errno=%d (%s)",
-                     errno, strerror(errno));
-        else if (rc != 0)
-            pm_message("WARNING: Shell process completion code = %d", rc);
+        REALLOCARRAY(argArray, n+1);
+
+        argArray[n++] = arg;
+
+        if (!arg)
+            endOfArgs = TRUE;
     }
 
-    if (feederPid) 
-        cleanupFeederProcess(feederPid);
+    va_end(args);
+
+    pm_system_vp(progName, argArray,
+                 stdinFeeder, feederParm, stdoutAccepter, accepterParm);
+
+    free(argArray);
 }
 
 
 
+void
+pm_system(void stdinFeeder(int, void *),
+          void *          const feederParm,
+          void stdoutAccepter(int, void *),
+          void *          const accepterParm,
+          const char *    const shellCommand) {
+/*----------------------------------------------------------------------------
+   Run a shell and have it run command 'shellCommand'.  Feed its
+   Standard Input with a pipe, which is fed by the routine
+   'stdinFeeder' with parameter 'feederParm'.  Process its Standard
+   Output with the routine 'stdoutAccepter' with parameter 'accepterParm'.
+
+   But if 'stdinFeeder' is NULL, just feed the shell our own Standard
+   Input.  And if 'stdoutFeeder' is NULL, just send its Standard Output
+   to our own Standard Output.
+-----------------------------------------------------------------------------*/
+
+    pm_system_lp("/bin/sh", 
+                 stdinFeeder, feederParm, stdoutAccepter, accepterParm,
+                 "sh", "-c", shellCommand, NULL);
+}
+
+
 
 void
 pm_feed_from_memory(int    const pipeToFeedFd,
diff --git a/lib/pm_system.h b/lib/pm_system.h
index 0605f888..a7560f48 100644
--- a/lib/pm_system.h
+++ b/lib/pm_system.h
@@ -10,13 +10,28 @@ extern "C" {
 
 
 void
+pm_system_vp(const char *    const progName,
+             const char **   const argArray,
+             void stdinFeeder(int, void *),
+             void *          const feederParm,
+             void stdoutAccepter(int, void *),
+             void *          const accepterParm);
+
+void
+pm_system_lp(const char *    const progName,
+             void stdinFeeder(int, void *),
+             void *          const feederParm,
+             void stdoutAccepter(int, void *),
+             void *          const accepterParm,
+             ...);
+
+void
 pm_system(void                  stdinFeeder(int, void *),
           void *          const feederParm,
           void                  stdoutAccepter(int, void *),
           void *          const accepterParm,
           const char *    const shellCommand);
 
-
 struct bufferDesc {
     /* This is just a parameter for the routines below */
     unsigned int    size;
diff --git a/lib/util/mallocvar.h b/lib/util/mallocvar.h
index a26d007b..e5b7b1ea 100644
--- a/lib/util/mallocvar.h
+++ b/lib/util/mallocvar.h
@@ -57,11 +57,22 @@ static __inline__ void
 reallocProduct(void **      const blockP,
                unsigned int const factor1,
                unsigned int const factor2) {
+
+    void * const oldBlockP = *blockP;
+
+    void * newBlockP;
     
     if (UINT_MAX / factor2 < factor1) 
-        *blockP = NULL;
+        newBlockP = NULL;
     else 
-        *blockP = realloc(*blockP, factor1 * factor2); 
+        newBlockP = realloc(oldBlockP, factor1 * factor2); 
+
+    if (newBlockP)
+        *blockP = newBlockP;
+    else {
+        free(oldBlockP);
+        *blockP = NULL;
+    }
 }
 
 
diff --git a/lib/util/nstring.c b/lib/util/nstring.c
index 58500547..feb8215e 100644
--- a/lib/util/nstring.c
+++ b/lib/util/nstring.c
@@ -878,19 +878,22 @@ stripeq(const char * const comparand,
 
 
 
-const char *
-memmemN(const char * const haystack,
+const void *
+memmemN(const void * const haystackArg,
         size_t       const haystacklen,
-        const char * const needle,
+        const void * const needleArg,
         size_t       const needlelen) {
 
+    const unsigned char * const haystack = haystackArg;
+    const unsigned char * const needle   = needleArg;
+
     /* This does the same as the function of the same name in the GNU
        C library
     */
-    const char * p;
+    const unsigned char * p;
 
     for (p = haystack; p <= haystack + haystacklen - needlelen; ++p)
-        if (MEMEQ(p, needle, needlelen))
+        if (memeq(p, needle, needlelen))
             return p;
 
     return NULL;
diff --git a/lib/util/nstring.h b/lib/util/nstring.h
index 70a53f45..9d61cfa5 100644
--- a/lib/util/nstring.h
+++ b/lib/util/nstring.h
@@ -15,7 +15,7 @@ extern "C" {
 } /* to fake out automatic code indenters */
 #endif
 
-/* Here is are string functions that respect the size of the array
+/* Here are string functions that respect the size of the array
    into which you are copying -- E.g. STRSCPY truncates the source string as
    required so that it fits, with the terminating null, in the destination
    array.
@@ -26,20 +26,8 @@ extern "C" {
 	(strncmp((A), (B), sizeof(A)))
 #define STRSCAT(A,B) \
     (strncpy(A+strlen(A), B, sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
-
-#define STREQ(A, B) \
-    (strcmp((A), (B)) == 0)
-#define STRNEQ(A, B, C) \
-    (strncmp((A), (B), (C)) == 0)
-#define STRCASEEQ(A, B) \
-    (strcasecmp((A), (B)) == 0)
-#define STRNCASEEQ(A, B, C) \
-    (strncasecmp((A), (B), (C)) == 0)
 #define STRSEQ(A, B) \
-	(strncmp((A), (B), sizeof(A)) == 0)
-
-#define MEMEQ(A, B, C) \
-    (memcmp((A), (B), (C)) == 0)
+	(strneq((A), (B), sizeof(A)))
 #define MEMSZERO(A) \
     bzero((A), sizeof(A))
 
@@ -51,6 +39,42 @@ streq(const char * const comparand,
     return strcmp(comparand, comparator) == 0;
 }
 
+static __inline__ int
+strneq(const char * const comparand,
+       const char * const comparator,
+       size_t       const size) {
+
+    return strncmp(comparand, comparator, size) == 0;
+}
+
+static __inline__ int
+memeq(const void * const comparand,
+      const void * const comparator,
+      size_t       const size) {
+    
+    return memcmp(comparand, comparator, size) == 0;
+}
+
+/* The Standard C Library may not declare strcasecmp() if the including
+   source file doesn't request BSD functions, with _BSD_SOURCE.  So
+   we don't define functions that use strcasecmp() in that case.
+*/
+#ifdef _BSD_SOURCE
+static __inline__ int
+strcaseeq(const char * const comparand,
+          const char * const comparator) {
+
+    return strcasecmp(comparand, comparator) == 0;
+}
+
+static __inline__ int
+strncaseeq(const char * const comparand,
+           const char * const comparator,
+           size_t       const size) {
+
+    return strncasecmp(comparand, comparator, size) == 0;
+}
+#endif
 
 
 /* The standard C library routines isdigit(), for some weird 
@@ -150,10 +174,10 @@ int
 stripeq(const char * const comparand,
         const char * const comparator);
 
-const char *
-memmemN(const char * const haystack,
+const void *
+memmemN(const void * const haystackArg,
         size_t       const haystacklen,
-        const char * const needle,
+        const void * const needleArg,
         size_t       const needlelen);
 
 bool
diff --git a/other/pamx/window.c b/other/pamx/window.c
index 1a6e510b..2eb48241 100644
--- a/other/pamx/window.c
+++ b/other/pamx/window.c
@@ -6,6 +6,8 @@
    See COPYRIGHT file for copyright information.
 */
 
+#define _BSD_SOURCE    /* Make sure strcaseeq() is in nstring.h */
+
 #include <assert.h>
 #include <ctype.h>
 #include <signal.h>
@@ -555,7 +557,7 @@ visualClassFromName(const char * const name) {
     bool found;
     
     for (a = 0, found = FALSE; VisualClassName[a].name; ++a) {
-        if (STRCASEEQ(VisualClassName[a].name, name)) {
+        if (strcaseeq(VisualClassName[a].name, name)) {
             /* Check for uniqueness.  We special-case StaticGray
                because we have two spellings but they are unique if
                we find either.
diff --git a/urt/rle_open_f.c b/urt/rle_open_f.c
index d2575c11..70110f29 100644
--- a/urt/rle_open_f.c
+++ b/urt/rle_open_f.c
@@ -1,10 +1,10 @@
 /* 
  * rle_open_f.c - Open a file with defaults.
  * 
- * Author : 	Jerry Winters 
- * 		EECS Dept.
- * 		University of Michigan
- * Date:	11/14/89
+ * Author :     Jerry Winters 
+ *      EECS Dept.
+ *      University of Michigan
+ * Date:    11/14/89
  * Copyright (c) 1990, University of Michigan
  */
 
@@ -43,55 +43,55 @@ my_popen(const char * const cmd,
     /* Check args. */
     if ( *mode != 'r' && *mode != 'w' )
     {
-	errno = EINVAL;
-	return NULL;
+        errno = EINVAL;
+        return NULL;
     }
 
     if ( pipe(pipefd) < 0 )
-	return NULL;
+        return NULL;
     
     /* Flush known files. */
     fflush(stdout);
     fflush(stderr);
     if ( (thepid = fork()) < 0 )
     {
-	close(pipefd[0]);
-	close(pipefd[1]);
-	return NULL;
+        close(pipefd[0]);
+        close(pipefd[1]);
+        return NULL;
     }
     else if (thepid == 0) {
-	/* In child. */
-	/* Rearrange file descriptors. */
-	if ( *mode == 'r' )
-	{
-	    /* Parent reads from pipe, so reset stdout. */
-	    close(1);
-	    dup2(pipefd[1],1);
-	} else {
-	    /* Parent writing to pipe. */
-	    close(0);
-	    dup2(pipefd[0],0);
-	}
-	/* Close anything above fd 2. (64 is an arbitrary magic number). */
-	for ( i = 3; i < 64; i++ )
-	    close(i);
-
-	/* Finally, invoke the program. */
-	if ( execl("/bin/sh", "sh", "-c", cmd, NULL) < 0 )
-	    exit(127);
-	/* NOTREACHED */
-    }	
+        /* In child. */
+        /* Rearrange file descriptors. */
+        if ( *mode == 'r' )
+        {
+            /* Parent reads from pipe, so reset stdout. */
+            close(1);
+            dup2(pipefd[1],1);
+        } else {
+            /* Parent writing to pipe. */
+            close(0);
+            dup2(pipefd[0],0);
+        }
+        /* Close anything above fd 2. (64 is an arbitrary magic number). */
+        for ( i = 3; i < 64; i++ )
+            close(i);
+
+        /* Finally, invoke the program. */
+        if ( execl("/bin/sh", "sh", "-c", cmd, NULL) < 0 )
+            exit(127);
+        /* NOTREACHED */
+    }   
 
     /* Close file descriptors, and gen up a FILE ptr */
     if ( *mode == 'r' )
     {
-	/* Parent reads from pipe. */
-	close(pipefd[1]);
-	retfile = fdopen( pipefd[0], mode );
+        /* Parent reads from pipe. */
+        close(pipefd[1]);
+        retfile = fdopen( pipefd[0], mode );
     } else {
-	/* Parent writing to pipe. */
-	close(pipefd[0]);
-	retfile = fdopen( pipefd[1], mode );
+        /* Parent writing to pipe. */
+        close(pipefd[0]);
+        retfile = fdopen( pipefd[1], mode );
     }
 
     /* Return the PID. */
@@ -113,10 +113,10 @@ my_popen(const char * const cmd,
  *
  *  parameters
  *   input:
- *     prog_name: 	name of the calling program.
- *     file_name : 	name of the file to open
- *     mode : 		either "r" for read or input file or "w" for write or
- *            		output file
+ *     prog_name:   name of the calling program.
+ *     file_name :  name of the file to open
+ *     mode :       either "r" for read or input file or "w" for write or
+ *                  output file
  *
  *   output:
  *     a file pointer
@@ -185,12 +185,12 @@ rle_open_f_noexit(const char * const prog_name,
          *  
          *  If it starts with "|", popen that command.
          */
-	    
+        
         cp = file_name + strlen( (char*) file_name ) - 2;
         /* Pipe case. */
         if ( *file_name == '|' )
         {
-            int thepid;		/* PID from my_popen */
+            int thepid;     /* PID from my_popen */
             if ( (fp = my_popen( file_name + 1, mode, &thepid )) == NULL )
             {
                 err_str = "%s: can't invoke <<%s>> for %s: ";
@@ -205,7 +205,7 @@ rle_open_f_noexit(const char * const prog_name,
         /* Compress case. */
         else if ( cp > file_name && *cp == '.' && *(cp + 1) == 'Z' )
         {
-            int thepid;		/* PID from my_popen. */
+            int thepid;     /* PID from my_popen. */
             combuf = (char *)malloc( 20 + strlen( file_name ) );
             if ( combuf == NULL )
             {
@@ -244,7 +244,7 @@ rle_open_f_noexit(const char * const prog_name,
                defined.  But for Netpbm, there is no need make a distinction;
                we always add the "b".  -BJH 2000.07.20.  
             */
-            char mode_string[32];	/* Should be enough. */
+            char mode_string[32];   /* Should be enough. */
 
             /* Concatenate a 'b' onto the mode. */
             mode_string[0] = mode[0];
@@ -261,14 +261,14 @@ rle_open_f_noexit(const char * const prog_name,
 
     return fp;
 
-err:
-	fprintf( stderr, err_str,
+                  err:
+    fprintf( stderr, err_str,
              prog_name, file_name,
              (*mode == 'w') ? "output" :
              (*mode == 'a') ? "append" :
              "input" );
-	perror( "" );
-	return NULL;
+    perror( "" );
+    return NULL;
 
 }
 
@@ -278,7 +278,7 @@ rle_open_f(const char * prog_name, const char * file_name, const char * mode)
     FILE *fp;
 
     if ( (fp = rle_open_f_noexit( prog_name, file_name, mode )) == NULL )
-	exit( -1 );
+        exit( -1 );
 
     return fp;
 }
@@ -290,21 +290,21 @@ rle_open_f(const char * prog_name, const char * file_name, const char * mode)
  * Close a file opened by rle_open_f.  If the file is stdin or stdout,
  * it will not be closed.
  * Inputs:
- * 	fd:	File to close.
+ *  fd: File to close.
  * Outputs:
- * 	None.
+ *  None.
  * Assumptions:
- * 	fd is open.
+ *  fd is open.
  * Algorithm:
- * 	If fd is NULL, just return.
- * 	If fd is stdin or stdout, don't close it.  Otherwise, call fclose.
+ *  If fd is NULL, just return.
+ *  If fd is stdin or stdout, don't close it.  Otherwise, call fclose.
  */
 void
 rle_close_f( fd )
-FILE *fd;
+    FILE *fd;
 {
     if ( fd == NULL || fd == stdin || fd == stdout )
-	return;
+        return;
     else
-	fclose( fd );
+        fclose( fd );
 }