about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xconverter/other/anytopnm14
-rw-r--r--converter/other/fiasco/params.c13
-rw-r--r--doc/HISTORY8
-rwxr-xr-xeditor/pnmmargin8
-rwxr-xr-xeditor/pnmquant19
-rwxr-xr-xeditor/pnmquantall15
-rwxr-xr-xeditor/ppmfade16
-rwxr-xr-xeditor/ppmshadow38
-rwxr-xr-xgenerator/pgmcrater25
-rwxr-xr-xgenerator/ppmrainbow41
10 files changed, 169 insertions, 28 deletions
diff --git a/converter/other/anytopnm b/converter/other/anytopnm
index 397faae5..e5de85cc 100755
--- a/converter/other/anytopnm
+++ b/converter/other/anytopnm
@@ -527,14 +527,18 @@ if [ $# -gt 1 ] ; then
          "input file name." 1>&2
     exit 1
 elif [ $# -eq 1 ] ; then
-    inputFile="$1"
+    if [ $1 = "--version" -o $1 = "-version" ] ; then
+        pamtopnm --version ; exit $?
+    else 
+        inputFile="$1"
+    fi
 else
-    inputFile="-"
+        inputFile="-"
+
 fi
 
-tempdir="${TMPDIR-/tmp}/anytopnm.$$"
-mkdir -m 0700 $tempdir || \
-  { echo "Could not create temporary file. Exiting."; exit 1;}
+tempdir=$(mktemp -d "${TMPDIR:-/tmp}/anytopnm.XXXXXXXX") ||
+    ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) 
 trap 'rm -rf $tempdir' 0
 
 # Take out all spaces
diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c
index afacbada..fef004e8 100644
--- a/converter/other/fiasco/params.c
+++ b/converter/other/fiasco/params.c
@@ -325,8 +325,17 @@ parseargs (param_t *usr_params,
 		      NO, sys_path, usr_file_name);
 	    else if (streq (params [param_index].name, "version"))
 	    {
-	       fprintf (stderr, "%s " VERSION "\n", argv [0]);
-	       exit (2);
+           fprintf (stderr, "%s " VERSION "\n", argv [0]);
+           {
+              /* Kludge for standard Netpbm version announcement */
+              char * modified_argv[2];
+              int argc;
+              modified_argv[0] = argv[0];
+              modified_argv[1] = (char *) "--version";
+              argc = 2;
+              pm_proginit(&argc, (const char **) modified_argv);
+           }
+           exit (2);
 	    }
 	    else if (streq (params [param_index].name, "verbose"))
 	       fiasco_set_verbosity (
diff --git a/doc/HISTORY b/doc/HISTORY
index 57b7d400..5e74e762 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -17,6 +17,14 @@ not yet  BJH  Release 10.75.00
 
               pbmreduce: add -randomseed.
 
+              anytopnm, pnmmargin, pnmquant, pnmquantall, pgmcrater,
+              ppmfade, ppmrainbow, ppmshadow: Add -version.
+
+              fiascotopnm: change -version to include Netpbm version.
+
+              ppmshadow: fix bug: don't ignore invalid option.  Introduced in
+              Netpbm 10.9 (September 2002).
+
               pnmpaste: fix possible invalid memory access.  Introduced in
               Netpbm 1.44 (September 2008).
 
diff --git a/editor/pnmmargin b/editor/pnmmargin
index 0f57d1d4..9dbe24b7 100755
--- a/editor/pnmmargin
+++ b/editor/pnmmargin
@@ -11,9 +11,8 @@
 # documentation.  This software is provided "as is" without express or
 # implied warranty.
 
-tempdir="${TMPDIR-/tmp}/pnmmargin.$$"
-mkdir -m 0700 $tempdir || \
-  { echo "Could not create temporary file. Exiting." 1>&2; exit 1;}
+tempdir=$(mktemp -d "${TMPDIR:-/tmp}/netpbm.XXXXXXXX") ||
+    ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) 
 trap 'rm -rf $tempdir' 0 1 3 15
 
 tmp1=$tempdir/pnmm1
@@ -27,6 +26,9 @@ plainopt=""
 # Parse args.
 while true ; do
     case "$1" in
+        -version|--version )
+        pnmpad --version; exit $?;
+        ;;
         -p|-pl|-pla|-plai|-plain )
         plainopt="-plain"
         shift
diff --git a/editor/pnmquant b/editor/pnmquant
index 93d452cd..35a75e96 100755
--- a/editor/pnmquant
+++ b/editor/pnmquant
@@ -42,6 +42,21 @@ my ($TRUE, $FALSE) = (1,0);
 
 my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2);
 
+
+
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('pnmcolormap', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+
 sub tempFile($) {
 
     # We trust Perl's File::Temp to do a better job of creating the temp
@@ -93,7 +108,7 @@ sub parseCommandLine(@) {
               scalar(@ARGV), "\n");
         exit(1);
     } 
-    if (@ARGV < 1) {
+    elsif (@ARGV < 1) {
         print(STDERR 
               "You must specify the number of colors as an argument.\n");
         exit(1);
@@ -267,6 +282,8 @@ sub remap($$$$) {
 #                              MAIN PROGRAM
 ##############################################################################
 
+doVersionHack(\@ARGV);
+
 my $cmdlineR = parseCommandLine(@ARGV);
 
 openSeekableAsStdin($cmdlineR->{infile}); 
diff --git a/editor/pnmquantall b/editor/pnmquantall
index 0890383e..844fc13d 100755
--- a/editor/pnmquantall
+++ b/editor/pnmquantall
@@ -61,6 +61,19 @@ my $TRUE=1; my $FALSE = 0;
 
 
 
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('pnmcolormap', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+
 sub parseArgs($$$$) {
     my ($argvR, $extR, $newColorCtR, $fileNamesR) = @_;
 
@@ -179,6 +192,8 @@ sub remapFiles($$$$) {
 
 my $progError;
 
+doVersionHack(\@ARGV);
+
 parseArgs(\@ARGV, \my $ext, \my $newColorCt, \my @fileNames);
 
 my ($colorMapFh, $colorMapFileName) = tempFile("pnm");
diff --git a/editor/ppmfade b/editor/ppmfade
index 027fc793..dcd7bf26 100755
--- a/editor/ppmfade
+++ b/editor/ppmfade
@@ -41,6 +41,19 @@ exec perl -w -x -S -- "$0" "$@"
 ##############################################################################
 use strict;
 
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('ppmmix', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+
 my $SPREAD =  1;
 my $SHIFT =   2;
 my $RELIEF =  3;
@@ -59,6 +72,7 @@ my $base_name = "fade";		# default base name of output files
 my $image = "ppm";		# default output storage format
 my $mode = $SPREAD;		# default fading mode
 
+doVersionHack(\@ARGV);
 
 my $n;  # argument number
 
@@ -98,8 +112,6 @@ for ($n = 0; $n < @ARGV; $n++) {
         $mode = $BLOCK;
     } elsif ("$ARGV[$n]" eq "-mix") {
         $mode = $MIX;
-    } elsif ($ARGV[$n] eq "-help" || $ARGV[$n] eq "-h") {
-        usage();
     } else {
         print "Unknown argument: $ARGV[$n]\n";
         exit 100;
diff --git a/editor/ppmshadow b/editor/ppmshadow
index 62cdf8b8..87ccd292 100755
--- a/editor/ppmshadow
+++ b/editor/ppmshadow
@@ -48,6 +48,7 @@ exec perl -w -x -S -- "$0" "$@"
 ##############################################################################
 
 use strict;
+use File::Temp;
 require 5.0;
 #  The good open() syntax, with the mode separate from the file name,
 #  came after 5.0.  So did mkdir() with default mode.
@@ -55,6 +56,20 @@ require 5.0;
 my $true=1; my $false=0;
 
 
+
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('pamarith', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+
 sub getDimensions($) {
     my ($fileName) = @_;
 #-----------------------------------------------------------------------------
@@ -95,15 +110,10 @@ sub makeConvolutionKernel($$) {
 #                           MAINLINE
 ##############################################################################
 
-
-my $tmpdir = $ENV{TMPDIR} || "/tmp";
-my $ourtmp = "$tmpdir/ppmshadow$$";
-mkdir($ourtmp, 0777) or
-    die("Unable to create directory for temporary files '$ourtmp");
+doVersionHack(\@ARGV);
 
 #   Process command line options
 
-
 my $ifile; # Input file name
 my ($xoffset, $yoffset);
 
@@ -113,6 +123,7 @@ my $translucent = $false;            # Default not translucent
 
 while (@ARGV) {
     my $arg = shift;
+
     if ((substr($arg, 0, 1) eq '-') && (length($arg) > 1)) {
         my $opt;
         $opt = substr($arg, 1, 1);
@@ -142,6 +153,8 @@ while (@ARGV) {
             if ($yoffset < 0) {
                 $yoffset = -$xoffset;
             }
+        } else {
+            die("Unknown option '$opt'\n");
         }
     } else {
         if (defined $ifile) {
@@ -151,6 +164,19 @@ while (@ARGV) {
     }
 }
 
+# Create temporary directory
+
+my $tmpdir = $ENV{TMPDIR} || "/tmp";
+my $ourtmp;
+
+if ($keeptemp) {
+    $ourtmp = "$tmpdir/ppmshadow$$";
+    mkdir($ourtmp, 0777) or
+        die("Unable to create directory for temporary files '$ourtmp");
+} else {
+    $ourtmp = File::Temp::tempdir("$tmpdir/ppmrainbowXXXX", UNLINK=>1);
+}
+
 #   Apply defaults for arguments not specified
 
 if (!(defined $xoffset)) {
diff --git a/generator/pgmcrater b/generator/pgmcrater
index 1c22ed70..0a5d3fe9 100755
--- a/generator/pgmcrater
+++ b/generator/pgmcrater
@@ -37,6 +37,26 @@ use strict;
 
 use Getopt::Long;
 
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('pamcrater', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+##############################################################################
+#
+#  MAINLINE
+#
+##############################################################################
+
+doVersionHack();
+
 my @pgmcraterArgv = @ARGV;
 
 my $validOptions = GetOptions(
@@ -53,6 +73,11 @@ if (!$validOptions) {
     exit(100);
 }
 
+if (defined($versionOpt)) {
+    my $termStatus = system("pamcrater --version");
+    exit($termStatus);
+}
+
 my $pamcraterArgs;
 
 $pamcraterArgs = '';  # initial value
diff --git a/generator/ppmrainbow b/generator/ppmrainbow
index c0568d9b..a4f90a09 100755
--- a/generator/ppmrainbow
+++ b/generator/ppmrainbow
@@ -25,11 +25,27 @@ exec perl -w -x -S -- "$0" "$@"
 #!/usr/bin/perl
 use strict;
 use Getopt::Long;
+use File::Temp;
 
 my ($FALSE, $TRUE) = (0,1);
 
 (my $myname = $0) =~ s#\A.*/##;
 
+
+
+sub doVersionHack($) {
+    my ($argvR) = @_;
+
+    my $arg1 = $argvR->[0];
+
+    if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) {
+        my $termStatus = system('pgmramp', '--version');
+        exit($termStatus == 0 ? 0 : 1);
+    }
+}
+
+
+
 sub fatal($) {
     my ($msg) = @_;
 
@@ -37,19 +53,29 @@ sub fatal($) {
     exit(1);
 }
 
-my ($Twid, $Thgt, $tmpdir, $norepeat, $verbose);
+
+
+##############################################################################
+#
+#                                 MAINLINE
+#
+##############################################################################
+
+doVersionHack(\@ARGV);
+
+my ($Twid, $Thgt, $tmpdir, $repeat, $verbose);
 
 # set defaults
 $Twid = 600;
 $Thgt = 8;
 $tmpdir = $ENV{"TMPDIR"} || "/tmp";
-$norepeat = $FALSE;
+$repeat = $TRUE;
 $verbose = $FALSE;
 
 GetOptions("width=i"   => \$Twid,
            "height=i"  => \$Thgt,
            "tmpdir=s"  => \$tmpdir,
-           "norepeat!" => \$norepeat,
+           "repeat!"   => \$repeat,
            "verbose!"  => \$verbose);
 
 if ($Twid < 1 || $Thgt < 1) {
@@ -59,7 +85,7 @@ my $verboseCommand = $verbose ? "set -x;" : "";
 
 if (@ARGV < 1) {
     fatal("You must specify at least one color as an argument");
-} elsif (@ARGV < 2 && $norepeat) {
+} elsif (@ARGV < 2 && ! $repeat) {
     fatal("With the -norepeat option, you must specify at least two colors " .
           "as arguments.");
 }
@@ -67,14 +93,11 @@ if (@ARGV < 1) {
 my @colorlist;
 
 @colorlist = @ARGV;
-if (!$norepeat) {
+if ($repeat) {
     push @colorlist, $ARGV[0];
 }
 
-my $ourtmp = "$tmpdir/ppmrainbow$$";
-mkdir($ourtmp, 0777) or
-    die("Unable to create directory for temporary files '$ourtmp");
-
+my $ourtmp = File::Temp::tempdir("$tmpdir/ppmrainbowXXXX", UNLINK=>1);
 
 my $widthRemaining;
 my $n;