about summary refs log tree commit diff
path: root/editor/ppmshadow
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-04-24 22:54:44 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-04-24 22:54:44 +0000
commitffa0d9869fe04de4649c4101f2117473ad91fcdf (patch)
tree53aacebe4475320acafb3bd76e40006525a5ab5f /editor/ppmshadow
parent2ec45a90b13b406f4028963b7985f3070550e7cf (diff)
downloadnetpbm-mirror-ffa0d9869fe04de4649c4101f2117473ad91fcdf.tar.gz
netpbm-mirror-ffa0d9869fe04de4649c4101f2117473ad91fcdf.tar.xz
netpbm-mirror-ffa0d9869fe04de4649c4101f2117473ad91fcdf.zip
Add -version, change temporary file handling
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2717 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/ppmshadow')
-rwxr-xr-xeditor/ppmshadow38
1 files changed, 32 insertions, 6 deletions
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)) {