about summary refs log tree commit diff
path: root/editor/pnmquant
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-01-24 04:20:13 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-01-24 04:20:13 +0000
commit0d4071a0d1261a4136269b4225d79413f175ffe5 (patch)
tree3c8c5b7e0078ebf12edb7acb8848d4611c09ac04 /editor/pnmquant
parentde766f4cb39f3c179dd903a723ce170390348040 (diff)
downloadnetpbm-mirror-0d4071a0d1261a4136269b4225d79413f175ffe5.tar.gz
netpbm-mirror-0d4071a0d1261a4136269b4225d79413f175ffe5.tar.xz
netpbm-mirror-0d4071a0d1261a4136269b4225d79413f175ffe5.zip
Include program name in error messages
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4027 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmquant')
-rwxr-xr-xeditor/pnmquant43
1 files changed, 24 insertions, 19 deletions
diff --git a/editor/pnmquant b/editor/pnmquant
index f7af9e7a..0bebce69 100755
--- a/editor/pnmquant
+++ b/editor/pnmquant
@@ -37,9 +37,16 @@ use Getopt::Long;
 use File::Spec;
 #use Fcntl ":seek";  # not available in Perl 5.00503
 use Fcntl;  # gets open flags
+use IO::Handle;
 
 my ($TRUE, $FALSE) = (1,0);
 
+sub pm_message($) {
+    STDERR->print("pnmquant: $_[0]\n");
+}
+
+
+
 my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2);
 
 
@@ -102,17 +109,16 @@ sub parseCommandLine(@) {
                                   "plain");
 
     if (!$optsAreValid) {
-        print(STDERR "Invalid option syntax.\n");
+        pm_message("Invalid option syntax");
         exit(1);
     }
     if (@ARGV > 2) {
-        print(STDERR "This program takes at most 2 arguments.  You specified ",
-              scalar(@ARGV), "\n");
+        pm_message("This program takes at most 2 arguments.  You specified " .
+                   scalar(@ARGV));
         exit(1);
     } 
     elsif (@ARGV < 1) {
-        print(STDERR 
-              "You must specify the number of colors as an argument.\n");
+        pm_message("You must specify the number of colors as an argument.");
         exit(1);
     }
     my $infile;
@@ -120,9 +126,8 @@ sub parseCommandLine(@) {
     
     if (!($cmdline{ncolors} =~ m{ ^[[:digit:]]+$ }x ) || 
         $cmdline{ncolors} == 0) {
-        print(STDERR 
-              "Number of colors argument '$cmdline{ncolors}' " .
-              "is not a positive integer.\n");
+        pm_message("Number of colors argument '$cmdline{ncolors}' " .
+                   "is not a positive integer.");
         exit(1);
     }
 
@@ -210,8 +215,8 @@ sub makeColormap($$$$$$$) {
     my ($mapfileFh, $mapfileSpec) = tempFile(".pnm");
 
     if (!defined($mapfileFh)) {
-        print(STDERR "Unable to create temporary file for colormap.  " .
-              "errno = $ERRNO\n");
+        pm_message("Unable to create temporary file for colormap.  " .
+                   "errno = $ERRNO");
         exit(1);
     }
        
@@ -223,8 +228,8 @@ sub makeColormap($$$$$$$) {
         (defined($opt_center)    ? 1 : 0);
 
     if ($colorSummaryOptCt > 1) {
-        print(STDERR "You can specify only one of " .
-              "-meanpixel, -meancolor, and -center\n");
+        pm_message("You can specify only one of " .
+                   "-meanpixel, -meancolor, and -center");
         exit(1);
     }
     if (defined($opt_meanpixel)) {
@@ -240,8 +245,8 @@ sub makeColormap($$$$$$$) {
         (defined($opt_spreadbrightness) ? 1 : 0);
 
     if ($spreadOptCt > 1) {
-        print(STDERR "You can specify only one of " .
-              "-spreadluminosity and -spreadbrightness\n");
+        pm_message("You can specify only one of " .
+                   "-spreadluminosity and -spreadbrightness");
         exit(1);
     }
 
@@ -263,7 +268,7 @@ sub makeColormap($$$$$$$) {
     my $maprc = system("pnmcolormap", $ncolors, @options);
 
     if ($maprc != 0) {
-        print(STDERR "pnmcolormap failed, rc=$maprc\n");
+        pm_message("pnmcolormap failed, rc=$maprc");
         exit(1);
     } 
     return $mapfileSpec;
@@ -287,15 +292,15 @@ sub remap($$$$$$) {
     }
     if ($opt_norandom) {
         if (defined($opt_randomseed)) {
-             print(STDERR "You cannot specify -randomseed with -norandom\n");
+             pm_message("You cannot specify -randomseed with -norandom");
              exit(1);
         }
         push(@options, "-norandom");
     }
     if (defined($opt_randomseed)) {
         if ($opt_randomseed < 0) {
-             print(STDERR "-randomseed value must not be negative.  " .
-                   "You specified $opt_randomseed\n");
+             pm_message("-randomseed value must not be negative.  " .
+                        "You specified $opt_randomseed");
              exit(10);
         }
         push(@options, "-randomseed=$opt_randomseed");
@@ -310,7 +315,7 @@ sub remap($$$$$$) {
     my $remaprc = system("pnmremap", "-mapfile=$mapfileSpec", @options);
     
     if ($remaprc != 0) {
-        print(STDERR "pnmremap failed, rc=$remaprc\n");
+        pm_message("pnmremap failed, rc=$remaprc");
         exit(1);
     }
 }