diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-01-24 04:20:13 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-01-24 04:20:13 +0000 |
commit | 0d4071a0d1261a4136269b4225d79413f175ffe5 (patch) | |
tree | 3c8c5b7e0078ebf12edb7acb8848d4611c09ac04 | |
parent | de766f4cb39f3c179dd903a723ce170390348040 (diff) | |
download | netpbm-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
-rw-r--r-- | converter/pbm/pbmtox10bm | 15 | ||||
-rwxr-xr-x | editor/pnmflip | 10 | ||||
-rwxr-xr-x | editor/pnmquant | 43 | ||||
-rwxr-xr-x | editor/pnmquantall | 15 | ||||
-rwxr-xr-x | generator/pgmcrater | 12 | ||||
-rwxr-xr-x | generator/ppmrainbow | 30 |
6 files changed, 83 insertions, 42 deletions
diff --git a/converter/pbm/pbmtox10bm b/converter/pbm/pbmtox10bm index deb3aeab..ca82fcd2 100644 --- a/converter/pbm/pbmtox10bm +++ b/converter/pbm/pbmtox10bm @@ -37,6 +37,16 @@ exec perl -w -x -S -- "$0" "$@" use strict; use File::Basename; use Cwd 'abs_path'; +use IO::Handle; + + + +sub pm_message($) { + STDERR->print("pbmtox10bm: $_[0]\n"); +} + + + sub doVersionHack($) { my ($argvR) = @_; @@ -56,13 +66,12 @@ my $infile; foreach (@ARGV) { if (/^-/) { # It's an option. But Pbmtox10bm didn't have any options. - print(STDERR "Invalid option '$_'\n"); + pm_message("Invalid option '$_'"); exit(10); } else { # It's a parameter if (defined($infile)) { - print(STDERR - "You may specify at most one non-option parameter.\n"); + pm_message("You may specify at most one non-option parameter."); exit(10); } else { $infile = $_; diff --git a/editor/pnmflip b/editor/pnmflip index 07d4ddb9..962198a2 100755 --- a/editor/pnmflip +++ b/editor/pnmflip @@ -46,6 +46,13 @@ exec perl -w -x -S -- "$0" "$@" use strict; use File::Basename; use Cwd 'abs_path'; +use IO::Handle; + +sub pm_message($) { + STDERR->print("pnmflip: $_[0]\n"); +} + + my $xformOpt; my @miscOptions; @@ -78,8 +85,7 @@ foreach (@ARGV) { } else { # It's a parameter if (defined($infile)) { - print(STDERR - "You may specify at most one non-option parameter.\n"); + pm_message("You may specify at most one non-option parameter."); exit(10); } else { $infile = $_; 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); } } diff --git a/editor/pnmquantall b/editor/pnmquantall index aea6cc84..80d00fce 100755 --- a/editor/pnmquantall +++ b/editor/pnmquantall @@ -57,11 +57,18 @@ use warnings; use English; use Fcntl; # gets open flags use File::Copy; +use IO::Handle; my $TRUE=1; my $FALSE = 0; +sub pm_message($) { + STDERR->print("pnmquantall: $_[0]\n"); +} + + + sub doVersionHack($) { my ($argvR) = @_; @@ -84,7 +91,7 @@ sub parseArgs($$$$) { if (@argv > 0 && $argv[0] eq "-ext") { if (@argv < 2) { - print STDERR ("-ext requires a value\n"); + pm_message("-ext requires a value"); exit(100); } else { $$extR = $argv[1]; @@ -96,8 +103,8 @@ sub parseArgs($$$$) { } if (@argv < $firstArgPos + 2) { - print STDERR ("Not enough arguments. You need at least the number " . - "of colors and one file name\n"); + pm_message("Not enough arguments. You need at least the number " . + "of colors and one file name"); exit(100); } @@ -212,7 +219,7 @@ if (!$progError) { my $exitStatus; if ($progError) { - print STDERR ("Failed. $progError\n"); + pm_message("Failed. $progError"); $exitStatus = 1; } else { $exitStatus = 0; diff --git a/generator/pgmcrater b/generator/pgmcrater index c66f5576..6d81df39 100755 --- a/generator/pgmcrater +++ b/generator/pgmcrater @@ -36,6 +36,16 @@ exec perl -w -x -S -- "$0" "$@" use strict; use Getopt::Long; +use IO::Handle; + + + +sub pm_message($) { + STDERR->print("pgmcrater: $_[0]\n"); +} + + + sub doVersionHack($) { my ($argvR) = @_; @@ -69,7 +79,7 @@ my $validOptions = GetOptions( 'randomseed=i' => \my $randomseedOpt); if (!$validOptions) { - print STDERR "Invalid syntax\n"; + pm_message("Invalid syntax"); exit(100); } diff --git a/generator/ppmrainbow b/generator/ppmrainbow index e8a329ff..a5c2689d 100755 --- a/generator/ppmrainbow +++ b/generator/ppmrainbow @@ -26,6 +26,19 @@ exec perl -w -x -S -- "$0" "$@" use strict; use Getopt::Long; use File::Temp; +use IO::Handle; + + + +sub pm_message($) { + STDERR->print("ppmrainbow: $_[0]\n"); +} + +sub pm_error($) { + pm_message($_[0]); + exit(1); +} + my ($FALSE, $TRUE) = (0,1); @@ -46,15 +59,6 @@ sub doVersionHack($) { -sub fatal($) { - my ($msg) = @_; - - print(STDERR "ppmrainbow: $msg\n"); - exit(1); -} - - - ############################################################################## # # MAINLINE @@ -79,14 +83,14 @@ GetOptions("width=i" => \$Twid, "verbose!" => \$verbose); if ($Twid < 1 || $Thgt < 1) { - fatal("invalid width and/or height"); + pm_error("invalid width and/or height"); } my $verboseCommand = $verbose ? "set -x;" : ""; if (@ARGV < 1) { - fatal("You must specify at least one color as an argument"); + pm_error("You must specify at least one color as an argument"); } elsif (@ARGV < 2 && ! $repeat) { - fatal("With the -norepeat option, you must specify at least two colors " . + pm_error("With the -norepeat option, you must specify at least two colors " . "as arguments."); } @@ -115,7 +119,7 @@ while (@colorlist >= 2) { my $rc = system("$verboseCommand pgmramp -lr $w $Thgt | " . "pgmtoppm \"$colorlist[0]-$colorlist[1]\" >$outfile"); if ($rc != 0) { - fatal("pgmramp|pgmtoppm pipe failed."); + pm_error("pgmramp|pgmtoppm pipe failed."); } $widthRemaining -= $w; $n++; |